Touchpad support implemented



  • Re: Touch pin functionality
    When I finally came around to using all those wonderful touch pads on the GPy pinout, it was quite disheartening to find posts, 1 and 2 years old, asking about when it'd be implemented and nothing since. Groan.

    So I've created a branch of the latest firmware that actually has touchpad support. Hopefully it'll be merged into the main trunk but in the meantime you can get it at
    https://github.com/psychogenic/pycom-micropython-sigfox/tree/touchsupport

    I made it part of the machine module, as machine.TouchPad. Sample usage:

    # define a callback, triggered by touches
    def hullo(thepad):
        print("Hullooo: %s" % str(thepad))
    
    # trigger arg is optional, but makes the pads 
    # much more useful... create some touch pads
    t6 = machine.TouchPad('P23', trigger=hullo)
    t8 = machine.TouchPad('P20', trigger=hullo)
    
    # to figure out thresholds, do a read:
    t6.read()
    # >> 1149
    t8.read()
    # >> 1034
    
    t6.threshold(600)
    t8.threshold(500)
    
    # and that's it, on touch you'll see something like
    # Hullooo: TouchPad(T8)
    
    # you can also access the pad id (the "touch index")
    t6.id()
    # >> 6
    
    # clean-up when done
    t6.deinit()
    t8.deinit()
    

    Enjoy and let me know if you hit any issues.
    Pat Deegan


 

Pycom on Twitter