mirror of https://github.com/arendst/Tasmota.git
Merge pull request #6547 from shantur/ps_16_dz-dimmer-max
Ps 16 dz dimmer max
This commit is contained in:
commit
97de80bba1
|
@ -125,8 +125,8 @@
|
|||
#ifndef ENERGY_OVERTEMP
|
||||
#define ENERGY_OVERTEMP 90 // Overtemp in Celsius
|
||||
#endif
|
||||
#ifndef TUYA_DIMMER_MAX
|
||||
#define TUYA_DIMMER_MAX 100
|
||||
#ifndef DEFAULT_DIMMER_MAX
|
||||
#define DEFAULT_DIMMER_MAX 100
|
||||
#endif
|
||||
|
||||
enum WebColors {
|
||||
|
@ -774,7 +774,7 @@ void SettingsDefaultSet2(void)
|
|||
// Settings.light_rotation = 0;
|
||||
SettingsDefaultSet_5_8_1(); // Clock color
|
||||
|
||||
Settings.param[P_TUYA_DIMMER_MAX] = TUYA_DIMMER_MAX;
|
||||
Settings.param[P_DIMMER_MAX] = DEFAULT_DIMMER_MAX;
|
||||
|
||||
// Display
|
||||
SettingsDefaultSet_5_10_1(); // Display settings
|
||||
|
@ -1084,9 +1084,9 @@ void SettingsDelta(void)
|
|||
if (Settings.version < 0x06060008) {
|
||||
// Move current tuya dimmer range to the new param.
|
||||
if (Settings.flag3.tuya_dimmer_range_255) {
|
||||
Settings.param[P_TUYA_DIMMER_MAX] = 100;
|
||||
Settings.param[P_DIMMER_MAX] = 100;
|
||||
} else {
|
||||
Settings.param[P_TUYA_DIMMER_MAX] = 255;
|
||||
Settings.param[P_DIMMER_MAX] = 255;
|
||||
}
|
||||
}
|
||||
if (Settings.version < 0x06060009) {
|
||||
|
|
|
@ -249,7 +249,7 @@ enum Shortcuts { SC_CLEAR, SC_DEFAULT, SC_USER };
|
|||
|
||||
enum SettingsParamIndex { P_HOLD_TIME, P_MAX_POWER_RETRY, P_ex_TUYA_DIMMER_ID, P_MDNS_DELAYED_START, P_BOOT_LOOP_OFFSET, P_RGB_REMAP, P_IR_UNKNOW_THRESHOLD, // SetOption32 .. SetOption38
|
||||
P_CSE7766_INVALID_POWER, P_HOLD_IGNORE, P_ex_TUYA_RELAYS, P_OVER_TEMP, // SetOption39 .. SetOption42
|
||||
P_TUYA_DIMMER_MAX,
|
||||
P_DIMMER_MAX,
|
||||
P_ex_TUYA_VOLTAGE_ID, P_ex_TUYA_CURRENT_ID, P_ex_TUYA_POWER_ID, // SetOption43 .. SetOption46
|
||||
P_ex_ENERGY_TARIFF1, P_ex_ENERGY_TARIFF2, // SetOption47 .. SetOption48
|
||||
P_MAX_PARAM8 }; // Max is PARAM8_SIZE (18) - SetOption32 until SetOption49
|
||||
|
|
|
@ -687,7 +687,7 @@ void CmndSetoption(void)
|
|||
break;
|
||||
#endif
|
||||
#ifdef USE_TUYA_MCU
|
||||
case P_TUYA_DIMMER_MAX:
|
||||
case P_DIMMER_MAX:
|
||||
restart_flag = 2; // Need a restart to update GUI
|
||||
break;
|
||||
#endif
|
||||
|
|
|
@ -297,14 +297,14 @@ void LightSerialDuty(uint8_t duty)
|
|||
if (Settings.flag3.tuya_dimmer_min_limit) { // Enable dimming limit SetOption69: Enabled by default
|
||||
if (duty < 25) { duty = 25; } // dimming acts odd below 25(10%) - this mirrors the threshold set on the faceplate itself
|
||||
}
|
||||
duty = changeUIntScale(duty, 0, 255, 0, Settings.param[P_TUYA_DIMMER_MAX]);
|
||||
duty = changeUIntScale(duty, 0, 255, 0, Settings.param[P_DIMMER_MAX]);
|
||||
if (Tuya.new_dim != duty) {
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Send dim value=%d (id=%d)"), duty, dpid);
|
||||
TuyaSendValue(dpid, duty);
|
||||
}
|
||||
} else if (dpid > 0) {
|
||||
Tuya.ignore_dim = false; // reset flag
|
||||
duty = changeUIntScale(duty, 0, 255, 0, Settings.param[P_TUYA_DIMMER_MAX]);
|
||||
duty = changeUIntScale(duty, 0, 255, 0, Settings.param[P_DIMMER_MAX]);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Send dim skipped value=%d"), duty); // due to 0 or already set
|
||||
} else {
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Cannot set dimmer. Dimmer Id unknown")); //
|
||||
|
@ -375,7 +375,7 @@ void TuyaPacketProcess(void)
|
|||
bool tuya_energy_enabled = (XNRG_16 == energy_flg);
|
||||
if (fnId == TUYA_MCU_FUNC_DIMMER) {
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX Dim State=%d"), Tuya.buffer[13]);
|
||||
Tuya.new_dim = changeUIntScale((uint8_t) Tuya.buffer[13], 0, Settings.param[P_TUYA_DIMMER_MAX], 0, 100);
|
||||
Tuya.new_dim = changeUIntScale((uint8_t) Tuya.buffer[13], 0, Settings.param[P_DIMMER_MAX], 0, 100);
|
||||
if ((power || Settings.flag3.tuya_apply_o20) && (Tuya.new_dim > 0) && (abs(Tuya.new_dim - Settings.light_dimmer) > 1)) {
|
||||
Tuya.ignore_dim = true;
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ void PS16DZSerialSendUpdateCommand(void)
|
|||
uint8_t light_state_dimmer = light_state.getDimmer();
|
||||
// Dimming acts odd below 10% - this mirrors the threshold set on the faceplate itself
|
||||
light_state_dimmer = (light_state_dimmer < 10) ? 10 : light_state_dimmer;
|
||||
light_state_dimmer = (light_state_dimmer > Settings.param[P_DIMMER_MAX]) ? Settings.param[P_DIMMER_MAX] : light_state_dimmer;
|
||||
|
||||
snprintf_P(Ps16dz.tx_buffer, PS16DZ_BUFFER_SIZE, PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"switch\":\"%s\",\"bright\":%d"),
|
||||
LocalTime(), millis()%1000, power?"on":"off", light_state_dimmer);
|
||||
|
|
Loading…
Reference in New Issue