Created
November 14, 2016 02:25
-
-
Save SaraJo/1b3d6967d7bc2ef2e70d79025b755eb9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "LED.h" | |
#include "led_sequence.h" | |
#ifdef __cplusplus | |
extern "C"{ | |
#endif // __cplusplus | |
uint8_t color_values[]; | |
LED() | |
{} | |
~LED() | |
{} | |
void LED::on(uint8_t number, char *color, uint8_t length) { | |
enable_led(); | |
clear_led(); | |
color_lookup(*color); | |
led_cmd_t *options = {number, color_values[0], color_values[1], color_values[2], 1}; | |
set_led_state_handler(options); | |
nrf_delay_us(length); | |
clear_led(); | |
} | |
void color_lookup(char *color) | |
{ | |
if(color == "red") { | |
color_values[0] = 0x3F; | |
color_values[1] = 0x00; | |
color_values[2] = 0x00; | |
} | |
else if (color == "orange"){ | |
color_values[0] = 0x3F; | |
color_values[1] = 0x1C; | |
color_values[2] = 0x00; | |
} | |
else if (color == "yellow"){ | |
color_values[0] = 0x3F; | |
color_values[1] = 0x3F; | |
color_values[2] = 0x00; | |
} | |
else if (color == "green"){ | |
color_values[0] = 0x00; | |
color_values[1] = 0x3F; | |
color_values[2] = 0x00; | |
} | |
else if (color == "blue"){ | |
color_values[0] = 0x00; | |
color_values[1] = 0x00; | |
color_values[2] = 0x3F; | |
} | |
else if (color == "violet"){ | |
color_values[0] = 0x1F; | |
color_values[1] = 0x00; | |
color_values[2] = 0x3F; | |
} | |
else if (color == "pink"){ | |
color_values[0] = 0x3F; | |
color_values[1] = 0x1A; | |
color_values[2] = 0x3A; | |
} | |
else if (color == "magenta"){ | |
color_values[0] = 0x3F; | |
color_values[1] = 0x0C; | |
color_values[2] = 0x3F; | |
} | |
} | |
#ifdef __cplusplus | |
} // extern "C" | |
#endif // __cplusplus |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment