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.
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:
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
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
Start the 'closed' cycle by invoking function setup();.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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:
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 nextdeclare 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 valueStart the 'closed' cycle by invoking function
setup();
.