Closed computer-lov closed 2 years ago
Moving to reciew
############### tasks that run in response to stress level ##############
# sends email warning stress levels are high
def notifyStessLevels():
stressHigh.wait()
message = """\
Subject: Stress Level Elevated!
BPM above 110 and SPO2 below 95%."""
# sendEmail(message)
# updates encouriging messages
def updateDisplay():
enableMessages.wait()
while True:
if state:
timeDisplay()
else:
messageDisplay()
# updates breathing
def updateBreathing():
enableBreathing.wait()
while True:
with spiL:
lBar.turnOnLBar()
lBar.breathe_in()
lBar.breathe_out()
# turns on soothing music
def playMusic():
enableMusic.wait()
sd.play()
# stops music, breathing exercise, and ecouraging messages
def haltStressRelief():
disableAll.wait()
sd.stop()
with spiL:
lBar.turnOffLBar()
with i2cL:
oled.turnDisplayOff()
############### tasks that run in response to baby wakeup ##############
# adds to log and sends email when wakeup event occurs
def wakeupEvent():
global log
wakeup.wait()
wakeupTime = datetime.now().strftime("%B %d, %Y %H:%M:%S %p")
log.append(wakeupTime)
message = """\
Subject: Your baby is Awake!
Your baby woke up at approximately """ + wakeupTime + "."
# sendEmail(message)
wakeup.clear()
############### tasks that run in response to stress browser UI ##############
# toggles message and time for display
def changeScreenView():
global state
if state:
state = 0
else:
state = 1
# pauses messages
def pauseMessages():
with i2cL:
oled.turnDisplayOff()
# resumes messages
def resumeMessages():
with i2cL:
oled.turnDisplayOn()
# pauses breathing
def pauseBreathing():
with spiL:
lBar.turnOffLBar()
# resumes breathing
def resumeBreathing():
with spiL:
lBar.turnOnLBar()
# pauses music
def pauseMusic():
sd.pause()
# resumes music
def resumeMusic():
sd.unpause()
# adjusts volume
def adjustVolume(volLevel):
with spiL:
sd.setVol(volLevel)
############### tasks that run in response to physical UI ##############
# updates brightness
def updateBrightness():
with spiL:
phyUI.toggleBrightness()
# updates volume
def updateVolume():
with spiL:
phyUI.toggleVolume()
# send SOS message to parent
def sendSOS():
if phyUI.triggerSOS():
# send email
message = """\
Subject: SOS
In dire need of assistance! Please come help!"""
#sendEmail(message)
# show confirmation on display
confirmMes = "Email sent successfully!"
with i2cL:
oled.clearDisplay()
oled.printMessage(confirmMes)
time.sleep(3) # let it appear on
```screen for 3 seconds