def gen_next(self): start = self._msTime() t = int(time.time()) assert self._sleep, "GameOfLifeClock requires a set FPS!" self.next_history = self.generate_history(t + 60, 60000 // self._sleep) self.next_ready = True log.debug("History Generate Time: {}".format(self._msTime() - start))
def loadGIFFile(self, gif): _, ext = os.path.splitext(gif) next_buf = self.next_img_buf() if not ext.lower().endswith("gif"): raise ValueError('Must be a GIF file!') log.debug("Loading {0} ...".format(gif)) self._image_buffers[next_buf] = self._loadGIFSequence(gif)
def next_draw_obj(self): self.cur_vis += 1 if self.cur_vis >= len(self.vis_list): self.cur_vis = 0 if self.draw_obj: del self.draw_obj name = self.vis_list[self.cur_vis] log.debug("Loading {}".format(name)) self.draw_obj = self.vis_dict[name]
def find_serial_devices(self): self.devices = {} hardware_id = "(?i)" + self.hardware_id # forces case insensitive for ports in self.list_ports.grep(hardware_id): port = ports[0] id = 0 ver = 0 if getattr(ports, '__len__', lambda: 0)(): log.debug('Multi-port device %s:%s:%s with %s ports found', self.hardware_id, id, ver, len(ports)) if id < 0: log.debug('Serial device %s:%s:%s with id %s < 0', self.hardware_id, id, ver) else: self.devices[id] = port, ver return self.devices
def step(self, amt=1): self.layout.all_off() t = time.localtime() hrs = t.tm_hour % 12 mins = t.tm_min sec = t.tm_sec h_hrs = hrs * (256 // 12) h_min = mins * (256 // 60) h_sec = sec * (256 // 60) grad = [] grad += hue_gradient(h_hrs, h_min, self.half) if self.odd: grad += [h_min] grad += hue_gradient(h_min, h_sec, self.half) log.debug('{}:{}:{}'.format(hrs, mins, sec)) for x in range(self.cdim): self.layout.drawLine(x, 0, x, self.height - 1, self.palette(grad[x]))
from bibliopixel.animation.matrix import Matrix from bibliopixel.util import log import numpy as np try: import cv2 except ImportError: log.error('Could not import cv2 library') import os grab = None if os.name == 'nt': try: from desktopmagic.screengrab_win32 import getRectAsImage, getScreenAsImage log.debug("Using desktopmagic module") def nt_grab(bbox=None): if bbox is None: img = getScreenAsImage() else: img = getRectAsImage(bbox) return img grab = nt_grab except Exception: pass if grab is None: try: from mss.linux import MSS as mss from PIL import Image