Skip to content

Commit a13d387

Browse files
committed
feat(board-ssd1306/oled-esp32): ssd1306 OLED display test
1 parent 7486694 commit a13d387

File tree

9 files changed

+109
-1
lines changed

9 files changed

+109
-1
lines changed

.github/workflows/wokwi-test.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
branches:
77
- main
88
schedule:
9-
- cron: "0 12 * * *"
9+
- cron: '0 12 * * *'
1010

1111
jobs:
1212
test:
@@ -15,6 +15,9 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
test:
18+
- name: oled-esp32
19+
path: board-ssd1306/oled-esp32
20+
scenario: ssd1306.test.yaml
1821
- name: dht22-uno
1922
path: wokwi-dht22/dht22-uno
2023
scenario: dht22.test.yaml

board-ssd1306/oled-esp32/diagram.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"version": 1,
3+
"author": "Wokwi",
4+
"editor": "wokwi",
5+
"parts": [
6+
{ "type": "board-esp32-devkit-c-v4", "id": "esp32", "top": 0, "left": 0, "attrs": {} },
7+
{
8+
"type": "board-ssd1306",
9+
"id": "oled1",
10+
"top": 102.7,
11+
"left": 203.5,
12+
"attrs": { "width": "128", "height": "64" }
13+
}
14+
],
15+
"connections": [
16+
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
17+
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
18+
[ "esp32:21", "oled1:SDA", "green", [ "v0", "h0" ] ],
19+
[ "esp32:22", "oled1:SCL", "yellow", [ "v0", "h0" ] ],
20+
[ "esp32:GND.1", "oled1:GND", "black", [ "h-23.81", "v86.4", "h220.42", "v-144", "h40.45" ] ],
21+
[ "esp32:3V3", "oled1:VCC", "red", [ "v-38.4", "h246.51" ] ]
22+
],
23+
"dependencies": {}
24+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[env:esp32]
2+
platform = espressif32
3+
board = esp32dev
4+
framework = arduino
5+
lib_deps =
6+
adafruit/Adafruit SSD1306@^2.5.7
7+
adafruit/Adafruit GFX Library@^1.11.5
8+
adafruit/Adafruit BusIO@^1.14.1
9+
build_flags = -D ARDUINO_ARCH_ESP32
417 Bytes
Loading
402 Bytes
Loading
415 Bytes
Loading

board-ssd1306/oled-esp32/src/main.cpp

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <Wire.h>
2+
#include <Adafruit_GFX.h>
3+
#include <Adafruit_SSD1306.h>
4+
5+
#define SCREEN_WIDTH 128
6+
#define SCREEN_HEIGHT 64
7+
#define OLED_RESET -1
8+
#define SCREEN_ADDRESS 0x3C
9+
10+
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
11+
12+
void setup() {
13+
Serial.begin(115200);
14+
Wire.begin(21, 22); // SDA, SCL pins for ESP32
15+
16+
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
17+
Serial.println(F("SSD1306 allocation failed"));
18+
for(;;);
19+
}
20+
21+
display.clearDisplay();
22+
display.setTextSize(1);
23+
display.setTextColor(SSD1306_WHITE);
24+
display.setCursor(0, 0);
25+
display.println("SSD1306 Test");
26+
display.println("Hello World!");
27+
display.display();
28+
Serial.println("Display initialized");
29+
}
30+
31+
void loop() {
32+
// Add some animation
33+
static int counter = 0;
34+
display.clearDisplay();
35+
display.setCursor(0, 0);
36+
display.print("Counter: ");
37+
display.println(counter);
38+
display.display();
39+
Serial.print("Counter: ");
40+
Serial.println(counter);
41+
counter++;
42+
delay(1000);
43+
}
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: 'ESP32 SSD1306 OLED Test'
2+
version: 1
3+
author: 'Test Author'
4+
5+
steps:
6+
- wait-serial: 'Display initialized'
7+
- delay: 100ms
8+
9+
- wait-serial: 'Counter: 0'
10+
- take-screenshot:
11+
part-id: 'oled1'
12+
compare-with: 'screenshots/counter-0.png'
13+
- delay: 1000ms
14+
15+
- wait-serial: 'Counter: 1'
16+
- take-screenshot:
17+
part-id: 'oled1'
18+
compare-with: 'screenshots/counter-1.png'
19+
- delay: 1000ms
20+
21+
- wait-serial: 'Counter: 2'
22+
- take-screenshot:
23+
part-id: 'oled1'
24+
compare-with: 'screenshots/counter-2.png'

board-ssd1306/oled-esp32/wokwi.toml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[wokwi]
2+
version = 1
3+
firmware = '.pio/build/esp32/firmware.elf'
4+
elf = '.pio/build/esp32/firmware.elf'
5+

0 commit comments

Comments
 (0)