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

[Bug]: GPIO incorrect for Lilygo Lora32 2.1 1.6.1 #6213

Open
edwar64896 opened this issue Mar 3, 2025 · 6 comments
Open

[Bug]: GPIO incorrect for Lilygo Lora32 2.1 1.6.1 #6213

edwar64896 opened this issue Mar 3, 2025 · 6 comments
Labels
bug Something isn't working requires-protos A change in device that requires changes to protobufs

Comments

@edwar64896
Copy link

edwar64896 commented Mar 3, 2025

Category

Other

Hardware

T-Lora v2 1.6

Firmware Version

2.5.20 (latest beta)

Description

have connected a switch across IO12 and GND as per doc, however this doesn't appear to have any effect as a user button. Continuity and circuit both checked. Am currently checking code for this board to see where the GPIO is configured...

PIN_BUTTON defined as '12' in Device Config (Android app)

Relevant log output

@edwar64896 edwar64896 added the bug Something isn't working label Mar 3, 2025
@edwar64896
Copy link
Author

edwar64896 commented Mar 3, 2025

3ae85e2 appears to be the commit where BUTTON_PIN was nuked. I read somewhere that for the PIN_BUTTON configuration parameter to function, BUTTON_PIN must be defined...

src/input/ScanAndSelect.cpp

@ndoo ?

@edwar64896
Copy link
Author

Further investigation: as this is my first foray into this repository, not entirely sure yet exactly where buttonGpio is getting handled for the Lilygo TLora32, but certainly, putting #define BUTTON_PIN 12 back into variant.h fixes the issue. I suspect though this isn't the end of the story.

@edwar64896
Copy link
Author

ok here we are...

#if defined(BUTTON_PIN) || defined(ARCH_PORTDUINO) || defined(USERPREFS_BUTTON_PIN)

Suspect that there are going to be more references like this meaning that really, BUTTON_PIN is going to have to be defined in variant.h for now unless someone wants to dig through the whole codebase to fix the dependency!

edwar64896 added a commit to edwar64896/firmware that referenced this issue Mar 4, 2025
@ndoo
Copy link
Contributor

ndoo commented Mar 4, 2025

Seems like the logic that makes the user definition not work needs to be fixed instead. Because restoring this causes electrical noise to trigger the GPIO since it's floating (as expected) since the board has no pull up/down resistors on the pin (as it was never intended to be used this way).

@todd-herbert
Copy link
Contributor

todd-herbert commented Mar 5, 2025

The preferred way for tlora_v2_1_16 to add a user button would be by setting config.device.button_gpio. I'm seeing the same thing as you guys: it looks to me like setting this value won't have any impact if the variant doesn't originally define a BUTTON_PIN or USERPREFS_BUTTON_PIN.

Looking back through git blame, this one might be my fault. Sorry about that..

Fix button interrupt after light sleep (#3587)

  • Don't assume device has a button..

This doesn't seem to have impacted NRF52 devices, because they tend to define PIN_BUTTON1 in variant.h, which is then assigned as BUTTON PIN here

#ifdef PIN_BUTTON1
#define BUTTON_PIN PIN_BUTTON1
#endif

I think the reason we're noticing this now is: a few months ago, the decision was made that things like BUTTON_PIN shouldn't be defined in variant.h unless they're stock hardware on a board. That attitude definitely makes sense to me, but as you guys had already spotted, it seems like the ButtonThread logic needs some updating to accommodate this.

As @edwar64896 also noticed, the doc about adding a button to LILYGO® TTGO Lora also needs updating.

Are either of you keen to work on changes to ButtonThread, or would you like me to take a look at it?

Edit: oh, I didn't realize this was already summed up nicely by #6222 (comment)

@fifieldt fifieldt added the requires-protos A change in device that requires changes to protobufs label Mar 5, 2025
@edwar64896
Copy link
Author

keen but about to jump into a 3 week project so will have bandwidth early April. If this isn't soon enough am happy to watch from the sidelines...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working requires-protos A change in device that requires changes to protobufs
Projects
None yet
Development

No branches or pull requests

4 participants