matekasse_NFC-Reader/oled.py

28 lines
649 B
Python
Raw Normal View History

2024-04-12 19:32:20 +00:00
from board import SCL, SDA
2024-04-12 19:20:15 +00:00
import busio
import adafruit_ssd1306
2024-04-12 20:01:57 +00:00
import time
2024-04-12 19:20:15 +00:00
i2c = busio.I2C(SCL, SDA)
2024-04-12 19:34:37 +00:00
display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
2024-04-12 19:20:15 +00:00
2024-04-12 19:44:03 +00:00
def clear():
display.fill(0)
display.show()
2024-04-12 19:20:15 +00:00
2024-04-17 18:17:13 +00:00
async def balance(user_name, balance):
2024-04-17 18:01:14 +00:00
clear()
2024-04-12 19:44:03 +00:00
display.text(str(user_name), 50, 0, (255,255,255), size=1)
2024-04-12 19:55:48 +00:00
display.text(str(balance), 0, 15, (255,255,255), size=2)
2024-04-12 19:45:14 +00:00
display.show()
2024-04-17 18:17:13 +00:00
await time.sleep(5)
2024-04-17 18:01:14 +00:00
clear()
2024-04-12 19:20:15 +00:00
2024-04-17 17:46:43 +00:00
def error(code):
2024-04-17 17:03:48 +00:00
clear()
display.text("!!!!ERROR!!!!", 50, 0 (255,255,255), size=2)
display.text(str(code), 50, 10, (255,255,255), size=2)
2024-04-12 19:44:03 +00:00
if __name__ == "__main__":
2024-04-12 19:57:22 +00:00
Balance("Test", -255555)