Old Workaround vs. New ellipse() Call
Run the Old Workaround vs. New ellipse() Call MicroSim Fullscreen
About This MicroSim
The same circle can be drawn two ways, and this MicroSim puts them side by side. One approach is the pre-2023 workaround: import math, loop around the circle, and connect points with fb.line(). The other is the single fb.ellipse() call that MicroPython has shipped since v1.20.0. Your goal is to contrast the two and differentiate exactly what each one costs in code, in memory, and in mental effort. The circle on the display never changes when you toggle, so the only visible difference is the difference that actually matters.
How to Use
- Click Old Workaround or New ellipse() Call to swap the code panel. Watch the display panel stay exactly the same.
- Watch the counter at the top count between 11 lines and 1 line as you toggle.
- Hover over the code panel to highlight the single line that draws the circle's edge in each version.
- Read the colored badge under each code block to see what that approach requires beyond the code itself.
- Click Why does this matter? to reveal a short summary connecting the difference back to one contributor's pull request.
Iframe Embed Code
You can add this MicroSim to any web page by adding this to your HTML:
1 2 3 4 | |
Lesson Plan
Grade Level
9-12 (High School)
Duration
10-15 minutes
Prerequisites
- Reading a simple Python function definition, a
forloop, and animportstatement, from Chapters 3 and 4 - Drawing into a frame buffer with
fb.line(), from Chapter 6 - Calling
fb.ellipse()with a center point and two radii, from Chapter 7 - Knowing that a version number such as v1.20.0 identifies one release of MicroPython, from earlier in Chapter 8
Activities
- Exploration (5 min): Toggle between the two states three or four times, watching only the display panel. Write one sentence describing what changed on the display, and one describing what changed in the code.
- Guided Practice (5 min): Hover over each code panel and find the highlighted line. In the workaround, list every other line that has to run before that highlighted line can work. Then count how many supporting lines the
ellipse()version needs. - Assessment (5 min): Using the two badges, write a short comparison of what each approach requires. Then click Why does this matter? and decide whether your comparison agrees with the summary.
Assessment
- The student states that the circle on the display is identical in both states, so the output is not what changed.
- The student identifies the
fb.line()call as the drawing step in the workaround and the wholefb.ellipse()call in the current version. - The student names at least three costs of the workaround: the
mathimport, the loop, the trigonometry, or tracking the previous point. - The student explains that
ellipse()became available to everyone only after a contributed change was merged and then shipped in a stable release.
References
- MicroPython framebuf Module Documentation - The official reference for
ellipse(),poly(), and the older drawing methods. - MicroPython Downloads and Releases - Where official stable releases, including v1.20.0 and later, are published.
- MicroPython - Wikipedia - Background on the project, its history, and its open source development model.
- Distributed version control - Wikipedia - Context for pull requests, development branches, and how a contributed change reaches a release.