mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 13:16:45 +00:00
Make .val obsolete with relays
This commit is contained in:
parent
3b8985784a
commit
fd5dec8f8b
@ -92,8 +92,7 @@ static void gpio_event_handler(AceButton* button, uint8_t eventType, uint8_t but
|
|||||||
switch(eventType) {
|
switch(eventType) {
|
||||||
case AceButton::kEventPressed:
|
case AceButton::kEventPressed:
|
||||||
if(gpioConfig[btnid].type != hasp_gpio_type_t::BUTTON) {
|
if(gpioConfig[btnid].type != hasp_gpio_type_t::BUTTON) {
|
||||||
eventid = HASP_EVENT_ON;
|
eventid = HASP_EVENT_ON;
|
||||||
gpioConfig[btnid].power = 1;
|
|
||||||
} else {
|
} else {
|
||||||
eventid = HASP_EVENT_DOWN;
|
eventid = HASP_EVENT_DOWN;
|
||||||
}
|
}
|
||||||
@ -116,8 +115,7 @@ static void gpio_event_handler(AceButton* button, uint8_t eventType, uint8_t but
|
|||||||
// break;
|
// break;
|
||||||
case AceButton::kEventReleased:
|
case AceButton::kEventReleased:
|
||||||
if(gpioConfig[btnid].type != hasp_gpio_type_t::BUTTON) {
|
if(gpioConfig[btnid].type != hasp_gpio_type_t::BUTTON) {
|
||||||
eventid = HASP_EVENT_OFF;
|
eventid = HASP_EVENT_OFF;
|
||||||
gpioConfig[btnid].power = 0;
|
|
||||||
} else {
|
} else {
|
||||||
eventid = HASP_EVENT_RELEASE;
|
eventid = HASP_EVENT_RELEASE;
|
||||||
}
|
}
|
||||||
@ -126,6 +124,7 @@ static void gpio_event_handler(AceButton* button, uint8_t eventType, uint8_t but
|
|||||||
eventid = HASP_EVENT_LOST;
|
eventid = HASP_EVENT_LOST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpioConfig[btnid].power = Parser::get_event_state(eventid);
|
||||||
event_gpio_input(gpioConfig[btnid].pin, eventid);
|
event_gpio_input(gpioConfig[btnid].pin, eventid);
|
||||||
|
|
||||||
// update objects and gpios in this group
|
// update objects and gpios in this group
|
||||||
@ -188,8 +187,9 @@ static void gpio_setup_pin(uint8_t index)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t input_mode;
|
uint8_t input_mode = INPUT_PULLUP;
|
||||||
bool default_state = gpio->inverted ? LOW : HIGH; // default pullup
|
bool default_state = gpio->inverted ? LOW : HIGH; // default pullup
|
||||||
|
|
||||||
switch(gpio->gpio_function) {
|
switch(gpio->gpio_function) {
|
||||||
case hasp_gpio_function_t::OUTPUT_PIN:
|
case hasp_gpio_function_t::OUTPUT_PIN:
|
||||||
input_mode = OUTPUT;
|
input_mode = OUTPUT;
|
||||||
@ -207,7 +207,7 @@ static void gpio_setup_pin(uint8_t index)
|
|||||||
#endif
|
#endif
|
||||||
case hasp_gpio_function_t::INTERNAL_PULLUP:
|
case hasp_gpio_function_t::INTERNAL_PULLUP:
|
||||||
default:
|
default:
|
||||||
input_mode = INPUT_PULLUP;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpio->power = 1; // on by default, value is set to 0
|
gpio->power = 1; // on by default, value is set to 0
|
||||||
@ -277,9 +277,11 @@ static void gpio_setup_pin(uint8_t index)
|
|||||||
Serial1.begin(115200UL, SERIAL_8N1, UART_PIN_NO_CHANGE, gpio->pin,
|
Serial1.begin(115200UL, SERIAL_8N1, UART_PIN_NO_CHANGE, gpio->pin,
|
||||||
gpio->type == hasp_gpio_type_t::SERIAL_DIMMER_EU); // true = EU, false = AU
|
gpio->type == hasp_gpio_type_t::SERIAL_DIMMER_EU); // true = EU, false = AU
|
||||||
Serial1.flush();
|
Serial1.flush();
|
||||||
delay(20);
|
//delay(10);
|
||||||
Serial1.print(" ");
|
//Serial1.print(" ");
|
||||||
delay(20);
|
Serial1.write(0x20);
|
||||||
|
Serial1.write(0x20);
|
||||||
|
// delay(10);
|
||||||
Serial1.write((const uint8_t*)command, 8);
|
Serial1.write((const uint8_t*)command, 8);
|
||||||
#endif
|
#endif
|
||||||
gpio_log_serial_dimmer(command);
|
gpio_log_serial_dimmer(command);
|
||||||
@ -613,6 +615,10 @@ bool gpio_set_pin_state(uint8_t pin, bool power, int32_t val)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(gpio->max == 1) { // it's a relay
|
||||||
|
gpio->val = gpio->power; // val and power are equal
|
||||||
|
}
|
||||||
|
|
||||||
if(gpio->group) {
|
if(gpio->group) {
|
||||||
// update objects and gpios in this group
|
// update objects and gpios in this group
|
||||||
gpio->power = power;
|
gpio->power = power;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user