With a few hours free yesterday I decided to take an initial stab at implementing blocks for ezDisplay. First, a few concerns:
- Barnabas Blocks only supports the Arduino Nano and Uno and their functionality. I had to create a new board and set of blocks for ezDisplay.
- Therefore, the new set of the blocks is a subset of all the blocks from Arduino, keeping only the functionality built into C and some Arduino functions. However, it must also add support for manipulating an LCD.
- These sets of blocks are called lessons - there is a simple lesson called the "Bot" (as in Barnabas Bot, the introductory course in Barnabas's catalog) which contains only the blocks that are useful on a Barnabas Bot and simplifies many blocks (for example, there is no setup block, delays are done in whole seconds instead of milliseconds, etc.). There is also the advanced lesson which introduces full functionality. I based the ezDisplay lesson on the advanced one, but removed all the irrelevant functionality (for example, the wiring of the ezDisplay cannot manipulate servos, so the servo related blocks were removed).
I created this new set of blocks (aka a "lesson") and proceeded with adding block functionality. So far, I've implemented:
- oled.clear() - Clear the display.
- oled.setCursor(x, y) - Move the location from which content will be drawn. This is like moving your pen somewhere else on the paper before signing your name.
- oled.print(string): Print this string to the screen starting at the cursor, in the currently selected font. On that note...
- oled.setFont(font): This takes in a special font object and makes all the oled.print function calls after this line of code use the specified font.
- There are around 40 fonts available. The process of implementing these became quite tedious, as I had to manually create a dropdown with 40 entries. Fortunately, I wrote a program to help automatically convert this dropdown to C code, so not everything was a complete pain.
- I created this font block, then created the setFont block which accepted this font block.
To demonstrate everything, I made the following program using only Barnabas Blocks that prints out the lyrics of Baby Shark (I had no other immediate ideas), then waits for a press of the button to restart the song from the start.
The C code generates properly and sure enough it spits out the lyrics when uploaded (we haven't figured out to upload to the display from the web app yet, so I used arduino-cli to upload the C code).
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
Nice Dante!
Are you sure? yes | no