Example #1
0
def drawTask(onSleep=False):
	global gui_redraw, cfg_nickname, gui_apps, gui_app_current, ota_available
	if gui_redraw or onSleep:
		gui_redraw = False
		display.drawFill(COLOR_BG)
		currHeight = 0
		noLine = False
		if gui_app_current < 0:
			if cfg_logo:
				if cfg_nickname:
					# Logo and nickename enabled, first print nickname
					display.drawText((display.width()-display.getTextWidth(cfg_nick_text, "roboto_regular12"))//2, currHeight, cfg_nick_text, COLOR_FG, "roboto_regular12")
					currHeight += display.getTextHeight(cfg_nick_text, "roboto_regular12")#easydraw.nickname()
					currHeight += 4
					display.drawLine(0, currHeight, display.width()-1, currHeight, COLOR_FG)
					currHeight += 4
				#Print logo
				app_height = display.height()-16-currHeight
				logoHeight = drawLogo(currHeight, app_height, True)
				if logoHeight > 0:
					noLine = True
				if logoHeight < 1:
					#Logo enabled but failed to display
					title = "BADGE.TEAM"
					subtitle = "PLATFORM"
					logoHeight = display.getTextHeight(title, "permanentmarker22")+display.getTextHeight(subtitle, "fairlight12")
					display.drawText((display.width()-display.getTextWidth(title, "permanentmarker22"))//2, currHeight + (app_height - logoHeight)//2,title, COLOR_FG, "permanentmarker22")
					currHeight += display.getTextHeight(title, "permanentmarker22")
					display.drawText((display.width()-display.getTextWidth(subtitle, "fairlight12"))//2, currHeight + (app_height - logoHeight)//2,subtitle, COLOR_FG, "fairlight12")
					currHeight += display.getTextHeight(subtitle, "fairlight12")
			else:
				noLine = True
				display.drawPng(0,0,LOGO)
		else:
			display_app(currHeight)

		if onSleep:
			info = 'Sleeping...'
		#elif not rtc.isSet():
		#	info = "RTC not available"
		elif ota_available:
			info = "Update available!"
		#elif wifi_status_curr:
		#	info = "WiFi connected"
		else:
			info = ""#'Press START'
		if not noLine:
			display.drawLine(0, display.height()-16, display.width(), display.height()-16, COLOR_FG)
		easydraw.disp_string_right_bottom(0, info)
		if len(gui_apps) > 0:
			drawPageIndicator(len(gui_apps), gui_app_current)
		if cfg_greyscale:
			display.flush(display.FLAG_LUT_GREYSCALE)
		else:
			display.flush(display.FLAG_LUT_NORMAL)
	return 1000
Example #2
0
def draw(mode, goingToSleep=False):
	info1 = ''
	info2 = ''
	if mode:
		# We flush the buffer and wait
		ugfx.flush(ugfx.GREYSCALE)
	else:
		# We prepare the screen refresh
		ugfx.clear(ugfx.WHITE)
		easydraw.nickname()
		if goingToSleep:
			info = 'Sleeping...'
		elif badge.safe_mode():
			info = "(Services disabled!)"
		elif otac.available(False):
			info = 'Update available!'
		else:
			info = ''
		easydraw.disp_string_right_bottom(0, info)
Example #3
0
def show_categories(pressed=True):
	if not pressed:
		return
	ugfx.clear(ugfx.WHITE)
	#Hide category list
	category_list.visible(False)
	category_list.enabled(False)
	#Show categories list
	categories_list.visible(True)
	categories_list.enabled(True)
	#Input handling
	ugfx.input_attach(ugfx.BTN_START, btn_exit)
	ugfx.input_attach(ugfx.BTN_SELECT, btn_update)
	ugfx.input_attach(ugfx.BTN_A, show_category)
	ugfx.input_attach(ugfx.BTN_B, btn_unhandled)
	ugfx.input_attach(ugfx.JOY_UP, btn_unhandled)
	ugfx.input_attach(ugfx.JOY_DOWN, btn_unhandled)
	ugfx.input_attach(ugfx.JOY_LEFT, btn_unhandled)
	ugfx.input_attach(ugfx.JOY_RIGHT, btn_unhandled)
	#Hint
	easydraw.disp_string_right_bottom(0, "START: Exit app")
	easydraw.disp_string_right_bottom(1, "A: Open category")
	easydraw.disp_string_right_bottom(2, "SELECT: Update repo")
	#Flush screen
	ugfx.flush()
Example #4
0
def show_categories(pressed=True, fromAppInstall=False):
    if not pressed:
        return
    ugfx.input_attach(ugfx.JOY_UP, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_DOWN, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_LEFT, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_RIGHT, btn_unhandled)
    ugfx.input_attach(ugfx.BTN_A, btn_unhandled)
    ugfx.input_attach(ugfx.BTN_B, btn_unhandled)
    ugfx.clear(ugfx.WHITE)
    myList.clear()
    for category in repo.categories:
        myList.add_item("%s (%d) >" % (category["name"], category["eggs"]))
    myList.enabled(True)
    myList.visible(True)
    #Input handling
    ugfx.input_attach(ugfx.BTN_START, btn_exit)
    ugfx.input_attach(ugfx.BTN_SELECT, btn_update)
    ugfx.input_attach(ugfx.BTN_A, show_category)
    ugfx.input_attach(ugfx.BTN_B, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_UP, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_DOWN, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_LEFT, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_RIGHT, btn_unhandled)
    #Hint
    easydraw.disp_string_right_bottom(0, "START: Exit app")
    easydraw.disp_string_right_bottom(1, "A: Open category")
    easydraw.disp_string_right_bottom(2, "SELECT: Update repo")
    #Flush screen
    display.flush(display.FLAG_LUT_NORMAL)
Example #5
0
def drawTask(onSleep=False):
    global gui_redraw, cfg_nickname, gui_apps, gui_app_current, ota_available
    if gui_redraw or onSleep:
        gui_redraw = False
        ugfx.clear(ugfx.WHITE)
        currHeight = 0
        if gui_app_current < 0:
            if cfg_nickname:
                currHeight += easydraw.nickname()
                currHeight += 4
                ugfx.line(0, currHeight, ugfx.width(), currHeight, ugfx.BLACK)
                currHeight += 4
            app_height = ugfx.height() - 16 - currHeight
            logoHeight = drawLogo(currHeight, app_height, True)
        else:
            display_app(currHeight)

        if onSleep:
            info = 'Sleeping...'
        #elif badge.safe_mode():
        #	info = "Recovery mode"
        #elif not rtc.isSet():
        #	info = "Clock not set"
        elif ota_available:
            info = "Update available!"
        #elif wifi_status_curr:
        #	info = "WiFi connected"
        else:
            info = 'Press START'
        ugfx.line(0,
                  ugfx.height() - 16, ugfx.width(),
                  ugfx.height() - 16, ugfx.BLACK)
        easydraw.disp_string_right_bottom(0, info)
        if len(gui_apps) > 0:
            drawPageIndicator(len(gui_apps), gui_app_current)
        ugfx.flush(ugfx.LUT_NORMAL)
    return 1000
Example #6
0
def show_category(pressed=True, fromAppInstall=False):
    global lastCategory
    if not pressed:
        return
    ugfx.input_attach(ugfx.JOY_UP, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_DOWN, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_LEFT, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_RIGHT, btn_unhandled)
    ugfx.input_attach(ugfx.BTN_A, btn_unhandled)
    ugfx.input_attach(ugfx.BTN_B, btn_unhandled)
    ugfx.clear(ugfx.WHITE)
    global category
    if not fromAppInstall:
        lastCategory = myList.selected_index()
    slug = repo.categories[lastCategory]["slug"]
    showMessage("Loading " + slug + "...")
    display.drawFill()
    myList.clear()
    try:
        try:
            category = repo.getCategory(slug)
        except BaseException as e:
            showMessage("Failed to open category " + slug + "!", True)
            display.drawFill()
            print("CAT OPEN ERR", e)
            time.sleep(1)
            show_categories()
            return
        gc.collect()
        for package in category:
            myList.add_item("%s rev. %s" %
                            (package["name"], package["revision"]))
        myList.visible(True)
        myList.enabled(True)
        #Input handling
        ugfx.input_attach(ugfx.BTN_START, btn_exit)
        ugfx.input_attach(ugfx.BTN_SELECT, btn_unhandled)
        ugfx.input_attach(ugfx.BTN_A, install_app)
        ugfx.input_attach(ugfx.BTN_B, show_categories)
        ugfx.input_attach(ugfx.JOY_UP, btn_unhandled)
        ugfx.input_attach(ugfx.JOY_DOWN, btn_unhandled)
        ugfx.input_attach(ugfx.JOY_LEFT, btn_unhandled)
        ugfx.input_attach(ugfx.JOY_RIGHT, btn_unhandled)
        #Hint
        easydraw.disp_string_right_bottom(0, "START: Exit")
        easydraw.disp_string_right_bottom(1, "A: Install app")
        easydraw.disp_string_right_bottom(2, "B: Back")
        #Flush screen
        display.flush(display.FLAG_LUT_NORMAL)
    except BaseException as e:
        sys.print_exception(e)
        print("ERROR", e)
        showMessage("Internal error", True)
        display.drawFill()
        time.sleep(1)
        show_categories()
Example #7
0
def show_category(pressed=True):
    if not pressed:
        return
    ugfx.clear(ugfx.WHITE)
    global category
    categories_list.visible(False)
    categories_list.enabled(False)
    slug = repo.categories[categories_list.selected_index()]["slug"]
    showMessage("Loading " + slug + "...")
    #Clean up list
    while category_list.count() > 0:
        category_list.remove_item(0)
    try:
        try:
            category = repo.getCategory(slug)
        except:
            showMessage("Failed to open category " + slug + "!", True)
            time.sleep(1)
            show_categories()
        gc.collect()
        for package in category:
            category_list.add_item("%s rev. %s" %
                                   (package["name"], package["revision"]))
        category_list.selected_index(0)
        category_list.visible(True)
        category_list.enabled(True)
        #Input handling
        ugfx.input_attach(ugfx.BTN_START, btn_exit)
        ugfx.input_attach(ugfx.BTN_SELECT, btn_unhandled)
        ugfx.input_attach(ugfx.BTN_A, install_app)
        ugfx.input_attach(ugfx.BTN_B, show_categories)
        ugfx.input_attach(ugfx.JOY_UP, btn_unhandled)
        ugfx.input_attach(ugfx.JOY_DOWN, btn_unhandled)
        ugfx.input_attach(ugfx.JOY_LEFT, btn_unhandled)
        ugfx.input_attach(ugfx.JOY_RIGHT, btn_unhandled)
        #Hint
        easydraw.disp_string_right_bottom(0, "START: Exit")
        easydraw.disp_string_right_bottom(1, "A: Install app")
        easydraw.disp_string_right_bottom(2, "B: Back")
        #Flush screen
        ugfx.flush()
    except BaseException as e:
        sys.print_exception(e)
        showMessage(e, True)
        time.sleep(1)
        show_categories()
Example #8
0
def show_category(pressed=True):
	global category
	if pressed:
		categories_list.visible(False)
		categories_list.enabled(False)
		slug = categories[categories_list.selected_index()]["slug"]
		easydraw.msg("Loading "+slug+"...", "Loading...", True)
		#Clean up list
		while category_list.count() > 0:
			category_list.remove_item(0)
		try:
			print("Loading "+slug+"...")
			f = open(woezel_repo+"/"+slug+".json")
			category = json.loads(f.read())
			f.close()
			gc.collect()
			for package in category:
				category_list.add_item("%s rev. %s" % (package["name"], package["revision"]))
			category_list.selected_index(0)
			category_list.visible(True)
			category_list.enabled(True)
			#Input handling
			ugfx.input_attach(ugfx.BTN_START, btn_home)
			ugfx.input_attach(ugfx.BTN_SELECT, btn_unhandled)
			ugfx.input_attach(ugfx.BTN_A, install_app)
			ugfx.input_attach(ugfx.BTN_B, show_categories)
			ugfx.input_attach(ugfx.JOY_UP, btn_unhandled)
			ugfx.input_attach(ugfx.JOY_DOWN, btn_unhandled)
			ugfx.input_attach(ugfx.JOY_LEFT, btn_unhandled)
			ugfx.input_attach(ugfx.JOY_RIGHT, btn_unhandled)
			#Hint
			easydraw.disp_string_right_bottom(0, "START:  Home")
			easydraw.disp_string_right_bottom(1, "B:      Back")
			easydraw.disp_string_right_bottom(2, "A:      Install")
			#Flush screen
			ugfx.flush()
		except BaseException as e:
			sys.print_exception(e)
			easydraw.msg("", "Error", True)
			time.sleep(1)
			show_categories()
Example #9
0
def show_categories(pressed=True):
	ugfx.clear(ugfx.WHITE)
	if pressed:
		#Hide category list
		category_list.visible(False)
		category_list.enabled(False)
		#Show categories list
		categories_list.visible(True)
		categories_list.enabled(True)
		#Input handling
		ugfx.input_attach(ugfx.BTN_START, btn_home)
		ugfx.input_attach(ugfx.BTN_SELECT, btn_update)
		ugfx.input_attach(ugfx.BTN_A, show_category)
		ugfx.input_attach(ugfx.BTN_B, btn_unhandled)
		ugfx.input_attach(ugfx.JOY_UP, btn_unhandled)
		ugfx.input_attach(ugfx.JOY_DOWN, btn_unhandled)
		ugfx.input_attach(ugfx.JOY_LEFT, btn_unhandled)
		ugfx.input_attach(ugfx.JOY_RIGHT, btn_unhandled)
		#Hint
		easydraw.disp_string_right_bottom(0, "START:  Home")
		easydraw.disp_string_right_bottom(1, "SELECT: Update")
		easydraw.disp_string_right_bottom(2, "A:      Select")
		#Flush screen
		ugfx.flush()
def drawTask(onSleep=False):
    global gui_redraw, cfg_nickname, gui_apps, gui_app_current, ota_available
    if gui_redraw or onSleep:
        gui_redraw = False
        display.drawFill(COLOR_BG)
        currHeight = 0
        noLine = False
        if gui_app_current < 0:
            if cfg_logo:
                #Print logo
                app_height = display.height() - 16 - currHeight
                logoHeight = drawLogo(currHeight, app_height, True)
                if logoHeight > 0:
                    noLine = True
                if logoHeight < 1:
                    #Logo enabled but failed to display
                    title = "BADGE.TEAM"
                    subtitle = "PLATFORM"
                    logoHeight = display.getTextHeight(
                        title, "permanentmarker22") + display.getTextHeight(
                            subtitle, "fairlight12")
                    display.drawText(
                        (display.width() -
                         display.getTextWidth(title, "permanentmarker22")) //
                        2, currHeight + (app_height - logoHeight) // 2, title,
                        COLOR_FG, "permanentmarker22")
                    currHeight += display.getTextHeight(
                        title, "permanentmarker22")
                    display.drawText(
                        (display.width() -
                         display.getTextWidth(subtitle, "fairlight12")) // 2,
                        currHeight + (app_height - logoHeight) // 2, subtitle,
                        COLOR_FG, "fairlight12")
                    currHeight += display.getTextHeight(
                        subtitle, "fairlight12")
            else:
                noLine = True
                display.drawPng(0, 0, LOGO)
        else:
            display_app(currHeight)

        if onSleep:
            info = 'Sleeping...'
            owner = machine.nvs_getstr("owner", "name")
            fontlist = [
                "permanentmarker22", "Roboto_Regular18", "Roboto_Regular12"
            ]
            if (owner):
                display.drawFill(COLOR_BG)
                for font in fontlist:
                    if font == fontlist[-1]:
                        display.drawText(0, 0, owner, COLOR_FG, font)
                    elif display.getTextWidth(owner, font) <= display.width():
                        display.drawText(
                            (display.width() -
                             display.getTextWidth(owner, font)) // 2, 0, owner,
                            COLOR_FG, font)
                        break
        #elif not rtc.isSet():
        #	info = "RTC not available"
        elif ota_available:
            info = "Update available!"
        #elif wifi_status_curr:
        #	info = "WiFi connected"
        else:
            info = ""  #'Press START'
        if not noLine:
            display.drawLine(0,
                             display.height() - 16, display.width(),
                             display.height() - 16, COLOR_FG)
        easydraw.disp_string_right_bottom(0, info)
        if len(gui_apps) > 0:
            drawPageIndicator(len(gui_apps), gui_app_current)
        if cfg_greyscale:
            display.flush(display.FLAG_LUT_GREYSCALE)
        else:
            display.flush(display.FLAG_LUT_NORMAL)
    return 1000
Example #11
0
def drawTask(onSleep=False):
    global gui_redraw, cfg_nickname, gui_apps, gui_app_current, ota_available
    if gui_redraw or onSleep:
        gui_redraw = False
        display.drawFill(0xFFFFFF)
        currHeight = 0
        noLine = False
        if gui_app_current < 0:
            if cfg_logo and cfg_nickname:
                currHeight += easydraw.nickname()
                currHeight += 4
                display.drawLine(0, currHeight,
                                 display.width() - 1, currHeight, 0x000000)
                currHeight += 4
            app_height = display.height() - 16 - currHeight
            logoHeight = drawLogo(currHeight, app_height, True)
            if logoHeight > 0:
                noLine = True
            if logoHeight < 1 and cfg_logo:
                title = "BADGE.TEAM"
                subtitle = "PLATFORM"
                logoHeight = display.getTextHeight(
                    title, "permanentmarker22") + display.getTextHeight(
                        subtitle, "fairlight12")
                display.drawText(
                    (display.width() -
                     display.getTextWidth(title, "permanentmarker22")) // 2,
                    currHeight + (app_height - logoHeight) // 2, title,
                    0x000000, "permanentmarker22")
                currHeight += display.getTextHeight(title, "permanentmarker22")
                display.drawText(
                    (display.width() -
                     display.getTextWidth(subtitle, "fairlight12")) // 2,
                    currHeight + (app_height - logoHeight) // 2, subtitle,
                    0x000000, "fairlight12")
                currHeight += display.getTextHeight(subtitle, "fairlight12")
            if (not cfg_logo) and cfg_nickname:
                noLine = True
                nick = machine.nvs_getstr("owner", "name")
                if nick == None:
                    nick = "BADGE.TEAM"
                currHeight += (
                    display.getTextHeight(nick, "permanentmarker22") // 2) - 8
                display.drawText(
                    (display.width() -
                     display.getTextWidth(nick, "permanentmarker22")) // 2,
                    currHeight, nick, 0x000000, "permanentmarker22")
                currHeight += display.getTextHeight(nick, "permanentmarker22")
        else:
            display_app(currHeight)

        if onSleep:
            info = 'Sleeping...'
        #elif not rtc.isSet():
        #	info = "RTC not available"
        elif ota_available:
            info = "Update available!"
        #elif wifi_status_curr:
        #	info = "WiFi connected"
        else:
            info = 'Press START'
        if not noLine:
            display.drawLine(0,
                             display.height() - 16, display.width(),
                             display.height() - 16, 0x000000)
        easydraw.disp_string_right_bottom(0, info)
        if len(gui_apps) > 0:
            drawPageIndicator(len(gui_apps), gui_app_current)
        if cfg_greyscale:
            display.flush(display.FLAG_LUT_GREYSCALE)
        else:
            display.flush(display.FLAG_LUT_NORMAL)
    return 1000
Example #12
0
def drawTask(onSleep=False):
    global gui_redraw, cfg_nickname, gui_apps, gui_app_current, ota_available
    if gui_redraw or onSleep:
        gui_redraw = False
        display.drawFill(COLOR_BG)
        currHeight = 0
        noLine = False
        if gui_app_current < 0:
            if cfg_logo:
                #Print logo
                app_height = display.height() - 16 - currHeight
                logoHeight = drawLogo(currHeight, app_height, True)
                if logoHeight > 0:
                    noLine = True
                if logoHeight < 1:
                    #Logo enabled but failed to display
                    title = "BADGE.TEAM"
                    subtitle = "PLATFORM"
                    logoHeight = display.getTextHeight(
                        title, "permanentmarker22") + display.getTextHeight(
                            subtitle, "fairlight12")
                    display.drawText(
                        (display.width() -
                         display.getTextWidth(title, "permanentmarker22")) //
                        2, currHeight + (app_height - logoHeight) // 2, title,
                        COLOR_FG, "permanentmarker22")
                    currHeight += display.getTextHeight(
                        title, "permanentmarker22")
                    display.drawText(
                        (display.width() -
                         display.getTextWidth(subtitle, "fairlight12")) // 2,
                        currHeight + (app_height - logoHeight) // 2, subtitle,
                        COLOR_FG, "fairlight12")
                    currHeight += display.getTextHeight(
                        subtitle, "fairlight12")
            else:
                noLine = True
                textWidth = display.getTextWidth(cfg_nick_text, "ocra22")
                textHeight = display.getTextHeight(cfg_nick_text, "ocra22")
                textX = (display.width() - textWidth) // 2
                textY = (display.height() - textHeight) // 2
                display.drawText(textX, textY, cfg_nick_text, COLOR_FG,
                                 "ocra22")
        else:
            display_app(currHeight)

        if onSleep:
            info = 'Zzz...'
        elif ota_available:
            info = "(Firmware update available!)"
        else:
            info = ""  #'Press START to open the menu.'
        if not noLine:
            display.drawLine(0,
                             display.height() - 16, display.width(),
                             display.height() - 16, COLOR_FG)
        easydraw.disp_string_right_bottom(0, info)
        if len(gui_apps) > 0:
            drawPageIndicator(len(gui_apps), gui_app_current)
        if cfg_greyscale:
            display.flush(display.FLAG_LUT_GREYSCALE)
        else:
            display.flush(display.FLAG_LUT_NORMAL)
    return 1000