-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuring pin as non-touch after being in touch mode leads to crash #73
Comments
thanks @dpgeorge. @jamesadevine - can you please fix this one up? we should deregister in the appropriate destructor... |
Destructors are evil: #72 :) |
:-) Well, let's face it, C++ is evil... But when in leagues with the devil, his minions should be turned to do our bidding. :-) |
Ok, thanks for the tip! It was just for debugging purposes in this case. MicroPython has its own internal printf implementation that we use (but I wouldn't be surprised if there were some stray native printf's in there somewhere...). |
The destructor for MicroBitButton didn't take into account the fact that an instance can be destructed after registering a callback. This would then result in a HardFault if an instance was destructed. A clear repro case was registering a Touch input on a pin (abstracted as a button) and swapping to a DigitalIn.
Thanks @jamesadevine! |
@dpgeorge I'm revising the patch a little bit - will update in a short while! :) |
issue #73 highlighted an issue whereby the destruction of an instance registered as an idle or system component, would result in a hardfault. This was due to not deregistering idle or system callbacks. This patch has been applied to all components currently in use by the idle or system callbacks.
Formatting corrections and further fixes for #73
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:
It works the first time round, but on the second loop it hangs.
The text was updated successfully, but these errors were encountered: