-
Notifications
You must be signed in to change notification settings - Fork 0
/
charge.py
38 lines (33 loc) · 1.05 KB
/
charge.py
1
2
3
4
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
import screen
import eventreader
import vcs
import time
from eventreader import Buttons
import bus
from rfid import writeBlock, readBlock, readValue, initValue, incValue, decValue, readCardID, sleepCard, readSector, writeSector
import rfid
STATUS_OK = 1
STATUS_NOOFFTAG = 2
STATUS_TRANSPORT = 4
STATUS_GETOFF = 8
def chargeProcess(busNo, stationID, stationName):
vcs.write(35, 20, "Please tag your bus card!")
while True:
if(bus.isTagged()[0] == STATUS_OK):
Money = rfid.readValue(bus.BLOCK_MONEY)[1]
screen.chargeScreen(Money)
while True:
eventreader.updateButtonState()
amount = 0
if(eventreader.isButtonDown(Buttons.HOME)): amount = 1000
elif(eventreader.isButtonDown(Buttons.ENTER)): amount = 5000
elif(eventreader.isButtonDown(Buttons.MENU)): amount = 10000
elif(eventreader.isButtonDown(Buttons.BACK)):amount = 20000
else:
time.sleep(0.1)
continue
bus.topUp(amount, stationID)
[res,Money] = rfid.readValue(bus.BLOCK_MONEY)
time.sleep(3)
screen.runScreen(stationName, busNo)
return res