Nan xiZhong YuhanYendiLEYI
Published

Restify

A smart tracker that monitors laptop usage, detects activity, and provides break reminders with health tips to reduce burnout.

BeginnerFull instructions provided7 days62
Restify

Things used in this project

Story

Read more

Schematics

Block Diagram ( M5Stack)

Flowchart ( M5Stack)

M5Stack Blockly Code

Circuit Layout

Prototype

Code

M5Stack Code

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

setScreenColor(0x222222)

pir_0 = unit.get(unit.PIR, unit.PORTC)
tof_0 = unit.get(unit.TOF, unit.PORTA)
servo_0 = unit.get(unit.SERVO, unit.PORTB)
rgb_0 = unit.get(unit.RGB, unit.PORTC)

settime = None
timer = None

label1 = M5TextBox(89, 59, "Work time (hr) : ", lcd.FONT_Comic, 0xFFFFFF, rotate=0)
label2 = M5TextBox(50, 210, "1hr", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label3 = M5TextBox(148, 210, "2hr", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label4 = M5TextBox(235, 210, "3hr", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label5 = M5TextBox(165, 112, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)

from numbers import Number

label1.False()
label2.False()
label3.False()
label4.False()
label5.True()

settime = 0
timer = 0

while True:
    if btnA.isPressed():
        settime = 1
    elif btnB.isPressed():
        settime = 2
    elif btnC.isPressed():
    settime = 3

if settime >= 1:
    label5.setText(str(settime))
    label2.True()
    label3.True()
    label4.True()

    while True:
        if (pir_0.state) == 1:
            while True:
                wait(1)
                timer = (timer if isinstance(timer, Number) else 0) + 1

                if (tof_0.distance) < 400:
                    rgb_0.setColorAll(0xff0000)
                    speaker.tone(1800, 200)
                    rgb_0.setColorAll(0x000000)

                if timer == settime * 3600:
                    servo_0.write_angle(45)
                    rgb_0.setColorAll(0x99FF99)
                    wait(1800)
                    servo_0.write_angle(0)
                    rgb_0.setColorAll(0x000000)

                    while True:
                        rgb_0.setColorAll(0xff0000)
                        wait_ms(2)

                     wait_ms(2)
                  wait_ms(2)
                wait_ms(2)

Credits

Nan xi
1 project • 0 followers
Zhong Yuhan
1 project • 0 followers
Yendi
1 project • 0 followers
LEYI
1 project • 0 followers

Comments