def drawTemp(self, draw): s = u'{:+.1f} \xf8c'.format(self.weather.temp) w, _ = textsize(s, font=utils.proportional2(TINY_FONT)) text(draw, (36 - w, 2), s, fill="white", font=utils.proportional2(TINY_FONT))
def drawLed(self, draw): date_str = u"LED: %d%%" % (intensity) txtlen, _ = textsize(date_str, font=utils.proportional2(TINY_FONT)) coords = (36 - txtlen, 2) text(draw, coords, date_str, fill="white", font=utils.proportional2(TINY_FONT))
def drawDesc(self, draw): date_str = self.weather.lastData['weather'][0]['main'].lower() txtlen, _ = textsize(date_str, font=utils.proportional2(TINY_FONT)) coords = (36 - txtlen, 2) text(draw, coords, date_str, fill="white", font=utils.proportional2(TINY_FONT))
def drawDay(self, draw): date_str = time.strftime("%A").upper() txtlen, _ = textsize(date_str, font=utils.proportional2(TINY_FONT)) coords = (36 - txtlen, 2) text(draw, coords, date_str, fill="white", font=utils.proportional2(TINY_FONT))
def update(self, draw): self.currentView = 1 if self.currentView == 0 else 0 date_str = time.strftime( "%d %B") if self.currentView == 1 else time.strftime("%A") txtlen, _ = textsize(date_str, font=utils.proportional2(TINY_FONT)) coords = (36 - txtlen, 2) text(draw, coords, date_str, fill="white", font=utils.proportional2(TINY_FONT))
def drawClock(draw, width=0, height=0): time_str = time.strftime("%H:%M" if int(time.time()) % 2 > 0 else "%H %M") coords = (0, 1) text(draw, coords, time_str, fill="white", font=utils.proportional2(LCD_FONT))
def __init__(self, text, width, height, font=None, fill="white", doneFunc=None): self.text = text self.font = font or utils.proportional2(TINY_FONT) self.fill = fill self.doneFunc = doneFunc self.viewportWidth = width self.viewportHeight = height self.textWidth, self.textHeight = textsize(self.text, font=self.font) self.offsetX = self.viewportWidth self.offsetY = self.viewportHeight - self.textHeight + 2 hotspot.__init__(self, self.viewportWidth, self.viewportHeight, self.update)