|
29 | 29 | #define MAIN_H |
30 | 30 |
|
31 | 31 | #define MAX_BUFFER (3013 * 3 + 1) |
32 | | -#define HELLO_MESSAGE "\r\nWelcome!\r\nAwa driver 9.\r\n" |
| 32 | +#define HELLO_MESSAGE "\r\nWelcome!\r\nAwa driver 11.\r\n" |
33 | 33 |
|
34 | 34 | #include "calibration.h" |
35 | 35 | #include "statistics.h" |
@@ -81,13 +81,28 @@ void processData() |
81 | 81 | case AwaProtocol::HEADER_A: |
82 | 82 | // assume it's protocol version 1, verify it later |
83 | 83 | frameState.setProtocolVersion2(false); |
| 84 | + frameState.setProtocolVersion3(false); |
84 | 85 | if (input == 'A') |
85 | 86 | frameState.setState(AwaProtocol::HEADER_w); |
86 | 87 | break; |
87 | 88 |
|
88 | 89 | case AwaProtocol::HEADER_w: |
89 | 90 | if (input == 'w') |
90 | 91 | frameState.setState(AwaProtocol::HEADER_a); |
| 92 | +#if defined(NEOPIXEL_RGBW) || defined(SPILED_APA102) |
| 93 | + else if (input == 'W') |
| 94 | + frameState.setState(AwaProtocol::HEADER_W); |
| 95 | +#endif |
| 96 | + else |
| 97 | + frameState.setState(AwaProtocol::HEADER_A); |
| 98 | + break; |
| 99 | + case AwaProtocol::HEADER_W: |
| 100 | + // detect protocol version 3 |
| 101 | + if (input == 'a') |
| 102 | + { |
| 103 | + frameState.setState(AwaProtocol::HEADER_HI); |
| 104 | + frameState.setProtocolVersion3(true); |
| 105 | + } |
91 | 106 | else |
92 | 107 | frameState.setState(AwaProtocol::HEADER_A); |
93 | 108 | break; |
@@ -167,10 +182,38 @@ void processData() |
167 | 182 | frameState.setState(AwaProtocol::BLUE); |
168 | 183 | break; |
169 | 184 |
|
| 185 | + case AwaProtocol::EXTRA_COLOR_BYTE_4: |
| 186 | + #ifdef NEOPIXEL_RGBW |
| 187 | + frameState.color.W = input; |
| 188 | + #elif defined(SPILED_APA102) |
| 189 | + frameState.color.Brightness = input; |
| 190 | + #endif |
| 191 | + frameState.addFletcher(input); |
| 192 | + |
| 193 | + if (base.setStripPixel(frameState.getCurrentLedIndex(), frameState.color)) |
| 194 | + { |
| 195 | + frameState.setState(AwaProtocol::RED); |
| 196 | + } |
| 197 | + else |
| 198 | + { |
| 199 | + frameState.setState(AwaProtocol::FLETCHER1); |
| 200 | + } |
| 201 | + break; |
| 202 | + |
170 | 203 | case AwaProtocol::BLUE: |
171 | 204 | frameState.color.B = input; |
172 | 205 | frameState.addFletcher(input); |
173 | 206 |
|
| 207 | + if (frameState.isProtocolVersion3()) |
| 208 | + { |
| 209 | + frameState.setState(AwaProtocol::EXTRA_COLOR_BYTE_4); |
| 210 | + break; |
| 211 | + } |
| 212 | + |
| 213 | + #if defined(SPILED_APA102) |
| 214 | + frameState.color.Brightness = 0xFF; |
| 215 | + #endif |
| 216 | + |
174 | 217 | #ifdef NEOPIXEL_RGBW |
175 | 218 | // calculate RGBW from RGB using provided calibration data |
176 | 219 | frameState.rgb2rgbw(); |
|
0 commit comments