Why gpio set in HandleLightBulbOnRead?
skanico opened this issue · 3 comments
Hello,
I'm trying to understand your sample.
I wonder, why do you set gpio level in HandleLightBulbOnRead
?
I thought it was only used to read characteristic state...
Thanks
switch(i)
{
case 2:
gpio_pad_select_gpio(26);
gpio_set_direction(26, GPIO_MODE_OUTPUT);
gpio_set_level(26, !accessoryConfiguration.state.lightBulbOn[2]);
break;
case 3:
gpio_pad_select_gpio(27);
gpio_set_direction(27, GPIO_MODE_OUTPUT);
gpio_set_level(27, !accessoryConfiguration.state.lightBulbOn[3]);
break;
}
it is used to read characteristic state from the memory. Imagen a situation when there is a power outage with this code the esp will resume the previous state when power is back online
OK, I understand better.
If the goal is to restore the state after a power outage, wouldn't it be better to set the gpio after LoadAccessoryState
in AppCreate
? Isn't it overkill to write to gpio each time you read the state?
I'm just discovering ADK... sorry if this is a bad idea ;-)
Btw, I'd like to understand how to catch gpio input interrupt. Have you ever tried something about it?
Thanks
Probably yes it would be better but I wanted the changes as compact as they can be for new people. Might be a bad approach on my part. Yes it probably is.
The idea is great if you want I can add you as a collaborator to this repository. TBH there is a ton of improvements to be done here but alone I just don't have the time.
In fact yes I have but as of now only with the arduino-IDE. Check this boi out: https://youtu.be/CJhWlfkf-5M
If you are working on a ESP32 you may also enjoy this: https://youtu.be/k_D_Qu0cgu8