from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit
setScreenColor(0x222222)
pahub_0 = unit.get(unit.PAHUB, unit.PORTA)
rfid_1 = unit.get(unit.RFID, unit.PAHUB1)
tof_0 = unit.get(unit.TOF, unit.PAHUB0)
light_0 = unit.get(unit.LIGHT, unit.PORTB)
people = None
label0 = M5TextBox(260, 58, "Text", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label1 = M5TextBox(19, 123, "Text", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
label2 = M5TextBox(19, 64, "Number of people in store:", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
label3 = M5TextBox(19, 12, "*********************", lcd.FONT_Comic, 0x20c8ea, rotate=0)
label4 = M5TextBox(19, 205, "**********************", lcd.FONT_Comic, 0x20c8ea, rotate=0)
label5 = M5TextBox(19, 151, "Text", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
label6 = M5TextBox(80, 107, "Text", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
# Describe this function...
def labelshow():
global people
label0.setText(str(people))
label1.setText('Store capacity: Normal.')
label5.setText('You may enter now!')
label0.show()
label2.show()
label3.show()
label4.show()
label5.show()
label6.hide()
# Describe this function...
def card():
global people
for count in range(3):
speaker.sing(932, 1)
wait(0.5)
rgb.setColorAll(0xff0000)
wait(0.5)
speaker.sing(932, 1)
wait(0.5)
rgb.setColorAll(0x000000)
wait(0.5)
# Describe this function...
def label_hide():
global people
label0.hide()
label1.hide()
label2.hide()
label3.hide()
label4.hide()
label5.hide()
label6.show()
label6.setText('Robber Alert!!')
people = 0
labelshow()
while True:
if rfid_1.isCardOn():
label_hide()
card()
labelshow()
else:
if (light_0.analogValue) < 500:
people = people + 1
wait(0.5)
label0.setText(str(people))
if (tof_0.distance) < 75:
people = people - 1
wait(0.5)
label0.setText(str(people))
if people >= 5:
label1.setText('Store capacity: Maximum!')
label5.setText('Please wait till someone exits')
rgb.setColorAll(0xff6600)
elif people < 0:
label0.setText(str(0))
else:
label1.setText('Store capacity: Normal. ')
label5.setText('You may enter now!')
rgb.setColorAll(0x33cc00)
wait_ms(2)
Comments