When the OLED initialize block is used, it sets up the Propeller microcontroller to communicate with the Color OLED module. The OLED initialize block installs 1 small font, which allows you to print text and numbers to the OLED module’s screen. You may want to use a medium or large sized font instead. In order to use different fonts, you will have to install them into the EEPROM memory on your Activity Board.
The EEPROM memory on the Activity Board and Propeller FLiP can hold up to 64 kilobytes (KB) of data. The first 32 KB is used to hold your programs when you click “Save to EEPROM”. The remaining memory — often called upper EEPROM — is used to hold information that can be accessed by the programs you write.
The chart below illustrates how the EEPROM is used. When you install the Display Fonts, they use about 23 KB of EEPROM memory:
If you look carefully at the chart above, when Fonts are installed, there are about 7.8 kilobytes available for other uses. In BlocklyProp, that area is accessible via the Memory > EEPROM blocks.
Load the Fonts
Installing the fonts does not actually require any circuits, not even the OLED itself. The program to install the fonts is only a single block.
- Build the program shown above, just using the single COMMUNICATE > OLED > OLED font loader block:
- Click the Load and run (save code to EEEPROM) button.
- Do not disconnect your board, click any buttons, or press any keys while the fonts are loading.
- The Terminal window will appear, and the P26/P27 LEDs will begin to blink. The install process takes about 1 minute to complete.
- Wait for your Terminal window to say “done” and the P26/P27 LED to turn off before disconnecting or turning off your Activity Board.
Did You Know?
Four Fonts, Three Sizes — The default Sans font style does not need the OLED font loader block. But once you have loaded the OLED font loader block project to EEPROM, you have the fancy Serif, Script, and Bubble fonts to use. Here are the sizes available to each font:
- Sans: (default) available in small, medium and large
- Serif: medium and large only
- Script: medium and large only
- Bubble: medium and large only
Fixed-width & fixed-height Fonts — This means that each character takes up the same amount of space. This makes it much easier to predict where characters will appear on your screen.
The width of each character increases by 6 pixels from small (6 pixels wide) to medium (12 pixels wide) to large (18 pixels wide). The height increases by 8 pixels from small (8 pixels tall) to medium (16 pixels tall) to large (24 pixels tall). Because there is a 1 pixel spacer on the right and top of each character, the actual character size is 1 pixel less:
Try This - Change the Font and Size
Now that you have loaded fonts to your Propeller board’s EEPROM, you are ready to experiment with those different fonts and sizes. By default, the OLED print text block will use the Sans font in size small. You can now change that with the OLED text size block.
- Disable or remove the OLED font loader block.
- Build the program shown below.
- Click the Run once button. The screen will display:
- Change the OLED set text size to large, and then click Run once again. Notice that the text wraps to the beginning of the next line.
- Add the word "World" back in to the OLED print text block, so it says "Hello World! again, and run it. If the text does not have enough room at the bottom of the screen, it will wrap back to the top left corner of the screen.
- Keep trying combinations of words, fonts, and sizes until you are familiar with how the different options look together.
Your Turn — Change Color
By default, the OLED print text block will use white text on a black background. The OLED font color block adds another element of fun and functionality!
Add the OLED font color block to your project, just under the OLED set text block.
- Click in the white box in each color block to chose a font color and font background color setting.
- Click Run once to see the effect.
- Try setting both blocks back to white, and run it. What happens?
- Try setting font color to white, and font background color to black. What happens?
- Try different combinations of font and background colors, fonts, and font sizes to see which are easier to read, and which are harder. Make a note of your favorites.