Skip to content

Commit 8b13dc8

Browse files
committed
Direct 32-bit rendering for HD107 or RGBW
1 parent 485b5b3 commit 8b13dc8

3 files changed

Lines changed: 70 additions & 1 deletion

File tree

include/calibration.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
#ifdef NEOPIXEL_RGBW
2929
typedef RgbwColor ColorDefinition;
30+
#elif defined(SPILED_APA102)
31+
typedef DotStarColor ColorDefinition;
3032
#else
3133
typedef RgbColor ColorDefinition;
3234
#endif

include/framestate.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
enum class AwaProtocol
3636
{
3737
HEADER_A,
38+
HEADER_W,
3839
HEADER_w,
3940
HEADER_a,
4041
HEADER_HI,
@@ -47,6 +48,7 @@ enum class AwaProtocol
4748
RED,
4849
GREEN,
4950
BLUE,
51+
EXTRA_COLOR_BYTE_4,
5052
FLETCHER1,
5153
FLETCHER2,
5254
FLETCHER_EXT
@@ -60,6 +62,7 @@ class
6062
{
6163
volatile AwaProtocol state = AwaProtocol::HEADER_A;
6264
bool protocolVersion2 = false;
65+
bool protocolVersion3 = false;
6366
uint8_t CRC = 0;
6467
uint16_t count = 0;
6568
uint16_t currentLed = 0;
@@ -169,6 +172,27 @@ class
169172
return protocolVersion2;
170173
}
171174

175+
/**
176+
* @brief Set if frame protocol version 3 (direct 32bit mode)
177+
*
178+
* @param newVer
179+
*/
180+
inline void setProtocolVersion3(bool newVer)
181+
{
182+
protocolVersion3 = newVer;
183+
}
184+
185+
/**
186+
* @brief Verify if frame protocol version 3 (direct 32bit mode)
187+
*
188+
* @return true
189+
* @return false
190+
*/
191+
inline bool isProtocolVersion3() const
192+
{
193+
return protocolVersion3;
194+
}
195+
172196
/**
173197
* @brief Set new AWA frame state
174198
*

include/main.h

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#else
3434
#define MAX_BUFFER (4096)
3535
#endif
36-
#define HELLO_MESSAGE "\r\nWelcome!\r\nAwa driver 10."
36+
#define HELLO_MESSAGE "\r\nWelcome!\r\nAwa driver 11."
3737

3838
#include "calibration.h"
3939
#include "statistics.h"
@@ -113,13 +113,28 @@ void processData()
113113
case AwaProtocol::HEADER_A:
114114
// assume it's protocol version 1, verify it later
115115
frameState.setProtocolVersion2(false);
116+
frameState.setProtocolVersion3(false);
116117
if (input == 'A')
117118
frameState.setState(AwaProtocol::HEADER_w);
118119
break;
119120

120121
case AwaProtocol::HEADER_w:
121122
if (input == 'w')
122123
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+
}
123138
else
124139
frameState.setState(AwaProtocol::HEADER_A);
125140
break;
@@ -196,10 +211,38 @@ void processData()
196211
frameState.setState(AwaProtocol::BLUE);
197212
break;
198213

214+
case AwaProtocol::EXTRA_COLOR_BYTE_4:
215+
#ifdef NEOPIXEL_RGBW
216+
frameState.color.W = input;
217+
#elif defined(SPILED_APA102)
218+
frameState.color.Brightness = 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+
199232
case AwaProtocol::BLUE:
200233
frameState.color.B = input;
201234
frameState.addFletcher(input);
202235

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.Brightness = 0xFF;
244+
#endif
245+
203246
#ifdef NEOPIXEL_RGBW
204247
// calculate RGBW from RGB using provided calibration data
205248
frameState.rgb2rgbw();

0 commit comments

Comments
 (0)