• You don't mention any pinMode();. Espruino has a useful auto-behavior for setting pin mode, which may cause this strange behavior in combination with the different hardware: see Note in Reference.

    Therefore, give it a shot and define pin's mode first. I used both analog and digital input in conjunction with Resistive Touchscreen directly (no touch controller). You may get some ideas from there.

    Basically, I set the pin up for digital single shot watch with pull_up/down, in the callback I change the setup and make analog reads with no-pulls to get the x/y coordinates of the resistive touch screen, and return to initial setup with single shot watch.

    For you, this means:

    1. declare a function process() { ... } that:
      i) sets pin up for analog read - input with no pull up or down - to get untainted analog value
      ii) read the analog value and process it
      iii) invoke watch(), - see next

    2. declare a function watch() { ... } that:
      i) sets pin up for watch - input with pull-up or down and single trigger and desired rising/falling/both trigger - to get the trigger
      ii) use process as the watch's callback to handle the triggering value

    3. Start the 'closed' cycle by invoking function setup();.

About

Avatar for allObjects @allObjects started