RGB LEDs Control
Dependencies: mbed QEI PololuLedStrip
RgbControl.cpp@8:2a4298cbae3f, 2019-05-04 (annotated)
- Committer:
- whutsup
- Date:
- Sat May 04 18:51:43 2019 +0000
- Revision:
- 8:2a4298cbae3f
Lune RGB LEDs control;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
whutsup | 8:2a4298cbae3f | 1 | #include "mbed.h" |
whutsup | 8:2a4298cbae3f | 2 | #include "QEI.h" |
whutsup | 8:2a4298cbae3f | 3 | #include "PololuLedStrip.h" |
whutsup | 8:2a4298cbae3f | 4 | |
whutsup | 8:2a4298cbae3f | 5 | |
whutsup | 8:2a4298cbae3f | 6 | PololuLedStrip led7(PB_0); |
whutsup | 8:2a4298cbae3f | 7 | PololuLedStrip led6(PA_12); |
whutsup | 8:2a4298cbae3f | 8 | PololuLedStrip led5(PB_6); |
whutsup | 8:2a4298cbae3f | 9 | PololuLedStrip led4(PB_1); |
whutsup | 8:2a4298cbae3f | 10 | PololuLedStrip led3(PA_8); |
whutsup | 8:2a4298cbae3f | 11 | PololuLedStrip led2(PA_11); |
whutsup | 8:2a4298cbae3f | 12 | PololuLedStrip led1(PA_3); |
whutsup | 8:2a4298cbae3f | 13 | PololuLedStrip led0(PA_4); |
whutsup | 8:2a4298cbae3f | 14 | |
whutsup | 8:2a4298cbae3f | 15 | #define LED_COUNT 16 |
whutsup | 8:2a4298cbae3f | 16 | |
whutsup | 8:2a4298cbae3f | 17 | rgb_color colors0[LED_COUNT]; |
whutsup | 8:2a4298cbae3f | 18 | rgb_color colors1[LED_COUNT]; |
whutsup | 8:2a4298cbae3f | 19 | rgb_color colors2[LED_COUNT]; |
whutsup | 8:2a4298cbae3f | 20 | rgb_color colors3[LED_COUNT]; |
whutsup | 8:2a4298cbae3f | 21 | rgb_color colors4[LED_COUNT]; |
whutsup | 8:2a4298cbae3f | 22 | rgb_color colors5[LED_COUNT]; |
whutsup | 8:2a4298cbae3f | 23 | rgb_color colors6[LED_COUNT]; |
whutsup | 8:2a4298cbae3f | 24 | rgb_color colors7[LED_COUNT]; |
whutsup | 8:2a4298cbae3f | 25 | |
whutsup | 8:2a4298cbae3f | 26 | Ticker led; |
whutsup | 8:2a4298cbae3f | 27 | |
whutsup | 8:2a4298cbae3f | 28 | extern QEI re; |
whutsup | 8:2a4298cbae3f | 29 | extern int R; |
whutsup | 8:2a4298cbae3f | 30 | extern int G; |
whutsup | 8:2a4298cbae3f | 31 | extern int B; |
whutsup | 8:2a4298cbae3f | 32 | extern Serial bt; |
whutsup | 8:2a4298cbae3f | 33 | extern int dayLed; |
whutsup | 8:2a4298cbae3f | 34 | |
whutsup | 8:2a4298cbae3f | 35 | void LedOn1() |
whutsup | 8:2a4298cbae3f | 36 | { |
whutsup | 8:2a4298cbae3f | 37 | |
whutsup | 8:2a4298cbae3f | 38 | int pulse = re.getPulses(); |
whutsup | 8:2a4298cbae3f | 39 | int d = pulse/200; |
whutsup | 8:2a4298cbae3f | 40 | |
whutsup | 8:2a4298cbae3f | 41 | if(48>=d) |
whutsup | 8:2a4298cbae3f | 42 | { |
whutsup | 8:2a4298cbae3f | 43 | |
whutsup | 8:2a4298cbae3f | 44 | uint8_t r[8]; |
whutsup | 8:2a4298cbae3f | 45 | uint8_t g[8]; |
whutsup | 8:2a4298cbae3f | 46 | uint8_t b[8]; |
whutsup | 8:2a4298cbae3f | 47 | |
whutsup | 8:2a4298cbae3f | 48 | for (int i=0 ; i<8 ; i++) |
whutsup | 8:2a4298cbae3f | 49 | { |
whutsup | 8:2a4298cbae3f | 50 | int n = (i+1); |
whutsup | 8:2a4298cbae3f | 51 | int moveL_r = ((R/6)*(d-1*n*6))+R; |
whutsup | 8:2a4298cbae3f | 52 | int moveL_g = ((G/6)*(d-1*n*6))+G; |
whutsup | 8:2a4298cbae3f | 53 | int moveL_b = ((B/6)*(d-1*n*6))+B; |
whutsup | 8:2a4298cbae3f | 54 | |
whutsup | 8:2a4298cbae3f | 55 | moveL_r = (0 >= moveL_r) ? 0: moveL_r; |
whutsup | 8:2a4298cbae3f | 56 | moveL_g = (0 >= moveL_g) ? 0: moveL_g; |
whutsup | 8:2a4298cbae3f | 57 | moveL_b = (0 >= moveL_b) ? 0: moveL_b; |
whutsup | 8:2a4298cbae3f | 58 | |
whutsup | 8:2a4298cbae3f | 59 | moveL_r = (R <= moveL_r) ? R: moveL_r; |
whutsup | 8:2a4298cbae3f | 60 | moveL_g = (G <= moveL_g) ? G: moveL_g; |
whutsup | 8:2a4298cbae3f | 61 | moveL_b = (B <= moveL_b) ? B: moveL_b; |
whutsup | 8:2a4298cbae3f | 62 | |
whutsup | 8:2a4298cbae3f | 63 | |
whutsup | 8:2a4298cbae3f | 64 | r[i] = moveL_r; |
whutsup | 8:2a4298cbae3f | 65 | g[i] = moveL_g; |
whutsup | 8:2a4298cbae3f | 66 | b[i] = moveL_b; |
whutsup | 8:2a4298cbae3f | 67 | |
whutsup | 8:2a4298cbae3f | 68 | } |
whutsup | 8:2a4298cbae3f | 69 | |
whutsup | 8:2a4298cbae3f | 70 | |
whutsup | 8:2a4298cbae3f | 71 | |
whutsup | 8:2a4298cbae3f | 72 | for(int i=0; i<16; i++) |
whutsup | 8:2a4298cbae3f | 73 | { |
whutsup | 8:2a4298cbae3f | 74 | colors0[i] = (rgb_color){ r[0], g[0], b[0] }; |
whutsup | 8:2a4298cbae3f | 75 | colors1[i] = (rgb_color){ r[1], g[1], b[1] }; |
whutsup | 8:2a4298cbae3f | 76 | colors2[i] = (rgb_color){ r[2], g[2], b[2] }; |
whutsup | 8:2a4298cbae3f | 77 | colors3[i] = (rgb_color){ r[3], g[3], b[3] }; |
whutsup | 8:2a4298cbae3f | 78 | colors4[i] = (rgb_color){ r[4], g[4], b[4] }; |
whutsup | 8:2a4298cbae3f | 79 | colors5[i] = (rgb_color){ r[5], g[5], b[5] }; |
whutsup | 8:2a4298cbae3f | 80 | colors6[i] = (rgb_color){ r[6], g[6], b[6] }; |
whutsup | 8:2a4298cbae3f | 81 | colors7[i] = (rgb_color){ r[7], g[7], b[7] }; |
whutsup | 8:2a4298cbae3f | 82 | } |
whutsup | 8:2a4298cbae3f | 83 | |
whutsup | 8:2a4298cbae3f | 84 | |
whutsup | 8:2a4298cbae3f | 85 | led0.write(colors0, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 86 | led1.write(colors1, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 87 | led2.write(colors2, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 88 | led3.write(colors3, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 89 | led4.write(colors4, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 90 | led5.write(colors5, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 91 | led6.write(colors6, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 92 | led7.write(colors7, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 93 | |
whutsup | 8:2a4298cbae3f | 94 | } |
whutsup | 8:2a4298cbae3f | 95 | |
whutsup | 8:2a4298cbae3f | 96 | else if(52<=d) |
whutsup | 8:2a4298cbae3f | 97 | { |
whutsup | 8:2a4298cbae3f | 98 | uint8_t r[8]; |
whutsup | 8:2a4298cbae3f | 99 | uint8_t g[8]; |
whutsup | 8:2a4298cbae3f | 100 | uint8_t b[8]; |
whutsup | 8:2a4298cbae3f | 101 | |
whutsup | 8:2a4298cbae3f | 102 | for (int i=0 ; i<8 ; i++) |
whutsup | 8:2a4298cbae3f | 103 | { |
whutsup | 8:2a4298cbae3f | 104 | int moveR_r = -1*(R/6)*(d-1*(52+(i+1)*6))+R; |
whutsup | 8:2a4298cbae3f | 105 | int moveR_g = -1*(G/6)*(d-1*(52+(i+1)*6))+G; |
whutsup | 8:2a4298cbae3f | 106 | int moveR_b = -1*(B/6)*(d-1*(52+(i+1)*6))+B; |
whutsup | 8:2a4298cbae3f | 107 | |
whutsup | 8:2a4298cbae3f | 108 | |
whutsup | 8:2a4298cbae3f | 109 | moveR_r = (0 >= moveR_r) ? 0: moveR_r; |
whutsup | 8:2a4298cbae3f | 110 | moveR_g = (0 >= moveR_g) ? 0: moveR_g; |
whutsup | 8:2a4298cbae3f | 111 | moveR_b = (0 >= moveR_b) ? 0: moveR_b; |
whutsup | 8:2a4298cbae3f | 112 | |
whutsup | 8:2a4298cbae3f | 113 | moveR_r = (R <= moveR_r) ? R: moveR_r; |
whutsup | 8:2a4298cbae3f | 114 | moveR_g = (G <= moveR_g) ? G: moveR_g; |
whutsup | 8:2a4298cbae3f | 115 | moveR_b = (B <= moveR_b) ? B: moveR_b; |
whutsup | 8:2a4298cbae3f | 116 | |
whutsup | 8:2a4298cbae3f | 117 | |
whutsup | 8:2a4298cbae3f | 118 | r[i] = moveR_r; |
whutsup | 8:2a4298cbae3f | 119 | g[i] = moveR_g; |
whutsup | 8:2a4298cbae3f | 120 | b[i] = moveR_b; |
whutsup | 8:2a4298cbae3f | 121 | } |
whutsup | 8:2a4298cbae3f | 122 | |
whutsup | 8:2a4298cbae3f | 123 | |
whutsup | 8:2a4298cbae3f | 124 | |
whutsup | 8:2a4298cbae3f | 125 | for(int i=0; i<16; i++) |
whutsup | 8:2a4298cbae3f | 126 | { |
whutsup | 8:2a4298cbae3f | 127 | colors0[i] = (rgb_color){ r[0], g[0], b[0] }; |
whutsup | 8:2a4298cbae3f | 128 | colors1[i] = (rgb_color){ r[1], g[1], b[1] }; |
whutsup | 8:2a4298cbae3f | 129 | colors2[i] = (rgb_color){ r[2], g[2], b[2] }; |
whutsup | 8:2a4298cbae3f | 130 | colors3[i] = (rgb_color){ r[3], g[3], b[3] }; |
whutsup | 8:2a4298cbae3f | 131 | colors4[i] = (rgb_color){ r[4], g[4], b[4] }; |
whutsup | 8:2a4298cbae3f | 132 | colors5[i] = (rgb_color){ r[5], g[5], b[5] }; |
whutsup | 8:2a4298cbae3f | 133 | colors6[i] = (rgb_color){ r[6], g[6], b[6] }; |
whutsup | 8:2a4298cbae3f | 134 | colors7[i] = (rgb_color){ r[7], g[7], b[7] }; |
whutsup | 8:2a4298cbae3f | 135 | } |
whutsup | 8:2a4298cbae3f | 136 | |
whutsup | 8:2a4298cbae3f | 137 | |
whutsup | 8:2a4298cbae3f | 138 | led0.write(colors0, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 139 | led1.write(colors1, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 140 | led2.write(colors2, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 141 | led3.write(colors3, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 142 | led4.write(colors4, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 143 | led5.write(colors5, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 144 | led6.write(colors6, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 145 | led7.write(colors7, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 146 | |
whutsup | 8:2a4298cbae3f | 147 | } |
whutsup | 8:2a4298cbae3f | 148 | |
whutsup | 8:2a4298cbae3f | 149 | else |
whutsup | 8:2a4298cbae3f | 150 | { |
whutsup | 8:2a4298cbae3f | 151 | |
whutsup | 8:2a4298cbae3f | 152 | for(int i=0; i<16; i++) |
whutsup | 8:2a4298cbae3f | 153 | { |
whutsup | 8:2a4298cbae3f | 154 | colors0[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 155 | colors1[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 156 | colors2[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 157 | colors3[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 158 | colors4[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 159 | colors5[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 160 | colors6[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 161 | colors7[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 162 | } |
whutsup | 8:2a4298cbae3f | 163 | |
whutsup | 8:2a4298cbae3f | 164 | |
whutsup | 8:2a4298cbae3f | 165 | led0.write(colors0, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 166 | led1.write(colors1, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 167 | led2.write(colors2, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 168 | led3.write(colors3, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 169 | led4.write(colors4, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 170 | led5.write(colors5, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 171 | led6.write(colors6, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 172 | led7.write(colors7, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 173 | } |
whutsup | 8:2a4298cbae3f | 174 | |
whutsup | 8:2a4298cbae3f | 175 | } |
whutsup | 8:2a4298cbae3f | 176 | |
whutsup | 8:2a4298cbae3f | 177 | |
whutsup | 8:2a4298cbae3f | 178 | void LedOn2() |
whutsup | 8:2a4298cbae3f | 179 | { |
whutsup | 8:2a4298cbae3f | 180 | |
whutsup | 8:2a4298cbae3f | 181 | int pulse = re.getPulses(); |
whutsup | 8:2a4298cbae3f | 182 | int p = pulse/200; |
whutsup | 8:2a4298cbae3f | 183 | uint8_t k[8]; |
whutsup | 8:2a4298cbae3f | 184 | int n = 8; |
whutsup | 8:2a4298cbae3f | 185 | int d = 6; |
whutsup | 8:2a4298cbae3f | 186 | double bi= 0.02f; |
whutsup | 8:2a4298cbae3f | 187 | |
whutsup | 8:2a4298cbae3f | 188 | uint8_t r[8]; |
whutsup | 8:2a4298cbae3f | 189 | uint8_t g[8]; |
whutsup | 8:2a4298cbae3f | 190 | uint8_t b[8]; |
whutsup | 8:2a4298cbae3f | 191 | |
whutsup | 8:2a4298cbae3f | 192 | for (int i=0 ; i<8 ; i++) |
whutsup | 8:2a4298cbae3f | 193 | { |
whutsup | 8:2a4298cbae3f | 194 | k[i] = ((n-i)*d)/log((1/bi)+1); |
whutsup | 8:2a4298cbae3f | 195 | } |
whutsup | 8:2a4298cbae3f | 196 | |
whutsup | 8:2a4298cbae3f | 197 | |
whutsup | 8:2a4298cbae3f | 198 | if(48>=p) |
whutsup | 8:2a4298cbae3f | 199 | { |
whutsup | 8:2a4298cbae3f | 200 | |
whutsup | 8:2a4298cbae3f | 201 | |
whutsup | 8:2a4298cbae3f | 202 | for (int i=0 ; i<8 ; i++) |
whutsup | 8:2a4298cbae3f | 203 | { |
whutsup | 8:2a4298cbae3f | 204 | |
whutsup | 8:2a4298cbae3f | 205 | int moveL_r = R*bi*(10^((p-1*i*d)/k[i])-1); |
whutsup | 8:2a4298cbae3f | 206 | int moveL_g = G*bi*(10^((p-1*i*d)/k[i])-1); |
whutsup | 8:2a4298cbae3f | 207 | int moveL_b = B*bi*(10^((p-1*i*d)/k[i])-1);; |
whutsup | 8:2a4298cbae3f | 208 | |
whutsup | 8:2a4298cbae3f | 209 | moveL_r = (0 >= moveL_r) ? 0: moveL_r; |
whutsup | 8:2a4298cbae3f | 210 | moveL_g = (0 >= moveL_g) ? 0: moveL_g; |
whutsup | 8:2a4298cbae3f | 211 | moveL_b = (0 >= moveL_b) ? 0: moveL_b; |
whutsup | 8:2a4298cbae3f | 212 | |
whutsup | 8:2a4298cbae3f | 213 | moveL_r = (R <= moveL_r) ? R: moveL_r; |
whutsup | 8:2a4298cbae3f | 214 | moveL_g = (G <= moveL_g) ? G: moveL_g; |
whutsup | 8:2a4298cbae3f | 215 | moveL_b = (B <= moveL_b) ? B: moveL_b; |
whutsup | 8:2a4298cbae3f | 216 | |
whutsup | 8:2a4298cbae3f | 217 | r[i] = moveL_r; |
whutsup | 8:2a4298cbae3f | 218 | g[i] = moveL_g; |
whutsup | 8:2a4298cbae3f | 219 | b[i] = moveL_b; |
whutsup | 8:2a4298cbae3f | 220 | |
whutsup | 8:2a4298cbae3f | 221 | } |
whutsup | 8:2a4298cbae3f | 222 | |
whutsup | 8:2a4298cbae3f | 223 | |
whutsup | 8:2a4298cbae3f | 224 | for(int i=0; i<16; i++) |
whutsup | 8:2a4298cbae3f | 225 | { |
whutsup | 8:2a4298cbae3f | 226 | colors0[i] = (rgb_color){ r[0], g[0], b[0] }; |
whutsup | 8:2a4298cbae3f | 227 | colors1[i] = (rgb_color){ r[1], g[1], b[1] }; |
whutsup | 8:2a4298cbae3f | 228 | colors2[i] = (rgb_color){ r[2], g[2], b[2] }; |
whutsup | 8:2a4298cbae3f | 229 | colors3[i] = (rgb_color){ r[3], g[3], b[3] }; |
whutsup | 8:2a4298cbae3f | 230 | colors4[i] = (rgb_color){ r[4], g[4], b[4] }; |
whutsup | 8:2a4298cbae3f | 231 | colors5[i] = (rgb_color){ r[5], g[5], b[5] }; |
whutsup | 8:2a4298cbae3f | 232 | colors6[i] = (rgb_color){ r[6], g[6], b[6] }; |
whutsup | 8:2a4298cbae3f | 233 | colors7[i] = (rgb_color){ r[7], g[7], b[7] }; |
whutsup | 8:2a4298cbae3f | 234 | } |
whutsup | 8:2a4298cbae3f | 235 | |
whutsup | 8:2a4298cbae3f | 236 | |
whutsup | 8:2a4298cbae3f | 237 | led0.write(colors0, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 238 | led1.write(colors1, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 239 | led2.write(colors2, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 240 | led3.write(colors3, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 241 | led4.write(colors4, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 242 | led5.write(colors5, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 243 | led6.write(colors6, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 244 | led7.write(colors7, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 245 | |
whutsup | 8:2a4298cbae3f | 246 | |
whutsup | 8:2a4298cbae3f | 247 | |
whutsup | 8:2a4298cbae3f | 248 | } |
whutsup | 8:2a4298cbae3f | 249 | |
whutsup | 8:2a4298cbae3f | 250 | else if(49<=p) |
whutsup | 8:2a4298cbae3f | 251 | { |
whutsup | 8:2a4298cbae3f | 252 | |
whutsup | 8:2a4298cbae3f | 253 | |
whutsup | 8:2a4298cbae3f | 254 | for (int i=0 ; i<8 ; i++) |
whutsup | 8:2a4298cbae3f | 255 | { |
whutsup | 8:2a4298cbae3f | 256 | |
whutsup | 8:2a4298cbae3f | 257 | int moveR_r = R*bi*(10^((-1*p+(n+1+i)*d)/k[n-1-i])-1); |
whutsup | 8:2a4298cbae3f | 258 | int moveR_g = G*bi*(10^((-1*p+(n+1+i)*d)/k[n-1-i])-1); |
whutsup | 8:2a4298cbae3f | 259 | int moveR_b = B*bi*(10^((-1*p+(n+1+i)*d)/k[n-1-i])-1); |
whutsup | 8:2a4298cbae3f | 260 | |
whutsup | 8:2a4298cbae3f | 261 | moveR_r = (0 >= moveR_r) ? 0: moveR_r; |
whutsup | 8:2a4298cbae3f | 262 | moveR_g = (0 >= moveR_g) ? 0: moveR_g; |
whutsup | 8:2a4298cbae3f | 263 | moveR_b = (0 >= moveR_b) ? 0: moveR_b; |
whutsup | 8:2a4298cbae3f | 264 | |
whutsup | 8:2a4298cbae3f | 265 | moveR_r = (R <= moveR_r) ? R: moveR_r; |
whutsup | 8:2a4298cbae3f | 266 | moveR_g = (G <= moveR_g) ? G: moveR_g; |
whutsup | 8:2a4298cbae3f | 267 | moveR_b = (B <= moveR_b) ? B: moveR_b; |
whutsup | 8:2a4298cbae3f | 268 | |
whutsup | 8:2a4298cbae3f | 269 | r[i] = moveR_r; |
whutsup | 8:2a4298cbae3f | 270 | g[i] = moveR_g; |
whutsup | 8:2a4298cbae3f | 271 | b[i] = moveR_b; |
whutsup | 8:2a4298cbae3f | 272 | |
whutsup | 8:2a4298cbae3f | 273 | } |
whutsup | 8:2a4298cbae3f | 274 | |
whutsup | 8:2a4298cbae3f | 275 | |
whutsup | 8:2a4298cbae3f | 276 | |
whutsup | 8:2a4298cbae3f | 277 | for(int i=0; i<16; i++) |
whutsup | 8:2a4298cbae3f | 278 | { |
whutsup | 8:2a4298cbae3f | 279 | colors0[i] = (rgb_color){ r[0], g[0], b[0] }; |
whutsup | 8:2a4298cbae3f | 280 | colors1[i] = (rgb_color){ r[1], g[1], b[1] }; |
whutsup | 8:2a4298cbae3f | 281 | colors2[i] = (rgb_color){ r[2], g[2], b[2] }; |
whutsup | 8:2a4298cbae3f | 282 | colors3[i] = (rgb_color){ r[3], g[3], b[3] }; |
whutsup | 8:2a4298cbae3f | 283 | colors4[i] = (rgb_color){ r[4], g[4], b[4] }; |
whutsup | 8:2a4298cbae3f | 284 | colors5[i] = (rgb_color){ r[5], g[5], b[5] }; |
whutsup | 8:2a4298cbae3f | 285 | colors6[i] = (rgb_color){ r[6], g[6], b[6] }; |
whutsup | 8:2a4298cbae3f | 286 | colors7[i] = (rgb_color){ r[7], g[7], b[7] }; |
whutsup | 8:2a4298cbae3f | 287 | } |
whutsup | 8:2a4298cbae3f | 288 | |
whutsup | 8:2a4298cbae3f | 289 | |
whutsup | 8:2a4298cbae3f | 290 | led0.write(colors0, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 291 | led1.write(colors1, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 292 | led2.write(colors2, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 293 | led3.write(colors3, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 294 | led4.write(colors4, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 295 | led5.write(colors5, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 296 | led6.write(colors6, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 297 | led7.write(colors7, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 298 | |
whutsup | 8:2a4298cbae3f | 299 | } |
whutsup | 8:2a4298cbae3f | 300 | |
whutsup | 8:2a4298cbae3f | 301 | // else |
whutsup | 8:2a4298cbae3f | 302 | // { |
whutsup | 8:2a4298cbae3f | 303 | // |
whutsup | 8:2a4298cbae3f | 304 | // for(int i=0; i<16; i++) |
whutsup | 8:2a4298cbae3f | 305 | // { |
whutsup | 8:2a4298cbae3f | 306 | // colors0[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 307 | // colors1[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 308 | // colors2[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 309 | // colors3[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 310 | // colors4[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 311 | // colors5[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 312 | // colors6[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 313 | // colors7[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 314 | // } |
whutsup | 8:2a4298cbae3f | 315 | // |
whutsup | 8:2a4298cbae3f | 316 | // |
whutsup | 8:2a4298cbae3f | 317 | // led0.write(colors0, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 318 | // led1.write(colors1, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 319 | // led2.write(colors2, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 320 | // led3.write(colors3, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 321 | // led4.write(colors4, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 322 | // led5.write(colors5, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 323 | // led6.write(colors6, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 324 | // led7.write(colors7, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 325 | // } |
whutsup | 8:2a4298cbae3f | 326 | |
whutsup | 8:2a4298cbae3f | 327 | } |
whutsup | 8:2a4298cbae3f | 328 | |
whutsup | 8:2a4298cbae3f | 329 | void LedOn3() |
whutsup | 8:2a4298cbae3f | 330 | { |
whutsup | 8:2a4298cbae3f | 331 | |
whutsup | 8:2a4298cbae3f | 332 | int pulse = re.getPulses(); |
whutsup | 8:2a4298cbae3f | 333 | int d = pulse/200; |
whutsup | 8:2a4298cbae3f | 334 | |
whutsup | 8:2a4298cbae3f | 335 | |
whutsup | 8:2a4298cbae3f | 336 | if(48>=d) |
whutsup | 8:2a4298cbae3f | 337 | { |
whutsup | 8:2a4298cbae3f | 338 | |
whutsup | 8:2a4298cbae3f | 339 | uint8_t r[8]; |
whutsup | 8:2a4298cbae3f | 340 | uint8_t g[8]; |
whutsup | 8:2a4298cbae3f | 341 | uint8_t b[8]; |
whutsup | 8:2a4298cbae3f | 342 | |
whutsup | 8:2a4298cbae3f | 343 | |
whutsup | 8:2a4298cbae3f | 344 | for (int i=0 ; i<8 ; i++) |
whutsup | 8:2a4298cbae3f | 345 | { |
whutsup | 8:2a4298cbae3f | 346 | int moveL_r = ((R/(48-6*(i)))+1)*(d-48)+R; |
whutsup | 8:2a4298cbae3f | 347 | int moveL_g = ((G/(48-6*(i)))+1)*(d-48)+G; |
whutsup | 8:2a4298cbae3f | 348 | int moveL_b = ((B/(48-6*(i)))+1)*(d-48)+B; |
whutsup | 8:2a4298cbae3f | 349 | |
whutsup | 8:2a4298cbae3f | 350 | r[i] = (0 >= moveL_r) ? 0: moveL_r; |
whutsup | 8:2a4298cbae3f | 351 | g[i] = (0 >= moveL_g) ? 0: moveL_g; |
whutsup | 8:2a4298cbae3f | 352 | b[i] = (0 >= moveL_b) ? 0: moveL_b; |
whutsup | 8:2a4298cbae3f | 353 | } |
whutsup | 8:2a4298cbae3f | 354 | |
whutsup | 8:2a4298cbae3f | 355 | |
whutsup | 8:2a4298cbae3f | 356 | |
whutsup | 8:2a4298cbae3f | 357 | for(int i=0; i<16; i++) |
whutsup | 8:2a4298cbae3f | 358 | { |
whutsup | 8:2a4298cbae3f | 359 | colors0[i] = (rgb_color){ r[0], g[0], b[0] }; |
whutsup | 8:2a4298cbae3f | 360 | colors1[i] = (rgb_color){ r[1], g[1], b[1] }; |
whutsup | 8:2a4298cbae3f | 361 | colors2[i] = (rgb_color){ r[2], g[2], b[2] }; |
whutsup | 8:2a4298cbae3f | 362 | colors3[i] = (rgb_color){ r[3], g[3], b[3] }; |
whutsup | 8:2a4298cbae3f | 363 | colors4[i] = (rgb_color){ r[4], g[4], b[4] }; |
whutsup | 8:2a4298cbae3f | 364 | colors5[i] = (rgb_color){ r[5], g[5], b[5] }; |
whutsup | 8:2a4298cbae3f | 365 | colors6[i] = (rgb_color){ r[6], g[6], b[6] }; |
whutsup | 8:2a4298cbae3f | 366 | colors7[i] = (rgb_color){ r[7], g[7], b[7] }; |
whutsup | 8:2a4298cbae3f | 367 | } |
whutsup | 8:2a4298cbae3f | 368 | |
whutsup | 8:2a4298cbae3f | 369 | |
whutsup | 8:2a4298cbae3f | 370 | led0.write(colors0, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 371 | led1.write(colors1, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 372 | led2.write(colors2, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 373 | led3.write(colors3, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 374 | led4.write(colors4, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 375 | led5.write(colors5, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 376 | led6.write(colors6, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 377 | led7.write(colors7, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 378 | |
whutsup | 8:2a4298cbae3f | 379 | } |
whutsup | 8:2a4298cbae3f | 380 | |
whutsup | 8:2a4298cbae3f | 381 | else if(52<=d) |
whutsup | 8:2a4298cbae3f | 382 | { |
whutsup | 8:2a4298cbae3f | 383 | uint8_t r[8]; |
whutsup | 8:2a4298cbae3f | 384 | uint8_t g[8]; |
whutsup | 8:2a4298cbae3f | 385 | uint8_t b[8]; |
whutsup | 8:2a4298cbae3f | 386 | |
whutsup | 8:2a4298cbae3f | 387 | for (int i=0 ; i<8 ; i++) |
whutsup | 8:2a4298cbae3f | 388 | { |
whutsup | 8:2a4298cbae3f | 389 | int moveR_r = ((-1*R/(6+6*(i)))-1)*(d-52)+R; |
whutsup | 8:2a4298cbae3f | 390 | int moveR_g = ((-1*G/(6+6*(i)))-1)*(d-52)+G; |
whutsup | 8:2a4298cbae3f | 391 | int moveR_b = ((-1*B/(6+6*(i)))-1)*(d-52)+B; |
whutsup | 8:2a4298cbae3f | 392 | |
whutsup | 8:2a4298cbae3f | 393 | r[i] = (0 >= moveR_r) ? 0:moveR_r ; |
whutsup | 8:2a4298cbae3f | 394 | g[i] = (0 >= moveR_g) ? 0:moveR_g ; |
whutsup | 8:2a4298cbae3f | 395 | b[i] = (0 >= moveR_b) ? 0:moveR_b ; |
whutsup | 8:2a4298cbae3f | 396 | } |
whutsup | 8:2a4298cbae3f | 397 | |
whutsup | 8:2a4298cbae3f | 398 | |
whutsup | 8:2a4298cbae3f | 399 | |
whutsup | 8:2a4298cbae3f | 400 | for(int i=0; i<16; i++) |
whutsup | 8:2a4298cbae3f | 401 | { |
whutsup | 8:2a4298cbae3f | 402 | colors0[i] = (rgb_color){ r[0], g[0], b[0] }; |
whutsup | 8:2a4298cbae3f | 403 | colors1[i] = (rgb_color){ r[1], g[1], b[1] }; |
whutsup | 8:2a4298cbae3f | 404 | colors2[i] = (rgb_color){ r[2], g[2], b[2] }; |
whutsup | 8:2a4298cbae3f | 405 | colors3[i] = (rgb_color){ r[3], g[3], b[3] }; |
whutsup | 8:2a4298cbae3f | 406 | colors4[i] = (rgb_color){ r[4], g[4], b[4] }; |
whutsup | 8:2a4298cbae3f | 407 | colors5[i] = (rgb_color){ r[5], g[5], b[5] }; |
whutsup | 8:2a4298cbae3f | 408 | colors6[i] = (rgb_color){ r[6], g[6], b[6] }; |
whutsup | 8:2a4298cbae3f | 409 | colors7[i] = (rgb_color){ r[7], g[7], b[7] }; |
whutsup | 8:2a4298cbae3f | 410 | } |
whutsup | 8:2a4298cbae3f | 411 | |
whutsup | 8:2a4298cbae3f | 412 | |
whutsup | 8:2a4298cbae3f | 413 | led0.write(colors0, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 414 | led1.write(colors1, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 415 | led2.write(colors2, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 416 | led3.write(colors3, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 417 | led4.write(colors4, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 418 | led5.write(colors5, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 419 | led6.write(colors6, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 420 | led7.write(colors7, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 421 | |
whutsup | 8:2a4298cbae3f | 422 | } |
whutsup | 8:2a4298cbae3f | 423 | |
whutsup | 8:2a4298cbae3f | 424 | else |
whutsup | 8:2a4298cbae3f | 425 | { |
whutsup | 8:2a4298cbae3f | 426 | |
whutsup | 8:2a4298cbae3f | 427 | for(int i=0; i<16; i++) |
whutsup | 8:2a4298cbae3f | 428 | { |
whutsup | 8:2a4298cbae3f | 429 | colors0[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 430 | colors1[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 431 | colors2[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 432 | colors3[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 433 | colors4[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 434 | colors5[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 435 | colors6[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 436 | colors7[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 437 | } |
whutsup | 8:2a4298cbae3f | 438 | |
whutsup | 8:2a4298cbae3f | 439 | |
whutsup | 8:2a4298cbae3f | 440 | led0.write(colors0, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 441 | led1.write(colors1, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 442 | led2.write(colors2, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 443 | led3.write(colors3, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 444 | led4.write(colors4, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 445 | led5.write(colors5, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 446 | led6.write(colors6, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 447 | led7.write(colors7, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 448 | } |
whutsup | 8:2a4298cbae3f | 449 | |
whutsup | 8:2a4298cbae3f | 450 | } |
whutsup | 8:2a4298cbae3f | 451 | |
whutsup | 8:2a4298cbae3f | 452 | void MoonPhase() |
whutsup | 8:2a4298cbae3f | 453 | { |
whutsup | 8:2a4298cbae3f | 454 | |
whutsup | 8:2a4298cbae3f | 455 | int d = dayLed;; |
whutsup | 8:2a4298cbae3f | 456 | |
whutsup | 8:2a4298cbae3f | 457 | if(48>=d) |
whutsup | 8:2a4298cbae3f | 458 | { |
whutsup | 8:2a4298cbae3f | 459 | |
whutsup | 8:2a4298cbae3f | 460 | uint8_t r[8]; |
whutsup | 8:2a4298cbae3f | 461 | uint8_t g[8]; |
whutsup | 8:2a4298cbae3f | 462 | uint8_t b[8]; |
whutsup | 8:2a4298cbae3f | 463 | |
whutsup | 8:2a4298cbae3f | 464 | for (int i=0 ; i<8 ; i++) |
whutsup | 8:2a4298cbae3f | 465 | { |
whutsup | 8:2a4298cbae3f | 466 | int n = (i+1); |
whutsup | 8:2a4298cbae3f | 467 | int moveL_r = ((R/6)*(d-1*n*6))+R; |
whutsup | 8:2a4298cbae3f | 468 | int moveL_g = ((G/6)*(d-1*n*6))+G; |
whutsup | 8:2a4298cbae3f | 469 | int moveL_b = ((B/6)*(d-1*n*6))+B; |
whutsup | 8:2a4298cbae3f | 470 | |
whutsup | 8:2a4298cbae3f | 471 | moveL_r = (0 >= moveL_r) ? 0: moveL_r; |
whutsup | 8:2a4298cbae3f | 472 | moveL_g = (0 >= moveL_g) ? 0: moveL_g; |
whutsup | 8:2a4298cbae3f | 473 | moveL_b = (0 >= moveL_b) ? 0: moveL_b; |
whutsup | 8:2a4298cbae3f | 474 | |
whutsup | 8:2a4298cbae3f | 475 | moveL_r = (R <= moveL_r) ? R: moveL_r; |
whutsup | 8:2a4298cbae3f | 476 | moveL_g = (G <= moveL_g) ? G: moveL_g; |
whutsup | 8:2a4298cbae3f | 477 | moveL_b = (B <= moveL_b) ? B: moveL_b; |
whutsup | 8:2a4298cbae3f | 478 | |
whutsup | 8:2a4298cbae3f | 479 | |
whutsup | 8:2a4298cbae3f | 480 | r[i] = moveL_r; |
whutsup | 8:2a4298cbae3f | 481 | g[i] = moveL_g; |
whutsup | 8:2a4298cbae3f | 482 | b[i] = moveL_b; |
whutsup | 8:2a4298cbae3f | 483 | |
whutsup | 8:2a4298cbae3f | 484 | } |
whutsup | 8:2a4298cbae3f | 485 | |
whutsup | 8:2a4298cbae3f | 486 | |
whutsup | 8:2a4298cbae3f | 487 | |
whutsup | 8:2a4298cbae3f | 488 | for(int i=0; i<16; i++) |
whutsup | 8:2a4298cbae3f | 489 | { |
whutsup | 8:2a4298cbae3f | 490 | colors0[i] = (rgb_color){ r[0], g[0], b[0] }; |
whutsup | 8:2a4298cbae3f | 491 | colors1[i] = (rgb_color){ r[1], g[1], b[1] }; |
whutsup | 8:2a4298cbae3f | 492 | colors2[i] = (rgb_color){ r[2], g[2], b[2] }; |
whutsup | 8:2a4298cbae3f | 493 | colors3[i] = (rgb_color){ r[3], g[3], b[3] }; |
whutsup | 8:2a4298cbae3f | 494 | colors4[i] = (rgb_color){ r[4], g[4], b[4] }; |
whutsup | 8:2a4298cbae3f | 495 | colors5[i] = (rgb_color){ r[5], g[5], b[5] }; |
whutsup | 8:2a4298cbae3f | 496 | colors6[i] = (rgb_color){ r[6], g[6], b[6] }; |
whutsup | 8:2a4298cbae3f | 497 | colors7[i] = (rgb_color){ r[7], g[7], b[7] }; |
whutsup | 8:2a4298cbae3f | 498 | } |
whutsup | 8:2a4298cbae3f | 499 | |
whutsup | 8:2a4298cbae3f | 500 | |
whutsup | 8:2a4298cbae3f | 501 | led0.write(colors0, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 502 | led1.write(colors1, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 503 | led2.write(colors2, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 504 | led3.write(colors3, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 505 | led4.write(colors4, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 506 | led5.write(colors5, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 507 | led6.write(colors6, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 508 | led7.write(colors7, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 509 | |
whutsup | 8:2a4298cbae3f | 510 | } |
whutsup | 8:2a4298cbae3f | 511 | |
whutsup | 8:2a4298cbae3f | 512 | else if(52<=d) |
whutsup | 8:2a4298cbae3f | 513 | { |
whutsup | 8:2a4298cbae3f | 514 | uint8_t r[8]; |
whutsup | 8:2a4298cbae3f | 515 | uint8_t g[8]; |
whutsup | 8:2a4298cbae3f | 516 | uint8_t b[8]; |
whutsup | 8:2a4298cbae3f | 517 | |
whutsup | 8:2a4298cbae3f | 518 | for (int i=0 ; i<8 ; i++) |
whutsup | 8:2a4298cbae3f | 519 | { |
whutsup | 8:2a4298cbae3f | 520 | int moveR_r = -1*(R/6)*(d-1*(52+(i+1)*6))+R; |
whutsup | 8:2a4298cbae3f | 521 | int moveR_g = -1*(G/6)*(d-1*(52+(i+1)*6))+G; |
whutsup | 8:2a4298cbae3f | 522 | int moveR_b = -1*(B/6)*(d-1*(52+(i+1)*6))+B; |
whutsup | 8:2a4298cbae3f | 523 | |
whutsup | 8:2a4298cbae3f | 524 | |
whutsup | 8:2a4298cbae3f | 525 | moveR_r = (0 >= moveR_r) ? 0: moveR_r; |
whutsup | 8:2a4298cbae3f | 526 | moveR_g = (0 >= moveR_g) ? 0: moveR_g; |
whutsup | 8:2a4298cbae3f | 527 | moveR_b = (0 >= moveR_b) ? 0: moveR_b; |
whutsup | 8:2a4298cbae3f | 528 | |
whutsup | 8:2a4298cbae3f | 529 | moveR_r = (R <= moveR_r) ? R: moveR_r; |
whutsup | 8:2a4298cbae3f | 530 | moveR_g = (G <= moveR_g) ? G: moveR_g; |
whutsup | 8:2a4298cbae3f | 531 | moveR_b = (B <= moveR_b) ? B: moveR_b; |
whutsup | 8:2a4298cbae3f | 532 | |
whutsup | 8:2a4298cbae3f | 533 | |
whutsup | 8:2a4298cbae3f | 534 | r[i] = moveR_r; |
whutsup | 8:2a4298cbae3f | 535 | g[i] = moveR_g; |
whutsup | 8:2a4298cbae3f | 536 | b[i] = moveR_b; |
whutsup | 8:2a4298cbae3f | 537 | } |
whutsup | 8:2a4298cbae3f | 538 | |
whutsup | 8:2a4298cbae3f | 539 | |
whutsup | 8:2a4298cbae3f | 540 | |
whutsup | 8:2a4298cbae3f | 541 | for(int i=0; i<16; i++) |
whutsup | 8:2a4298cbae3f | 542 | { |
whutsup | 8:2a4298cbae3f | 543 | colors0[i] = (rgb_color){ r[0], g[0], b[0] }; |
whutsup | 8:2a4298cbae3f | 544 | colors1[i] = (rgb_color){ r[1], g[1], b[1] }; |
whutsup | 8:2a4298cbae3f | 545 | colors2[i] = (rgb_color){ r[2], g[2], b[2] }; |
whutsup | 8:2a4298cbae3f | 546 | colors3[i] = (rgb_color){ r[3], g[3], b[3] }; |
whutsup | 8:2a4298cbae3f | 547 | colors4[i] = (rgb_color){ r[4], g[4], b[4] }; |
whutsup | 8:2a4298cbae3f | 548 | colors5[i] = (rgb_color){ r[5], g[5], b[5] }; |
whutsup | 8:2a4298cbae3f | 549 | colors6[i] = (rgb_color){ r[6], g[6], b[6] }; |
whutsup | 8:2a4298cbae3f | 550 | colors7[i] = (rgb_color){ r[7], g[7], b[7] }; |
whutsup | 8:2a4298cbae3f | 551 | } |
whutsup | 8:2a4298cbae3f | 552 | |
whutsup | 8:2a4298cbae3f | 553 | |
whutsup | 8:2a4298cbae3f | 554 | led0.write(colors0, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 555 | led1.write(colors1, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 556 | led2.write(colors2, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 557 | led3.write(colors3, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 558 | led4.write(colors4, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 559 | led5.write(colors5, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 560 | led6.write(colors6, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 561 | led7.write(colors7, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 562 | |
whutsup | 8:2a4298cbae3f | 563 | } |
whutsup | 8:2a4298cbae3f | 564 | |
whutsup | 8:2a4298cbae3f | 565 | else |
whutsup | 8:2a4298cbae3f | 566 | { |
whutsup | 8:2a4298cbae3f | 567 | |
whutsup | 8:2a4298cbae3f | 568 | for(int i=0; i<16; i++) |
whutsup | 8:2a4298cbae3f | 569 | { |
whutsup | 8:2a4298cbae3f | 570 | colors0[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 571 | colors1[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 572 | colors2[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 573 | colors3[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 574 | colors4[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 575 | colors5[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 576 | colors6[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 577 | colors7[i] = (rgb_color){ R, G, B }; |
whutsup | 8:2a4298cbae3f | 578 | } |
whutsup | 8:2a4298cbae3f | 579 | |
whutsup | 8:2a4298cbae3f | 580 | |
whutsup | 8:2a4298cbae3f | 581 | led0.write(colors0, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 582 | led1.write(colors1, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 583 | led2.write(colors2, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 584 | led3.write(colors3, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 585 | led4.write(colors4, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 586 | led5.write(colors5, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 587 | led6.write(colors6, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 588 | led7.write(colors7, LED_COUNT); |
whutsup | 8:2a4298cbae3f | 589 | } |
whutsup | 8:2a4298cbae3f | 590 | |
whutsup | 8:2a4298cbae3f | 591 | } |
whutsup | 8:2a4298cbae3f | 592 | |
whutsup | 8:2a4298cbae3f | 593 | |
whutsup | 8:2a4298cbae3f | 594 | void ModeSelect(int mode) |
whutsup | 8:2a4298cbae3f | 595 | { |
whutsup | 8:2a4298cbae3f | 596 | |
whutsup | 8:2a4298cbae3f | 597 | switch(mode) |
whutsup | 8:2a4298cbae3f | 598 | { |
whutsup | 8:2a4298cbae3f | 599 | |
whutsup | 8:2a4298cbae3f | 600 | case 0 : |
whutsup | 8:2a4298cbae3f | 601 | |
whutsup | 8:2a4298cbae3f | 602 | led.detach(); |
whutsup | 8:2a4298cbae3f | 603 | |
whutsup | 8:2a4298cbae3f | 604 | |
whutsup | 8:2a4298cbae3f | 605 | break; |
whutsup | 8:2a4298cbae3f | 606 | |
whutsup | 8:2a4298cbae3f | 607 | case 1 : |
whutsup | 8:2a4298cbae3f | 608 | led.detach(); |
whutsup | 8:2a4298cbae3f | 609 | |
whutsup | 8:2a4298cbae3f | 610 | R = 119; |
whutsup | 8:2a4298cbae3f | 611 | G = 66; |
whutsup | 8:2a4298cbae3f | 612 | B = 255; |
whutsup | 8:2a4298cbae3f | 613 | |
whutsup | 8:2a4298cbae3f | 614 | led.attach(&LedOn1, 0.05); |
whutsup | 8:2a4298cbae3f | 615 | |
whutsup | 8:2a4298cbae3f | 616 | break; |
whutsup | 8:2a4298cbae3f | 617 | |
whutsup | 8:2a4298cbae3f | 618 | case 2 : |
whutsup | 8:2a4298cbae3f | 619 | |
whutsup | 8:2a4298cbae3f | 620 | led.detach(); |
whutsup | 8:2a4298cbae3f | 621 | |
whutsup | 8:2a4298cbae3f | 622 | R = 119; |
whutsup | 8:2a4298cbae3f | 623 | G = 66; |
whutsup | 8:2a4298cbae3f | 624 | B = 255; |
whutsup | 8:2a4298cbae3f | 625 | |
whutsup | 8:2a4298cbae3f | 626 | led.attach(&LedOn2, 0.05); |
whutsup | 8:2a4298cbae3f | 627 | break; |
whutsup | 8:2a4298cbae3f | 628 | |
whutsup | 8:2a4298cbae3f | 629 | case 3 : |
whutsup | 8:2a4298cbae3f | 630 | |
whutsup | 8:2a4298cbae3f | 631 | led.detach(); |
whutsup | 8:2a4298cbae3f | 632 | |
whutsup | 8:2a4298cbae3f | 633 | R = 119; |
whutsup | 8:2a4298cbae3f | 634 | G = 66; |
whutsup | 8:2a4298cbae3f | 635 | B = 255; |
whutsup | 8:2a4298cbae3f | 636 | |
whutsup | 8:2a4298cbae3f | 637 | led.attach(&LedOn3, 0.05); |
whutsup | 8:2a4298cbae3f | 638 | |
whutsup | 8:2a4298cbae3f | 639 | break; |
whutsup | 8:2a4298cbae3f | 640 | |
whutsup | 8:2a4298cbae3f | 641 | case 4 : |
whutsup | 8:2a4298cbae3f | 642 | |
whutsup | 8:2a4298cbae3f | 643 | led.detach(); |
whutsup | 8:2a4298cbae3f | 644 | |
whutsup | 8:2a4298cbae3f | 645 | R = 119; |
whutsup | 8:2a4298cbae3f | 646 | G = 66; |
whutsup | 8:2a4298cbae3f | 647 | B = 255; |
whutsup | 8:2a4298cbae3f | 648 | |
whutsup | 8:2a4298cbae3f | 649 | led.attach(&MoonPhase, 0.05); |
whutsup | 8:2a4298cbae3f | 650 | |
whutsup | 8:2a4298cbae3f | 651 | break; |
whutsup | 8:2a4298cbae3f | 652 | |
whutsup | 8:2a4298cbae3f | 653 | } |
whutsup | 8:2a4298cbae3f | 654 | |
whutsup | 8:2a4298cbae3f | 655 | } |
whutsup | 8:2a4298cbae3f | 656 |