From 77a5ad2549e4e38f6d36e84a8f027554e2c8240b Mon Sep 17 00:00:00 2001 From: surtur Date: Fri, 11 Dec 2020 17:12:01 +0100 Subject: [PATCH] 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) --- leds.cpp | 28 +++++++++++++++++++++++++++- leds.h | 8 +++++++- main.cpp | 8 ++++++-- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/leds.cpp b/leds.cpp index e8822e9..452199b 100644 --- a/leds.cpp +++ b/leds.cpp @@ -23,10 +23,14 @@ void LEDS_Init(void) { /* Configure pins as output*/ pinMode(LED_GREEN, OUTPUT); + pinMode(LED_BLUE, OUTPUT); + pinMode(LED_RED, OUTPUT); /* Turn off the LEDs; they are turned off by HIGH value. */ 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) */ 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); + +} diff --git a/leds.h b/leds.h index 309b20f..097513f 100644 --- a/leds.h +++ b/leds.h @@ -18,11 +18,17 @@ void LEDS_Init(void); /* Turn on green LED (RGB LED on FRDM-KL25Z board) */ void LEDS_GreenOn(void); + +void LEDS_BlueOn(void); + +void LEDS_RedOn(void); + /* Turn off green LED (RGB LED on FRDM-KL25Z board) */ void LEDS_GreenOff(void); -// TODO: add Red and Blue LED functions +void LEDS_BlueOff(void); +void LEDS_RedOff(void); #endif /* SOURCES_DRV_LEDS_H_ */ diff --git a/main.cpp b/main.cpp index d13aba8..cb2b065 100644 --- a/main.cpp +++ b/main.cpp @@ -11,9 +11,13 @@ int main() // blikani LED while(1) { LEDS_GreenOn(); - delay(); + system("sleep 1"); + LEDS_BlueOn(); + system("sleep 1"); LEDS_GreenOff(); - delay(); + system("sleep 1"); + LEDS_BlueOff(); + system("sleep 1"); } return 0; }