Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ON-OFF button support #318

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft

Conversation

gorbit99
Copy link
Contributor

@gorbit99 gorbit99 commented Mar 23, 2024

This PR adds in support for momentary push button based ON-OFF functionality using the ESP's deep sleep feature.

The code was tested on an ESP8266 (specifically a D1 mini) and an ESP32-C3 (supermini esp32c3). For the latter, attaching a push button between GND and any of the RTC GPIOs (GPIO0-5), the code should work, but for the ESP8266, the following hardware needs to be added:

kép

GPIO13 can be set to any of the safe pins (4, 5, 12, 13, 14), however the other ones are already used by the default SlimeVR setup. I have tried to make the setup work with a MOSFET instead of a transistor, but didn't manage to yet.

The on-off behaviour can be activated by defining ON_OFF_BUTTON inside defines.h. For example:

#define ON_OFF_BUTTON D7

for a D1 mini.

When the tracker is on, holding down the button for 1 second puts it to deep sleep (this is debounced). When it's in deep sleep, pressing the button once will wake it up, resetting it. The hold down time can be changed by defining ON_OFF_BUTTON_HOLD_TIME_MS in defines.h.

The tracker attempts to deinitialize the imus attached to it.

While it varies, this setup should drop the power consumption to somewhere around 100-200uA.

Things that need checking:

  • Is it possible to make the necessary circuitry for the ESP8266 out of a MOSFET
  • Are the 8266 quirks solvable
  • Are the deinitialization routines for the IMUs correct

It's also theoretically possible to add in a hold time for turning on the tracker for the ESP32 variant, but since this isn't at all possible for the ESP8266, I didn't implement it.

@kounocom
Copy link
Contributor

Tested on custom esp32-c3 board, works as expected

@gorbit99 gorbit99 marked this pull request as ready for review March 28, 2024 03:15
@gorbit99
Copy link
Contributor Author

gorbit99 commented May 7, 2024

Can I get some eyes on this?

@gorbit99
Copy link
Contributor Author

Brought this code up to date with the sfusion merging, now theoretically all IMUs supported by sfusion should also be supported by this PR.

@Vyolex Vyolex self-requested a review August 28, 2024 13:08
@Vyolex
Copy link
Member

Vyolex commented Aug 28, 2024

I'll check this later after work, looks good though.

@gorbit99
Copy link
Contributor Author

@Vyolex Currently there is a weird drifting issue that happens with this branch, and I want to rewrite some of the logic a bit, to make it non-blocking, so I wouldn't bother yet.

@gorbit99 gorbit99 marked this pull request as draft August 28, 2024 13:48
@Vyolex Vyolex removed their request for review August 28, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants