Minghao OngMarcus LimThe XxGamerProxXHeng Yu le
Published

Inventory Stock Management

Assist the workers to manage stocks conveniently, monitor amount of stock and temperature of the stocks

BeginnerShowcase (no instructions)212
Inventory Stock Management

Things used in this project

Story

Read more

Schematics

Foam Board

Overview of our project

Flowchart

ENV II and TOF

Block Diagram

Code Block

TOF , ENV II

Code Block

TOF, ENV II PART 2

RFID CODE BLOCK

Code

TOF ENV II PYTHON CODE

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

setScreenColor(0x222222)
env2_0 = unit.get(unit.ENV2, unit.PAHUB0)
tof_0 = unit.get(unit.TOF, unit.PAHUB1)
pbhub_0 = unit.get(unit.PBHUB, unit.PORTA)


temperature = None
running = None
distance = None



label0 = M5TextBox(180, 8, "Temperature", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(180, 38, "Temperature(D)", lcd.FONT_Default, 0xFFFFFF, rotate=0)
image0 = M5Img(217, 146, "res/error.jpg", True)
label2 = M5TextBox(180, 71, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label3 = M5TextBox(10, 8, "Current Temperature:", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label4 = M5TextBox(4, 38, "Desired Temperature: ", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label5 = M5TextBox(63, 71, "Stock level:", lcd.FONT_Default, 0xFFFFFF, rotate=0)

from numbers import Number



def buttonC_wasPressed():
  global temperature, running, distance
  temperature = (temperature if isinstance(temperature, Number) else 0) + 1
  label1.setText(str(temperature))
  pass
btnC.wasPressed(buttonC_wasPressed)

def buttonC_wasDoublePress():
  global temperature, running, distance
  temperature = (temperature if isinstance(temperature, Number) else 0) + -1
  label1.setText(str(temperature))
  pass
btnC.wasDoublePress(buttonC_wasDoublePress)


temperature = 23
label0.setText(str(env2_0.temperature))
label1.setText(str(temperature))
while True:
  image0.hide()
  if btnA.isPressed():
    running = True
    while running == True:
      image0.hide()
      distance = int(((tof_0.distance) / 10))
      if distance >= 32:
        image0.show()
        rgb.setColorAll(0x33cc00)
        speaker.tone(1800, 1000)
        label2.setText('Please Restock')
        wait(2)
        rgb.setColorAll(0x3333ff)
      elif distance >= 24:
        label2.setText('Stock is 40% full')
        rgb.setColorAll(0x33cc00)
      elif distance >= 14:
        label2.setText('Stock is 60% full')
        rgb.setColorAll(0xcc33cc)
      elif distance >= 8:
        label2.setText('Stock is 80% full')
        rgb.setColorAll(0x000099)
      elif distance >= 4:
        label2.setText('Stock is 100% full')
        rgb.setColorAll(0xffff66)
      if btnB.isPressed():
        running = False
  rgb.setColorAll(0x000000)
  wait(0.75)
  rgb.setColorAll(0x663333)
  if temperature > (env2_0.temperature) + 1:
    while temperature > (env2_0.temperature) + 1:
      speaker.tone(800, 200)
      rgb.setColorAll(0xff0000)
      wait_ms(500)
      rgb.setColorAll(0x000000)
      wait_ms(500)
  elif temperature < (env2_0.temperature) - 1:
    while temperature < (env2_0.temperature) - 1:
      speaker.tone(800, 200)
      rgb.setColorAll(0xff0000)
      wait_ms(500)
      rgb.setColorAll(0x000000)
      wait_ms(500)
  wait_ms(2)

RFID PYTHON CODE

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

setScreenColor(0x222222)
rfid_0 = unit.get(unit.RFID, unit.PORTA)


card1 = None



label0 = M5TextBox(114, 72, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(114, 133, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)




card1 = '0'
while True:
  if rfid_0.isCardOn():
    if card1 == (rfid_0.readUid()):
      label0.setText('Check-out')
      label1.setText(str(rfid_0.readUid()))
      card1 = '0'
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 400)
      wait(2)
    else:
      card1 = rfid_0.readUid()
      label0.setText('Check-in')
      label1.setText(str(rfid_0.readUid()))
      rgb.setColorAll(0x33ff33)
      speaker.tone(1600, 200)
      wait(2)
  else:
    label0.setText('Scanning...')
    label1.setText('UID:-')
    rgb.setColorAll(0x000000)
  wait_ms(2)

Credits

Minghao Ong
1 project • 1 follower
Contact
Marcus Lim
0 projects • 1 follower
Contact
The XxGamerProxX
0 projects • 0 followers
Contact
Heng Yu le
0 projects • 1 follower
Contact

Comments

Please log in or sign up to comment.