Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/calibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

#ifdef NEOPIXEL_RGBW
typedef RgbwColor ColorDefinition;
#elif defined(SPILED_APA102)
typedef RgbwColor ColorDefinition;
#else
typedef RgbColor ColorDefinition;
#endif
Expand Down
24 changes: 24 additions & 0 deletions include/framestate.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
enum class AwaProtocol
{
HEADER_A,
HEADER_W,
HEADER_w,
HEADER_a,
HEADER_HI,
Expand All @@ -47,6 +48,7 @@ enum class AwaProtocol
RED,
GREEN,
BLUE,
EXTRA_COLOR_BYTE_4,
FLETCHER1,
FLETCHER2,
FLETCHER_EXT
Expand All @@ -60,6 +62,7 @@ class
{
volatile AwaProtocol state = AwaProtocol::HEADER_A;
bool protocolVersion2 = false;
bool protocolVersion3 = false;
uint8_t CRC = 0;
uint16_t count = 0;
uint16_t currentLed = 0;
Expand Down Expand Up @@ -158,6 +161,27 @@ class
protocolVersion2 = newVer;
}

/**
* @brief Set if frame protocol version 3 (direct 32bit mode)
*
* @param newVer
*/
inline void setProtocolVersion3(bool newVer)
{
protocolVersion3 = newVer;
}

/**
* @brief Verify if frame protocol version 3 (direct 32bit mode)
*
* @return true
* @return false
*/
inline bool isProtocolVersion3() const
{
return protocolVersion3;
}

/**
* @brief Verify if frame protocol version 2 (contains calibration data)
*
Expand Down
45 changes: 44 additions & 1 deletion include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define MAIN_H

#define MAX_BUFFER (3013 * 3 + 1)
#define HELLO_MESSAGE "\r\nWelcome!\r\nAwa driver 9."
#define HELLO_MESSAGE "\r\nWelcome!\r\nAwa driver 11."

#include "calibration.h"
#include "statistics.h"
Expand Down Expand Up @@ -113,13 +113,28 @@ void processData()
case AwaProtocol::HEADER_A:
// assume it's protocol version 1, verify it later
frameState.setProtocolVersion2(false);
frameState.setProtocolVersion3(false);
if (input == 'A')
frameState.setState(AwaProtocol::HEADER_w);
break;

case AwaProtocol::HEADER_w:
if (input == 'w')
frameState.setState(AwaProtocol::HEADER_a);
#if defined(NEOPIXEL_RGBW) || defined(SPILED_APA102)
else if (input == 'W')
frameState.setState(AwaProtocol::HEADER_W);
#endif
else
frameState.setState(AwaProtocol::HEADER_A);
break;
case AwaProtocol::HEADER_W:
// detect protocol version 3
if (input == 'a')
{
frameState.setState(AwaProtocol::HEADER_HI);
frameState.setProtocolVersion3(true);
}
else
frameState.setState(AwaProtocol::HEADER_A);
break;
Expand Down Expand Up @@ -196,10 +211,38 @@ void processData()
frameState.setState(AwaProtocol::BLUE);
break;

case AwaProtocol::EXTRA_COLOR_BYTE_4:
#ifdef NEOPIXEL_RGBW
frameState.color.W = input;
#elif defined(SPILED_APA102)
frameState.color.W = input;
#endif
frameState.addFletcher(input);

if (base.setStripPixel(frameState.getCurrentLedIndex(), frameState.color))
{
frameState.setState(AwaProtocol::RED);
}
else
{
frameState.setState(AwaProtocol::FLETCHER1);
}
break;

case AwaProtocol::BLUE:
frameState.color.B = input;
frameState.addFletcher(input);

if (frameState.isProtocolVersion3())
{
frameState.setState(AwaProtocol::EXTRA_COLOR_BYTE_4);
break;
}

#if defined(SPILED_APA102)
frameState.color.W = 0xFF;
#endif

#ifdef NEOPIXEL_RGBW
// calculate RGBW from RGB using provided calibration data
frameState.rgb2rgbw();
Expand Down
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
#endif

#ifdef SPILED_APA102
#define LED_DRIVER NeoPixelBus<DotStarBgrFeature, DotStarEsp32DmaHspiMethod>
#define LED_DRIVER NeoPixelBus<DotStarLbgrFeature, DotStarEsp32DmaHspiMethod>
#elif SPILED_WS2801
#define LED_DRIVER NeoPixelBus<NeoRbgFeature, NeoWs2801Spi2MhzMethod>
#endif
Expand Down Expand Up @@ -111,7 +111,7 @@
#define LED_DRIVER2 NeoPixelBus<NeoGrbFeature, NeoEsp32I2s0Ws2812xMethod>
#endif
#elif SPILED_APA102
#define LED_DRIVER2 NeoPixelBus<DotStarBgrFeature, DotStarEsp32DmaHspiMethod>
#define LED_DRIVER2 NeoPixelBus<DotStarLbgrFeature, DotStarEsp32DmaHspiMethod>
#elif SPILED_WS2801
#define LED_DRIVER2 NeoPixelBus<NeoRbgFeature, NeoWs2801Spi2MhzMethod>
#endif
Expand All @@ -133,7 +133,7 @@
#define LED_DRIVER2 NeoPixelBus<NeoGrbFeature, NeoEsp32I2s0Ws2812xMethod>
#endif
#elif SPILED_APA102
#define LED_DRIVER2 NeoPixelBus<DotStarBgrFeature, DotStarEsp32DmaVspiMethod>
#define LED_DRIVER2 NeoPixelBus<DotStarLbgrFeature, DotStarEsp32DmaVspiMethod>
#elif SPILED_WS2801
#define LED_DRIVER2 NeoPixelBus<NeoRbgFeature, NeoWs2801Spi2MhzMethod>
#endif
Expand Down