from m5stack import *
from m5ui import *
from uiflow import *
import time
import machine
import unit
setScreenColor(0x222222)
servo1 = unit.get(unit.SERVO, unit.PORTB)
env24 = unit.get(unit.ENV2, unit.PAHUB1)
rfid4 = unit.get(unit.RFID, unit.PAHUB2)
pahub4 = unit.get(unit.PAHUB, unit.PORTA)
pir0 = unit.get(unit.PIR, (13, 5))
count = None
Pax = None
X = None
Totalcount = None
A1 = None
PWM0 = machine.PWM(26, freq=50, duty=7, timer=0)
line2 = M5Line(M5Line.PLINE, 160, 40, 160, 200, 0xfe0404)
Cover = M5Img(0, 10, "res/SEAM1.jpg", True)
divider = M5TextBox(65, 99, "/", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
line3 = M5Line(M5Line.PLINE, 0, 200, 320, 200, 0xfe0505)
line4 = M5Line(M5Line.PLINE, 0, 40, 320, 40, 0xf80707)
LabelTemp = M5TextBox(180, 59, "Temperature", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
LabelCheckIn = M5TextBox(15, 58, "Checked In", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
LabelQR = M5TextBox(189, 205, "QR Code", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
Degree = M5Img(261, 142, "res/Temp.jpg", True)
Crowd = M5Img(99, 140, "res/Crowd.jpg", True)
Gear = M5Img(72, 63, "res/Gear.jpg", True)
Header = M5Title(title="Welcome to SEAM", x=3, fgcolor=0xFFFFFF, bgcolor=0xff0000)
up = M5Triangle(65, 205, 50, 234, 80, 234, 0xFFFFFF, 0xFFFFFF)
Down = M5Triangle(160, 235, 140, 205, 175, 205, 0xFFFFFF, 0xFFFFFF)
Enter = M5TextBox(210, 205, "Enter", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
LabelCount = M5TextBox(146, 99, "0", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
Instruction = M5TextBox(0, 20, "Instruction", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
LabelTC = M5TextBox(90, 99, "0", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
LabelPax = M5TextBox(22, 99, "0", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
Temp = M5TextBox(189, 99, "Temp", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
QR = M5Img(200, 81, "res/QR.jpg", True)
speaker.setVolume(0.2)
Header.hide()
Cover.hide()
up.hide()
Down.hide()
Enter.hide()
Cover.show()
rgb.setColor(5, 0x6600cc)
rgb.setColor(6, 0x6600cc)
rgb.setColor(1, 0x000000)
rgb.setColor(2, 0x000000)
rgb.setColor(3, 0x000000)
rgb.setColor(4, 0x000000)
rgb.setColor(7, 0x000000)
rgb.setColor(8, 0x000000)
rgb.setColor(9, 0x000000)
rgb.setColor(10, 0x000000)
wait(0.5)
rgb.setColor(4, 0x6600cc)
rgb.setColor(7, 0x6600cc)
wait(0.5)
rgb.setColor(3, 0x6600cc)
rgb.setColor(8, 0x6600cc)
wait(0.5)
rgb.setColor(2, 0x6600cc)
rgb.setColor(9, 0x6600cc)
wait(0.5)
rgb.setColorAll(0x6600cc)
wait(0.5)
rgb.setColorAll(0x000000)
wait(0.5)
rgb.setColorAll(0x6600cc)
wait(0.5)
rgb.setColorAll(0x000000)
wait(0.5)
rgb.setColorAll(0x6600cc)
wait(1)
rgb.setColorAll(0x000000)
Cover.hide()
speaker.sing(988, 1/2)
speaker.sing(784, 1/2)
Header.show()
up.show()
Down.show()
Enter.show()
count = 0
LabelCount.setText(str(count))
Instruction.setText('Set the No of people:')
Pax = 0
X = 0
while True:
if X == 0:
if btnA.isPressed():
count = count + 1
LabelCount.setText(str(count))
wait(0.5)
elif btnB.isPressed():
count = count - 1
LabelCount.setText(str(count))
if count <= 0:
count = 0
LabelCount.setText(str(count))
wait(0.5)
elif btnC.isPressed():
Totalcount = count
Instruction.setText('The total count allow are')
LabelCount.setText(str(Totalcount))
rgb.setColorAll(0x33cc00)
wait(1)
rgb.setColorAll(0x000000)
wait(0.5)
rgb.setColorAll(0x33cc00)
wait(1)
rgb.setColorAll(0x000000)
speaker.sing(988, 1/2)
speaker.sing(784, 1/2)
X = X + 1
elif X == 1:
if Pax >= Totalcount:
Instruction.setText('Capacity is Full, Please wait.')
LabelPax.setText(str(Pax))
rgb.setColorAll(0xff0000)
wait(0.5)
rgb.setColorAll(0x000000)
wait(0.5)
rgb.setColorAll(0xff0000)
wait(0.5)
rgb.setColorAll(0x000000)
wait(0.5)
rgb.setColorAll(0xff0000)
wait(0.5)
rgb.setColorAll(0x000000)
wait(0.5)
rgb.setColorAll(0xff0000)
wait(0.5)
rgb.setColorAll(0x000000)
wait(0.5)
rgb.setColorAll(0xff0000)
wait(0.5)
rgb.setColorAll(0x000000)
Pax = Pax - 1
elif Pax < Totalcount:
X = X + 1
LabelCount.hide()
Instruction.setText('Adjust the motor')
PWM0.resume()
A1 = 7
LabelTemp.hide()
LabelCheckIn.hide()
line2.hide()
line3.hide()
line4.hide()
LabelPax.hide()
divider.hide()
Crowd.hide()
Degree.hide()
LabelTC.hide()
Temp.hide()
Gear.show()
up.show()
Down.show()
Enter.show()
elif X == 2:
if (btnA.isPressed()) and A1 > 3:
wait_ms(10)
A1 = A1 - 0.1
PWM0.duty(A1)
if A1 <= 3:
up.setBgColor(0x666666)
up.setBorderColor(0xff0000)
wait(1)
up.setBgColor(0xffffff)
up.setBorderColor(0xffffff)
elif (btnB.isPressed()) and A1 < 12:
wait_ms(10)
A1 = A1 + 0.1
PWM0.duty(A1)
if A1 >= 12:
Down.setBgColor(0x666666)
Down.setBorderColor(0xff0000)
wait(1)
Down.setBgColor(0xffffff)
Down.setBorderColor(0xffffff)
elif btnC.isPressed():
Gear.hide()
rgb.setColorAll(0x33cc00)
wait(1)
rgb.setColorAll(0x000000)
wait(0.5)
rgb.setColorAll(0x33cc00)
wait(1)
rgb.setColorAll(0x000000)
speaker.sing(988, 1/2)
speaker.sing(784, 1/2)
PWM0.pause()
up.hide()
Down.hide()
Enter.hide()
LabelTemp.show()
LabelCheckIn.show()
line2.show()
line3.show()
line4.show()
line2.setColor(0xff0000)
line3.setColor(0xff0000)
line4.setColor(0xff0000)
Crowd.show()
Degree.show()
divider.show()
Instruction.setText('Please take your Temperature')
LabelPax.show()
LabelTC.show()
LabelPax.setText(str(Pax))
LabelTC.setText(str(Totalcount))
wait(1)
X = X + 1
elif X == 3:
if (pir0.state) == 1:
if (env24.temperature) >= 37.5:
Instruction.setText('Entry denied.')
Temp.setText(str(env24.temperature))
Temp.setColor(0xff0000)
speaker.sing(220, 1)
rgb.setColorAll(0xff0000)
wait(0.5)
rgb.setColorAll(0x000000)
wait(0.5)
rgb.setColorAll(0xff0000)
wait(0.5)
rgb.setColorAll(0x000000)
wait(0.5)
rgb.setColorAll(0xff0000)
wait(0.5)
rgb.setColorAll(0x000000)
X = 1
LabelQR.hide()
Temp.setColor(0xffffff)
elif (env24.temperature) < 37.5:
LabelQR.show()
wait(0.5)
Instruction.setText('Scanning for Temperature')
wait(0.5)
Temp.setText(str(env24.temperature))
wait(0.5)
Instruction.setText('Check in')
rgb.setColorAll(0x33cc00)
X = X + 1
elif X == 4:
if btnC.isPressed():
Degree.hide()
LabelQR.hide()
LabelTemp.hide()
Temp.hide()
QR.show()
wait(5)
QR.hide()
Pax = Pax + 1
Instruction.setText('Door Open')
wait(2)
Instruction.setText('Door Close')
X = 1
elif rfid4.isCardOn():
Pax = Pax + 1
LabelQR.hide()
Instruction.setText('Door Open')
wait(2)
Instruction.setText('Door Close')
X = 1
wait_ms(2)
Comments