Skip to content

Commit cf5e1a7

Browse files
committed
Add Unit MiniOLED example
1 parent 22cd102 commit cf5e1a7

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

examples/KIT/SCALES_KIT/SCALES_KIT.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ M5Canvas canvas(&display);
3434
HX711 scale;
3535

3636
void setup() {
37-
M5.begin(); // Init M5Stack. 初始化M5Stack
38-
M5.Power.begin(); // Init power 初始化电源模块
37+
M5.begin(); // Init M5Stack. 初始化M5Stack
38+
M5.Power.begin(); // Init power 初始化电源模块
3939
display.begin();
4040
canvas.setColorDepth(1); // mono color
4141
canvas.createSprite(display.width(), display.height());

examples/Unit/MiniOLED/MiniOLED.ino

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2023 by M5Stack
4+
* Equipped with M5Core sample source code
5+
* 配套 M5Core 示例源代码
6+
* Visit for more information: https://docs.m5stack.com/en/unit/MiniOLED%20Unit
7+
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/unit/MiniOLED%20Unit
8+
*
9+
* Describe: Unit MiniOLED
10+
* Date: 2023/07/28
11+
*******************************************************************************
12+
Depend Libraries:
13+
-[U8g2](https://github.com/olikraus/U8g2_Arduino)
14+
Please install the required libraries and connect the Unit MiniOLED to the
15+
PORT-A port (G21/22)
16+
请安装依赖库并将Unit MiniOLED 连接到PORT-A端口(G21/22)
17+
*/
18+
#include <Arduino.h>
19+
#include <U8g2lib.h>
20+
#include <Wire.h>
21+
22+
#define SDA_PIN 21
23+
#define SCL_PIN 22
24+
25+
U8G2_SSD1306_72X40_ER_F_HW_I2C u8g2(
26+
U8G2_R0, /* reset=*/U8X8_PIN_NONE); // EastRising 0.42" OLED
27+
28+
void setup(void) {
29+
Wire.begin(SDA_PIN, SCL_PIN);
30+
u8g2.begin();
31+
}
32+
33+
void loop(void) {
34+
u8g2.clearBuffer(); // clear the internal memory
35+
u8g2.setFont(u8g2_font_ncenB08_tr); // choose a suitable font
36+
u8g2.drawStr(10, 20, "Hello"); // write something to the internal memory
37+
u8g2.drawStr(10, 30, "M5Stack!");
38+
u8g2.sendBuffer(); // transfer internal memory to the display
39+
delay(1000);
40+
}

0 commit comments

Comments
 (0)