Skip to content

Commit 138f777

Browse files
committed
first commit
1 parent 23d2379 commit 138f777

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

FunHouse_Mailslot/code.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2021 John Park for Adafruit
2+
#
3+
# SPDX-License-Identifier: MIT
4+
# FunHouse Mail Slot Detector
5+
6+
import board
7+
from adafruit_debouncer import Debouncer
8+
from digitalio import DigitalInOut, Pull
9+
from adafruit_funhouse import FunHouse
10+
11+
beam_sense_pin = DigitalInOut(board.A0) # defaults to input
12+
beam_sense_pin.pull = Pull.UP # turn on internal pull-up resistor
13+
beam_sensor = Debouncer(beam_sense_pin)
14+
15+
AMBER = 0xF0D000
16+
BLUE = 0x00D0F0
17+
RED = 0xFF0000
18+
WHITE = 0xFFFFFF
19+
GRAY = 0x606060
20+
21+
funhouse = FunHouse(default_bg=None, scale=3)
22+
funhouse.peripherals.dotstars.brightness = 0.05
23+
funhouse.peripherals.dotstars.fill(AMBER)
24+
25+
# Create the labels
26+
funhouse.display.show(None)
27+
mail_label = funhouse.add_text(
28+
text="No Mail yet", text_position=(4, 14), text_color=AMBER
29+
)
30+
reset_label = funhouse.add_text(text="reset", text_position=(3, 70), text_color=GRAY)
31+
32+
funhouse.display.show(funhouse.splash)
33+
34+
35+
def send_io_data(mail_value):
36+
funhouse.peripherals.led = True
37+
funhouse.network.push_to_io("mail", mail_value)
38+
funhouse.peripherals.led = False
39+
40+
41+
send_io_data(1)
42+
43+
while True:
44+
beam_sensor.update()
45+
46+
if beam_sensor.fell:
47+
funhouse.peripherals.set_dotstars(RED, WHITE, BLUE, WHITE, RED)
48+
funhouse.peripherals.play_tone(2000, 0.25)
49+
funhouse.set_text("Mail is here!", mail_label)
50+
funhouse.set_text_color(BLUE, mail_label)
51+
send_io_data(0)
52+
53+
if funhouse.peripherals.button_down:
54+
funhouse.peripherals.dotstars.fill(AMBER)
55+
funhouse.set_text("No Mail yet", mail_label)
56+
funhouse.set_text_color(AMBER, mail_label)
57+
send_io_data(1)

0 commit comments

Comments
 (0)