def update(self): if self.getCharImage(): ((x,y),(w,h)) = self.area left = self.calcShift() oled.shift(area=self.area, amount=(-left,0),fill=0) wx = x + w - left while left > 0: ww = min(left, self.tw - self.tx) oled.image(self.image, dst_area=(wx,y,ww,self.th), src_area=(self.tx,0,ww,self.th)) wx += ww left -= ww self.tx += ww if not self.getCharImage(): break return 1 elif self.sc_cnt > 0: shift = self.calcShift() ww = min(shift, self.sc_cnt) self.sc_cnt -= ww oled.shift(amount=(-ww,0),area=self.area) return 1 else: self.time_set = 0 return 0
def update(self): if self.minute == int(time.time() / 60): return self.minute = int(time.time() / 60) s = time.strftime("%m/%d(%a) %H:%M") ((x, y), (w, h)) = self.area self.drw.rectangle((x, y, x + w, y + h), fill=0) self.drw.text((0, 0), s, fill=1, font=self.font) oled.image(self.img, dst_area=self.area)
sys.exit(1) ftime = 1 / float(fps) oled.begin() oled.clear() im = Image.new('1', oled.size) frames = sys.argv[i:] f = 0 t_start = t = time.time() while f < len(frames): im2 = Image.open(frames[f]) im.paste(im2) oled.image(im, sync=1) # 進めるフレーム数を計算 # t + ftime * x > time.time() を満たす最小整数のx # x > (time.time() - t) / ftime now = time.time() x = math.ceil((now - t) / ftime) t_next = t + x * ftime t_sleep = t_next - now if (f != len(frames) - 1) and (f + x >= len(frames)): f = len(frames) - 1 # 最後のフレームは必ず表示 else: f += x t2 = time.time() if verbose:
size=14) oled.begin() sensor = BME280(t_mode=BME280_OSAMPLE_2, p_mode=BME280_OSAMPLE_16, h_mode=BME280_OSAMPLE_1, filter=BME280_FILTER_16, standby=BME280_STANDBY_125) #sensor = BME280() while True: temperature = sensor.read_temperature() pascals = sensor.read_pressure() hectopascals = pascals / 100 humidity = sensor.read_humidity() #print('Temp = {0:0.3f} deg C'.format(temperature)) #print('Pressure = {0:0.2f} hPa'.format(hectopascals)) #print('Humidity = {0:0.2f} %'.format(humidity)) print(temperature, humidity, hectopascals) draw.text((0, 0), datetime.now().strftime('%Y%m%d %H:%M:%S'), font=f, fill=255) draw.text((0, 16), ' 気温 {0:0.1f} °C'.format(temperature), font=f, fill=255) draw.text((0, 32), ' 湿度 {0:0.1f} %'.format(humidity), font=f, fill=255) draw.text((0, 48), ' 気圧 {0:0.2f} hPa'.format(hectopascals), font=f, fill=255) oled.image(image) sleep(0.25) draw.rectangle(((0, 0), (127, 63)), fill=0)
def draw_num(self, n): ((x, y), (w, h)) = self.num_area self.num_drw.rectangle((0, 0, w, h), fill=0) str = "[%2d/%2d]" % (n, self.noe) self.num_drw.text((0, 0), str, fill=1, font=self.num_font) oled.image(self.num_img, dst_area=self.num_area)