micropython-m5stack
micropython-m5stack copied to clipboard
Button callback: guru mediation if None
Using the example main.py, I wanted to have button C stopping the various button polls. So I added, within button_handler_c:
a._user_callback=None
hoping that button A would stop answering polls. What I got was:
File "/flash/lib/input.py", line 53, in _callback
TypeError: 'NoneType' object is not callable
Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC : 0x40093da6 PS : 0x00060d34 A0 : 0x80092442 A1 : 0x3ffb8550
A2 : 0x3ffc30d0 A3 : 0x3ffb8754 A4 : 0x00000001 A5 : 0x00000001
A6 : 0x00060d23 A7 : 0x00000000 A8 : 0x3ffb8754 A9 : 0x3ffb8754
A10 : 0x00000014 A11 : 0x00000014 A12 : 0x00000001 A13 : 0x00000001
A14 : 0x00060d23 A15 : 0x00000000 SAR : 0x0000000a EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x4009b015 LEND : 0x4009b025 LCOUNT : 0xffffffff
Backtrace: 0x40093da6:0x3ffb8550 0x4009243f:0x3ffb8570 0x40090790:0x3ffb8590 0x400d80d1:0x3ffb85d0 0x400e22fc:0x3ffb8600 0x400e26ab:0x3ffb8620 0x400d7c98:0x3ffb8660
Core 0 register dump:
PC : 0x400916fe PS : 0x00060034 A0 : 0x80092103 A1 : 0x3ffb13a0
A2 : 0x3ffb24c8 A3 : 0x0000cdcd A4 : 0xb33fffff A5 : 0x00000001
A6 : 0x00060021 A7 : 0x0000abab A8 : 0x0000abab A9 : 0x3ffb13a0
A10 : 0x00000003 A11 : 0x00060023 A12 : 0x00060021 A13 : 0x00000001
A14 : 0x00060520 A15 : 0x00000000 SAR : 0x0000001d EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
Backtrace: 0x400916fe:0x3ffb13a0 0x40092100:0x3ffb13d0 0x40090a2b:0x3ffb13f0 0x400932cd:0x3ffb1410 0x40084cd6:0x3ffb1420 0x400d6edf:0x00000000
CPU halted.
Basically: the code does not check whether _user_callback is set to None or not... So what one could do is just at the start of _callback (before disabling irqs) insert:
if self._user_callback is None:
return