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

Improved button-click accuracy #3188

Merged
merged 2 commits into from
Feb 9, 2024
Merged

Improved button-click accuracy #3188

merged 2 commits into from
Feb 9, 2024

Conversation

mverch67
Copy link
Collaborator

@mverch67 mverch67 commented Feb 9, 2024

The current button implementation polls the GPIO states periodically which often leads to missed button clicks or e.g executing double-press action when triple-press was intended.

This PR implements an interrupt based handling of the (default) button GPIO which is more accurate and improves the user experience.

Tested with tbeam, t3s3, t-echo.

Also:

  • added missing t-echo HW ID for vscode device upload
  • enabled triple-click function for t-echo (default)

@mverch67 mverch67 requested a review from thebentern February 9, 2024 15:43
@thebentern thebentern merged commit 54e52ae into master Feb 9, 2024
65 checks passed
@GPSFan
Copy link
Contributor

GPSFan commented Feb 11, 2024

If I push the button too fast or too often, I can get the esp-32 to coredump and reboot. Also a long press to put the device into deep sleep has some odd results, as in it shows the shutdown screen, starts to play the tone, after the first three tones I get a Guru meditation error.
Closer look, and they are both Guru meditation errors but seem to be from different causes.

@GPSFan
Copy link
Contributor

GPSFan commented Feb 11, 2024

Serial output for the first case:

DEBUG | 17:58:51 311 [RadioIf] AirTime - Packet received (noise?) : 542ms
INFO | 17:58:58 318 [Button] Sending position ping to 0xffffffff, wantReplies=1, channel=0
DEBUG | 17:58:58 318 [Button] cancelSending id=0x5f8240c8, removed=0
INFO | 17:58:58 318 [Button] Providing time to mesh 1707674338
INFO | 17:58:58 318 [Button] Position reply: time=1707674338, latI=388981841, lonI=--1075740630
DEBUG | 17:58:58 318 [Button] Update DB node 0xb2a56448, rx_time=1707674338
DEBUG | 17:58:58 318 [Button] handleReceived(LOCAL) (id=0x5f8240cf fr=0x48 to=0xff, WantAck=0, HopLim=3 Ch=0x0 Portnum=3 WGuru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on C

Core 1 register dump:
PC : 0x4009a5c2 PS : 0x00060d35 A0 : 0x80098b06 A1 : 0x3ffbfbdc
A2 : 0x3ffdc424 A3 : 0x3ffdb8f8 A4 : 0x00000004 A5 : 0x00060d23
A6 : 0x00060d23 A7 : 0x00000001 A8 : 0x3ffdb8f8 A9 : 0x00000018
A10 : 0x3ffdb8f8 A11 : 0x00000018 A12 : 0x3ffd28ac A13 : 0x00060d23
A14 : 0x007bfe28 A15 : 0x003fffff SAR : 0x0000000a EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x400858d5 LEND : 0x400858dd LCOUNT : 0x00000027
Core 1 was running in ISR context:
EPC1 : 0x40148ec7 EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x00000000

Backtrace: 0x4009a5bf:0x3ffbfbdc |<-CORRUPTED

Core 0 register dump:
PC : 0x4009a753 PS : 0x00060035 A0 : 0x8009872f A1 : 0x3ffbf54c
A2 : 0x3ffbfe28 A3 : 0xb33fffff A4 : 0x0000abab A5 : 0x00060023
A6 : 0x00060021 A7 : 0x0000cdcd A8 : 0x0000abab A9 : 0xffffffff
A10 : 0x00000000 A11 : 0x00000000 A12 : 0x3ffd1800 A13 : 0x3ff71030
A14 : 0x007bfe28 A15 : 0x003fffff SAR : 0x0000001c EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x40092148 LEND : 0x4009215e LCOUNT : 0xffffffff

Backtrace: 0x4009a750:0x3ffbf54c |<-CORRUPTED

ELF file SHA256: 378a178679a40d7a

E (2891) esp_core_dump_flash: Core dump flash config is corrupted! CRC=0x7bd5c66f instead of 0x0
Rebooting...
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x1f (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13192
load:0x40080400,len:3028
entry 0x400805e4
E (838) esp_core_dump_flash: No core dump par`f�����found!
E (838) esp_core_dump_flash: No core dump partition found!
[ 12][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
��@INFO | ??:??:?? 0

//\ E S H T /\ S T / C

@GPSFan
Copy link
Contributor

GPSFan commented Feb 11, 2024

Serial output for the second case:
INFO | 18:01:42 162 getFromRadio=STATE_SEND_PACKETS
DEBUG | 18:01:42 162 phone downloaded packet (id=0x205bd55c fr=0x64 to=0xff, WantAck=0, HopLim=3 Ch=0x0 Portnum=3 rxtime=1707674502 rxSNR=6 rxRSSI=-25)
DEBUG | 18:01:42 162 encoding toPhone packet to phone variant=2, 67 bytes
INFO | 18:01:42 162 From Radio onread
DEBUG | 18:01:43 162 [Power] Battery: usbPower=0, isCharging=0, batMv=0, batPct=0
DEBUG | 18:01:43 162 Long press stop!
[162828][D][Tone.cpp:124] tone(): _pin=19, frequency=277 Hz, duration=125 ms
[162829][D][Tone.cpp:124] tone(): _pin=19, frequency=233 Hz, duration=125 ms
[162832][D][Tone.cpp:124] tone(): _pin=19, frequency=185 Hz, duration=250 ms
INFO |Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1).

Core 1 register dump:
PC : 0x4009a5c2 PS : 0x00060335 A0 : 0x80098b06 A1 : 0x3ffbf9cc
A2 : 0x3ffbbe4c A3 : 0x3ffbd4dc A4 : 0x00000004 A5 : 0x00060323
A6 : 0x00060323 A7 : 0x00000001 A8 : 0x3ffbd4dc A9 : 0x00000019
A10 : 0x3ffbd4dc A11 : 0x00000019 A12 : 0x3ffd28ac A13 : 0x00060323
A14 : 0x007bfe28 A15 : 0x003fffff SAR : 0x00000004 EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x40093b49 LEND : 0x40093b59 LCOUNT : 0xfffffffe
Core 1 was running in ISR context:
EPC1 : 0x40148ec7 EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x00000000

Backtrace: 0x4009a5bf:0x3ffbf9cc |<-CORRUPTED

Core 0 register dump:
PC : 0x4009a755 PS : 0x00060035 A0 : 0x8009872f A1 : 0x3ffbf54c
A2 : 0x3ffbfe28 A3 : 0xb33fffff A4 : 0x0000abab A5 : 0x00060023
A6 : 0x00060021 A7 : 0x0000cdcd A8 : 0x0000abab A9 : 0xffffffff
A10 : 0x00000000 A11 : 0x00000000 A12 : 0x3ffd1800 A13 : 0x3ffbf53c
A14 : 0x007bfe28 A15 : 0x003fffff SAR : 0x0000001d EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000

Backtrace: 0x4009a752:0x3ffbf54c |<-CORRUPTED

ELF file SHA256: 378a178679a40d7a

E (8103) esp_core_dump_flash: Core dump flash config is corrupted! CRC=0x7bd5c66f instead of 0x0
Rebooting...
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x1f (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13192
load:0x40080400,len:3028
entry 0x400805e4
E (838) esp_core_dump_flash: No core dump par`f�����found!
E (838) esp_core_dump_flash: No core dump partition found!
[ 12][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
��@INFO | ??:??:?? 0

//\ E S H T /\ S T / C

@thebentern thebentern deleted the button-clicks branch February 11, 2024 19:19
@mverch67 mverch67 restored the button-clicks branch February 12, 2024 07:01
@mverch67
Copy link
Collaborator Author

I see... fix is under way.

@tropho23
Copy link
Contributor

I opened a new issue related to implementing this fix: #3238

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.

4 participants