コード例 #1
0
    def __init__(self, parent_app):
        self.parent_app = parent_app
        self.window_surface = pylogilcd.surface()

        self.button_0_delay = None
        self.button_1_delay = None
        self.button_2_delay = None
        self.button_3_delay = None
コード例 #2
0
def splitsurfacetowidth(surface, width):
    first = surface.split(width, surface.getheight(), 0, 0)
    second = surface.split(width, surface.getheight(), width, 0)
    newsurface = pylogilcd.surface(0, max(first.getwidth(), second.getwidth()),
                                   first.getheight() + second.getheight())
    newsurface.blitz(first, 0, 0)
    newsurface.blitz(second, 0, first.getheight())
    return newsurface
コード例 #3
0
def getdatetimesurface():
    datetimeobj = datetime.datetime.now()
    timestring = datetimeobj.strftime('%H:%M:%S')
    timesurface = font.getstringsurface(timestring)
    datestring = datetimeobj.strftime('%A, %d %b %Y')
    datesurface = font.getstringsurface(datestring)
    dtw = max(datesurface.getwidth(), timesurface.getwidth())
    dth = datesurface.getheight() + timesurface.getheight()
    datetimesurface = pylogilcd.surface(0, dtw, dth)
    datetimesurface.blitz(datesurface, datetimesurface.getwidth() - datesurface.getwidth(), 0)
    datetimesurface.blitz(timesurface, datetimesurface.getwidth() - timesurface.getwidth(),
                          datetimesurface.getheight() - timesurface.getheight())
    return datetimesurface
コード例 #4
0
    def get_push_surface(self, push=None):
        push_to_draw = self.push
        if push:
            push_to_draw = push

        title_surface = font.getstringsurface(push_to_draw.data.title)
        title_surface = title_surface.split(110, title_surface.getheight(), 0, 0)
        body_surface = font.getstringsurface(push_to_draw.data.body)
        body_surface = splitsurfacetowidth(body_surface, 120)
        msg_surface = pylogilcd.surface(0, max(title_surface.getwidth(), body_surface.getwidth()),
                                        title_surface.getheight() + body_surface.getheight())
        msg_surface.blitz(title_surface, 0, 0)
        msg_surface.blitz(body_surface, 0, title_surface.getheight())
        return msg_surface
コード例 #5
0
    def mainloop(self):
        if self.running:
            surface = pylogilcd.surface()
            if self.currentWindow:
                self.currentWindow.tick()
                surface = self.currentWindow.get_window_surface()

            if self.get_button(0, self.currentWindow.button_0_delay):
                self.currentWindow.on_button_0()
            if self.get_button(1, self.currentWindow.button_1_delay):
                self.currentWindow.on_button_1()
            if self.get_button(2, self.currentWindow.button_2_delay):
                self.currentWindow.on_button_2()
            if self.get_button(3, self.currentWindow.button_3_delay):
                self.currentWindow.on_button_3()

            self.app.update(surface)
            self.register(Event(self.mainloop))
コード例 #6
0
 def tick(self):
     self.window_surface = pylogilcd.surface()
コード例 #7
0
    newsurface.blitz(second, 0, first.getheight())
    return newsurface


# initialize app and font settings
charref = ' !"#$%&\'()*+,=./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}-'
font = pylogilcd.bitmapfont('images\\fontsmall.bmp', 4, 7, 32, charref)

icon_up = pylogilcd.surfacefrombmp('images\\up.bmp', 10, 10)
icon_down = pylogilcd.surfacefrombmp('images\\down.bmp', 10, 10)
icon_confirm = pylogilcd.surfacefrombmp('images\\confirm.bmp', 10, 10)
icon_options = pylogilcd.surfacefrombmp('images\\options.bmp', 10, 10)
icon_back = pylogilcd.surfacefrombmp('images\\back.bmp', 10, 10)
icon_dismiss = pylogilcd.surfacefrombmp('images\\dismiss.bmp', 10, 10)

icon_select = pylogilcd.surface(255, 5, 5)

icon_select.setpixel(2, 0, 0)
icon_select.setpixel(3, 0, 0)
icon_select.setpixel(4, 0, 0)
icon_select.setpixel(4, 1, 0)
icon_select.setpixel(2, 4, 0)
icon_select.setpixel(3, 4, 0)
icon_select.setpixel(4, 4, 0)
icon_select.setpixel(4, 3, 0)


class LcdWindow(object):
    def __init__(self, parent_app):
        self.parent_app = parent_app
        self.window_surface = pylogilcd.surface()