-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest4.py
More file actions
23 lines (20 loc) · 1 KB
/
test4.py
File metadata and controls
23 lines (20 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from ssd import SSD1306_I2C
from machine import Pin, I2C
class OLED:
@classmethod
def begin(cls):
i2c = I2C(0, scl=Pin(21), sda=Pin(20), freq=200000) # 클래스 메서드의 첫 번째 인자는 항상 cls i2c = I2C(0, scl=Pin(21), sda=Pin(20), freq=200000)
cls.display = SSD1306_I2C(128, 32, i2c)
cls.display.fill(0)
cls.display.show()
@classmethod
def oled_print(cls, msg, msg2=None, msg3=None, msg4=None):
cls.display.fill(0)
cls.display.text(msg, 0, 0, 1) # 첫 번째 메시지를 (0, 0) 좌표에 표시
msg2 and cls.display.text(msg2, 0, 8, 1) # 두 번째 메시지를 (0, 10) 좌표에 표시
msg3 and cls.display.text(msg3, 0, 16, 1) # 세 번째 메시지를 (0, 20) 좌표에 표시
msg4 and cls.display.text(msg4, 0, 24, 1) # 네 번째 메시지를 (0, 30) 좌표에 표시
cls.display.show()
if __name__ == '__main__':
OLED.begin()
OLED.oled_print("Hello", "python~")