Skip to content

Contributed by 沈夜, organized by Ai-Thinker

[Ai-WB2] Porting the OLED Library, Powerful Features

Problems encountered during the porting

I originally thought the M61 HAL library and the WB2 one should be compatible.

It turns out they are completely different.

Click to expand full code
c
#include "bflb_i2c.h"
#include "board.h"
#include <hosal_i2c.h>   //i2c库

The function names and file names are also different. I spent ages swapping them out before I noticed.

So I decisively went to copy some code

WB2 lights up an OLED screen

Copy and paste, done. Still tons of errors — remove the files that can't be found.

Wrote a python program to convert the relevant code. The output was all garbled. Cleared the font library and left an empty function — compile first, we'll talk later. Still errors

The delay function couldn't be found. I decisively copied the earlier program and changed the macro definition, so I didn't need to modify every function. #define Delay_ms(ms) vTaskDelay(ms)

After testing for a long time, neither demo lit up. Suspected it was a code problem, or the screen was broken. Found another board and verified the screen. It works fine. Then I wondered if the i2c address was wrong.

Search the forum for info

[Ai-WB2 Intermediate] I2C Communication Interface

The address also looked correct. Then I blindly tried a few more interfaces. Swapped sda and sdc around, and tried switching the screen to another board. At one point I connected it backwards and the screen died — it wouldn't light up at all anymore. Ha ha. Soldered two new ones

Still couldn't light it up. Switched to 13 14, still no luck. The onboard light even changed color. Dug out a multimeter and checked whether the ribbon cable was OK. Cheap cables can get damaged occasionally. Tested fine.

Went back to the boss's post, fixed the io, and successfully lit it up. The font library was corrupted and nothing displayed, so I rolled back the code. Errors again. Couldn't compile the firmware,

The hint said to add something to suppress the error — I added it and it worked

Finally, here's the source code

Attached file:

oled2.zip(22.24 KB, downloads: 1)

Released under the MIT License. Build Time 2026-09-11 14:52:23