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
Problems debugging and a proposal. #242
Comments
I just discovered: tinygo/src/machine/board_microbit.go Line 113 in 5569cd1
Explaining why my code isn't working as intended. |
So these are really two issues:
|
Thanks the reply! The issues are correlated because when my code didn't work, I was at a loss as to how to debug.
|
The led matrix in the micro:bit is multiplexed, that means that the leds can not be set on/off permanently, they need to be switched on/off continuously (and let POV do their magic). In a multiplexed array, you are not enabling an individual led, you are enabling the whole row or column and the led where they cross will light up. This will led to undesired results if you try to light up two or more leds. Here are some more information on the topic : https://en.wikipedia.org/wiki/Charlieplexing For the micro:bit matrix, I have this example : https://github.com/conejoninja/tinygoexamples/tree/master/microbit/scrolltext that will enable several leds at a time. I had plans to make a driver out of it, but didn't find the time yet to do it. |
This is very helpful, thank you.
I rewrote my sample app in C using the mbed tooling and was going to try to
better understand that implementation.
I'll have a look at your code.
|
The core of the TinyGo As such, I am going to close this, please re-open, or open new issues, as needed. Thank you everyone! |
Problem
I don't understand why this simple example does not work correctly:
https://gist.github.com/DazWilkin/7c6daa9c6048d8b5761831a7420f603c
enumerate
correctly enumerates each LED in turn so I know I'm deploying code and that all the LEDs work. However,display
incorrectly repeatedly flashes (every second, OK) the LED that corresponds tomachine.setLEDMatric(4,4)
; I intenddisplay
to render the provided number using the LEDs as its binary digits.I tried replacing the binary operators (
&1
and>>1
) with their equivalents (%2
and/2
) but it makes no difference. So, then feeling crazy, I repro'd the code in The Go Playground and it works as expected: https://play.golang.org/p/jBSgaIlNK1RDebugging
Is there an obvious way to debug tinygo code? There's no local debugger (see below) and a limited set of outputs on a device for logging. Are there obvious best practices for this that elude me?
Proposal
Has any thought been given to a virtual device and possible an emulator that would run on the host machine? Simplistically, if I could replace
--target=microbit
with--target=vdevice
and then run the resulting code locally -- like with The Go Playground 'equivalent` -- I could better test code before deploying it.I appreciate implementing the
machine
package usingfmt.PrintX
commands is likely entirely insufficient but it's better than nothing. A possibly (!?) reasonably simple but more compelling solution would be to implement thevdevice
as an HTTP server that would render a basic (exemplar) device, could provide a more elegant manifestation of LEDs and could implement buttons.The text was updated successfully, but these errors were encountered: