[GPIO] Added “Wake on Button Press” functionality.#5519
[GPIO] Added “Wake on Button Press” functionality.#5519chromoxdor wants to merge 19 commits intoletscontrolit:megafrom
Conversation
I tried to integrate the feature, though I am not sure if the structure is fine with you since I more or less guestimated some things, but I am happy to receive your suggestions. It also would help to do more testing on e.g. ESP32-S2,ESP32-C3,... - Add a checkbox in the switch plugin if the selected GPIO can wake the device from deep sleep. - tested on ESP32-S3 and ESP32-C6
|
I have to look at it tomorrow, as I was just about to go to bed. And maybe not the least... how must ESPEasy react on wake-up by GPIO? Just some ideas that pop up about this. |
Exactly my thought. But for simplicity, I was doing it in P001. |
|
Oh and another idea... |
- added "System#BootCause" and "System#GPIOWake" events - moved gpio-wake related functions to _Plugin_Helper
|
All seems to work fine, but I really need help with storing the bitmask to |
@TD-er, can you help me with that when you have some time to spare? |
|
And you think someone with his last diploma literally being one of tying his shoe laces will be able to? ;) Anyway, given the ESP's with the largest amount of GPIO pins are already close to 64 pins, I guess we should at least add a 64bit uint to the settings struct. This should be done at the end of the SettingsStruct, so other members won't shift and render the struct incompatible with stored ones. Then you should add a get/set function. Use these as inspiration: bool getNetworkEnabled(ESPEasy::net::networkIndex_t index) const;
void setNetworkEnabled(ESPEasy::net::networkIndex_t index, bool enabled);The Arduino |
|
Instead of adding extra bytes to the settings struct, you could reuse a couple of bytes from the |
Look at
That a good starting point |
|
Ton's argument is also a good one as #ifdef ESP32
uint32_t wakePin_bitmask_lo{};
uint32_t wakePin_bitmask_hi{};
unsigned int OLD_TaskDeviceID[N_TASKS - 10] = {0}; // UNUSED: this can be reused
#else
unsigned int OLD_TaskDeviceID[N_TASKS - 8] = {0}; // UNUSED: this can be reused
#endifAlso we can expect those values to be already set to 0 in existing settings. |
|
Should we reserve 2 bits per GPIO, so we can accommodate low and high activation? |
There are 8 uin32_t left, so we can go upto 4 bits per GPIO. Edit: |
|
Oh, oh, did I hear someone saying "low and high activation„? I will see how far I am coming. For now, I need to keep it as simple as possible, as I will probably very soon have no time at all for some months. |
Make sure you will get enough sleep before that will happen :) |
I tried this but getting: Any idea what I am doing wrong? |
|
By conditionally inserting 2 variables before the address of the Alternatively, you can also make (only) these variables not conditional, but also include them for ESP8266, as the size of the SettingsStruct doesn't change it won't have an impact on the build-size. Then you can just adjust the offset assertion as noted above, and it will fit either build-type. |
- using bitmask instead of bool for wakeonhigh - refining docs
|
Is wake-on-high vs. -low a global flag for all wake-up pin settings? Can you set multiple wake-up pins? |
Yes, as stated in the documentation I wrote ;)
You can check any GPIO that is supported. Just added a picture in the first post. |
- adding all what was suggested....
|
@chromoxdor |
|
Be my guest. :) I am done here (or at least I think I am) |
But to keep track of this multitude of different boards, it would need an extra database since there is no existing one. And an automatic detection of the specific board is impossible. Edit: And not everyone wants to use the onboard LED for that... |
- added a warning to the docs - added missing monitor keywords
When I am thinking about it, I would add at some point a checkbox for disabling internal pull-resistors to give the option to use exclusively external ones. But this will not happen in this PR anymore. The problem I had with the Espressif documentation is that it is sometimes inconclusive, not up to date, or hard to understand. So I had to research other sources as well until I got all the info I needed. But you never know... It also depends on how long it takes until this PR gets merged :) |
- added a "disable pull resistors" checkbox for EXT1 Wakeup
|
@TD-er |
- refinements
src/src/DataStructs/SettingsStruct.h
Outdated
| uint32_t unused_00 : 1; // Bit 0 | ||
| uint32_t unused_01 : 1; // Bit 1 | ||
| uint32_t wakeOnHigh_ckd : 1; // Bit 0 //HardwarePage: used for wake on high or low | ||
| uint32_t diableWakePulls : 1; // Bit 1 //HardwarePage: used for for disabling pulls in general |
There was a problem hiding this comment.
Is that a typo? disableWakePulls ?
Wasn't bit 1 already claimed? (not sure) (here)
- fixed typos
| struct { | ||
| uint32_t wakeOnHigh_ckd : 1; // Bit 0 //HardwarePage: used for wake on high or low | ||
| uint32_t diableWakePulls : 1; // Bit 1 //HardwarePage: used for for disabling pulls in general | ||
| uint32_t disableWakePulls : 1; // Bit 1 //HardwarePage: used for disabling internal pulls in general |
There was a problem hiding this comment.
It's still using bit 1... 🤔
There was a problem hiding this comment.
Well I already changed it in my code, so leave it.



I tried to integrate the feature, though I am not sure if the structure is fine with you since I more or less guestimated some things, but I am happy to receive your suggestions.
It also would help to do more testing on e.g. ESP32-S2,ESP32-C3,...
ToDo: