'Long press' changed after firmware upgrade?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Posts: 1
Joined: Sat Jan 11, 2020 11:43 am

'Long press' changed after firmware upgrade?

Post by dnoha » Sat Jan 11, 2020 11:55 am

I had one loop to determine if button at GPIO0 was just pressed or hold for more seconds.

With old firmware, my NodeMCU device reset automatically if button (GPIO0) was hold for more then 8 sec. Therefore I counted 6 seconds (with sound feedback to user after each second), and after that switch AP mode on. Copy of code bellow.

With new firmware same NodeMCU resets after only 2 or 3 seconds. So I can not use this function any more.

Something changed in firmware between those two versions, regarding this issue?

Old firmware used: esp8266-20190125-v1.10
New firmware used: esp8266-20191220-v1.12
(I did erase flush while upgrading)

Code: Select all

def pinBTN_cb(p):
    if p.value() == 0:
        t0 = time.ticks_ms()-1001
        t1 = t0

        b = 0
        # loop waiting button release
        while p.value() == 0:
            t2 = time.ticks_ms()
            # sound tick every sec
            if (t2-t1)>=1000:
                print('tick: ' + str(int((t2-t0-1000)/1000)) + ' sec')
            # sound tick after 6 sec
            if ((t2-t0)-1000>=6000 and b==0):
        # after release, continue program, b = number of seconds while pressed
        # short click (less then 1 sec)
        if d==0:
            # send some mqtt message
        # more then 6 sec
        if d>=6:
            print('STARTING AP')

Post Reply