Merge pull request #9589 from pcdiem/pwm8

Make button press rules override PWM Dimmer functions
This commit is contained in:
Theo Arends 2020-10-20 20:21:52 +02:00 committed by GitHub
commit 9414af5631
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -488,12 +488,16 @@ bool SendKey(uint32_t key, uint32_t device, uint32_t state)
Response_P(PSTR("{\"%s%d\":{\"State\":%d}}"), (key) ? "Switch" : "Button", device, state);
result = XdrvRulesProcess();
}
#ifdef USE_PWM_DIMMER
if (PWM_DIMMER == my_module_type && !result) {
#endif // USE_PWM_DIMMER
int32_t payload_save = XdrvMailbox.payload;
XdrvMailbox.payload = device_save << 24 | key << 16 | state << 8 | device;
XdrvCall(FUNC_ANY_KEY);
XdrvMailbox.payload = payload_save;
#ifdef USE_PWM_DIMMER
if (PWM_DIMMER == my_module_type) result = true;
result = true;
}
#endif // USE_PWM_DIMMER
return result;
}

View File

@ -108,7 +108,7 @@ void PWMModulePreInit(void)
PWMDimmerSetPoweredOffLed();
// The relay initializes to on. If the power is supposed to be off, turn the relay off.
if (!power && PinUsed(GPIO_REL1)) digitalWrite(Pin(GPIO_REL1), bitRead(rel_inverted, 0) ? 1 : 0);
// if (!power && PinUsed(GPIO_REL1)) digitalWrite(Pin(GPIO_REL1), bitRead(rel_inverted, 0) ? 1 : 0);
#ifdef USE_PWM_DIMMER_REMOTE
// If remote device mode is enabled, set the device group count to the number of buttons
@ -546,7 +546,6 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
else
SendDeviceGroupMessage(power_button_index, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, new_power);
#endif // USE_DEVICE_GROUPS
#ifdef USE_PWM_DIMMER_REMOTE
if (active_remote_pwm_dimmer)
active_remote_pwm_dimmer->power_button_increases_bri = (power_on_bri < 128);