Updated the code based on the feedback

* Updated xdrv_01_webserver.ino to show dimmer slider2 by default for Tuya Dimmer Module

 * Updated xdrv_16_tuyadimmer.ino remove the use of XdrvMailbox and removed the pow functions now the size for 6.5.0 build is 510kb

 * updated sonoff.ino to hold current device id
This commit is contained in:
thirug010 2019-05-18 18:13:57 -05:00
parent fce9ae6762
commit 6b013144ab
4 changed files with 25 additions and 20 deletions

View File

@ -1,8 +1,15 @@
/* 6.5.0.12 20190517
/*
* 6.5.0.13 20190518
* Updated xdrv_01_webserver.ino to show dimmer slider2 by default for Tuya Dimmer Module optionally disabled for non dimmers
* Updated xdrv_16_tuyadimmer.ino remove the use of XdrvMailbox and removed the pow functions
* updated sonoff.ino to hold current device id
*
* 6.5.0.12 20190517
* Add command SetOption65 (tuya_show_dimmer) to enable or disable dimmer Slider ( for 4 Gang Tuya switch)
* Added Seeting.pram9 to define no of Tuya MCU devices
* Updated xdrv_01_webserver.ino to check for the tuya_show_dimmer option to display slider2
* Updated xdrv_01_webserver.ino to check for the tuya_show_dimmer option to display slider2
* Updated xdrv_16_tuyadimmer.ino create bool serial packet based on the Device Id and set the power status based on the Device id from MCU packet
*
* 6.5.0.11 20190517
* Add command SetOption64 0/1 to switch between "-" or "_" as sensor index separator impacting DS18X20, DHT, BMP and SHT3X sensor names (#5689)
*

View File

@ -109,6 +109,7 @@ unsigned long pulse_timer[MAX_PULSETIMERS] = { 0 }; // Power off timer
unsigned long blink_timer = 0; // Power cycle timer
unsigned long backlog_delay = 0; // Command backlog delay
power_t power = 0; // Current copy of Settings.power
power_t deviceid = 1; // hold current deviceid
power_t blink_power; // Blink power state
power_t blink_mask = 0; // Blink relay active mask
power_t blink_powersave; // Blink start power save state
@ -1535,7 +1536,7 @@ void ExecuteCommandPower(uint8_t device, uint8_t state, int source)
// ShowSource(source);
XdrvMailbox.notused = device;
deviceid = device;
if (SONOFF_IFAN02 == my_module_type) {
blink_mask &= 1; // No blinking on the fan relays

View File

@ -890,7 +890,7 @@ void HandleRoot(void)
if ((LST_COLDWARM == (light_type &7)) || (LST_RGBWC == (light_type &7))) {
WSContentSend_P(HTTP_MSG_SLIDER1, LightGetColorTemp());
}
if(Settings.flag3.tuya_show_dimmer == 1)
if(Settings.flag3.tuya_show_dimmer == 0)
{
WSContentSend_P(HTTP_MSG_SLIDER2, Settings.light_dimmer);
}

View File

@ -123,26 +123,23 @@ bool TuyaSetPower(void)
int16_t source = XdrvMailbox.payload;
if (source != SRC_SWITCH && TuyaSerial) { // ignore to prevent loop from pushing state from faceplate interaction
boolean Bin[] = {0,0,0,0};
convertDecToBin(rpower, Bin);
TuyaSendBool(XdrvMailbox.notused, Bin[XdrvMailbox.notused-1]);
TuyaSendBool(deviceid, TuyaGetPower(rpower, deviceid));
status = true;
}
return status;
}
void convertDecToBin(int Dec, boolean Bin[]) {
for(int i = 3 ; i >= 0 ; i--) {
if(pow(2, i)<=Dec) {
Dec = Dec - pow(2, i);
Bin[(i)] = 1;
} else {
uint8_t TuyaGetPower(uint8_t p, uint8_t d) {
uint8_t g = 0;
for(int i = 7 ; i >= 0 ; i--) {
g = p >> i;
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: --SetDevicePower3-- for Device = %d, Power=%d"),i, k&1);
if (i== d-1)
{
return g&1;
}
}
}
bool TuyaSetChannels(void)
{
LightSerialDuty(((uint8_t*)XdrvMailbox.data)[0]);
@ -156,8 +153,8 @@ void LightSerialDuty(uint8_t duty)
duty = 25; // dimming acts odd below 25(10%) - this mirrors the threshold set on the faceplate itself
}
if(Settings.flag3.tuya_show_dimmer == 1) // no Dimmer for 4 relay
if(Settings.flag3.tuya_show_dimmer == 0)
{
AddLog_P2(LOG_LEVEL_DEBUG, PSTR( "TYA: Send Serial Packet Dim Value=%d (id=%d)"), duty, Settings.param[P_TUYA_DIMMER_ID]);
TuyaSendValue(Settings.param[P_TUYA_DIMMER_ID], duty);
@ -165,7 +162,7 @@ void LightSerialDuty(uint8_t duty)
} else {
tuya_ignore_dim = false; // reset flag
if(Settings.flag3.tuya_show_dimmer == 1) // no Dimmer for 4 relay
if(Settings.flag3.tuya_show_dimmer == 0)
{
AddLog_P2(LOG_LEVEL_DEBUG, PSTR( "TYA: Send Dim Level skipped due to 0 or already set. Value=%d"), duty);
}
@ -432,7 +429,7 @@ bool Xdrv16(uint8_t function)
if (tuya_heartbeat_timer > 10) {
tuya_heartbeat_timer = 0;
TuyaSendCmd(TUYA_CMD_HEARTBEAT);
}
}
break;
case FUNC_SET_CHANNELS:
result = TuyaSetChannels();