mirror of
https://github.com/arendst/Tasmota.git
synced 2025-08-01 15:07:42 +00:00
Merge pull request #5326 from gsimon75/issue_5310_rgb_order_setoption
Added SetOption37 for RGB remapping
This commit is contained in:
commit
813d2fd3f1
@ -422,7 +422,6 @@
|
|||||||
// #define USE_ALECTO_V2 // Add support for decoding Alecto V2 sensors like ACH2010, WS3000 and DKW2012 weather stations using 868MHz RF sensor receiver (+1k7 code)
|
// #define USE_ALECTO_V2 // Add support for decoding Alecto V2 sensors like ACH2010, WS3000 and DKW2012 weather stations using 868MHz RF sensor receiver (+1k7 code)
|
||||||
|
|
||||||
#define USE_SM16716 // Add support for SM16716 RGB LED controller (+0k7 code)
|
#define USE_SM16716 // Add support for SM16716 RGB LED controller (+0k7 code)
|
||||||
#define USE_SM16716_RGB_ORDER SM16716_RGB // SM16716 RGB order (SM16716_RGB, SM16716_RBG, SM16716_GRB, SM16716_GBR, SM16716_BRG, SM16716_BGR)
|
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Debug features are only supported in development branch
|
* Debug features are only supported in development branch
|
||||||
|
@ -587,6 +587,7 @@ void SettingsDefaultSet2(void)
|
|||||||
// Settings.flag.stop_flash_rotate = 0;
|
// Settings.flag.stop_flash_rotate = 0;
|
||||||
Settings.save_data = SAVE_DATA;
|
Settings.save_data = SAVE_DATA;
|
||||||
Settings.param[P_BOOT_LOOP_OFFSET] = BOOT_LOOP_OFFSET;
|
Settings.param[P_BOOT_LOOP_OFFSET] = BOOT_LOOP_OFFSET;
|
||||||
|
Settings.param[P_RGB_REMAP] = RGB_REMAP_RGBW;
|
||||||
Settings.sleep = APP_SLEEP;
|
Settings.sleep = APP_SLEEP;
|
||||||
if (Settings.sleep < 50) {
|
if (Settings.sleep < 50) {
|
||||||
Settings.sleep = 50; // Default to 50 for sleep, for now
|
Settings.sleep = 50; // Default to 50 for sleep, for now
|
||||||
@ -1055,6 +1056,9 @@ void SettingsDelta(void)
|
|||||||
if (Settings.version < 0x06040110) {
|
if (Settings.version < 0x06040110) {
|
||||||
ModuleDefault(WEMOS);
|
ModuleDefault(WEMOS);
|
||||||
}
|
}
|
||||||
|
if (Settings.version < 0x06040112) {
|
||||||
|
Settings.param[P_RGB_REMAP] = RGB_REMAP_RGBW;
|
||||||
|
}
|
||||||
|
|
||||||
Settings.version = VERSION;
|
Settings.version = VERSION;
|
||||||
SettingsSave(1);
|
SettingsSave(1);
|
||||||
|
@ -171,12 +171,12 @@ typedef unsigned long power_t; // Power (Relay) type
|
|||||||
|
|
||||||
#define LT_SM16716 16 // Lights that use SM16716 will have this bit set in light_type
|
#define LT_SM16716 16 // Lights that use SM16716 will have this bit set in light_type
|
||||||
|
|
||||||
#define SM16716_RGB 0
|
#define RGB_REMAP_RGBW 0
|
||||||
#define SM16716_RBG 1
|
#define RGB_REMAP_RBGW 6
|
||||||
#define SM16716_GRB 2
|
#define RGB_REMAP_GRBW 24
|
||||||
#define SM16716_GBR 3
|
#define RGB_REMAP_GBRW 30
|
||||||
#define SM16716_BRG 4
|
#define RGB_REMAP_BRGW 48
|
||||||
#define SM16716_BGR 5
|
#define RGB_REMAP_BGRW 54
|
||||||
|
|
||||||
#define MQTT_PUBSUBCLIENT 1 // Mqtt PubSubClient library
|
#define MQTT_PUBSUBCLIENT 1 // Mqtt PubSubClient library
|
||||||
#define MQTT_TASMOTAMQTT 2 // Mqtt TasmotaMqtt library based on esp-mqtt-arduino - soon obsolete
|
#define MQTT_TASMOTAMQTT 2 // Mqtt TasmotaMqtt library based on esp-mqtt-arduino - soon obsolete
|
||||||
@ -237,7 +237,7 @@ enum ButtonStates { PRESSED, NOT_PRESSED };
|
|||||||
|
|
||||||
enum Shortcuts { SC_CLEAR, SC_DEFAULT, SC_USER };
|
enum Shortcuts { SC_CLEAR, SC_DEFAULT, SC_USER };
|
||||||
|
|
||||||
enum SettingsParmaIndex {P_HOLD_TIME, P_MAX_POWER_RETRY, P_TUYA_DIMMER_ID, P_MDNS_DELAYED_START, P_BOOT_LOOP_OFFSET, P_MAX_PARAM8}; // Max is PARAM8_SIZE (18) - SetOption32 until SetOption49
|
enum SettingsParmaIndex {P_HOLD_TIME, P_MAX_POWER_RETRY, P_TUYA_DIMMER_ID, P_MDNS_DELAYED_START, P_BOOT_LOOP_OFFSET, P_RGB_REMAP, P_MAX_PARAM8}; // Max is PARAM8_SIZE (18) - SetOption32 until SetOption49
|
||||||
|
|
||||||
enum DomoticzSensors {DZ_TEMP, DZ_TEMP_HUM, DZ_TEMP_HUM_BARO, DZ_POWER_ENERGY, DZ_ILLUMINANCE, DZ_COUNT, DZ_VOLTAGE, DZ_CURRENT, DZ_AIRQUALITY, DZ_MAX_SENSORS};
|
enum DomoticzSensors {DZ_TEMP, DZ_TEMP_HUM, DZ_TEMP_HUM_BARO, DZ_POWER_ENERGY, DZ_ILLUMINANCE, DZ_COUNT, DZ_VOLTAGE, DZ_CURRENT, DZ_AIRQUALITY, DZ_MAX_SENSORS};
|
||||||
|
|
||||||
|
@ -789,9 +789,19 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
|
|||||||
param_low = 1;
|
param_low = 1;
|
||||||
param_high = 250;
|
param_high = 250;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case P_RGB_REMAP:
|
||||||
|
param_low = 0;
|
||||||
|
param_high = 119;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if ((payload >= param_low) && (payload <= param_high)) {
|
if ((payload >= param_low) && (payload <= param_high)) {
|
||||||
Settings.param[pindex] = payload;
|
Settings.param[pindex] = payload;
|
||||||
|
switch (pindex) {
|
||||||
|
case P_RGB_REMAP:
|
||||||
|
LightUpdateColorMapping();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,8 @@ struct LCwColor {
|
|||||||
#define MAX_FIXED_COLD_WARM 4
|
#define MAX_FIXED_COLD_WARM 4
|
||||||
const LCwColor kFixedColdWarm[MAX_FIXED_COLD_WARM] PROGMEM = { 0,0, 255,0, 0,255, 128,128 };
|
const LCwColor kFixedColdWarm[MAX_FIXED_COLD_WARM] PROGMEM = { 0,0, 255,0, 0,255, 128,128 };
|
||||||
|
|
||||||
|
uint8_t color_remap[5];
|
||||||
|
|
||||||
uint8_t ledTable[] = {
|
uint8_t ledTable[] = {
|
||||||
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
@ -397,12 +399,6 @@ void SM16716_SendByte(uint8_t v)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SM16716_SendRGB(uint8_t duty_r, uint8_t duty_g, uint8_t duty_b) {
|
|
||||||
SM16716_SendByte(duty_r);
|
|
||||||
SM16716_SendByte(duty_g);
|
|
||||||
SM16716_SendByte(duty_b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SM16716_Update(uint8_t duty_r, uint8_t duty_g, uint8_t duty_b)
|
void SM16716_Update(uint8_t duty_r, uint8_t duty_g, uint8_t duty_b)
|
||||||
{
|
{
|
||||||
if (sm16716_pin_sel < 99) {
|
if (sm16716_pin_sel < 99) {
|
||||||
@ -437,30 +433,18 @@ void SM16716_Update(uint8_t duty_r, uint8_t duty_g, uint8_t duty_b)
|
|||||||
|
|
||||||
// send start bit
|
// send start bit
|
||||||
SM16716_SendBit(1);
|
SM16716_SendBit(1);
|
||||||
// send 24-bit rgb data
|
SM16716_SendByte(duty_r);
|
||||||
#if USE_SM16716_RGB_ORDER == SM16716_RGB
|
SM16716_SendByte(duty_g);
|
||||||
SM16716_SendRGB(duty_r, duty_g, duty_b);
|
SM16716_SendByte(duty_b);
|
||||||
#elif USE_SM16716_RGB_ORDER == SM16716_RBG
|
|
||||||
SM16716_SendRGB(duty_r, duty_b, duty_g);
|
|
||||||
#elif USE_SM16716_RGB_ORDER == SM16716_GRB
|
|
||||||
SM16716_SendRGB(duty_g, duty_r, duty_b);
|
|
||||||
#elif USE_SM16716_RGB_ORDER == SM16716_GBR
|
|
||||||
SM16716_SendRGB(duty_g, duty_b, duty_r);
|
|
||||||
#elif USE_SM16716_RGB_ORDER == SM16716_BRG
|
|
||||||
SM16716_SendRGB(duty_b, duty_r, duty_g);
|
|
||||||
#elif USE_SM16716_RGB_ORDER == SM16716_BGR
|
|
||||||
SM16716_SendRGB(duty_b, duty_g, duty_r);
|
|
||||||
#else
|
|
||||||
// fall back to RGB
|
|
||||||
SM16716_SendRGB(duty_r, duty_g, duty_b);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// send a 'do it' pulse
|
// send a 'do it' pulse
|
||||||
// (if multiple chips are chained, each one processes the 1st '1rgb' 25-bit block and
|
// (if multiple chips are chained, each one processes the 1st '1rgb' 25-bit block and
|
||||||
// passes on the rest, right until the one starting with 0)
|
// passes on the rest, right until the one starting with 0)
|
||||||
//SM16716_Init();
|
//SM16716_Init();
|
||||||
SM16716_SendBit(0);
|
SM16716_SendBit(0);
|
||||||
SM16716_SendRGB(0, 0, 0);
|
SM16716_SendByte(0);
|
||||||
|
SM16716_SendByte(0);
|
||||||
|
SM16716_SendByte(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SM16716_ModuleSelected(void)
|
bool SM16716_ModuleSelected(void)
|
||||||
@ -581,6 +565,37 @@ void LightInit(void)
|
|||||||
light_power = 0;
|
light_power = 0;
|
||||||
light_update = 1;
|
light_update = 1;
|
||||||
light_wakeup_active = 0;
|
light_wakeup_active = 0;
|
||||||
|
|
||||||
|
LightUpdateColorMapping();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LightUpdateColorMapping(void)
|
||||||
|
{
|
||||||
|
uint8_t param = Settings.param[P_RGB_REMAP];
|
||||||
|
if(param > 119){
|
||||||
|
param = 119;
|
||||||
|
}
|
||||||
|
uint8_t tmp[] = {0,1,2,3,4};
|
||||||
|
color_remap[0] = tmp[param / 24];
|
||||||
|
for (uint8_t i = param / 24; i<4; ++i){
|
||||||
|
tmp[i] = tmp[i+1];
|
||||||
|
}
|
||||||
|
param = param % 24;
|
||||||
|
color_remap[1] = tmp[(param / 6)];
|
||||||
|
for (uint8_t i = param / 6; i<3; ++i){
|
||||||
|
tmp[i] = tmp[i+1];
|
||||||
|
}
|
||||||
|
param = param % 6;
|
||||||
|
color_remap[2] = tmp[(param / 2)];
|
||||||
|
for (uint8_t i = param / 2; i<2; ++i){
|
||||||
|
tmp[i] = tmp[i+1];
|
||||||
|
}
|
||||||
|
param = param % 2;
|
||||||
|
color_remap[3] = tmp[param];
|
||||||
|
color_remap[4] = tmp[1-param];
|
||||||
|
|
||||||
|
//snprintf_P(log_data, sizeof(log_data), "%d colors: %d %d %d %d %d",Settings.param[P_RGB_REMAP], color_remap[0],color_remap[1],color_remap[2],color_remap[3],color_remap[4]);
|
||||||
|
//AddLog(LOG_LEVEL_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightSetColorTemp(uint16_t ct)
|
void LightSetColorTemp(uint16_t ct)
|
||||||
@ -980,6 +995,16 @@ void LightAnimate(void)
|
|||||||
light_last_color[i] = light_new_color[i];
|
light_last_color[i] = light_new_color[i];
|
||||||
cur_col[i] = light_last_color[i]*Settings.rgbwwTable[i]/255;
|
cur_col[i] = light_last_color[i]*Settings.rgbwwTable[i]/255;
|
||||||
cur_col[i] = (Settings.light_correction) ? ledTable[cur_col[i]] : cur_col[i];
|
cur_col[i] = (Settings.light_correction) ? ledTable[cur_col[i]] : cur_col[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// color remapping
|
||||||
|
uint8_t orig_col[5];
|
||||||
|
memcpy(orig_col, cur_col, sizeof(orig_col));
|
||||||
|
for (uint8_t i = 0; i < 5; i++) {
|
||||||
|
cur_col[i] = orig_col[color_remap[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < light_subtype; i++) {
|
||||||
if (light_type < LT_PWM6) {
|
if (light_type < LT_PWM6) {
|
||||||
if (pin[GPIO_PWM1 +i] < 99) {
|
if (pin[GPIO_PWM1 +i] < 99) {
|
||||||
if (cur_col[i] > 0xFC) {
|
if (cur_col[i] > 0xFC) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user