Closed
Description
When calling pin.isTouched the pin automagically goes into touch mode and creates a MicroBitButton instance. It registers itself with the system ticker using addSystemComponent. Then if you call pin.getDigitalValue it deletes the MicroBitButton instance but does not seem to unregister itself with the system ticker. As such the system hangs.
Example code to reproduce:
void app_main() {
while (1) {
printf("digital mode\r\n");
for (int i = 0; i < 20 * 10; ++i) {
if (uBit.io.P0.getDigitalValue()) {
uBit.display.print('D');
} else {
uBit.display.clear();
}
uBit.sleep(50);
}
printf("touch mode\r\n");
for (int i = 0; i < 20 * 10; ++i) {
if (uBit.io.P0.isTouched()) {
uBit.display.print('T');
} else {
uBit.display.clear();
}
uBit.sleep(50);
}
}
}
It works the first time round, but on the second loop it hangs.
Metadata
Metadata
Assignees
Labels
No labels