Hello,
I am new to the field of the microcontroller programming and this is merely a project for my son but I am very compfortable with programming and building software itself.
So I just bought a mbot2 and started playing around with mBlock and the block building programming interface.
While that is a very nice start, after getting used to the features I definitely want to switch to python and use that as the primary development interface (my son is going there with his school activities anyways, so I want to figure it out before he needs it).
As a starting point I used the movement demo and accidently found a button (which I am now searching again) that generated python code based on the blocks. That’s gread to get started! Using that code in the editor was disappointing.
The editor is just a text editor. No autocompletion just syntax highlighting and a bit of easier retyping of already used words.
I was just happy to find out that there’s a dedicated python editor. But now I was the more surprised to not beeing able to use the same code as before due to issues with the event library. There are already some topics about the event library and I read them:
which both are pointing to this topic:
The solution pointed out in the post above does not help either, because the code:
import cyberpi
import time
import mbot2
from cyberpi import event
@event.start
def on_start():
# Moving function display
# Upload mode and Live mode are supported.
cyberpi.console.clear()
# cyberpi.console.set_font(12) <-- this api is not available with python 3
cyberpi.console.println("Welcome to mBot2")
will never start. It’s just a different API that does not work on the cyperpi that is shipped with mBot2.
A bit of research just showed that not beeing able to install the event
library is due to this beeing a python2 library but the python editor is using python 3.6.5 and there’s no option to change the interpreter for the editor.
Then I found out that if I upload the code without hitting the red Run button, I just works (with the python 2 library and syntax). This is still not good, as we don’t have any autocompletion for not installed python libraries or some libraries will not allow us certain APIs (like the cyberpi.console.set_font ).
My guess would be that the python code is uploaded directly to the CyberPi (maybe the websocket the console just mentions ws://localhost:20101/) and will be interpreted there without any issues.
There are many good python editors available so I would not mind using one of those and setting this up. Found the makeblock article about that:
https://education.makeblock.com/help/program-cyberpi-with-a-third-party-python-editor/
but after reading it (besides that it also suggests installing python 3.6.8) I just did not understand how the program will then be uploaded to the CyberPi/mBot2.
I hope I’m not the only one trying to solve that issue and not just going with the block programming model. From what I’ve seen is possible this can be a fun experience for a long time, but only if I can figure out a convenient setup.
thank you so much for reading and I hope you have some great ideas.