Skip to content
Snippets Groups Projects
Commit cce9740c authored by fxk8y's avatar fxk8y :spider:
Browse files

ST: Make sub-pixel color ordering configurable

parent cb0caaf3
No related branches found
No related tags found
No related merge requests found
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
// #include "freertos/queue.h" // #include "freertos/queue.h"
// project specific // project specific
#include <Types.hpp>
#include "FxVSync.hpp" #include "FxVSync.hpp"
#include "CyanBus.hpp" #include "CyanBus.hpp"
#include "SpiderLib/NumberTypes.hpp"
// qthing stuff // qthing stuff
// #include "" // #include ""
...@@ -148,5 +148,31 @@ namespace SiliconTorch { ...@@ -148,5 +148,31 @@ namespace SiliconTorch {
buffer1[px].b = 0; buffer1[px].b = 0;
} }
} }
str colorOrder2String(ColorOrder co) {
switch (co) {
case ColorOrder::RGB: return "RGB";
case ColorOrder::RBG: return "RBG";
case ColorOrder::GRB: return "GRB";
case ColorOrder::GBR: return "GBR";
case ColorOrder::BRG: return "BRG";
case ColorOrder::BGR: return "BGR";
}
return "RGB";
}
ColorOrder string2ColorOrder(str co) {
if (co.compare("RGB") == 0) return RGB;
else if (co.compare("RBG") == 0) return RBG;
else if (co.compare("GRB") == 0) return GRB;
else if (co.compare("GBR") == 0) return GBR;
else if (co.compare("BRG") == 0) return BRG;
else if (co.compare("BGR") == 0) return BGR;
return ColorOrder::RGB;
}
} }
} }
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
// project specific // project specific
#include "CyanBus.hpp" #include "CyanBus.hpp"
#include "SpiderLib/NumberTypes.hpp" #include "SpiderLib/Types.hpp"
// qthing stuff // qthing stuff
#include <qthing> #include <qthing>
...@@ -27,8 +27,21 @@ namespace SiliconTorch { ...@@ -27,8 +27,21 @@ namespace SiliconTorch {
u8 b; u8 b;
} Pixel; } Pixel;
extern const std::string HEADER; extern const std::string HEADER;
enum ColorOrder {
RGB, RBG,
GRB, GBR,
BRG, BGR
};
str colorOrder2String(ColorOrder co);
ColorOrder string2ColorOrder(str co);
class FxCyanRGB8 : public qthing::Animation<qthing::RGB> { class FxCyanRGB8 : public qthing::Animation<qthing::RGB> {
public: public:
FxCyanRGB8(u16 leds, u16 startIdx = 0); FxCyanRGB8(u16 leds, u16 startIdx = 0);
......
...@@ -60,8 +60,13 @@ namespace SiliconTorch { ...@@ -60,8 +60,13 @@ namespace SiliconTorch {
if (!info.valid) break; if (!info.valid) break;
ESP_LOGI(getName().c_str(), "Configuring: FxCyanRGB8{ info[ %d ] gpio[ %d ] leds[ %d ] startIdx[ %d ] }", idx, info.gpio, info.leds, info.startIdx); ESP_LOGI(getName().c_str(), "Configuring: FxCyanRGB8{ info[ %d ] gpio[ %d ] leds[ %d ] startIdx[ %d ] colorOrder[ %s ] }",
idx,
info.gpio,
info.leds,
info.startIdx,
FxCyanRGB8::colorOrder2String(info.colorOrder).c_str()
);
ChannelDriver channel = { ChannelDriver channel = {
.info = info, .info = info,
...@@ -109,6 +114,10 @@ namespace SiliconTorch { ...@@ -109,6 +114,10 @@ namespace SiliconTorch {
std::snprintf(tmp, sizeof(tmp), "ch%d_startIdx", channel); std::snprintf(tmp, sizeof(tmp), "ch%d_startIdx", channel);
ch.startIdx = nvs.getUnsignedInt(getNameSpace(), std::string(tmp), 0); ch.startIdx = nvs.getUnsignedInt(getNameSpace(), std::string(tmp), 0);
std::snprintf(tmp, sizeof(tmp), "ch%d_colorOrder", channel);
str _colorOrder = nvs.getString(getNameSpace(), std::string(tmp), "RGB");
ch.colorOrder = FxCyanRGB8::string2ColorOrder(_colorOrder);
ch.valid = ch.gpio < 0xFF && ch.leds > 0; ch.valid = ch.gpio < 0xFF && ch.leds > 0;
return ch; return ch;
......
...@@ -29,10 +29,11 @@ namespace SiliconTorch { ...@@ -29,10 +29,11 @@ namespace SiliconTorch {
typedef struct { typedef struct {
u8 gpio = 0; u8 gpio = 0;
u16 leds = 0; u16 leds = 0;
u16 startIdx = 0; u16 startIdx = 0;
bool valid = false; FxCyanRGB8::ColorOrder colorOrder = FxCyanRGB8::ColorOrder::RGB;
bool valid = false;
} ChannelInfo; } ChannelInfo;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment