feat: add prototypes+functions for moar LED blinks
yes. moar. * also for now remove the built-in delay() function callsas it's doing pretty much nothing and use system() to call OS sleep command (works on GNU/Linux)
This commit is contained in:
parent
633a3acf02
commit
77a5ad2549
28
leds.cpp
28
leds.cpp
@ -23,10 +23,14 @@ void LEDS_Init(void) {
|
|||||||
|
|
||||||
/* Configure pins as output*/
|
/* Configure pins as output*/
|
||||||
pinMode(LED_GREEN, OUTPUT);
|
pinMode(LED_GREEN, OUTPUT);
|
||||||
|
pinMode(LED_BLUE, OUTPUT);
|
||||||
|
pinMode(LED_RED, OUTPUT);
|
||||||
|
|
||||||
|
|
||||||
/* Turn off the LEDs; they are turned off by HIGH value. */
|
/* Turn off the LEDs; they are turned off by HIGH value. */
|
||||||
pinWrite(LED_GREEN, HIGH);
|
pinWrite(LED_GREEN, HIGH);
|
||||||
|
pinWrite(LED_BLUE, HIGH);
|
||||||
|
pinWrite(LED_RED, HIGH);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +41,18 @@ void LEDS_GreenOn(void) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LEDS_BlueOn(void) {
|
||||||
|
|
||||||
|
pinWrite(LED_BLUE, LOW);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void LEDS_RedOn(void) {
|
||||||
|
|
||||||
|
pinWrite(LED_RED, LOW);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Turn off green LED (RGB LED on FRDM-KL25Z board) */
|
/* Turn off green LED (RGB LED on FRDM-KL25Z board) */
|
||||||
void LEDS_GreenOff(void) {
|
void LEDS_GreenOff(void) {
|
||||||
@ -45,4 +61,14 @@ void LEDS_GreenOff(void) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add more functions...
|
void LEDS_BlueOff(void) {
|
||||||
|
|
||||||
|
pinWrite(LED_BLUE, HIGH);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void LEDS_RedOff(void) {
|
||||||
|
|
||||||
|
pinWrite(LED_RED, HIGH);
|
||||||
|
|
||||||
|
}
|
||||||
|
8
leds.h
8
leds.h
@ -18,11 +18,17 @@ void LEDS_Init(void);
|
|||||||
|
|
||||||
/* Turn on green LED (RGB LED on FRDM-KL25Z board) */
|
/* Turn on green LED (RGB LED on FRDM-KL25Z board) */
|
||||||
void LEDS_GreenOn(void);
|
void LEDS_GreenOn(void);
|
||||||
|
|
||||||
|
void LEDS_BlueOn(void);
|
||||||
|
|
||||||
|
void LEDS_RedOn(void);
|
||||||
|
|
||||||
/* Turn off green LED (RGB LED on FRDM-KL25Z board) */
|
/* Turn off green LED (RGB LED on FRDM-KL25Z board) */
|
||||||
void LEDS_GreenOff(void);
|
void LEDS_GreenOff(void);
|
||||||
|
|
||||||
// TODO: add Red and Blue LED functions
|
void LEDS_BlueOff(void);
|
||||||
|
|
||||||
|
void LEDS_RedOff(void);
|
||||||
|
|
||||||
#endif /* SOURCES_DRV_LEDS_H_ */
|
#endif /* SOURCES_DRV_LEDS_H_ */
|
||||||
|
|
||||||
|
8
main.cpp
8
main.cpp
@ -11,9 +11,13 @@ int main()
|
|||||||
// blikani LED
|
// blikani LED
|
||||||
while(1) {
|
while(1) {
|
||||||
LEDS_GreenOn();
|
LEDS_GreenOn();
|
||||||
delay();
|
system("sleep 1");
|
||||||
|
LEDS_BlueOn();
|
||||||
|
system("sleep 1");
|
||||||
LEDS_GreenOff();
|
LEDS_GreenOff();
|
||||||
delay();
|
system("sleep 1");
|
||||||
|
LEDS_BlueOff();
|
||||||
|
system("sleep 1");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user