Oled Display
A class to control an OLED display using I2C.
Source code in wsd_esp32\oled_display.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
__init__(sda_pin=21, scl_pin=22, freq=400000, width=128, height=32)
Initializes the OLED display.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sda_pin
|
int
|
The GPIO pin number for the I2C data line (SDA). Default is 21. |
21
|
scl_pin
|
int
|
The GPIO pin number for the I2C clock line (SCL). Default is 22. |
22
|
freq
|
int
|
The frequency for the I2C communication in Hz. Default is 400,000. |
400000
|
width
|
int
|
The width of the OLED display in pixels. Default is 128. |
128
|
height
|
int
|
The height of the OLED display in pixels. Default is 32. |
32
|
Source code in wsd_esp32\oled_display.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
clear()
Clears the OLED display by filling it with black pixels.
Source code in wsd_esp32\oled_display.py
28 29 30 31 32 33 |
|
write(text, x=0, y=0)
Displays text on the OLED screen.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to display on the screen. |
required |
x
|
int
|
The x-coordinate (horizontal position) where the text starts. Default is 0. |
0
|
y
|
int
|
The y-coordinate (vertical position) where the text starts. Default is 0. |
0
|
Source code in wsd_esp32\oled_display.py
35 36 37 38 39 40 41 42 43 44 45 |
|
demo()
Runs a simple demo to showcase the OLED display functionality.
Source code in wsd_esp32\oled_display.py
47 48 49 50 51 52 53 54 55 56 |
|