Willkommen bei bytebang » The blog about all and nothing » Add display fonts to custom built NodeMCU firmwares

Add display fonts to custom built NodeMCU firmwares

Apr 01 2018

The Problem

In my previous article I showed how to compile a custom firmware for the WeMos Lolin board and how to get the display up and running.

Since then I have played around with it and i wondered how to switch between different fonts for this display and where these magic constants within the LUA code are coming from.

The Solution

I figured out that fonts have to be 'enabled' within the firmware. It ts quiet simple to do this:

  1. Start the firmware configuration (with $ make menuconfig)
  2. Navigate to the following section Component Config -> NodeMCUModules -> U8G2 Module: Fonts 

There you will see a list of the currently enabled fonts. If you want to add another one then do the following:

  1. Browse to https://github.com/olikraus/u8g2/wiki/fntlistall
  2. Select your candidate (klick on the name opens a full preview) and write down the font name without the u8g2 prefix: u8g2_font_inr24_mf  =>  font_inr24_mf
  3. Append this name to the list of installed fonts 


After this you need to recompile the firmware, flash it onto the board and from there on you can use the font as follows:

-- SDA and SCL can be assigned freely to available GPIOs
id  = i2c.HW0
sda = 5
scl = 4
i2c.setup(id, sda, scl, i2c.FAST)

-- set up the display
sla = 0x3c
disp = u8g2.ssd1306_i2c_128x64_noname(id, sla)

-- display something
disp:drawStr(64, 45, "{b}")

-- choose other font
disp:drawStr(0, 45, "{b}")

The result shoul look like this:


Have fun !

Get Social

(c) 2018, by bytebang e.U. - Impressum - Datenschutz / Nutzungsbedingungen