def create_time_table(self, t): t = time.localtime(t) hr = t.tm_hour if not self.mil_time: hr = hr % 12 hrs = str(hr).zfill(2) mins = str(t.tm_min).zfill(2) val = hrs + ":" + mins w, h = font.str_dim(val, font=self.font_name, font_scale=self.scale, final_sep=False) x = (self.width - w) // 2 y = (self.height - h) // 2 old_buf = copy.copy(self._led.buffer) self._led.all_off() self._led.drawText(val, x, y, color=colors.Red, font=self.font_name, font_scale=self.scale) table = [] for y in range(self.height): table.append([0] * self.width) for x in range(self.width): table[y][x] = int(any(self._led.get(x, y))) self._led.setBuffer(old_buf) return table
def __init__(self, *args, text='ScrollText', xPos=0, yPos=0, color=colors.White, bgcolor=colors.Off, font_name=font.default_font, font_scale=1): owm = pyowm.OWM('1529be8c1919b4ef1703a9928139940f') obs = owm.weather_at_coords(39, -76.9501564922) forecast = owm.daily_forecast("Maryland,us") print(*args) super().__init__(*args) self.bgcolor = bgcolor self.color = color self._text = text self.xPos = xPos self.orig_xPos = xPos self.yPos = yPos self.font_name = font_name self.font_scale = font_scale self._strW = font.str_dim(text, font_name, font_scale, True)[0] self._text = (str((obs.get_weather( ).get_temperature('fahrenheit')['temp_min']))[0:2] + ":" + str( (obs.get_weather().get_temperature('fahrenheit')['temp']))[0:2] + ":" + str((obs.get_weather().get_temperature( 'fahrenheit')['temp_max']))[0:2]) self.count = 0
def __init__(self, led, text, xPos=0, yPos=0, color=colors.White, bgcolor=colors.Off, font_name=font.default_font, font_scale=1): super(ScrollText, self).__init__(led) self.bgcolor = bgcolor self.color = color self._text = text self.xPos = xPos self.yPos = yPos self.font_name = font_name self.font_scale = font_scale self._strW = font.str_dim(text, font_name, font_scale, True)[0]
def __init__(self, layout, text='BounceText', xPos=0, yPos=0, buffer=0, color=colors.White, bgcolor=colors.Off, font_name=font.default_font, font_scale=1): super(BounceText, self).__init__(layout) self.color = color self.bgcolor = bgcolor self._text = text self.xPos = xPos self.yPos = yPos self.font_name = font_name self.font_scale = font_scale self._strW = font.str_dim(text, font_name, font_scale, True)[0] self._dir = -1 self._buffer = buffer
def __init__(self, layout, font_name='16x8', mil_time=False): super(GameOfLifeClock, self).__init__(layout) self.font_name = font_name self.mil_time = mil_time self.scale = 1 self.steady_time = 2000 self.history = None self.next_history = None self.next_thread = None self.next_ready = False # Find the text size while True: x, y = font.str_dim('00:00', font=self.font_name, font_scale=self.scale, final_sep=False) if x > self.width or y > self.height: self.scale -= 1 break self.scale += 1 # create a time frame while we wait self.init_frame = self.create_time_table(int(time.time()))