Skip to content

Latest commit

 

History

History
76 lines (58 loc) · 3.14 KB

README.md

File metadata and controls

76 lines (58 loc) · 3.14 KB

i2c_oled

A 128x64 I2C OLED driver ported for Mbed.

使用前须知

防止有人看不见,屏幕不亮先自己去网上查,不要私信DT5EDU成员问问题。
请在issue中描述清楚你的问题,大家都可以看得到,DT5EDU没有一对一把你教会的义务。
报错是用英语写的,请您先自己翻译一下,或者复制报错信息用浏览器搜索一下。
这个驱动需要用Mbed Studio编译,别用浏览器打开Keil Studio Cloud编译!!!

How to use this library?

Note

Probably due to compiler optimization, binaries compiled at Keil Studio Cloud don't work. It is recommended to use Mbed Studio.

This is a bug of the driver. We will try to fix it later.

Step 1: Copy files to your project

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.

Step 2: Edit i2c_oled.h to configure the pins

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);

Step 3: Try using it in your main.cpp!

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

FAQ

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.

What are the font sizes I can choose from?

You can choose 8, 12, 16 or 24 for ASCII characters from ' ' to '~'.