Holland app
parent
01d5c2dc5c
commit
61dae74198
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
|
@ -0,0 +1,172 @@
|
||||||
|
"""Camp Holland app
|
||||||
|
"""
|
||||||
|
___name___ = "Holland"
|
||||||
|
___license___ = "MIT"
|
||||||
|
___dependencies___ = ["app", "sim800", "ugfx_helper"]
|
||||||
|
___categories___ = ["Villages"]
|
||||||
|
___bootstrapped___ = True
|
||||||
|
|
||||||
|
from app import *
|
||||||
|
from dialogs import *
|
||||||
|
import ugfx
|
||||||
|
import ugfx_helper
|
||||||
|
|
||||||
|
def show_screen(color1, color2, text, text2=""):
|
||||||
|
ugfx.clear(ugfx.html_color(color1))
|
||||||
|
ugfx.text(0, 100, text, ugfx.html_color(color2))
|
||||||
|
ugfx.text(0, 200, text2, ugfx.html_color(color2))
|
||||||
|
|
||||||
|
def show_vip(inv):
|
||||||
|
if (inv):
|
||||||
|
show_screen(0xFFFFFF, 0xFFA400, "Dutch VIP")
|
||||||
|
else:
|
||||||
|
show_screen(0xFFA400, 0xFFFFFF, "Dutch VIP")
|
||||||
|
|
||||||
|
def show_flag():
|
||||||
|
ugfx.display_image(0, 0, "holland/nederland.png")
|
||||||
|
|
||||||
|
ugfx_helper.init()
|
||||||
|
ugfx.clear()
|
||||||
|
ugfx.set_default_font(ugfx.FONT_NAME)
|
||||||
|
show_vip(False)
|
||||||
|
|
||||||
|
import sim800
|
||||||
|
from tilda import Buttons
|
||||||
|
|
||||||
|
sim800.poweron()
|
||||||
|
|
||||||
|
vip = False
|
||||||
|
vip_inv = False
|
||||||
|
|
||||||
|
def cbButtonA(button_id):
|
||||||
|
global vip
|
||||||
|
vip = False
|
||||||
|
show_flag()
|
||||||
|
|
||||||
|
def cbButtonB(button_id):
|
||||||
|
global vip
|
||||||
|
vip = True
|
||||||
|
show_vip(vip_inv)
|
||||||
|
|
||||||
|
def load():
|
||||||
|
global vip
|
||||||
|
vip = False
|
||||||
|
show_screen(0x000000, 0xFFFFFF, "LOADING")
|
||||||
|
print("Copy AMR")
|
||||||
|
sim800.fscreate("REC\\1.AMR")
|
||||||
|
f = open('holland/wilhelmus.amr', 'r')
|
||||||
|
data = f.read(256)
|
||||||
|
c = len(data)
|
||||||
|
sim800.fswrite("REC\\1.AMR", data, True)
|
||||||
|
pr = c
|
||||||
|
while (c>0):
|
||||||
|
data = f.read(256)
|
||||||
|
c = len(data)
|
||||||
|
sim800.fswrite("REC\\1.AMR", data, False)
|
||||||
|
pr = pr + c
|
||||||
|
show_screen(0x000000, 0xFFFFFF, "LOADING", str(pr))
|
||||||
|
print(str(pr))
|
||||||
|
f.close()
|
||||||
|
show_screen(0x000000, 0xFFFFFF, "DONE")
|
||||||
|
|
||||||
|
|
||||||
|
wilhelmus = (
|
||||||
|
("D", 300), ("G", 300), ("G", 300), ("A", 300), ("B", 300), ("C2", 300), ("A", 300), ("B", 300), ("A", 300), ("B", 300), ("C2", 300), ("B", 300), ("A", 300), ("G", 300), ("A", 600), ("G", 600), ("D", 300),
|
||||||
|
("G", 300), ("G", 300), ("A", 300), ("B", 300), ("C2", 300), ("A", 300), ("B", 300), ("A", 300), ("B", 300), ("C", 300), ("B", 300), ("A", 600), ("G", 600), ("A", 600), ("G", 600), ("B", 300), ("C", 300),
|
||||||
|
)
|
||||||
|
|
||||||
|
freq = {
|
||||||
|
"C": 2616,
|
||||||
|
"D": 2936,
|
||||||
|
"E": 3296,
|
||||||
|
"F": 3492,
|
||||||
|
"G": 3920,
|
||||||
|
"A": 4400,
|
||||||
|
"B": 4938,
|
||||||
|
"C2": 5322,
|
||||||
|
}
|
||||||
|
|
||||||
|
def cbButtonCall(button_id):
|
||||||
|
sim800.speakervolume(100)
|
||||||
|
show_screen(0x000000, 0xFFFFFF, "TONE")
|
||||||
|
for note, length in wilhelmus:
|
||||||
|
sim800.playtone(freq.get(note, 9000), length, False)
|
||||||
|
|
||||||
|
def cbButton1(button_id):
|
||||||
|
global vip
|
||||||
|
vip = False
|
||||||
|
ugfx.display_image(0, 0, "holland/eu.png")
|
||||||
|
|
||||||
|
def cbButton2(button_id):
|
||||||
|
show_screen(0x000000, 0xFFFFFF, "PLAY")
|
||||||
|
a = sim800.startplayback(1,0,100)
|
||||||
|
if not a:
|
||||||
|
sim800.fsrm("REC\\1.AMR")
|
||||||
|
sim800.fsrm("REC\\2.AMR")
|
||||||
|
sim800.fsrm("REC\\3.AMR")
|
||||||
|
load()
|
||||||
|
show_screen(0x000000, 0xFFFFFF, "PLAY")
|
||||||
|
sim800.startplayback(1,0,100)
|
||||||
|
|
||||||
|
def cbButton3(button_id):
|
||||||
|
show_screen(0x000000, 0xFFFFFF, "STOP")
|
||||||
|
sim800.stopplayback()
|
||||||
|
|
||||||
|
def cbButton4(button_id):
|
||||||
|
global vip
|
||||||
|
vip = False
|
||||||
|
ugfx.display_image(0, 0, "holland/otter.png")
|
||||||
|
|
||||||
|
Buttons.enable_interrupt(
|
||||||
|
Buttons.BTN_Call,
|
||||||
|
cbButtonCall,
|
||||||
|
on_press=True,
|
||||||
|
on_release=False);
|
||||||
|
|
||||||
|
Buttons.enable_interrupt(
|
||||||
|
Buttons.BTN_A,
|
||||||
|
cbButtonA,
|
||||||
|
on_press=True,
|
||||||
|
on_release=False);
|
||||||
|
|
||||||
|
Buttons.enable_interrupt(
|
||||||
|
Buttons.BTN_B,
|
||||||
|
cbButtonB,
|
||||||
|
on_press=True,
|
||||||
|
on_release=False);
|
||||||
|
|
||||||
|
Buttons.enable_interrupt(
|
||||||
|
Buttons.BTN_1,
|
||||||
|
cbButton1,
|
||||||
|
on_press=True,
|
||||||
|
on_release=False);
|
||||||
|
|
||||||
|
Buttons.enable_interrupt(
|
||||||
|
Buttons.BTN_2,
|
||||||
|
cbButton2,
|
||||||
|
on_press=True,
|
||||||
|
on_release=False);
|
||||||
|
|
||||||
|
Buttons.enable_interrupt(
|
||||||
|
Buttons.BTN_3,
|
||||||
|
cbButton3,
|
||||||
|
on_press=True,
|
||||||
|
on_release=False);
|
||||||
|
|
||||||
|
Buttons.enable_interrupt(
|
||||||
|
Buttons.BTN_4,
|
||||||
|
cbButton4,
|
||||||
|
on_press=True,
|
||||||
|
on_release=False);
|
||||||
|
|
||||||
|
vip = True
|
||||||
|
|
||||||
|
while True:
|
||||||
|
#sleep_or_exit(0.5)
|
||||||
|
if vip_inv:
|
||||||
|
vip_inv = False
|
||||||
|
else:
|
||||||
|
vip_inv = True
|
||||||
|
if vip:
|
||||||
|
show_vip(vip_inv)
|
||||||
|
pass
|
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 116 KiB |
Binary file not shown.
Loading…
Reference in New Issue