|
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." |
| 32 | +#define HELLO_MESSAGE "\r\nWelcome!\r\nAwa driver 11." |
33 | 33 |
|
34 | 34 | #include "calibration.h" |
35 | 35 | #include "statistics.h" |
@@ -113,13 +113,28 @@ void processData() |
113 | 113 | case AwaProtocol::HEADER_A: |
114 | 114 | // assume it's protocol version 1, verify it later |
115 | 115 | frameState.setProtocolVersion2(false); |
| 116 | + frameState.setProtocolVersion3(false); |
116 | 117 | if (input == 'A') |
117 | 118 | frameState.setState(AwaProtocol::HEADER_w); |
118 | 119 | break; |
119 | 120 |
|
120 | 121 | case AwaProtocol::HEADER_w: |
121 | 122 | if (input == 'w') |
122 | 123 | frameState.setState(AwaProtocol::HEADER_a); |
| 124 | +#if defined(NEOPIXEL_RGBW) || defined(SPILED_APA102) |
| 125 | + else if (input == 'W') |
| 126 | + frameState.setState(AwaProtocol::HEADER_W); |
| 127 | +#endif |
| 128 | + else |
| 129 | + frameState.setState(AwaProtocol::HEADER_A); |
| 130 | + break; |
| 131 | + case AwaProtocol::HEADER_W: |
| 132 | + // detect protocol version 3 |
| 133 | + if (input == 'a') |
| 134 | + { |
| 135 | + frameState.setState(AwaProtocol::HEADER_HI); |
| 136 | + frameState.setProtocolVersion3(true); |
| 137 | + } |
123 | 138 | else |
124 | 139 | frameState.setState(AwaProtocol::HEADER_A); |
125 | 140 | break; |
@@ -196,10 +211,38 @@ void processData() |
196 | 211 | frameState.setState(AwaProtocol::BLUE); |
197 | 212 | break; |
198 | 213 |
|
| 214 | + case AwaProtocol::EXTRA_COLOR_BYTE_4: |
| 215 | + #ifdef NEOPIXEL_RGBW |
| 216 | + frameState.color.W = input; |
| 217 | + #elif defined(SPILED_APA102) |
| 218 | + frameState.color.W = input; |
| 219 | + #endif |
| 220 | + frameState.addFletcher(input); |
| 221 | + |
| 222 | + if (base.setStripPixel(frameState.getCurrentLedIndex(), frameState.color)) |
| 223 | + { |
| 224 | + frameState.setState(AwaProtocol::RED); |
| 225 | + } |
| 226 | + else |
| 227 | + { |
| 228 | + frameState.setState(AwaProtocol::FLETCHER1); |
| 229 | + } |
| 230 | + break; |
| 231 | + |
199 | 232 | case AwaProtocol::BLUE: |
200 | 233 | frameState.color.B = input; |
201 | 234 | frameState.addFletcher(input); |
202 | 235 |
|
| 236 | + if (frameState.isProtocolVersion3()) |
| 237 | + { |
| 238 | + frameState.setState(AwaProtocol::EXTRA_COLOR_BYTE_4); |
| 239 | + break; |
| 240 | + } |
| 241 | + |
| 242 | + #if defined(SPILED_APA102) |
| 243 | + frameState.color.W = 0xFF; |
| 244 | + #endif |
| 245 | + |
203 | 246 | #ifdef NEOPIXEL_RGBW |
204 | 247 | // calculate RGBW from RGB using provided calibration data |
205 | 248 | frameState.rgb2rgbw(); |
|
0 commit comments