Open coleg012 opened 4 years ago
Here is modified code example to reproduce this issue (see lines //ISSUE: st will have bits set for all pads (i.e. 776 or 11 0000 1000), even if only one of them has been touched //Expected 10 0000 0000 for T9, 01 0000 0000 for T8, 00 0000 1000 for T4 ):
`load('api_esp32_touchpad.js');
let ts1 = TouchPad.GPIO[32]; //T9 let ts2 = TouchPad.GPIO[33]; //T8 let ts3 = TouchPad.GPIO[15]; //T4
TouchPad.init(); TouchPad.filterStart(10); TouchPad.setMeasTime(0x1000, 0xffff); TouchPad.setVoltage(TouchPad.HVOLT_2V4, TouchPad.LVOLT_0V8, TouchPad.HVOLT_ATTEN_1V5); TouchPad.config(ts1, 0); TouchPad.config(ts2, 0); TouchPad.config(ts3, 0); Sys.usleep(100000); // wait a bit for initial filtering. let noTouchVal1 = TouchPad.readFiltered(ts1); let touchThresh1 = noTouchVal1 2 / 3; let noTouchVal2 = TouchPad.readFiltered(ts2); let touchThresh2 = noTouchVal2 2 / 3; let noTouchVal3 = TouchPad.readFiltered(ts3); let touchThresh3 = noTouchVal3 * 2 / 3; TouchPad.setThresh(ts1, touchThresh1); TouchPad.setThresh(ts2, touchThresh2); TouchPad.setThresh(ts3, touchThresh3);
TouchPad.isrRegister(function(st) {
// st is a bitmap with 1 bit per sensor.
//ISSUE: st will have bits set for all pads (i.e. 776 or 11 0000 1000), even if only one of them has been touched
//Expected 10 0000 0000 for T9, 01 0000 0000 for T8, 00 0000 1000 for T4
print('Status1:', st);
}, null);
TouchPad.intrEnable();`
I'm getting trouble with identifying which touch pad triggered interrupt using sample code:
I initialized 6 touch pads and tried to touch few of them and print output is always 'Status: 1008' which is binary 11 1111 0000. Two questions regarding this.
Environment: mos version: The Mongoose OS command line tool Version: 2.17.0 Build ID: 20200204-173507/2.17.0-g18c1939 Update channel: release OS: Windows 10 Home 64 bits
Let me know if more details are needed.