From 657e19d23bdd44f07b756a2a9654f0ffcccee0f9 Mon Sep 17 00:00:00 2001 From: bton Date: Fri, 12 Apr 2024 22:01:57 +0200 Subject: [PATCH] display --- NFC_Reader.py | 5 ++++- oled.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NFC_Reader.py b/NFC_Reader.py index e3f366a..54d0f0d 100644 --- a/NFC_Reader.py +++ b/NFC_Reader.py @@ -2,6 +2,8 @@ import time import nfc import subprocess import requests +import asyncio +import oled url="http://172.16.1.105/api/" @@ -19,13 +21,14 @@ def onTagSense(tag): response = requests.post(f"{url}tag_id", data={"id":id}) try: if response.json()["mode"] == "balance" or response.json()["mode"] == "message": + asyncio.run(oled.Balance(response.json()["username"], response.json()["balance"])) return True except: None return False def start_nfc_normal(): - device = get_reader() + device = get_reader()i clf = nfc.ContactlessFrontend(device) clf.open(device) while True: diff --git a/oled.py b/oled.py index 81ba970..a3cd689 100644 --- a/oled.py +++ b/oled.py @@ -1,6 +1,7 @@ from board import SCL, SDA import busio import adafruit_ssd1306 +import time i2c = busio.I2C(SCL, SDA) display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c) @@ -14,6 +15,8 @@ def Balance(user_name, balance): display.text(str(user_name), 50, 0, (255,255,255), size=1) display.text(str(balance), 0, 15, (255,255,255), size=2) display.show() + time.sleep(5) + clear() if __name__ == "__main__": Balance("Test", -255555)