def __init__(self): self.dummy = use_dummy if use_dummy: self.pos = (0, 0) self.rows = [ " " * 16, " " * 16 ] sys.stdout.write(chr(0x1b) + "[2J") sys.stdout.flush() else: self.bus = SMBus(1) self.backlight = backlight.Backlight(self.bus, 0x62) self.screen = screen.Screen(self.bus, 0x3e)
def __init__(self, d=None): self.min_loop_duration = 12 #ms self.d = d if d else display.Display() self.b = backlight.Backlight() self.k = keyboard.Keyboard() self.l = looper.Looper(self.b, self.d) self.p = polyphony.Polyphony(self.k, self.d, self.l) self.l.p = self.p self.bat = battery.Battery(self.d) self.last_t = time.ticks_ms() self.last_t_disp = 0 self.longest_loop = 0
def __init__(self, cfg): self.cfg = cfg self.lcd = self._setup_lcd() self.widgets = [] # clock self.clock = ui.widgets.Clock((0,0)) self.widgets.append(self.clock) # scroller self.scroller = ui.widgets.Scroller((0,0),16) self.scroller.show(False) self.widgets.append(self.scroller) # alarm group self.alarm_group = ui.widgets.Group((0,0),16) self.room_label = ui.widgets.Label((0,0),8) self.duration_label = ui.widgets.Label((8,0),2,align=ui.widgets.Label.ALIGN_RIGHT) self.level_label = ui.widgets.Label((15,0),1,align=ui.widgets.Label.ALIGN_RIGHT) self.level_fifo = ui.widgets.Fifo((10,0),5) self.alarm_group.add_widget(self.room_label) self.alarm_group.add_widget(self.duration_label) self.alarm_group.add_widget(self.level_label) self.alarm_group.add_widget(self.level_fifo) self.alarm_group.show(False) self.widgets.append(self.alarm_group) # audio - reserve two instances a0 = ui.widgets.AudioShow((0,1), 1, self.lcd.bar_chars) a1 = ui.widgets.AudioShow((5,1), 2, self.lcd.bar_chars) a2 = ui.widgets.AudioShow((10,1), 3, self.lcd.bar_chars) self.widgets += [a0,a1,a2] self.audio_list = [a0,a1,a2] self.audio_map = {} self.alarm_audio = None # player self.player = None self.player_active = False self.player_show = ui.widgets.PlayerShow((15,1), self._index_mapper, self.lcd.play_char) self.widgets.append(self.player_show) # backlight self.backlight = backlight.Backlight(self.lcd) # quit self.quit_pending = False self.idle_start = None self.is_blank = False # init message self.scroller.add_message("pifon")
#/usr/bin/python2.7 import dot3k.joystick as j import time import sys import os import signal import screen, backlight, ledbar, temperature, joystick MESSAGE = screen.Screen() TEMP = temperature.Temperature() LED = ledbar.LedBar() SCROLLER = joystick.Scroller() LIGHT = backlight.Backlight() def main(): if SCROLLER.scrollnum >= len(TEMP.temperatures): SCROLLER.reset() if SCROLLER.scrollnum < 0: SCROLLER.scrollnum = len(TEMP.temperatures) - 1 MESSAGE.writeTemp(TEMP.temperatures[SCROLLER.scrollnum]) LIGHT.color(float(TEMP.temperatures[SCROLLER.scrollnum])) LED.set_size(float(TEMP.temperatures[SCROLLER.scrollnum])) return @j.on(j.UP) def handle_up(pin): MESSAGE.clearScreen() TEMP.readTemp()
def __init__(self): self.d = display.Display() self.b = backlight.Backlight() self.k = keyboard.Keyboard() self.l = looper.Looper(self.b, self.d) self.p = polyphony.Polyphony(self.k, self.d, self.l)
import display import backlight import os import re from board import vbat, vusb, vbat_ADC, vusb_ADC from time import ticks_ms, sleep_ms d = display.Display() b = backlight.Backlight() b.display(0x1, 0xF0) #Calibrate to get around 11mA def logfile_name(): "Returns the first unused logfile name in the format bat<num>.txt" index = 0 for f, *t in os.ilistdir(): m = re.match("bat([0-9]+)\\.txt", f) if m: index = max(index, int(m.group(1))) return "bat{}.txt".format(index + 1) def loop(): fn = logfile_name() fd = open(fn, "w") fd.write("timestamp,time,vbat,vusb,vbat_read16,vusb_read16,vref\n") fd.close() while (True): t = ticks_ms() // 1000 h = "{:02}h{:02}m{:02}s".format(t // 3600, t % 3600 // 60, t % 60)
def __init__(self, bus): self.backlight = backlight.Backlight(bus, 0x62) self.screen = screen.Screen(bus, 0x3e)