-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathled.c
109 lines (100 loc) · 2.58 KB
/
led.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
* @file led.c
*
* @date May 25, 2017
* @author hamster
*
* @brief Routines to handle drawing to groups of LEDs
*
*/
#include "system.h"
#include "led.h"
/**
* @brief Set the eye color
* @param eye which eye to use, enum
* @param color color to set, enum
*/
void set_eye_color(LED_EYE eye, EYE_COLOR color){
// Left eye
if(eye == eye_side_left || eye == eye_side_both){
switch(color){
case eye_color_none:
nrf_gpio_pin_set(LED_EYE_LEFT_RED);
nrf_gpio_pin_set(LED_EYE_LEFT_GREEN);
nrf_gpio_pin_set(LED_EYE_LEFT_BLUE);
break;
case eye_color_blue:
nrf_gpio_pin_set(LED_EYE_LEFT_RED);
nrf_gpio_pin_set(LED_EYE_LEFT_GREEN);
nrf_gpio_pin_clear(LED_EYE_LEFT_BLUE);
break;
case eye_color_green:
nrf_gpio_pin_set(LED_EYE_LEFT_RED);
nrf_gpio_pin_clear(LED_EYE_LEFT_GREEN);
nrf_gpio_pin_set(LED_EYE_LEFT_BLUE);
break;
case eye_color_red:
nrf_gpio_pin_clear(LED_EYE_LEFT_RED);
nrf_gpio_pin_set(LED_EYE_LEFT_GREEN);
nrf_gpio_pin_set(LED_EYE_LEFT_BLUE);
break;
case eye_color_all:
nrf_gpio_pin_clear(LED_EYE_LEFT_RED);
nrf_gpio_pin_clear(LED_EYE_LEFT_GREEN);
nrf_gpio_pin_clear(LED_EYE_LEFT_BLUE);
break;
default:
break;
}
}
// Right eye
if(eye == eye_side_right || eye == eye_side_both){
switch(color){
case eye_color_none:
nrf_gpio_pin_set(LED_EYE_RIGHT_RED);
nrf_gpio_pin_set(LED_EYE_RIGHT_GREEN);
nrf_gpio_pin_set(LED_EYE_RIGHT_BLUE);
break;
case eye_color_blue:
nrf_gpio_pin_set(LED_EYE_RIGHT_RED);
nrf_gpio_pin_set(LED_EYE_RIGHT_GREEN);
nrf_gpio_pin_clear(LED_EYE_RIGHT_BLUE);
break;
case eye_color_green:
nrf_gpio_pin_set(LED_EYE_RIGHT_RED);
nrf_gpio_pin_clear(LED_EYE_RIGHT_GREEN);
nrf_gpio_pin_set(LED_EYE_RIGHT_BLUE);
break;
case eye_color_red:
nrf_gpio_pin_clear(LED_EYE_RIGHT_RED);
nrf_gpio_pin_set(LED_EYE_RIGHT_GREEN);
nrf_gpio_pin_set(LED_EYE_RIGHT_BLUE);
break;
case eye_color_all:
nrf_gpio_pin_clear(LED_EYE_RIGHT_RED);
nrf_gpio_pin_clear(LED_EYE_RIGHT_GREEN);
nrf_gpio_pin_clear(LED_EYE_RIGHT_BLUE);
break;
default:
break;
}
}
}
/**
* @brief Toggle all the helmet LEDs on or off
* @param state true if you want the LEDs on
*/
void helmet_leds(uint8_t state){
for (int i = 0; i < HELMET_LEDS_NUMBER; i++){
nrf_gpio_pin_write(helmet_led_list[i], state);
}
}
/**
* @brief Toggle all the helmet wing LEDs on or off
* @param state true if you want the LEDs on
*/
void wing_leds(uint8_t state){
for (int i = 0; i < WING_LEDS_NUMBER; i++){
nrf_gpio_pin_write(wing_led_list[i], state);
}
}