display in NFC_Reader

This commit is contained in:
bton 2024-04-17 19:46:43 +02:00
parent c2d6110576
commit f223be9209
2 changed files with 4 additions and 4 deletions

View file

@ -3,7 +3,7 @@ import nfc
import subprocess import subprocess
import requests import requests
import oled import oled
from threading import Thread import subprocess
url="http://172.16.1.105/api/" url="http://172.16.1.105/api/"
@ -21,7 +21,7 @@ def onTagSense(tag):
response = requests.post(f"{url}tag_id", data={"id":id}) response = requests.post(f"{url}tag_id", data={"id":id})
try: try:
if response.json()["mode"] == "balance" or response.json()["mode"] == "message": if response.json()["mode"] == "balance" or response.json()["mode"] == "message":
# subprocess? Thread(target=oled.Balance, args=(response.json()["username"], response.json()["balance"])).run() subprocess.run(oled.balance(response.json()["user"], responese.json()["balance"]))
return True return True
except: except:
None None

View file

@ -10,7 +10,7 @@ def clear():
display.fill(0) display.fill(0)
display.show() display.show()
async def Balance(user_name, balance): async def balance(user_name, balance):
await clear() await clear()
display.text(str(user_name), 50, 0, (255,255,255), size=1) display.text(str(user_name), 50, 0, (255,255,255), size=1)
display.text(str(balance), 0, 15, (255,255,255), size=2) display.text(str(balance), 0, 15, (255,255,255), size=2)
@ -18,7 +18,7 @@ async def Balance(user_name, balance):
await time.sleep(5) await time.sleep(5)
await clear() await clear()
def Error(code): def error(code):
clear() clear()
display.text("!!!!ERROR!!!!", 50, 0 (255,255,255), size=2) display.text("!!!!ERROR!!!!", 50, 0 (255,255,255), size=2)
display.text(str(code), 50, 10, (255,255,255), size=2) display.text(str(code), 50, 10, (255,255,255), size=2)