Skip to content

Commit 7946604

Browse files
committed
Direct 32-bit rendering for HD107 or RGBW
1 parent 0642761 commit 7946604

File tree

3 files changed

+71
-4
lines changed

3 files changed

+71
-4
lines changed

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;
@@ -159,6 +162,27 @@ class
159162
protocolVersion2 = newVer;
160163
}
161164

165+
/**
166+
* @brief Set if frame protocol version 3 (direct 32bit mode)
167+
*
168+
* @param newVer
169+
*/
170+
inline void setProtocolVersion3(bool newVer)
171+
{
172+
protocolVersion3 = newVer;
173+
}
174+
175+
/**
176+
* @brief Verify if frame protocol version 3 (direct 32bit mode)
177+
*
178+
* @return true
179+
* @return false
180+
*/
181+
inline bool isProtocolVersion3() const
182+
{
183+
return protocolVersion3;
184+
}
185+
162186
/**
163187
* @brief Verify if frame protocol version 2 (contains calibration data)
164188
*

include/leds.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,17 @@ struct ColorGrbw
140140

141141
struct ColorDotstartBgr
142142
{
143-
uint8_t brightness;
143+
uint8_t Brightness;
144144
uint8_t B;
145145
uint8_t G;
146146
uint8_t R;
147147

148148
ColorDotstartBgr(uint8_t gray) :
149-
R(gray), G(gray), B(gray), brightness(gray | 0b11100000)
149+
R(gray), G(gray), B(gray), Brightness(gray | 0b11100000)
150150
{
151151
};
152152

153-
ColorDotstartBgr() : R(0), G(0), B(0), brightness(0xff)
153+
ColorDotstartBgr() : R(0), G(0), B(0), Brightness(0xff)
154154
{
155155
};
156156
};

include/main.h

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#define MAIN_H
3030

3131
#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"
3333

3434
#include "calibration.h"
3535
#include "statistics.h"
@@ -81,13 +81,28 @@ void processData()
8181
case AwaProtocol::HEADER_A:
8282
// assume it's protocol version 1, verify it later
8383
frameState.setProtocolVersion2(false);
84+
frameState.setProtocolVersion3(false);
8485
if (input == 'A')
8586
frameState.setState(AwaProtocol::HEADER_w);
8687
break;
8788

8889
case AwaProtocol::HEADER_w:
8990
if (input == 'w')
9091
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+
}
91106
else
92107
frameState.setState(AwaProtocol::HEADER_A);
93108
break;
@@ -167,10 +182,38 @@ void processData()
167182
frameState.setState(AwaProtocol::BLUE);
168183
break;
169184

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+
170203
case AwaProtocol::BLUE:
171204
frameState.color.B = input;
172205
frameState.addFletcher(input);
173206

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+
174217
#ifdef NEOPIXEL_RGBW
175218
// calculate RGBW from RGB using provided calibration data
176219
frameState.rgb2rgbw();

0 commit comments

Comments
 (0)