Jitbao ChauLutfilJoe Tanjed cael
Published © LGPL

C9_Egc177_jitbao_joe_hadi__mariaJED

Using retail solutions to counter climate change.

IntermediateFull instructions provided15 hours67
C9_Egc177_jitbao_joe_hadi__mariaJED

Things used in this project

Story

Read more

Schematics

Main M5stack Project Flowchart

Secondary M5Stack Project Flowchart

Code

Main M5Stack PythonCode

Python
from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit

setScreenColor(0x222222)
rfid_1 = unit.get(unit.RFID, unit.PAHUB5)
pahub_5 = unit.get(unit.PAHUB, unit.PORTA)
env2_3 = unit.get(unit.ENV2, unit.PAHUB0)


countwhite = None
countpurple = None
countblack = None



label2 = M5TextBox(20, 94, "Number Of items", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label3 = M5TextBox(5, 138, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
scan = M5TextBox(20, 15, "Scan Item", lcd.FONT_Default, 0xfbf5f5, rotate=0)
ID = M5TextBox(20, 58, "ID", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label0 = M5TextBox(237, 77, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(7, 164, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
image0 = M5Img(200, 122, "res/default.jpg", True)

from numbers import Number



def multiBtnCb_AB():
  global countwhite, countpurple, countblack
  countwhite = 0
  countpurple = 0
  countblack = 0
  pass
btn.multiBtnCb(btnA,btnB,multiBtnCb_AB)

def buttonA_wasPressed():
  global countwhite, countpurple, countblack
  label3.setText(str(countwhite))
  if countwhite < 10:
    label1.setText('Restock White')
  else:
    label1.setText('Sufficient Stock')
  pass
btnA.wasPressed(buttonA_wasPressed)

def buttonB_wasPressed():
  global countwhite, countpurple, countblack
  label3.setText(str(countpurple))
  if countpurple < 10:
    label1.setText('Restock purple')
  else:
    label1.setText('Sufficient Stock')
  pass
btnB.wasPressed(buttonB_wasPressed)

def buttonC_wasPressed():
  global countwhite, countpurple, countblack
  label3.setText(str(countblack))
  if countblack < 10:
    label1.setText('Restock Black')
  else:
    label1.setText('Sufficient Stock')
  pass
btnC.wasPressed(buttonC_wasPressed)


countwhite = 0
countpurple = 0
countblack = 0
while True:
  if rfid_1.isCardOn():
    rgb.setColorFrom(6 , 10 ,0xff0000)
    wait(1)
    if (rfid_1.readUid()) == 'c4385d2a8b':
      countwhite = (countwhite if isinstance(countwhite, Number) else 0) + 1
      label2.setText(str(countwhite))
      scan.setText('White Shirt')
      ID.setText(str(rfid_1.readUid()))
      speaker.tone(1800, 200)
      wait(0.25)
    elif (rfid_1.readUid()) == 'f45f941926':
      countpurple = (countpurple if isinstance(countpurple, Number) else 0) + 1
      label2.setText(str(countpurple))
      scan.setText('Purple Shirt')
      ID.setText(str(rfid_1.readUid()))
      speaker.tone(1800, 200)
      wait(0.25)
    elif (rfid_1.readUid()) == '64dc412ad3':
      countblack = (countblack if isinstance(countblack, Number) else 0) + 1
      label2.setText(str(countblack))
      scan.setText('Black Shirt')
      ID.setText(str(rfid_1.readUid()))
      speaker.tone(1800, 200)
      wait(0.25)
  elif (env2_3.temperature) < 24:
    label0.setText(str(env2_3.temperature))
    for count in range(1):
      rgb.setColorAll(0x66ffff)
      image0.changeImg("res/default.jpg")
      speaker.tone(1800, 100)
      wait(0.3)
      rgb.setColorAll(0x000000)
      speaker.tone(1800, 100)
      speaker.setVolume(0.5)
      wait(0.15)
  elif (env2_3.temperature) >= 25:
    image0.changeImg("res/default.jpg")
    label0.setText(str(env2_3.temperature))
    label1.setText('Optimal Temperature')
  else:
    scan.setText('Scan')
  wait_ms(2)

Secondary M5Stack Code Python

Python
from m5stack import *
from m5ui import *
from uiflow import *
import unit

setScreenColor(0x222222)
pir_3 = unit.get(unit.PIR, unit.PORTA)
rgb_3 = unit.get(unit.RGB, unit.PORTB)






image0 = M5Img(45, 0, "res/default.jpg", True)
label2 = M5TextBox(47, 224, "Thank You For Shopping With Us", lcd.FONT_Default, 0xFFFFFF, rotate=0)


image0.hide()
while True:
  if (pir_3.state) == 1:
    rgb_3.setColorAll(0xffff99)
    rgb_3.setBrightness(80)
    image0.changeImg("res/R.png")
  else:
    image0.changeImg("res/R.png")
    rgb_3.setColorAll(0x000000)
    rgb_3.setBrightness(1)
  wait_ms(2)

Credits

Jitbao Chau
1 project • 0 followers
Lutfil
1 project • 0 followers
Joe Tan
1 project • 0 followers
jed cael
2 projects • 0 followers

Comments