Change driver to user 10bit input (feature parity to original driver)

This commit is contained in:
oogm 2022-05-29 16:34:58 +02:00
parent 6dd20a566f
commit 4ec98e100e
2 changed files with 18 additions and 15 deletions

View File

@ -2193,12 +2193,15 @@ void LightSetOutputs(const uint16_t *cur_col_10) {
char *tmp_data = XdrvMailbox.data; char *tmp_data = XdrvMailbox.data;
char *tmp_topic = XdrvMailbox.topic; char *tmp_topic = XdrvMailbox.topic;
char *tmp_command = XdrvMailbox.command;
XdrvMailbox.data = (char*)cur_col; XdrvMailbox.data = (char*)cur_col;
XdrvMailbox.topic = (char*)scale_col; XdrvMailbox.topic = (char*)scale_col;
XdrvMailbox.command = (char*)cur_col_10;
if (XlgtCall(FUNC_SET_CHANNELS)) { /* Serviced */ } if (XlgtCall(FUNC_SET_CHANNELS)) { /* Serviced */ }
else if (XdrvCall(FUNC_SET_CHANNELS)) { /* Serviced */ } else if (XdrvCall(FUNC_SET_CHANNELS)) { /* Serviced */ }
XdrvMailbox.data = tmp_data; XdrvMailbox.data = tmp_data;
XdrvMailbox.topic = tmp_topic; XdrvMailbox.topic = tmp_topic;
XdrvMailbox.command = tmp_command;
} }
// Just apply basic Gamma to each channel // Just apply basic Gamma to each channel

View File

@ -123,24 +123,24 @@ void Bp5758dStop(void) {
/********************************************************************************************/ /********************************************************************************************/
bool Bp5758dSetChannels(void) { bool Bp5758dSetChannels(void) {
uint8_t *cur_col = (uint8_t*)XdrvMailbox.data; uint16_t *cur_col_10 = (uint16_t*)XdrvMailbox.command;
// Even though we could address changing channels only, in practice we observed that the lightbulb always sets all channels. // Even though we could address changing channels only, in practice we observed that the lightbulb always sets all channels.
Bp5758dStart(BP5758D_ADDR_OUT1_GL); Bp5758dStart(BP5758D_ADDR_OUT1_GL);
// Brigtness values are transmitted as two bytes. The light-bulb accepts a 10-bit integer (0-1023) as an input value. // Brigtness values are transmitted as two bytes. The light-bulb accepts a 10-bit integer (0-1023) as an input value.
// The first 5bits of this input are transmitted in first byte, the second 5bits in the second byte. // The first 5bits of this input are transmitted in second byte, the second 5bits in the first byte.
// Because or tasmota's controls are 8bit (0-255), we need to multiply by 4 (or shift two bits to the left). Bp5758dWrite((uint8_t)(cur_col_10[0] & 0x1F)); //Red: Only take last 3 bits, multiplied by 4 / shifted to left
// We thus transmit the first 5bits of tasmota's input as byte1, and the remaining 3bits as byte2 (shifted left two bits). Bp5758dWrite((uint8_t)(cur_col_10[0] >> 5)); //Only take first 5bits of tasmota's input
Bp5758dWrite((cur_col[0] & 0x07) << 2); //Red: Only take last 3 bits, multiplied by 4 / shifted to left Bp5758dWrite((uint8_t)(cur_col_10[1] & 0x1F)); //Green
Bp5758dWrite(cur_col[0] >> 3); //Only take first 5bits of tasmota's input Bp5758dWrite((uint8_t)(cur_col_10[1] >> 5));
Bp5758dWrite((cur_col[1] & 0x07) << 2); //Green Bp5758dWrite((uint8_t)(cur_col_10[2] & 0x1F)); //Blue
Bp5758dWrite(cur_col[1] >> 3); Bp5758dWrite((uint8_t)(cur_col_10[2] >> 5));
Bp5758dWrite((cur_col[2] & 0x07) << 2); //Blue Bp5758dWrite((uint8_t)(cur_col_10[4] & 0x1F)); //Cold
Bp5758dWrite(cur_col[2] >> 3); Bp5758dWrite((uint8_t)(cur_col_10[4] >> 5));
Bp5758dWrite((cur_col[4] & 0x07) << 2); //Cold Bp5758dWrite((uint8_t)(cur_col_10[3] & 0x1F)); //Warm
Bp5758dWrite(cur_col[4] >> 3); Bp5758dWrite((uint8_t)(cur_col_10[3] >> 5));
Bp5758dWrite((cur_col[3] & 0x07) << 2); //Warm
Bp5758dWrite(cur_col[3] >> 3);
Bp5758dStop(); Bp5758dStop();
return true; return true;
} }