In May of 2020, LEGO released MicroPython 2.0, which is an enhanced version of MicroPython 1.0 released one year ago. Is there much work load to upgrade the existing programs from MicroPython 1.0 to 2.0? How much more functionalities are there in MicroPython 2.0? I hope this post could answer some of your questions.
Default importing modules
MicroPython 1.0 default head of main.py:
MicroPython 2.0 default head of main.py:
As mentioned in the documentation “Upgrading from v1.0 to v2.0”:
Version 2.0 introduces the
EV3Brickclass. You can use it instead of the old
ev3brickmodule. The old
ev3brickmodule can still be used, but it is no longer recommended or documented.
EV3Brickclass improves the speed and reliability of the EV3 screen and the EV3 speaker. It also adds functionality like speech and drawing shapes. The default font size is also bigger to make it easier to read text on the screen.
The following are some examples and comparison between Version 1.0 and Version 2.0.
In Version 2.0, ev3.speaker replaces the brick.sound class.
Version 2.0 also adds a function called ev3.speaker.set_volume(). Due to this change, some functions do not need volume setting parameter any more. One example is the “beep” function, whose volume setting parameter is removed from Version 2.0.
There is a new function called ev3.speaker.say(), which could say a given text string. You could also use speaker.set_speech_options() function to set a different language, voice, speed and pitch.
One problem with the ev3.speaker is the low volume. Although the volume value has been set to the maximum of 100, I still could not hear it clearly. Compared to the sound effect from LEGO Programming software, the sound from MicroPython 2.0 is much softer and weaker.
The other problem is that the program needs a bit more time to call the speaker functions. The overall response of the robot speaking is slow compared to Version 1.0.
In Version 2.0, ev3.screen replaces brick.display class in Version 1.0.
Please note that the font class is not automatically imported. You need to import font class in the head section of main.py, as shown below.
The font size problem in Version 1.0 has been solved in Version 2.0. The function of ev3.screen.set_font() could set different font type and size.
The new ev3.screen functions enhances the brick.display in Version 1.0. You could output text, load image file, drawing different shapes, etc.
There is not much change for ev3.buttons. In MicroPython 1.0, brick.buttons() will return a list of pressed buttons. In MicroPython 2.0, the same result should use ev3.buttons.pressed() function.
Motors and Sensors
There is not much change in Motors or Sensors classes. Some PID related functions of Motor class have been moved to Control class. DriveBase class from Robotics module adds some new functions to control vehicles. I will explain their usage in the next post.
New Added Modules or Classes
As mentioned above, a new Font class has been introduced to set font size and type for the brick screen.
Version 2.0 adds the ev3.light.on() and ev3.light.off() functions. Now you can turn on the brick lights with different colors.
This class will create a file and log data into it.
nxtdevices and iodevices modules
Those modules enhance the functionality of MicroPython Version 2.0 to support an extended list of hardwares. Those modules enhance the functionality of MicroPython Version 2.0 to support an extended list of hardwares.
This module is also newly added into Version 2.0. An EV3 Brick can send information to other EV3 Bricks using Bluetooth.
That is the overall review of MicroPython 2.0. It adds many new functionalities to match those provided in LEGO Programming software. It adds functions to support NXT and other third party hardware. DriveBase class provides some advanced functionalities to control motors.
Generally, I feel more confident to use LEGO MicroPython 2.0 than version 1.0. If you are new to this, you could give it a try and explore new ways to play your LEGO EV3. In the next post, I will introduce how to use DriveBase to control EV3 vehicle. Stay tuned!
Note: All the analysis articles are copyright products of http://www.thecodingfun.com. Anyone re-posting them should credit author and original source. Anyone using them for commercial purposes or translating them into other languages should notify TheCodingFun and get confirmation first. All Rights Reserved.