コード例 #1
0
http://glyph.smarticons.co/
"""

___license___ = "MIT"
___dependencies___ = ["ospath", "shared/icons/unknown.gif", "buttons"]

import ugfx, ospath

_icon_size = 50;
_half_icon_size = _icon_size // 2
_padding = 5
_padded_size = _icon_size + _padding * 2
_text_height = 30

_icon_container_style = ugfx.Style()
_icon_container_style.set_disabled([ugfx.BLACK, ugfx.WHITE, ugfx.WHITE, ugfx.RED])
_icon_container_style.set_enabled([ugfx.BLACK, ugfx.RED, ugfx.WHITE, ugfx.RED])
#_icon_container_style.set_background(ugfx.html_color(ugfx.WHITE))

class Icon:
    def __init__(self, x, y, title, path_to_icon = None):
        if path_to_icon == None or not ospath.isfile(path_to_icon):
            path_to_icon = "shared/icons/unknown.gif"
        self._selected = False
        self._init_container(x, y, title, path_to_icon)


    def _init_container(self, x, y, title, path_to_icon):
        self.container = ugfx.Container(
            x - _half_icon_size - _padding, y - _half_icon_size - _padding,
コード例 #2
0
ファイル: main.py プロジェクト: tswsl1989/Mk4-Apps
___categories___ = ["Games"]
___bootstrapped___ = False  # Whether or not apps get downloaded on first install. Defaults to "False", mostly likely you won't have to use this at all.

import ugfx, json, random

from tilda import Buttons
from app import restart_to_default

ugfx.init()
ugfx.clear()
ugfx.text(10, 10, "CARDS AGAINST EMF", ugfx.BLACK)
ugfx.text(10, 40, "A for a question", ugfx.BLACK)
ugfx.text(10, 60, "B for an answer", ugfx.BLACK)
ugfx.text(10, 80, "MENU to exit", ugfx.BLACK)

b = ugfx.Style()
b.set_background(ugfx.BLACK)
b.set_enabled([ugfx.WHITE, ugfx.BLACK, ugfx.BLACK,
               ugfx.BLACK])  # sets the style for when something is enabled
w = ugfx.Style()
w.set_background(ugfx.WHITE)

with open("cards_against_emf/cards.json") as data:
    d = json.load(data)


def get_black():
    x = random.randint(1, 320)
    ugfx.clear(ugfx.html_color(0x000000))
    text = str(d["blackCards"][x]["text"])
    ugfx.Label(0, 0, 240, 400, text, style=b)
コード例 #3
0
    global orientation
    if orientation == 90:
        ugfx.orientation(270)
        orientation = 270
        draw_screen()
    else:
        ugfx.orientation(90)
        orientation = 90
        draw_screen()


ugfx.init()
ugfx.clear(ugfx.BLACK)
ugfx.set_default_font(ugfx.FONT_FIXED)

s = ugfx.Style()
s.set_enabled([ugfx.WHITE, ugfx.BLACK, ugfx.BLACK, ugfx.GREY])
s.set_background(ugfx.BLACK)
ugfx.set_default_style(s)

Buttons.enable_interrupt(Buttons.BTN_A,
                         lambda button_id: get_beer(),
                         on_press=True,
                         on_release=False)
Buttons.enable_interrupt(Buttons.BTN_B,
                         lambda button_id: toggle_orientation(),
                         on_press=True,
                         on_release=False)
Buttons.enable_interrupt(Buttons.BTN_Menu,
                         lambda button_id: app.restart_to_default(),
                         on_press=True,
コード例 #4
0
extra_text = "www.jakew.me"
status_height = 20
info_height = 30
logo_path = "shared/avatar.png"
logo_height = 150
logo_width = 150

# Maximum length of name before downscaling
max_name = 8

# Background stuff
init()
ugfx.clear(ugfx.html_color(0x2274A6))

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

# Logo stuff
ugfx.display_image(int((ugfx.width() - logo_width) / 2),
                   int((extra_height + name_height + intro_height + 10)),
                   logo_path)

# Draw for people to see
コード例 #5
0
ファイル: main.py プロジェクト: fooforever/Mk4-Apps
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)
コード例 #6
0
import ugfx

wb = ugfx.Style(ugfx.Font('IBMPlexSans_Regular22'))

wb.set_background(ugfx.BLACK)
wb.set_focus(ugfx.WHITE)
wb.set_pressed([
    ugfx.WHITE,
    ugfx.WHITE,
    ugfx.BLACK,
    ugfx.BLACK,
])
wb.set_enabled([
    ugfx.WHITE,
    ugfx.WHITE,
    ugfx.BLACK,
    ugfx.BLACK,
])
wb.set_disabled([
    ugfx.WHITE,
    ugfx.WHITE,
    ugfx.BLACK,
    ugfx.BLACK,
])

ibm_st = ugfx.Style(ugfx.Font('IBMPlexMono_Bold24'))

ibm_st.set_background(ugfx.WHITE)
ibm_st.set_focus(ugfx.WHITE)
ibm_st.set_pressed([
    ugfx.BLACK, # Text
コード例 #7
0
"""Some basic UGFX powered dialogs"""

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

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,
コード例 #8
0
print("Stats app starting")

# Initialise graphics

print("Init uGFX")

ugfx.init()
ugfx.area(0, 0, ugfx.width(), ugfx.height(), ugfx.BLACK)
ugfx.set_default_font(ugfx.FONT_TITLE)

# Set up all the styles

print("Init Styles")

sty = ugfx.Style()
sty.set_enabled([ugfx.PURPLE, ugfx.BLACK, ugfx.GREEN, ugfx.GREY])
sty.background(ugfx.BLACK)

styUse = ugfx.Style()
styUse.set_enabled([ugfx.PURPLE, ugfx.BLACK, ugfx.GREEN, ugfx.GREY])
styUse.background(ugfx.BLACK)

styLbl = ugfx.Style()
styLbl.set_enabled([0xdddddd, ugfx.BLACK, ugfx.GREEN, ugfx.GREY])
styLbl.background(ugfx.BLACK)

styVal = ugfx.Style()
styVal.set_enabled([ugfx.WHITE, ugfx.BLACK, ugfx.GREEN, ugfx.GREY])
styVal.background(ugfx.BLACK)
コード例 #9
0
			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="A: 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())