mirror of https://github.com/arendst/Tasmota.git
Merge pull request #10898 from pcdiem/dgr-device-map
Add DGR device map support
This commit is contained in:
commit
8c8e3bef33
|
@ -328,6 +328,7 @@
|
|||
#define D_CMND_DEVGROUP_SEND "DevGroupSend"
|
||||
#define D_CMND_DEVGROUP_SHARE "DevGroupShare"
|
||||
#define D_CMND_DEVGROUPSTATUS "DevGroupStatus"
|
||||
#define D_CMND_DEVGROUP_DEVICE "DevGroupTie"
|
||||
#define D_CMND_SERIALSEND "SerialSend"
|
||||
#define D_CMND_SERIALDELIMITER "SerialDelimiter"
|
||||
#define D_CMND_BAUDRATE "Baudrate"
|
||||
|
|
|
@ -631,7 +631,7 @@ struct {
|
|||
// Only 32 bit boundary variables below
|
||||
|
||||
uint64_t rf_protocol_mask; // FA8
|
||||
uint32_t device_group_maps; // FB0
|
||||
uint8_t device_group_tie[4]; // FB0
|
||||
SysBitfield5 flag5; // FB4
|
||||
uint16_t pulse_counter_debounce_low; // FB8
|
||||
uint16_t pulse_counter_debounce_high; // FBA
|
||||
|
|
|
@ -1232,6 +1232,9 @@ void SettingsDelta(void) {
|
|||
Settings.interlock[i] = (i < 4) ? Settings.ex_interlock[i] : 0;
|
||||
}
|
||||
}
|
||||
if (Settings.version < 0x09020007) {
|
||||
*(uint32_t *)&Settings.device_group_tie = 0x04030201;
|
||||
}
|
||||
|
||||
Settings.version = VERSION;
|
||||
SettingsSave(1);
|
||||
|
|
|
@ -36,7 +36,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix
|
|||
#ifdef USE_DEVICE_GROUPS_SEND
|
||||
D_CMND_DEVGROUP_SEND "|"
|
||||
#endif // USE_DEVICE_GROUPS_SEND
|
||||
D_CMND_DEVGROUP_SHARE "|" D_CMND_DEVGROUPSTATUS "|"
|
||||
D_CMND_DEVGROUP_SHARE "|" D_CMND_DEVGROUPSTATUS "|" D_CMND_DEVGROUP_DEVICE "|"
|
||||
#endif // USE_DEVICE_GROUPS
|
||||
D_CMND_SENSOR "|" D_CMND_DRIVER
|
||||
#ifdef ESP32
|
||||
|
@ -63,7 +63,7 @@ void (* const TasmotaCommand[])(void) PROGMEM = {
|
|||
#ifdef USE_DEVICE_GROUPS_SEND
|
||||
&CmndDevGroupSend,
|
||||
#endif // USE_DEVICE_GROUPS_SEND
|
||||
&CmndDevGroupShare, &CmndDevGroupStatus,
|
||||
&CmndDevGroupShare, &CmndDevGroupStatus, &CmndDevGroupTie,
|
||||
#endif // USE_DEVICE_GROUPS
|
||||
&CmndSensor, &CmndDriver
|
||||
#ifdef ESP32
|
||||
|
@ -2072,7 +2072,7 @@ void CmndDevGroupSend(void)
|
|||
{
|
||||
uint8_t device_group_index = (XdrvMailbox.usridx ? XdrvMailbox.index - 1 : 0);
|
||||
if (device_group_index < device_group_count) {
|
||||
if (!_SendDeviceGroupMessage(device_group_index, (DevGroupMessageType)(DGR_MSGTYPE_UPDATE_COMMAND + DGR_MSGTYPFLAG_WITH_LOCAL))) {
|
||||
if (!_SendDeviceGroupMessage(-device_group_index, (DevGroupMessageType)(DGR_MSGTYPE_UPDATE_COMMAND + DGR_MSGTYPFLAG_WITH_LOCAL))) {
|
||||
ResponseCmndChar(XdrvMailbox.data);
|
||||
}
|
||||
}
|
||||
|
@ -2092,6 +2092,16 @@ void CmndDevGroupStatus(void)
|
|||
{
|
||||
DeviceGroupStatus((XdrvMailbox.usridx ? XdrvMailbox.index - 1 : 0));
|
||||
}
|
||||
|
||||
void CmndDevGroupTie(void)
|
||||
{
|
||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_DEV_GROUP_NAMES)) {
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
Settings.device_group_tie[XdrvMailbox.index - 1] = XdrvMailbox.payload;
|
||||
}
|
||||
ResponseCmndIdxNumber(Settings.device_group_tie[XdrvMailbox.index - 1]);
|
||||
}
|
||||
}
|
||||
#endif // USE_DEVICE_GROUPS
|
||||
|
||||
void CmndSensor(void)
|
||||
|
|
|
@ -401,9 +401,10 @@ void SendReceiveDeviceGroupMessage(struct device_group * device_group, struct de
|
|||
switch (item) {
|
||||
case DGR_ITEM_POWER:
|
||||
if (Settings.flag4.multiple_device_groups) { // SetOption88 - Enable relays in separate device groups
|
||||
if (device_group_index < TasmotaGlobal.devices_present) {
|
||||
uint32_t device = Settings.device_group_tie[device_group_index];
|
||||
if (device) {
|
||||
bool on = (value & 1);
|
||||
if (on != (TasmotaGlobal.power & (1 << device_group_index))) ExecuteCommandPower(device_group_index + 1, (on ? POWER_ON : POWER_OFF), SRC_REMOTE);
|
||||
if (on != ((TasmotaGlobal.power >> (device - 1)) & 1)) ExecuteCommandPower(device, (on ? POWER_ON : POWER_OFF), SRC_REMOTE);
|
||||
}
|
||||
}
|
||||
else if (XdrvMailbox.index & DGR_FLAG_LOCAL) {
|
||||
|
@ -448,7 +449,7 @@ write_log:
|
|||
if (received) {
|
||||
if ((flags & DGR_FLAG_STATUS_REQUEST)) {
|
||||
if ((flags & DGR_FLAG_RESET) || device_group_member->acked_sequence != device_group->last_full_status_sequence) {
|
||||
_SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_FULL_STATUS);
|
||||
_SendDeviceGroupMessage(-device_group_index, DGR_MSGTYP_FULL_STATUS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -479,7 +480,7 @@ cleanup:
|
|||
}
|
||||
}
|
||||
|
||||
bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType message_type, ...)
|
||||
bool _SendDeviceGroupMessage(uint32_t device, DevGroupMessageType message_type, ...)
|
||||
{
|
||||
// If device groups is not up, ignore this request.
|
||||
if (!device_groups_up) return 1;
|
||||
|
@ -492,11 +493,16 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes
|
|||
if (ignore_dgr_sends && message_type != DGR_MSGTYPE_UPDATE_COMMAND) return 0;
|
||||
|
||||
// If device is < 0, the device group index is the device negated. If not, get the device group
|
||||
// index from the device group maps.
|
||||
// uint8_t device_group_index = -device;
|
||||
// if (device > 0) device_group_index = (Settings.device_group_maps >> (device - 1) * 3 & 0x7 - 1;
|
||||
|
||||
// If the device group index is higher then the number of device groups, ignore this request.
|
||||
// index for this device.
|
||||
uint8_t device_group_index = -device;
|
||||
if (device > 0) {
|
||||
device_group_index = 0;
|
||||
if (Settings.flag4.multiple_device_groups) { // SetOption88 - Enable relays in separate device groups
|
||||
for (; device_group_index < device_group_count; device_group_index++) {
|
||||
if (Settings.device_group_tie[device_group_index] == device) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (device_group_index >= device_group_count) return 0;
|
||||
|
||||
// Get a pointer to the device information for this device.
|
||||
|
@ -531,10 +537,9 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes
|
|||
// Call the drivers to build the status update.
|
||||
power_t power = TasmotaGlobal.power;
|
||||
if (Settings.flag4.multiple_device_groups) { // SetOption88 - Enable relays in separate device groups
|
||||
power >>= device_group_index;
|
||||
power &= 1;
|
||||
power = (power >> (Settings.device_group_tie[device_group_index] - 1)) & 1;
|
||||
}
|
||||
SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_NO_STATUS_SHARE, device_group->no_status_share, DGR_ITEM_POWER, power);
|
||||
SendDeviceGroupMessage(-device_group_index, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_NO_STATUS_SHARE, device_group->no_status_share, DGR_ITEM_POWER, power);
|
||||
XdrvMailbox.index = 0;
|
||||
if (device_group_index == 0 && first_device_group_is_local) XdrvMailbox.index = DGR_FLAG_LOCAL;
|
||||
XdrvMailbox.command_code = DGR_ITEM_STATUS;
|
||||
|
@ -599,10 +604,10 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes
|
|||
oper = value_ptr[1];
|
||||
value_ptr += 2;
|
||||
}
|
||||
value = (isdigit(*value_ptr) ? strtoul((char *)value_ptr, (char **)&value_ptr, 0) : 1);
|
||||
value = (isdigit(*value_ptr) ? strtoul((char *)value_ptr, (char **)&value_ptr, 0) : oper == '^' ? 0xffffffff : 1);
|
||||
if (oper) {
|
||||
old_value = (item <= DGR_ITEM_MAX_8BIT ? device_group->values_8bit[item] : (item <= DGR_ITEM_MAX_16BIT ? device_group->values_16bit[item - DGR_ITEM_MAX_8BIT - 1] : device_group->values_32bit[item - DGR_ITEM_MAX_16BIT - 1]));
|
||||
value = (oper == '+' ? old_value + value : oper == '-' ? old_value - value : oper == '^' ? old_value ^ (value ? value : 0xffffffff) : oper == '|' ? old_value | value : old_value == '&' ? old_value & value : old_value);
|
||||
value = (oper == '+' ? old_value + value : oper == '-' ? old_value - value : oper == '^' ? old_value ^ value : oper == '|' ? old_value | value : old_value == '&' ? old_value & value : old_value);
|
||||
}
|
||||
item_ptr->value = value;
|
||||
}
|
||||
|
@ -620,24 +625,30 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes
|
|||
switch (item) {
|
||||
case DGR_ITEM_LIGHT_CHANNELS:
|
||||
{
|
||||
int i = 0;
|
||||
bool hex = false;
|
||||
char * endptr;
|
||||
value = strtoul((char *)value_ptr, &endptr, 10);
|
||||
if ((*endptr && *endptr != ',' && *endptr != ' ') || value > 255) {
|
||||
for (; i < 6; i++) {
|
||||
if (!*value_ptr || *value_ptr == ' ') break;
|
||||
uint8_t * next_value_ptr = value_ptr + 2;
|
||||
uint8_t save_char = *next_value_ptr;
|
||||
*next_value_ptr = 'X';
|
||||
*out_ptr++ = strtoul((char *)value_ptr, (char **)&value_ptr, 16);
|
||||
*next_value_ptr = save_char;
|
||||
if (*value_ptr == '#') {
|
||||
value_ptr++;
|
||||
hex = true;
|
||||
}
|
||||
for (int i = 0; i < 6; i++) {
|
||||
*out_ptr = 0;
|
||||
if (*value_ptr != ' ') {
|
||||
if (hex) {
|
||||
endptr = (char *)value_ptr + 2;
|
||||
chr = *endptr;
|
||||
*endptr = 0;
|
||||
*out_ptr = strtoul((char *)value_ptr, (char **)&value_ptr, 16);
|
||||
*endptr = chr;
|
||||
}
|
||||
for (; i < 6; i++) {
|
||||
*out_ptr++ = (*value_ptr == ' ' ? 0 : strtoul((char *)value_ptr, (char **)&value_ptr, 10));
|
||||
else {
|
||||
*out_ptr = strtoul((char *)value_ptr, (char **)&value_ptr, 10);
|
||||
if (*value_ptr == ',') value_ptr++;
|
||||
}
|
||||
}
|
||||
out_ptr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -933,7 +944,7 @@ AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Checking next_check_time=%u, now=%u"), next_c
|
|||
// If we've sent the initial status request message the set number of times, send our
|
||||
// status to all the members.
|
||||
else {
|
||||
_SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_FULL_STATUS);
|
||||
_SendDeviceGroupMessage(-device_group_index, DGR_MSGTYP_FULL_STATUS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -586,10 +586,11 @@ void ExecuteCommandPower(uint32_t device, uint32_t state, uint32_t source)
|
|||
}
|
||||
#ifdef USE_DEVICE_GROUPS
|
||||
if (TasmotaGlobal.power != old_power && SRC_REMOTE != source && SRC_RETRY != source) {
|
||||
if (Settings.flag4.multiple_device_groups) // SetOption88 - Enable relays in separate device groups
|
||||
SendDeviceGroupMessage(device - 1, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, (TasmotaGlobal.power >> (device - 1)) & 1 | 0x01000000); // Explicitly set number of relays to one
|
||||
else
|
||||
SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, TasmotaGlobal.power);
|
||||
power_t dgr_power = TasmotaGlobal.power;
|
||||
if (Settings.flag4.multiple_device_groups) { // SetOption88 - Enable relays in separate device groups
|
||||
dgr_power = (dgr_power >> (device - 1)) & 1;
|
||||
}
|
||||
SendDeviceGroupMessage(device, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, dgr_power);
|
||||
}
|
||||
#endif // USE_DEVICE_GROUPS
|
||||
SetDevicePower(TasmotaGlobal.power, source);
|
||||
|
|
|
@ -471,7 +471,6 @@ const char kWebColors[] PROGMEM =
|
|||
|
||||
#ifdef USE_DEVICE_GROUPS
|
||||
#define SendDeviceGroupMessage(DEVICE_INDEX, REQUEST_TYPE, ...) _SendDeviceGroupMessage(DEVICE_INDEX, REQUEST_TYPE, __VA_ARGS__, 0)
|
||||
#define SendLocalDeviceGroupMessage(REQUEST_TYPE, ...) _SendDeviceGroupMessage(0, REQUEST_TYPE, __VA_ARGS__, 0)
|
||||
uint8_t device_group_count = 0;
|
||||
bool first_device_group_is_local = true;
|
||||
#endif // USE_DEVICE_GROUPS
|
||||
|
|
|
@ -20,6 +20,6 @@
|
|||
#ifndef _TASMOTA_VERSION_H_
|
||||
#define _TASMOTA_VERSION_H_
|
||||
|
||||
const uint32_t VERSION = 0x09020006;
|
||||
const uint32_t VERSION = 0x09020007;
|
||||
|
||||
#endif // _TASMOTA_VERSION_H_
|
||||
|
|
|
@ -234,7 +234,6 @@ struct LIGHT {
|
|||
bool fade_initialized = false; // dont't fade at startup
|
||||
bool fade_running = false;
|
||||
#ifdef USE_DEVICE_GROUPS
|
||||
uint8_t device_group_index;
|
||||
uint8_t last_scheme = 0;
|
||||
bool devgrp_no_channels_out = false; // don't share channels with device group (e.g. if scheme set by other device)
|
||||
#ifdef USE_DGR_LIGHT_SEQUENCE
|
||||
|
@ -1118,12 +1117,6 @@ void LightInit(void)
|
|||
Light.device--; // we take the last two devices as lights
|
||||
}
|
||||
LightCalcPWMRange();
|
||||
#ifdef USE_DEVICE_GROUPS
|
||||
Light.device_group_index = 0;
|
||||
if (Settings.flag4.multiple_device_groups) { // SetOption88 - Enable relays in separate device groups
|
||||
Light.device_group_index = Light.device - 1;
|
||||
}
|
||||
#endif // USE_DEVICE_GROUPS
|
||||
#ifdef DEBUG_LIGHT
|
||||
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightInit Light.pwm_multi_channels=%d Light.subtype=%d Light.device=%d TasmotaGlobal.devices_present=%d",
|
||||
Light.pwm_multi_channels, Light.subtype, Light.device, TasmotaGlobal.devices_present);
|
||||
|
@ -1708,7 +1701,7 @@ void LightAnimate(void)
|
|||
#ifdef USE_DEVICE_GROUPS
|
||||
if (Settings.light_scheme != Light.last_scheme) {
|
||||
Light.last_scheme = Settings.light_scheme;
|
||||
SendDeviceGroupMessage(Light.device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_SCHEME, Settings.light_scheme);
|
||||
SendDeviceGroupMessage(Light.device, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_SCHEME, Settings.light_scheme);
|
||||
Light.devgrp_no_channels_out = false;
|
||||
}
|
||||
#endif // USE_DEVICE_GROUPS
|
||||
|
@ -2188,12 +2181,12 @@ void LightSendDeviceGroupStatus()
|
|||
if (building_status_message || memcmp(channels, last_channels, LST_MAX)) {
|
||||
memcpy(last_channels, channels, LST_MAX);
|
||||
last_channels[LST_MAX]++;
|
||||
SendDeviceGroupMessage(Light.device_group_index, (send_bri_update ? DGR_MSGTYP_PARTIAL_UPDATE : DGR_MSGTYP_UPDATE), DGR_ITEM_LIGHT_CHANNELS, last_channels);
|
||||
SendDeviceGroupMessage(Light.device, (send_bri_update ? DGR_MSGTYP_PARTIAL_UPDATE : DGR_MSGTYP_UPDATE), DGR_ITEM_LIGHT_CHANNELS, last_channels);
|
||||
}
|
||||
}
|
||||
if (send_bri_update) {
|
||||
last_bri = bri;
|
||||
SendDeviceGroupMessage(Light.device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_BRI, light_state.getBri());
|
||||
SendDeviceGroupMessage(Light.device, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_BRI, light_state.getBri());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2202,7 +2195,7 @@ void LightHandleDevGroupItem(void)
|
|||
static bool send_state = false;
|
||||
static bool restore_power = false;
|
||||
|
||||
if (*XdrvMailbox.topic != Light.device_group_index) return;
|
||||
if (Settings.device_group_tie[*XdrvMailbox.topic] != Light.device) return;
|
||||
bool more_to_come;
|
||||
uint32_t value = XdrvMailbox.payload;
|
||||
switch (XdrvMailbox.command_code) {
|
||||
|
@ -2318,7 +2311,7 @@ void LightHandleDevGroupItem(void)
|
|||
}
|
||||
break;
|
||||
case DGR_ITEM_STATUS:
|
||||
SendLocalDeviceGroupMessage(DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_LIGHT_FADE, Settings.light_fade,
|
||||
SendDeviceGroupMessage(Light.device, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_LIGHT_FADE, Settings.light_fade,
|
||||
DGR_ITEM_LIGHT_SPEED, Settings.light_speed, DGR_ITEM_LIGHT_SCHEME, Settings.light_scheme);
|
||||
LightSendDeviceGroupStatus();
|
||||
break;
|
||||
|
@ -2742,7 +2735,7 @@ void CmndDimmer(void)
|
|||
uint8_t bri = light_state.getBri();
|
||||
if (bri != Settings.bri_power_on) {
|
||||
Settings.bri_power_on = bri;
|
||||
SendDeviceGroupMessage(Light.device_group_index, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_BRI_POWER_ON, Settings.bri_power_on);
|
||||
SendDeviceGroupMessage(Light.device, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_BRI_POWER_ON, Settings.bri_power_on);
|
||||
}
|
||||
#endif // USE_PWM_DIMMER && USE_DEVICE_GROUPS
|
||||
Light.update = true;
|
||||
|
@ -2849,7 +2842,7 @@ void CmndFade(void)
|
|||
break;
|
||||
}
|
||||
#ifdef USE_DEVICE_GROUPS
|
||||
if (XdrvMailbox.payload >= 0 && XdrvMailbox.payload <= 2) SendDeviceGroupMessage(Light.device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_FADE, Settings.light_fade);
|
||||
if (XdrvMailbox.payload >= 0 && XdrvMailbox.payload <= 2) SendDeviceGroupMessage(Light.device, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_FADE, Settings.light_fade);
|
||||
#endif // USE_DEVICE_GROUPS
|
||||
if (!Settings.light_fade) { Light.fade_running = false; }
|
||||
ResponseCmndStateText(Settings.light_fade);
|
||||
|
@ -2883,7 +2876,7 @@ void CmndSpeed(void)
|
|||
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload <= 40)) {
|
||||
Settings.light_speed = XdrvMailbox.payload;
|
||||
#ifdef USE_DEVICE_GROUPS
|
||||
SendDeviceGroupMessage(Light.device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_SPEED, Settings.light_speed);
|
||||
SendDeviceGroupMessage(Light.device, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_SPEED, Settings.light_speed);
|
||||
#endif // USE_DEVICE_GROUPS
|
||||
}
|
||||
ResponseCmndNumber(Settings.light_speed);
|
||||
|
|
|
@ -2191,7 +2191,7 @@ void CmndEvent(void)
|
|||
if (XdrvMailbox.data_len > 0) {
|
||||
strlcpy(Rules.event_data, XdrvMailbox.data, sizeof(Rules.event_data));
|
||||
#ifdef USE_DEVICE_GROUPS
|
||||
SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_EVENT, XdrvMailbox.data);
|
||||
SendDeviceGroupMessage(1, DGR_MSGTYP_UPDATE, DGR_ITEM_EVENT, XdrvMailbox.data);
|
||||
#endif // USE_DEVICE_GROUPS
|
||||
}
|
||||
if (XdrvMailbox.command) ResponseCmndDone();
|
||||
|
|
|
@ -252,11 +252,11 @@ void PWMDimmerHandleDevGroupItem(void)
|
|||
#ifdef USE_PWM_DIMMER_REMOTE
|
||||
if (is_local)
|
||||
#endif // USE_PWM_DIMMER_REMOTE
|
||||
SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_BRI_POWER_ON, Settings.bri_power_on,
|
||||
SendDeviceGroupMessage(0, DGR_MSGTYP_UPDATE, DGR_ITEM_BRI_POWER_ON, Settings.bri_power_on,
|
||||
DGR_ITEM_BRI_PRESET_LOW, Settings.bri_preset_low, DGR_ITEM_BRI_PRESET_HIGH, Settings.bri_preset_high);
|
||||
#ifdef USE_PWM_DIMMER_REMOTE
|
||||
else
|
||||
SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, remote_pwm_dimmer->power_on,
|
||||
SendDeviceGroupMessage(-device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, remote_pwm_dimmer->power_on,
|
||||
DGR_ITEM_BRI_POWER_ON, remote_pwm_dimmer->bri_power_on, DGR_ITEM_BRI_PRESET_LOW, remote_pwm_dimmer->bri_preset_low,
|
||||
DGR_ITEM_BRI_PRESET_HIGH, remote_pwm_dimmer->bri_preset_high);
|
||||
#endif // USE_PWM_DIMMER_REMOTE
|
||||
|
@ -491,6 +491,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
|
|||
}
|
||||
|
||||
// If we need to adjust the brightness, do it.
|
||||
uint32_t negated_device_group_index = -power_button_index;
|
||||
if (bri_offset) {
|
||||
int32_t bri;
|
||||
#ifdef USE_PWM_DIMMER_REMOTE
|
||||
|
@ -509,7 +510,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
|
|||
}
|
||||
if (new_bri != bri) {
|
||||
#ifdef USE_DEVICE_GROUPS
|
||||
SendDeviceGroupMessage(power_button_index, (dgr_more_to_come ? DGR_MSGTYP_UPDATE_MORE_TO_COME : DGR_MSGTYP_UPDATE_DIRECT), DGR_ITEM_LIGHT_BRI, new_bri);
|
||||
SendDeviceGroupMessage(negated_device_group_index, (dgr_more_to_come ? DGR_MSGTYP_UPDATE_MORE_TO_COME : DGR_MSGTYP_UPDATE_DIRECT), DGR_ITEM_LIGHT_BRI, new_bri);
|
||||
#endif // USE_DEVICE_GROUPS
|
||||
#ifdef USE_PWM_DIMMER_REMOTE
|
||||
if (active_remote_pwm_dimmer) {
|
||||
|
@ -559,9 +560,9 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
|
|||
}
|
||||
#endif // USE_PWM_DIMMER_REMOTE
|
||||
if (new_power)
|
||||
SendDeviceGroupMessage(power_button_index, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_BRI, power_on_bri, DGR_ITEM_POWER, new_power);
|
||||
SendDeviceGroupMessage(negated_device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_BRI, power_on_bri, DGR_ITEM_POWER, new_power);
|
||||
else
|
||||
SendDeviceGroupMessage(power_button_index, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, new_power);
|
||||
SendDeviceGroupMessage(negated_device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, new_power);
|
||||
#endif // USE_DEVICE_GROUPS
|
||||
#ifdef USE_PWM_DIMMER_REMOTE
|
||||
if (active_remote_pwm_dimmer)
|
||||
|
@ -639,7 +640,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
|
|||
if (handle_tap)
|
||||
#endif // USE_PWM_DIMMER_REMOTE
|
||||
message_type = (DevGroupMessageType)(message_type + DGR_MSGTYPFLAG_WITH_LOCAL);
|
||||
SendDeviceGroupMessage(power_button_index, message_type, dgr_item, dgr_value);
|
||||
SendDeviceGroupMessage(negated_device_group_index, message_type, dgr_item, dgr_value);
|
||||
#endif // USE_DEVICE_GROUPS
|
||||
#ifdef USE_PWM_DIMMER_REMOTE
|
||||
if (!active_remote_pwm_dimmer)
|
||||
|
@ -697,7 +698,7 @@ void CmndBriPreset(void)
|
|||
Settings.bri_preset_high = parm[0];
|
||||
}
|
||||
#ifdef USE_DEVICE_GROUPS
|
||||
SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_BRI_PRESET_LOW, Settings.bri_preset_low, DGR_ITEM_BRI_PRESET_HIGH, Settings.bri_preset_high);
|
||||
SendDeviceGroupMessage(0, DGR_MSGTYP_UPDATE, DGR_ITEM_BRI_PRESET_LOW, Settings.bri_preset_low, DGR_ITEM_BRI_PRESET_HIGH, Settings.bri_preset_high);
|
||||
#endif // USE_DEVICE_GROUPS
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue