mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 13:46:36 +00:00
Add gpio_log_serial_dimmer
This commit is contained in:
parent
68da6a07bd
commit
52089e631a
@ -94,6 +94,14 @@ static void gpio_event_handler(AceButton* button, uint8_t eventType, uint8_t but
|
|||||||
|
|
||||||
/* ********************************* GPIO Setup *************************************** */
|
/* ********************************* GPIO Setup *************************************** */
|
||||||
|
|
||||||
|
void gpio_log_serial_dimmer(const char* command)
|
||||||
|
{
|
||||||
|
char buffer[32];
|
||||||
|
snprintf_P(buffer, sizeof(buffer), PSTR("Dimmer: %02x %02x %02x %02x"), command[0], command[1], command[2],
|
||||||
|
command[3]);
|
||||||
|
LOG_VERBOSE(TAG_GPIO, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
void aceButtonSetup(void)
|
void aceButtonSetup(void)
|
||||||
{
|
{
|
||||||
ButtonConfig* buttonConfig = ButtonConfig::getSystemButtonConfig();
|
ButtonConfig* buttonConfig = ButtonConfig::getSystemButtonConfig();
|
||||||
@ -282,11 +290,7 @@ void gpioSetup()
|
|||||||
delay(20);
|
delay(20);
|
||||||
const char command[5] = "\xEF\x01\x4D\xA3"; // Start Lanbon Dimmer
|
const char command[5] = "\xEF\x01\x4D\xA3"; // Start Lanbon Dimmer
|
||||||
Serial2.print(command);
|
Serial2.print(command);
|
||||||
|
gpio_log_serial_dimmer(command);
|
||||||
char buffer[32];
|
|
||||||
snprintf_P(buffer, sizeof(buffer), PSTR("Dimmer: %02x %02x %02x %02x"), command[0], command[1],
|
|
||||||
command[2], command[3]);
|
|
||||||
LOG_VERBOSE(TAG_GPIO, buffer);
|
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -299,7 +303,7 @@ void gpio_get_value(hasp_gpio_config_t gpio)
|
|||||||
{
|
{
|
||||||
char payload[32];
|
char payload[32];
|
||||||
char topic[12];
|
char topic[12];
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("gpio%dp%d"), gpio.type, gpio.pin);
|
snprintf_P(topic, sizeof(topic), PSTR("gpio%d"), gpio.pin);
|
||||||
snprintf_P(payload, sizeof(payload), PSTR("%d"), gpio.val);
|
snprintf_P(payload, sizeof(payload), PSTR("%d"), gpio.val);
|
||||||
|
|
||||||
dispatch_state_subtopic(topic, payload);
|
dispatch_state_subtopic(topic, payload);
|
||||||
@ -354,6 +358,7 @@ void gpio_set_value(hasp_gpio_config_t gpio, int16_t val)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HASP_GPIO_SERIAL_DIMMER: {
|
case HASP_GPIO_SERIAL_DIMMER: {
|
||||||
|
gpio.val = val >= 100 ? 100 : val > 0 ? val : 0;
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
char command[5] = "\xEF\x02\x00\xED";
|
char command[5] = "\xEF\x02\x00\xED";
|
||||||
if(gpio.val == 0) {
|
if(gpio.val == 0) {
|
||||||
@ -363,7 +368,7 @@ void gpio_set_value(hasp_gpio_config_t gpio, int16_t val)
|
|||||||
command[3] ^= command[2];
|
command[3] ^= command[2];
|
||||||
}
|
}
|
||||||
Serial2.print(command);
|
Serial2.print(command);
|
||||||
LOG_VERBOSE(TAG_GPIO, F("%02x %02x %02x %02x"), command[0], command[1], command[2], command[3]);
|
gpio_log_serial_dimmer(command);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
@ -373,7 +378,7 @@ void gpio_set_value(hasp_gpio_config_t gpio, int16_t val)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gpio_get_value(gpio);
|
gpio_get_value(gpio);
|
||||||
LOG_VERBOSE(TAG_GPIO, F(D_BULLET "Group %d - Pin %d = %d"), gpio.group, gpio.pin, gpio.val);
|
LOG_VERBOSE(TAG_GPIO, F("Group %d - Pin %d = %d"), gpio.group, gpio.pin, gpio.val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpio_set_value(uint8_t pin, int16_t val)
|
void gpio_set_value(uint8_t pin, int16_t val)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user