A 128x64 I2C OLED driver ported for Mbed.
First, download the source code in the Releases page.
Then, copy i2c_oled.h
, i2c_oled.cpp
, font.h
and genshin.h
into your project, which is usually at C:\Users\<username>\Mbed Programs\<projectname>
for Mbed Studio Windows users.
Edit lines 7 & 8 to the pins you need. Note that you don't have to choose ones that support i2c peripheral. Any GPIO pin will work.
DigitalOut OLED_SCL(D3);
DigitalOut OLED_SDA(D4);
Here is an example.
#include "mbed.h"
#include "i2c_oled.h"
int main() {
DigitalOut VCC(D2);
VCC=1; // Power the screen by setting the pin high. This is not recommended.
ThisThread::sleep_for(100ms);
OLED_Init();
OLED_Genshin();
}
(Optional) Step 4: Download Genshin Impact
What if I don't want Genshin Impact in my program?
Genshin Impact is an excellent open-world fantasy game. You should definitely try it.
OLED_Genshin()
is actually a helper function to help you verify that you have done the steps above correctly. If you use other functions to display, please note that they only write to a buffer. You need to send the buffer to the screen. Here is an example.
#include "mbed.h"
#include "i2c_oled.h"
int main() {
DigitalOut VCC(D2);
VCC=1; // Power the screen by setting the pin high. This is not recommended.
ThisThread::sleep_for(100ms);
OLED_Init();
OLED_ShowStringBuffered(0, 0, "Genshin Impact", 8, 1);
OLED_SendBuffer();
}
Is it possible to remove Genshin Impact from my program completely?
Yes, but it is not recommended. Genshin Impact is an excellent open-world fantasy game. You should definitely try it.
The Genshin Impact image is so great! How can I use my own image?
You can download the tutorial on the Releases page. It is in Chinese.
You can choose 8, 12, 16 or 24 for ASCII characters from ' '
to '~'
.