Beispiel #1
0
def download_avatar():
    avatar_url = db.get("avatar_url", "")
    if avatar_url:
        if (avatar_url.endswith(".png") or avatar_url.startswith("http")):
            try:
                image = http.get(avatar_url).raise_for_status().content
                ugfx.orientation(90)
                ugfx.display_image(0, 0, bytearray(image))
                #f = open(avatar_file_name, 'w')
                #f.write(image)
                #f.close()
                #ugfx.display_image(0,0,bytearray(image))
            except:
                ugfx.clear(ugfx.html_color(0x000000))
                ugfx.orientation(270)
                ugfx.text(3, 65, "Couldn't download the avatar.", ugfx.RED)
                return False
        else:
            ugfx.clear(ugfx.html_color(0x000000))
            ugfx.orientation(270)
            ugfx.text(3, 65, "Invalid avatar url.", ugfx.RED)
            return False
    else:
        ugfx.clear(ugfx.html_color(0x000000))
        ugfx.orientation(270)
        ugfx.text(3, 65, "No avatar url.", ugfx.RED)
    return True
Beispiel #2
0
    def setup_screen(self):
        """ Set up the screen and the labels that display
            values on it. 
        """
        ugfx.init()
        width=ugfx.width()
        height=ugfx.height()
        ugfx.clear(ugfx.html_color(0x800080))
        style = ugfx.Style()
        style.set_enabled([ugfx.WHITE, ugfx.html_color(0x800080), ugfx.html_color(0x800080), ugfx.html_color(0x800080)])
        style.set_background(ugfx.html_color(0x800080))
        ugfx.set_default_style(style)
        ugfx.orientation(90)
        ugfx.set_default_font(ugfx.FONT_TITLE)
        ugfx.Label(0, 0, width, 60,"Air Quality", justification=ugfx.Label.CENTER)
        label_height=45
        self.ppm10_label = ugfx.Label(0, label_height, width, label_height,"PPM 10: starting", justification=ugfx.Label.CENTER)
        self.ppm25_label = ugfx.Label(0, label_height*2, width, label_height,"PPM 2.5: starting", justification=ugfx.Label.CENTER)

        self.temp_label = ugfx.Label(0, label_height*3, width, label_height,"Temp: starting", justification=ugfx.Label.CENTER)
        self.humid_label = ugfx.Label(0, label_height*4, width, label_height,"Humid: starting", justification=ugfx.Label.CENTER)
        self.error_label = ugfx.Label(0, label_height*5, width, label_height,"", justification=ugfx.Label.CENTER)
        self.message_label = ugfx.Label(0, label_height*6, width, label_height,"", justification=ugfx.Label.CENTER)
        self.error_count = 0
        self.error_message = ""
        self.neopix = Neopix()
        self.p10_decode = ((100,0x00ff00),(250,0xffff00),(350,0xff8000),(430,0xff0000),(-1,0xcc6600))
        self.p25_decode = ((60, 0x00ff00),(91, 0xffff00), (121,0xff8000),(251,0xff0000),(-1,0xcc6600))
Beispiel #3
0
    def __init__(self, config):

        # Get the config
        self.__debug = config.get('debug')

        # Configure the style and layout
        ugfx.set_default_font(ugfx.FONT_MEDIUM)
        ugfx.set_default_style(dialogs.default_style_badge)
        self.__sty_tb = ugfx.Style(dialogs.default_style_badge)
        self.__sty_tb.set_enabled([
            ugfx.WHITE,
            ugfx.html_color(0xA66FB0),
            ugfx.html_color(0x5e5e5e), ugfx.RED
        ])
        self.__sty_tb.set_background(ugfx.GREY)
        self.__win_bv = ugfx.Container(0, 0, 80, 25, style=self.__sty_tb)
        self.__win_wifi = ugfx.Container(82, 0, 60, 25, style=self.__sty_tb)
        self.__win_clock = ugfx.Container(250, 0, 70, 25, style=self.__sty_tb)
        self.__win_wifi.show()
        self.__win_bv.show()
        self.__win_clock.show()

        # Init var for last RSSI
        self.__last_rssi = 0

        # Schedule next status update
        self.__next_status_update = pyb.millis() + 500
Beispiel #4
0
def draw_badge():
	style.set_enabled([ugfx.WHITE, ugfx.html_color(0x800080), ugfx.html_color(0x800080), ugfx.html_color(0x800080)])
	style.set_background(ugfx.html_color(0x800080))
	ugfx.clear(ugfx.html_color(0x800080))
	ugfx.set_default_style(style)
	# Logo stuff
	ugfx.display_image(
		int((ugfx.width() - logo_width) / 2),
		int((ugfx.height() - logo_height) / 2),
		logo_path
	)

	# Draw for people to see
	ugfx.orientation(90)
	# Draw introduction
	ugfx.set_default_font(ugfx.FONT_TITLE)
	ugfx.Label(0, ugfx.height() - name_height - intro_height, ugfx.width(), intro_height, intro_text, justification=ugfx.Label.CENTER)
	# Process name
	name_setting = name("Set your name in the settings app")
	if len(name_setting) <= max_name:
		ugfx.set_default_font(ugfx.FONT_NAME)
	else:
		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)

	# Draw for wearer to see
	ugfx.orientation(270)
	ugfx.set_default_font(ugfx.FONT_SMALL)
	status = ugfx.Label(0, ugfx.height() - status_height, ugfx.width(), status_height, "", justification=ugfx.Label.LEFT)
Beispiel #5
0
def show_screen(color1, color2, text, text2="", flip=False):
    if flip:
        ugfx.orientation(90)
    ugfx.clear(ugfx.html_color(color1))
    ugfx.set_default_font(ugfx.FONT_NAME)
    ugfx.text(0, 100, text, ugfx.html_color(color2))
    ugfx.set_default_font(ugfx.FONT_SMALL)
    ugfx.text(0, 200, text2, ugfx.html_color(color2))
    if flip:
        ugfx.orientation(270)
Beispiel #6
0
def top_left_logo():
    ugfx.clear(ugfx.html_color(0x000000))
    try:
        logo = http.get("https://i.imgur.com/5HXmXBU.png").raise_for_status().content
        ugfx.display_image(0, 5, bytearray(logo))
    except:
        pass
def drawui():
    ugfx.init()
    buttons.init()
    ugfx.clear(ugfx.html_color(0x87F717))

    ugfx.set_default_font(ugfx.FONT_MEDIUM)

    ugfx.fill_circle(50,50, 20, ugfx.WHITE)
    ugfx.fill_circle(50, 100, 20, ugfx.WHITE)

    ugfx.text(45, 45, "A", ugfx.RED)
    ugfx.text(45, 95, "B", ugfx.RED)

    ugfx.text(95, 45, "Flash the lights", ugfx.WHITE)
    ugfx.text(95, 95, "Disco Inferno", ugfx.WHITE)

    ugfx.fill_polygon(270,50, [ [0,0], [40,0], [40, 175], [0, 175] ], ugfx.RED)#  , [230, 100], [230, 60]
    ugfx.fill_polygon(270,50, [ [0,0], [-20,10], [-20, 50], [0, 40] ], ugfx.RED)#  , [230, 100], [230, 60]

    ugfx.area(283, 61, 14, 10, ugfx.WHITE)
    ugfx.area(283, 79, 14, 10, ugfx.WHITE)
    ugfx.area(283, 97, 14, 10, ugfx.WHITE)
    ugfx.area(283, 115, 14, 10, ugfx.WHITE)
    ugfx.area(283, 133, 14, 10, ugfx.WHITE)
    ugfx.area(283, 151, 14, 10, ugfx.WHITE)
    ugfx.area(283, 169, 14, 10, ugfx.WHITE)
    ugfx.area(283, 187, 14, 10, ugfx.WHITE)
Beispiel #8
0
def render_ui():
    ugfx.clear(ugfx.html_color(0xffffff))
    # draw squares
    current_row = int(
        (time.ticks_ms() - start_time) / time_per_row) % total_rows

    for row in range(total_rows):
        for col in range(total_cols):
            colour = inactive_colour
            if active and row == current_row:
                if active_states[row][col] == True:
                    colour = current_active_colour
                else:
                    colour = current_inactive_colour
            elif active_states[row][col] == True:
                colour = active_colour

            ugfx.area(col_width * col + line_width,
                      row_height * row + line_width, col_width - line_width,
                      row_height - line_width, colour)

    # highlight working area
    ugfx.area(active_h_block * block_width, active_v_block * block_height,
              line_width, block_height, ugfx.RED)
    ugfx.area((active_h_block + 1) * block_width,
              active_v_block * block_height, line_width, block_height,
              ugfx.RED)
    ugfx.area(active_h_block * block_width, active_v_block * block_height,
              block_width, line_width, ugfx.RED)
    ugfx.area(active_h_block * block_width,
              (active_v_block + 1) * block_height, block_width + line_width,
              line_width, ugfx.RED)
Beispiel #9
0
def a_was_pushed():
    ugfx.clear(ugfx.html_color(0x000000))
    ugfx.orientation(270)
    ugfx.text(5,5, "You pressed A", ugfx.WHITE)
    ugfx.text(5,45, "Press MENU to exit", ugfx.WHITE)
    while True:
        if buttons.is_triggered(Buttons.BTN_Menu):
            break
Beispiel #10
0
def nick_screen(container_handle):
    if not container_handle:
        container_handle = ugfx.Container(0, 0, 320, 240)
    container_handle.area(0, 0, 320, 240, ugfx.html_color(pyb.rng()%0xffffff))
    ugfx.display_image(0, 0, "apps/sponsors/splash3.gif")

    container_handle.show()
    return container_handle
Beispiel #11
0
def dash():
    if AF:
        ch1 = t4.channel(1, pyb.Timer.PWM, pin=pyb.Pin("BUZZ"), pulse_width=(t4.period() + 1) // 2)
    ugfx.area(25,75,270,90,ugfx.BLACK)
    pyb.delay(SIGN_SCALING*DASH)
    if AF:
        pyb.Pin("BUZZ",pyb.Pin.OUT).low()
    ugfx.area(0,0,320,240,ugfx.html_color(0x00FF00))
    pyb.delay(SIGN_SCALING*PAUSE_ELEMENT)
Beispiel #12
0
def draw_flag(colours):
    # Orientation for other people to see
    ugfx.orientation(90)

    # Draw each "band" of colour in the flag
    colour_width = ugfx.width() / len(colours)
    for num, colour in enumerate(colours):
        width_loc = int(num * colour_width)
        flag_height = ugfx.height() - (name_height + info_height)
        ugfx.area(width_loc, info_height, int(colour_width), flag_height,
                  ugfx.html_color(colour))
Beispiel #13
0
def sendReq(btnNum):
	ugfx.clear(ugfx.html_color(0x002e5c))
	ugfx.text(1, 10, "You pressed " + str(btnNum), ugfx.WHITE)
	#neo.display(0x888888)
	time.sleep(0.2)
	with http.get('http://'+URL, urlencoded=params+str(btnNum)) as resp:
		if resp.text == "OK": 
			#neo.display(0x008800)
			ugfx.text(1, 30, "Sent OK", ugfx.WHITE)
		else: 
			#neo.display(0x880000)
			ugfx.text(1, 30, "Bad Response:" + resp.text, ugfx.WHITE)
Beispiel #14
0
def init():
    # Background stuff
    ugfx_helper.init()
    ugfx.clear(ugfx.WHITE)

    # Colour stuff
    color = ugfx.html_color(333333)
    style = ugfx.Style()
    # [text_colour, edge_colour, fill_colour, progress_colour]
    style.set_enabled([color, color, ugfx.WHITE, ugfx.GREY])
    style.set_background(ugfx.WHITE)
    ugfx.set_default_style(style)
Beispiel #15
0
def next_person(my_profile):
    ugfx.clear(ugfx.html_color(0x000000))
    ugfx.text(5, 100, "Loading...", ugfx.WHITE)
    try:
        resp = http.get(api_url+'/get_user/'+my_profile['unique_identifier']).json()
    except:
        ugfx.clear()
        ugfx.text(5, 100, "Error. Try again later. :(", ugfx.BLACK)
        return

    if resp['success']:
        display_person(resp['value'])
    else:
        no_more(my_profile)
Beispiel #16
0
def render_splash_screen():
    ugfx.clear(ugfx.html_color(0x000000))
    try:
        logo = http.get("https://i.imgur.com/0TjxEPs.png").raise_for_status().content
        ugfx.display_image(
            int((ugfx.width() - 164)/2),
            20,
            bytearray(logo))
    except:
        pass

    ugfx.text(160, 100, "TILDR", ugfx.WHITE)
    ugfx.text(0, 270, "Find your match @emfcamp ;)", ugfx.WHITE)
    ugfx.text(45, 300, "Press A to begin", ugfx.WHITE)
Beispiel #17
0
def load_avatar():
    #Load the avatar from the local storage
    try:
        f = open(avatar_file_name, 'r')
        avatar_file = f.read()
        ugfx.orientation(90)
        ugfx.display_image(0, 0, bytearray(avatar_file))
        f.close()
        return True
    except:
        ugfx.clear(ugfx.html_color(0x000000))
        ugfx.orientation(270)
        ugfx.text(3, 65, "No local avatar.", ugfx.RED)
        return False
Beispiel #18
0
    def display_idle(self, lh_call="", lh_name=""):

        if self.__debug:
            print("emf_hub_mon: Drawing Idle Screen")

        self.__pending_idle = False

        ugfx.backlight(40)
        self.draw_background(ugfx.html_color(0xf7f4f4))
        ugfx.set_default_font(ugfx.FONT_TITLE)

        self.__text_centre("IDLE", ugfx.FONT_TITLE, ugfx.GREY, 120)
        self.__display_lh(lh_call, lh_name)
        self.__led.off()
Beispiel #19
0
    def tx(self, call, name):

        if self.__debug:
            print("emf_hub_mon: Drawing the Tx display")

        ugfx.backlight(100)

        self.draw_background(ugfx.html_color(0xaefcbd))

        ugfx.set_default_font(ugfx.FONT_TITLE)

        self.__text_centre(call, ugfx.FONT_TITLE, ugfx.BLACK, 110)
        self.__text_centre(name, ugfx.FONT_MEDIUM_BOLD, ugfx.BLACK, 140)

        self.__led.on()
Beispiel #20
0
def show_threads():
    ugfx.clear(ugfx.html_color(colour_black))
    threads = http.get(api_url + "/threads").raise_for_status().content
    threads = [{
        "title": thread.title,
        "threadID": thread.id
    } for thread in threads]
    thread = prompt_option(threads,
                           none_text="Create new thread",
                           text="Select a thread to view or create.")

    if thread == -1:
        create_thread()
    else:
        show_thread(thread)
Beispiel #21
0
def showPage():
    global current_page
    # avoid out of bounds errors
    current_page = max(1, min(current_page, total_pages))
    
    start = (current_page - 1) * APPS_PER_PAGE
    end = start + APPS_PER_PAGE
    apps_on_current_page = all_apps[start:end]

    # Refresh page
    ugfx.clear(ugfx.html_color(EMF_PURPLE))

    # Write current page number and arrows
    ugfx.Label(0, 20, ugfx.width(), 20, "Page {} of {}".format(current_page, total_pages), justification=ugfx.Label.CENTER)

    if current_page > 1:
        ugfx.fill_polygon(10, 16, [[0, 10], [15, 20], [15, 0]], ugfx.WHITE)
        
    if current_page < total_pages:
        ugfx.fill_polygon(ugfx.width() - 30, 16, [[0, 0], [15, 10], [0, 20]], ugfx.WHITE)
    
    # Write app numbers and names
    i = 0
    yOffset = 45
    xOffset = 0
    for a in apps_on_current_page:
        # xOffset = (i % 3) * 8  # offset lines to match the physical layout of the keypad
        ugfx.area(20 + xOffset, yOffset + 2, 20, 20, ugfx.WHITE)
        ugfx.text(23 + xOffset, yOffset + 3, keypadLabels[i] + " ", EMF_PURPLE)

        ugfx.Label(46 + xOffset, yOffset + 3, ugfx.width(), 20, a['title'], justification=ugfx.Label.LEFT)
        yOffset = yOffset + 22
        i = i + 1

    while True:
        for key in keypad:
            keyIndex = keypad.index(key)
            if buttons.is_pressed(key) and (keyIndex < len(apps_on_current_page)):
                apps_on_current_page[keyIndex]['app'].boot()
                break

        if buttons.is_triggered(Buttons.JOY_Right) and (current_page is not total_pages):
            current_page = current_page + 1
            return
        if buttons.is_triggered(Buttons.JOY_Left) and (current_page is not 1):
            current_page = current_page - 1
            return
Beispiel #22
0
    def __draw_wifi(self, back_colour, rssi, connected, connecting, win_wifi):
        x = int((rssi + 100) / 14)
        x = min(5, x)
        x = max(1, x)
        y = x * 4
        x = x * 5

        outline = [[0, 20], [25, 20], [25, 0]]
        outline_rssi = [[0, 20], [x, 20], [x, 20 - y]]

        if connected:
            win_wifi.fill_polygon(0, 0, outline, ugfx.html_color(0xC4C4C4))
            win_wifi.fill_polygon(0, 0, outline_rssi, ugfx.WHITE)
        elif connecting:
            win_wifi.fill_polygon(0, 0, outline, ugfx.YELLOW)
        else:
            win_wifi.fill_polygon(0, 0, outline, ugfx.RED)
Beispiel #23
0
def draw_trans():
	style.set_enabled([ugfx.BLACK, ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc)])
	style.set_background(ugfx.html_color(0x55cdfc))
	ugfx.set_default_style(style)
	ugfx.display_image(0, 0, "home_trans/trans.png")

	# Logo stuff
	ugfx.display_image(
	    int((ugfx.width() - logo_width) / 2),
	    int((ugfx.height() - logo_height) / 2)+9,
	    trans_logo_path
	)

	# Draw for people to see
	ugfx.orientation(90)
	# Draw introduction
	style.set_enabled([ugfx.BLACK, ugfx.html_color(0xf8b0be), ugfx.html_color(0xf8b0be), ugfx.html_color(0xf8b0be)])
	style.set_background(ugfx.html_color(0xf8b0be))
	ugfx.set_default_style(style)
	ugfx.set_default_font(ugfx.FONT_TITLE)
	ugfx.Label(0, ugfx.height() - name_height - intro_height, ugfx.width(), intro_height, intro_text, justification=ugfx.Label.CENTER)
	# Prepare to draw name
	style.set_enabled([ugfx.BLACK, ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc), ugfx.html_color(0x55cdfc)])
	style.set_background(ugfx.html_color(0x55cdfc))
	ugfx.set_default_style(style)
	# Process name
	name_setting = name("Set your name in the settings app")
	if len(name_setting) <= max_name:
		ugfx.set_default_font(ugfx.FONT_NAME)
	else:
		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)

	# Draw for wearer to see
	ugfx.orientation(270)
	ugfx.set_default_font(ugfx.FONT_SMALL)
	status = ugfx.Label(0, ugfx.height() - status_height, ugfx.width(), status_height, "", justification=ugfx.Label.LEFT)
Beispiel #24
0
def draw_wifi(back_colour, rssi, connected, connecting, win_wifi):

	x = int((rssi+100)/14)
	x = min(5,x)
	x = max(1,x)
	y = x*4
	x = x*5

	outline      = [[0,20],[25,20],[25,0]]
	outline_rssi = [[0,20],[x,20],[x,20-y]]

	#win_wifi.fill_polygon(0, 0, outline, back_colour^0xFFFF)

	if connected:
		win_wifi.fill_polygon(0, 0, outline, ugfx.html_color(0xC4C4C4))
		win_wifi.fill_polygon(0, 0, outline_rssi, ugfx.WHITE)
	elif connecting:
		win_wifi.fill_polygon(0, 0, outline, ugfx.YELLOW)
	else:
		win_wifi.fill_polygon(0, 0, outline, ugfx.RED)
Beispiel #25
0
def drawdata(data):
    width = 10
    selx = selected[0]*width
    sely = selected[1]*width

    data = list(data)
    if(len(data) < 512):
        data.extend([0] * (512 - len(data))) #pad out to 512 bytes

    for y in range(0, 16):
        for x in range(0, 32):
            val = data[y*32+x] 
            colour = ugfx.html_color(int("0x{:02X}{:02X}{:02X}".format(val,val,val)))

            container.area(x*width, y*width, width, width, colour)
            container.box(x*width, y*width, width, width, ugfx.ORANGE)

            container.box(selx, sely, width, width, ugfx.WHITE)
            container.show()

    container.show()
    return processbuttons(data)
Beispiel #26
0
def drawdata(data):
    width = 10
    selx = selected[0] * width
    sely = selected[1] * width

    data = list(data)
    if (len(data) < 512):
        data.extend([0] * (512 - len(data)))  #pad out to 512 bytes

    for y in range(0, 16):
        for x in range(0, 32):
            val = data[y * 32 + x]
            colour = ugfx.html_color(
                int("0x{:02X}{:02X}{:02X}".format(val, val, val)))

            container.area(x * width, y * width, width, width, colour)
            container.box(x * width, y * width, width, width, ugfx.ORANGE)

            container.box(selx, sely, width, width, ugfx.WHITE)
            container.show()

    container.show()
    return processbuttons(data)
Beispiel #27
0
def create_profile(my_profile):
    ugfx.clear(ugfx.html_color(0x000000))

    name, age = "", ""
    while name == "":
        name = dialogs.prompt_text("What's your name?")
    while age == "":
        age = dialogs.prompt_text("What's your age?")
    tag_line = dialogs.prompt_text("Tell us your tagline:")
    looking_for = dialogs.prompt_text("And what you're looking for:")
    contact = dialogs.prompt_text("And your twitter username?")
    imei = sim800.imei()

    top_left_logo()
    ugfx.text(5, 100, "Working...", ugfx.BLACK)

    profile = {
        'unique_identifier': imei,
        'username': name,
        'age': age,
        'tag_line': tag_line,
        'looking_for': looking_for,
        'contact': contact
    }

    profile_json = ujson.dumps(profile)

    try:
        http.post(api_url+'/create_user', json=profile).raise_for_status().close()
    except:
        ugfx.clear()
        ugfx.text(5, 100, "Error. Try again later. :(", ugfx.BLACK)
        return False

    database.set("tildr_profile", profile_json)

    return True
Beispiel #28
0
___dependencies___ = ["sleep", "app", "ugfx_helper", "buttons", "homescreen"]
___categories___ = ["Homescreens"]

import ugfx, os, time, sleep, ugfx_helper, math
from tilda import Buttons
from homescreen import *

width = 240
height = 320
ugfx_helper.init()

s = ugfx.Style()
s.set_background(ugfx.BLACK)
s.set_enabled([
    ugfx.WHITE,
    ugfx.html_color(0x800080),
    ugfx.html_color(0x800080),
    ugfx.html_color(0x800080)
])
ugfx.set_default_style(s)


# This was taken from the stock home app
def draw_name():
    intro_text = "Hi! I'm"
    intro_height = 30
    name_height = 60
    max_name = 8

    ugfx.orientation(90)
    ugfx.set_default_font(ugfx.FONT_TITLE)
Beispiel #29
0
import pyb
import stm
import buttons
import dialogs
from database import *
from filesystem import *
import uio
import sys
import gc
import onboard
from app import *

ugfx.init()
buttons.init()
ugfx.set_default_style(dialogs.default_style_badge)
ugfx.clear(ugfx.html_color(dialogs.default_style_badge.background()))

def update_options(options, category, pinned):
	options.disable_draw()
	apps = get_local_apps(category)
	out = []
	while options.count():
		options.remove_item(0)

	for app in apps:
		if app.get_attribute("built-in") == "hide":
			continue # No need to show the home app

		if app.folder_name in pinned:
			options.add_item("*%s" % app.title)
		else:
Beispiel #30
0
import pyb
import stm
import buttons
import dialogs
from database import *
from filesystem import *
import uio
import sys
import gc
import onboard
from app import *

ugfx.init()
buttons.init()
ugfx.set_default_style(dialogs.default_style_badge)
ugfx.clear(ugfx.html_color(dialogs.default_style_badge.background()))


def update_options(options, category, pinned):
    options.disable_draw()
    apps = get_local_apps(category)
    out = []
    while options.count():
        options.remove_item(0)

    for app in apps:
        if app.get_attribute("built-in") == "hide":
            continue  # No need to show the home app

        if app.folder_name in pinned:
            options.add_item("*%s" % app.title)
Beispiel #31
0
# Padding for name
intro_height = 30
intro_text = "Hi! I'm"
name_height = 60
status_height = 20
info_height = 30
logo_path = "shared/logo.png"
logo_height = 150
logo_width = 56

# Maximum length of name before downscaling
max_name = 8

# Background stuff

ugfx.clear(ugfx.html_color(0x800080))

# Colour stuff
style = ugfx.Style()
style.set_enabled([
    ugfx.WHITE,
    ugfx.html_color(0x800080),
    ugfx.html_color(0x800080),
    ugfx.html_color(0x800080)
])
style.set_background(ugfx.html_color(0x800080))
ugfx.set_default_style(style)

# Logo stuff
ugfx.display_image(int((ugfx.width() - logo_width) / 2),
                   int((ugfx.height() - logo_height) / 2), logo_path)
Beispiel #32
0
    "wifi", "http", "ugfx_helper", "sleep", "dialogs", "sim800", "database"
]
___categories___ = ["Other"]
___bootstrapped___ = False

import app, buttons, ugfx, ugfx_helper, sleep, http, dialogs, sim800, database, ujson
from tilda import Buttons

from tildr.profile import get_profile
from tildr.shared import clear
from tildr import splash, profile, person, nomore

api_url = "http://emf2018.us-east-2.elasticbeanstalk.com"

ugfx_helper.init()
ugfx.clear(ugfx.html_color(0x000000))

style = ugfx.Style()
style.set_enabled([
    ugfx.WHITE, ugfx.WHITE,
    ugfx.html_color(0x888888),
    ugfx.html_color(0x444444)
])
style.set_background(ugfx.html_color(0x000000))
ugfx.set_default_style(style)


def error_screen(state):
    ugfx.text(5, 100, "Error: try again later :(", ugfx.WHITE)

Beispiel #33
0
background is the pride flag.
"""

___name___         = "Pride"
___license___      = "MIT"
___categories___   = ["Homescreens"]
___dependencies___ = ["homescreen", "app"]


from app import restart_to_default
import ugfx
import homescreen


homescreen.init()
ugfx.clear(ugfx.html_color(0xFF0000))

# Used for placement around text
name_height = 55
info_height = 20

# Maximum length of name before downscaling
max_name = 8

# Orientation for other people to see
ugfx.orientation(90)

# Pride flag colours
colours = [0xE70000, 0xFF8C00, 0xFFEF00, 0x00811F, 0x0044FF, 0x760089]

# Draw each "band" of colour in the flag
Beispiel #34
0
### Description: Wearables Controller
### Category: Flashy
### License: MIT
### Appname : Wearables
### Built-in: no

import ugfx
from database import *
import dialogs
import buttons

buttons.init()
buttons.disable_menu_reset()

ugfx.init()
ugfx.clear(ugfx.html_color(0x7c1143))

pin_options = [
	{"title": "Onboard NeoPixel", "value":"PB13"},
	{"title": "Servo Header 2", "value":"X2"},
]

led_pin_name = database_get("led-port", "PB13")
pinnm = dialogs.prompt_option(pin_options, text="What connector are your neopixels on?", title="Wearables Controller")
if pinnm:
	database_set("led-port", pinnm['value'])

menu_items = [
	{"title": "Rainbow", "value":"rainbow"},
	{"title": "Matrix", "value":"matrix"},
	{"title": "Colour", "value":"colour"},
Beispiel #35
0
# Padding for name
intro_height = 30
intro_text = "Hi! I'm"
name_height = 60
status_height = 20
info_height = 30
logo_path = "shared/logo.png"
logo_height = 150
logo_width = 56

# Maximum length of name before downscaling
max_name = 8

# Background stuff

ugfx.clear(ugfx.html_color(0x800080))

# Colour stuff
style = ugfx.Style()
style.set_enabled([ugfx.WHITE, ugfx.html_color(0x800080), ugfx.html_color(0x800080), ugfx.html_color(0x800080)])
style.set_background(ugfx.html_color(0x800080))
ugfx.set_default_style(style)

# Logo stuff
ugfx.display_image(
    int((ugfx.width() - logo_width) / 2),
    int((ugfx.height() - logo_height) / 2),
    logo_path
)

Beispiel #36
0
"""Some basic UGFX powered dialogs"""

___license___ = "MIT"
___dependencies___ = ["buttons", "sleep"]

import ugfx, buttons, sleep

default_style_badge = ugfx.Style()
default_style_badge.set_focus(ugfx.RED)
default_style_badge.set_enabled([ugfx.WHITE, ugfx.html_color(0x3C0246), ugfx.GREY, ugfx.RED])
default_style_badge.set_background(ugfx.html_color(0x3C0246))

default_style_dialog = ugfx.Style()
default_style_dialog.set_enabled([ugfx.BLACK, ugfx.html_color(0xA66FB0), ugfx.html_color(0xdedede), ugfx.RED])
default_style_dialog.set_background(ugfx.html_color(0xFFFFFF))


TILDA_COLOR = ugfx.html_color(0x7c1143);
FONT_SMALL = 0 #todo: find correct values
FONT_MEDIUM_BOLD = 0

def notice(text, title="TiLDA", close_text="Close", font=FONT_SMALL, style=None):
    prompt_boolean(text, title = title, true_text = close_text, false_text = None, font=font, style=style)

def prompt_boolean(text, title="TiLDA", true_text="Yes", false_text="No", font=FONT_SMALL, style=None):
    """A simple one and two-options dialog

    if 'false_text' is set to None only one button is displayed.
    If both 'true_text' and 'false_text' are given a boolean is returned
    """
    global default_style_dialog
Beispiel #37
0
def screen_3():
    ugfx.clear(ugfx.html_color(0x7c1143))
    ugfx.text(27, 90, "Thank you!", ugfx.WHITE)
Beispiel #38
0
### Author: core
### Description: Simple visual morse widget
### Category: morse
### License: MIT
### Appname: cw_flash

import ugfx, pyb, buttons

ugfx.init()
ugfx.clear()
ugfx.area(0,0,320,240,ugfx.html_color(0x00FF00))
buttons.init()
ugfx.set_default_font(ugfx.FONT_NAME)

t4 = pyb.Timer(4, freq=300, mode=pyb.Timer.CENTER)

SIGN_SCALING = 100
DOT = 1
DASH = 3
PAUSE_ELEMENT = DOT
PAUSE_CHARACTER = 3 * DOT - DOT
PAUSE_WORD = 7 * DOT - DOT

AF = True

def dot():
    if AF:
        ch1 = t4.channel(1, pyb.Timer.PWM, pin=pyb.Pin("BUZZ"), pulse_width=(t4.period() + 1) // 2)
    ugfx.area(100,75,90,90,ugfx.BLACK)
    pyb.delay(SIGN_SCALING*DOT)
    if AF:
Beispiel #39
0
				break;
			if buttons.is_triggered("BTN_A"):
				break;
			if buttons.is_triggered("BTN_B"):
				break;
			if buttons.is_triggered("JOY_CENTER"):
				break;
			pyb.delay(1)


onboard.hide_splash_on_next_boot(False)

ugfx.set_default_style(dialogs.default_style_badge)

sty_tb = ugfx.Style(dialogs.default_style_badge)
sty_tb.set_enabled([ugfx.WHITE, ugfx.html_color(0xA66FB0), ugfx.html_color(0x5e5e5e), ugfx.RED])
sty_tb.set_background(ugfx.html_color(0xA66FB0))

orientation = ugfx.orientation()

with Database() as db:
	if not db.get("home_firstrun"):
		stats_upload = dialogs.prompt_boolean("""Press menu to see all the available apps and download more.""", title="Welcome to the EMF camp badge!", true_text="OK", false_text = None, width = 320, height = 240)
		db.set("home_firstrun", True)
		db.set("stats_upload", stats_upload)

def home_main():
	global orientation, next_tick, tick

	ugfx.area(0,0,320,240,sty_tb.background())
Beispiel #40
0
def twitter(container_handle):
    if not container_handle:
        container_handle = ugfx.Container(0, 0, 320, 240)
        container_handle.area(0, 0, 320, 240, ugfx.html_color(0))
    container_handle.text(27, 90, "@tofu_li", ugfx.GREEN)
    container_handle.show()
Beispiel #41
0
	buttons.init()
	while True:
		pyb.wfi()
		if buttons.is_triggered("BTN_B"):
			break;

	database_set("stats_upload", chk_upload.checked())

wi = ugfx.width()
hi = ugfx.height()

ugfx.clear()

s = ugfx.Style()

s.set_enabled([ugfx.BLACK, ugfx.html_color(0xA66FB0), ugfx.html_color(0x5e5e5e), ugfx.RED])
s.set_background(ugfx.html_color(0xFFFFFF))

ugfx.set_default_style(s)

win_header = ugfx.Container(0,0,wi,33,style=s)
win_legend = ugfx.Container(0,hi-30,wi,30,style=s)


toplot = ['vbat','vunreg','light','rssi']
# scale  to fit on the y scale (range 0->150)
scale_m = [75,   75,   0.4,  1]
scale_c = [-255, -255, 0,    100]
colour =  [ugfx.RED, ugfx.ORANGE, ugfx.YELLOW, ugfx.BLUE]

buttons.disable_menu_reset()
Beispiel #42
0
### Author: EMF Badge team
### Description: Some basic UGFX powered dialogs
### License: MIT

import ugfx
import buttons
import pyb

default_style_badge = ugfx.Style()
default_style_badge.set_focus(ugfx.RED)
default_style_badge.set_enabled([ugfx.WHITE, ugfx.html_color(0x3C0246), ugfx.GREY, ugfx.RED])
default_style_badge.set_background(ugfx.html_color(0x3C0246))

default_style_dialog = ugfx.Style()
default_style_dialog.set_enabled([ugfx.BLACK, ugfx.html_color(0xA66FB0), ugfx.html_color(0xdedede), ugfx.RED])
default_style_dialog.set_background(ugfx.html_color(0xFFFFFF))


TILDA_COLOR = ugfx.html_color(0x7c1143);

def notice(text, title="TiLDA", close_text="Close", width = 260, height = 180, font=ugfx.FONT_SMALL, style=None):
	prompt_boolean(text, title = title, true_text = close_text, false_text = None, width = width, height = height, font=font, style=style)

def prompt_boolean(text, title="TiLDA", true_text="Yes", false_text="No", width = 260, height = 180, font=ugfx.FONT_SMALL, style=None):
	"""A simple one and two-options dialog

	if 'false_text' is set to None only one button is displayed.
	If both 'true_text' and 'false_text' are given a boolean is returned
	"""
	global default_style_dialog
	if style == None:
Beispiel #43
0
def clear():
    ugfx.clear(ugfx.html_color(0x7c1143))
Beispiel #44
0
            if buttons.is_triggered("BTN_A"):
                break
            if buttons.is_triggered("BTN_B"):
                break
            if buttons.is_triggered("JOY_CENTER"):
                break
            pyb.delay(1)

onboard.hide_splash_on_next_boot(False)

ugfx.set_default_style(dialogs.default_style_badge)

sty_tb = ugfx.Style(dialogs.default_style_badge)
sty_tb.set_enabled([
    ugfx.WHITE,
    ugfx.html_color(0xA66FB0),
    ugfx.html_color(0x5e5e5e), ugfx.RED
])
sty_tb.set_background(ugfx.html_color(0xA66FB0))

orientation = ugfx.orientation()

with Database() as db:
    if not db.get("home_firstrun"):
        stats_upload = dialogs.prompt_boolean(
            """Press menu to see all the available apps and download more.

This badge can occasionally send anonymous sensor data via the BARMS app powered by Microsoft. See the badge wiki for more information. Are you OK with that?
		""",
            title="Welcome to EMF camp!",
            true_text="That's OK",
### Category: Games 
### License: MIT
### reboot-before-run: True
### Appname : DroneHunt

import buttons
import ugfx
import micropython
import pyb
from dialogs import prompt_boolean, notice
import gc

crosshair_x = 100
crosshair_y = 100
score = 0
GROUND_1 = ugfx.html_color(0x804000)
GROUND_2 = ugfx.html_color(0xf05030)
GRASS = ugfx.html_color(0x4DBD33)
SKIES = (
    None,
    ugfx.html_color(0xA2B5BB),
    ugfx.html_color(0x91C3E0),
    ugfx.html_color(0x87CEFA),
    ugfx.html_color(0x4080DF),
    ugfx.html_color(0x1249C5),
    ugfx.html_color(0x082978),
)
QUADCOPTER_BODY = ugfx.BLACK
QUADCOPTER_BODY_SIZE = 5
SCREEN_DURATION = 100
ENEMY_FREQUENCY = 2800