Ejemplo n.º 1
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))
Ejemplo n.º 2
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
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
        delay = 2000
        while delay:
            delay -= 1
            if buttons.is_triggered("BTN_MENU"):
                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.
Ejemplo n.º 7
0
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
)



# 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)
Ejemplo n.º 8
0
		while delay:
			delay -= 1
			if buttons.is_triggered("BTN_MENU"):
				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
Ejemplo n.º 9
0
def drawEMFscreen():
    # 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
    init()
    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
    )

    # 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)
    # 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)
    # info
    ugfx.Label(0, ugfx.height() - info_height, ugfx.width(), info_height, "Press MENU", justification=ugfx.Label.CENTER)

    ugfx.set_default_font(ugfx.FONT_SMALL)
    status = ugfx.Label(0, ugfx.height() - info_height * 2 - status_height, ugfx.width(), status_height, "",
                        justification=ugfx.Label.CENTER)

    text = ""
    value_wifi_strength = wifi_strength()
    value_battery = battery()
    if value_wifi_strength:
        text += "Wi-Fi: %s%%, " % int(value_wifi_strength)
    if value_battery:
        text += "Battery: %s%%" % int(value_battery)
    status.text(text)
Ejemplo n.º 10
0
		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()

ugfx.set_default_font(ugfx.FONT_TITLE)
title = ugfx.Label(3,3,wi-10,45,"Log Viewer",parent=win_header)