Merge branch 'master' into andrejusk/bday

andrejusk/bday
Andrejus 2018-09-01 17:40:43 +01:00
commit c2a59438a9
6 changed files with 92 additions and 26 deletions

View File

@ -24,7 +24,7 @@ def firmware_update(verbose):
print("3) Your badge is in DFU mode. You can tell by a small, red flashing light at the back")
print("")
print("To put your badge into DFU mode (or if you're unsure whether it really is) you need to")
print("press the joystick to the right while pressing the reset button at the back.")
print("press the joystick centrally down while pressing the reset button at the back.")
print("")
print("After that, please try this script again.")
return

View File

@ -16,6 +16,13 @@ import ugfx
from homescreen import *
import time
# We ❤️ our sponsors
ugfx.display_image(0, 0, "shared/sponsors.png")
wait = 5
while wait:
wait-=1
sleep_or_exit(0.5)
# Padding for name
intro_height = 30
intro_text = "Hi! I'm"
@ -45,8 +52,8 @@ ugfx.orientation(90)
# Logo stuff
ugfx.display_image(
int((ugfx.width() - logo_width) / 2),
int((ugfx.height() - logo_height) / 2),
int((ugfx.width() - logo_width) / 2),
int((ugfx.height() - logo_height) / 2),
logo_path
)
# Draw introduction
@ -57,7 +64,7 @@ name_setting = name("Birthday kid")
if len(name_setting) <= max_name:
ugfx.set_default_font(ugfx.FONT_NAME)
else:
ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
# Draw name
ugfx.Label(0, ugfx.height() - name_height, ugfx.width(), name_height, name_setting, justification=ugfx.Label.CENTER)
@ -67,7 +74,7 @@ ugfx.Label(0, ugfx.height() - name_height, ugfx.width(), name_height, name_setti
ugfx.orientation(270)
# Title
ugfx.set_default_font(ugfx.FONT_TITLE)
ugfx.Label(0, ugfx.height() - info_height * 2, ugfx.width(), info_height, "TiLDA Mk4", justification=ugfx.Label.CENTER)
ugfx.Label(0, ugfx.height() - info_height * 2, ugfx.width(), info_height, "TiLDA Mk4", justification=ugfx.Label.CENTER)
# info
ugfx.Label(0, ugfx.height() - info_height, ugfx.width(), info_height, "Press MENU", justification=ugfx.Label.CENTER)

View File

@ -6,15 +6,17 @@ ___dependencies___ = ["dialogs", "ugfx_helper"]
___categories___ = ["EMF"]
___bootstrapped___ = True
import ugfx, tilda, ugfx_helper, dialogs
import ugfx, tilda, ugfx_helper, dialogs, app, time
ugfx_helper.init()
ugfx.clear()
print("enabling USB storage...")
tilda.storage_enable_usb()
time.sleep(1)
print("DONE")
with dialogs.WaitingMessage(title="Mass Storage Enabled", text="You can now use the badge like a USB key.\nPlease safely eject afterwards. This app will close automatically."):
print("Waiting for USB mass storage to be unmounted...")
tilda.storage_disable_usb()
print("DONE")
app.restart_to_default()

View File

@ -29,7 +29,7 @@ def answercall():
else:
notice("No call to answer.", title="TiLDA Phone")
def handupcall():
def hangupcall():
sim800.hangup()
def playdtmf():
@ -38,37 +38,26 @@ def playdtmf():
while True:
if buttons.is_pressed(buttons.Buttons.BTN_0):
sim800.dtmf("0")
time.sleep(1)
if buttons.is_pressed(buttons.Buttons.BTN_1):
sim800.dtmf("1")
time.sleep(1)
if buttons.is_pressed(buttons.Buttons.BTN_2):
sim800.dtmf("2")
time.sleep(1)
if buttons.is_pressed(buttons.Buttons.BTN_3):
sim800.dtmf("3")
time.sleep(1)
if buttons.is_pressed(buttons.Buttons.BTN_4):
sim800.dtmf("4")
time.sleep(1)
if buttons.is_pressed(buttons.Buttons.BTN_5):
sim800.dtmf("5")
time.sleep(1)
if buttons.is_pressed(buttons.Buttons.BTN_6):
sim800.dtmf("6")
time.sleep(1)
if buttons.is_pressed(buttons.Buttons.BTN_7):
sim800.dtmf("7")
time.sleep(1)
if buttons.is_pressed(buttons.Buttons.BTN_8):
sim800.dtmf("8")
time.sleep(1)
if buttons.is_pressed(buttons.Buttons.BTN_9):
sim800.dtmf("9")
time.sleep(1)
if buttons.is_pressed(buttons.Buttons.BTN_Star):
sim800.dtmf("*")
time.sleep(1)
if buttons.is_pressed(buttons.Buttons.BTN_Hash):
sim800.dtmf("#")
if buttons.is_pressed(buttons.Buttons.BTN_A):
@ -139,12 +128,13 @@ def selectoperator():
for op in sim800.listoperators():
opset.append({ "title" : op[1], "index" : op[3] })
selectedop = prompt_option(opset, text="Operator", select_text="Select", none_text="Cancel")
if selectedop["index"]==-1:
sim800.setoperator(0)
notice("perator selection set to automatic.", title="TiLDA Phone")
else:
sim800.setoperator(1,2,selectedop["index"])
notice(selectedop["title"] + " set as operator.", title="TiLDA Phone")
if selectedop:
if selectedop["index"]==-1:
sim800.setoperator(0)
notice("Operator selection set to automatic.", title="TiLDA Phone")
else:
sim800.setoperator(1,2,selectedop["index"])
notice(selectedop["title"] + " set as operator.", title="TiLDA Phone")
menuset = []
menuset.append({ "title" : "Call", "index" : 1 })

View File

@ -24,8 +24,8 @@ def send_message():
number = ""
message = ""
while True:
num = prompt_text("Number to message:", init_text=number)
if num is None:
number = prompt_text("Number to message:", init_text=number)
if number is None:
return
message = prompt_text("Message:", init_text=message)
if message is not None:

67
sysinfo/main.py Normal file
View File

@ -0,0 +1,67 @@
"""This app tests all the onboard sensors and system info"""
___name___ = "System Info"
___license___ = "MIT"
___dependencies___ = ["sleep", "app", "sim800"]
___categories___ = ["EMF", "System"]
___bootstrapped___ = True
#import ugfx, os, time, sleep, app, sim800
import ugfx, app, sim800
from tilda import Buttons
from tilda import Sensors
from machine import ADC
from time import sleep
mag = ADC(ADC.ADC_HALLEFFECT)
status_height = 20
ugfx.init()
ugfx.clear()
ugfx.set_default_font(ugfx.FONT_FIXED)
simversion = sim800.getfirmwarever()[9:]
simphonenumber = sim800.getmynumber()
simoperator = sim800.currentoperator()
if simphonenumber == None or len(simphonenumber) == 0 :
ugfx.Label(5, 155, 240, 15, "No Number Yet")
else:
ugfx.Label(5, 155, 240, 15, simphonenumber)
if simoperator == None or len(simoperator) == 0 :
ugfx.Label(5, 170, 240, 15, "No Operator Yet")
else:
ugfx.Label(5, 170, 240, 15, "Your network is " + simoperator)
ugfx.Label(5, 185, 240, 15, simversion)
ugfx.Label(5, 300, 240, 15, "** Hold A or B or MENU to exit **")
while (not Buttons.is_pressed(Buttons.BTN_A)) and (not Buttons.is_pressed(Buttons.BTN_B)) and (not Buttons.is_pressed(Buttons.BTN_Menu)):
ugfx.Label(5, 5, 240, 15, "Temperature (tmp) : {:.2f} C".format(Sensors.get_tmp_temperature()))
ugfx.Label(5, 20, 240, 15, "Temperature (hdc) : {:.2f} C".format(Sensors.get_hdc_temperature()))
ugfx.Label(5, 35, 240, 15, "Humidity (hdc) : {:.2f} %".format(Sensors.get_hdc_humidity()))
ugfx.Label(5, 50, 240, 15, "Light (opt) : {:.2f} Lux".format(Sensors.get_lux()))
ugfx.Label(5, 65, 240, 15, "Mag Field: (drv) : {:.2f} ".format(mag.convert()))
ugfx.Label(5, 80, 240, 15, "Sensor samplerate : {} ms".format(Sensors.sample_rate()))
charging = Sensors.get_charge_status()
if charging == Sensors.BAT_PRE_CHARGING or charging == Sensors.BAT_FAST_CHARGING:
ugfx.Label(5, 110, 240, 15, "Battery is : charging")
elif charging == Sensors.BAT_DONE_CHARGING:
ugfx.Label(5, 110, 240, 15, "Battery is : full")
elif charging == Sensors.BAT_NOT_CHARGING:
ugfx.Label(5, 110, 240, 15, "Battery is : discharging")
ugfx.Label(5, 125, 240, 15, "Battery is : {:.2f} %".format(sim800.batterycharge()))
sleep(2)
ugfx.clear()
app.restart_to_default()