class PinWidget(HilgaWidget): def __init__(self, (x, y, w, h), pin, label, **opts): HilgaWidget.__init__(self, (x, y, w, h), **opts) self.pinface = PinIface(pin) self.label = label self.last_level = None self.fnt = load_font("Anton.ttf", 24)
class D100Widget(HilgaWidget): def __init__(self, d100iface, (x, y), **opts): HilgaWidget.__init__(self, (x, y, 120, 140), **opts) # Instance of D100Iface self.d100 = d100iface self.prevstatus = {} self.fnt = load_font("Anton.ttf", 32)
class ClockWidget(HilgaWidget): def __init__(self, obdiface, (x, y), period=1, timefun=time.time, **opts): HilgaWidget.__init__(self, (x, y, 120, 32), **opts) self.timefun = timefun self.period = period self.time = "" self.new_time = self.format_time() self.fnt = load_font("Anton.ttf", 18) self.pool.spawn_n(self.loop_time)
class BatteryWidget(HilgaWidget): def __init__(self, obdiface, (x, y), period=5, **opts): HilgaWidget.__init__(self, (x, y, 120, 32), **opts) self.period = period self.voltage = "" self.fnt = load_font("Anton.ttf", 18) self.vre = re.compile("([01234567890.]+)V") self.obd = obdiface self.obd.voltage = self.obd.command("atrv") self.pool.spawn_n(self.loop_temp)
class RpmWidget(HilgaGauge): def __init__(self, obdiface, (x, y), **opts): HilgaGauge.__init__(self, (x, y, 220, 440), ("0", "1", "2", "3", "4", "5", "6"), (RPM_MIN, RPM_MAX), (ASTART, ASTOP), ptype="long", pcolor=(180, 0, 0), **opts) self.obd = obdiface self.obd.rpm = self.rpm = 0 self.load = None self.fnt = load_font("Anton.ttf", 32)
class OdoWidget(HilgaWidget): TRP_COLOR = (200, 200, 200) ODO_COLOR = (150, 150, 150) def __init__(self, odoiface, (x, y), **opts): HilgaWidget.__init__(self, (x, y, 32 * 5, 64)) self.odo = odoiface self.odo_all = -1 self.odo_cur = -1 self.need_redraw = True self.odo.add_hook('onincrease', self.set_need_redrw) self.fnt = load_font("Anton.ttf", 24)
class GpsSpeedWidget(HilgaGauge): def __init__(self, gps, (x, y), **opts): HilgaGauge.__init__(self, (x, y, SG_WIDTH, SG_WIDTH * 2), ("0", "", "20", "", "40", "", "60", "", "80", "", "100", "", "120", "", "140", "", "160"), (SPEED_MIN, SPEED_MAX), (ASTART, ASTOP), **opts) self.gps = gps self.speed = -100 self.avg_speed = AvgSpeed() self.fnt = load_font("Anton.ttf", 64) self.fnt = load_font("Anton.ttf", 96) self.dfnt = load_font("bebas.ttf", 24) # precalculate position for 1,2,3-symbol speed label def gen_ssxoff(lbl): ss = self.fnt.render(lbl, True, (255, 255, 255)) ssr = ss.get_rect() ssr.centerx = SG_WIDTH / 2 return ssr.x self.ssxoffs = map(gen_ssxoff, ["0", "00", "120"])
class RpmSpeedWidget(HilgaWidget): def __init__(self, obdiface, (x, y), **opts): HilgaWidget.__init__(self, (x, y, SW_WIDTH, SW_WIDTH * 2)) self.obd = obdiface self.speed = -100 self.speed4 = self.speed5 = 0 self.avg_speed = AvgValue() self.fnt = load_font("Anton.ttf", 32) # precalculate position for 1,2,3-symbol speed label def gen_ssxoff(lbl): ss = self.fnt.render(lbl, True, (255, 255, 255)) ssr = ss.get_rect() ssr.centerx = self.size[0] / 2 return ssr.x self.ssxoffs = map(gen_ssxoff, ["0", "00", "120"])
class CoolantWidget(HilgaGauge): def __init__(self, obdiface, (x, y), period=3, **opts): HilgaGauge.__init__(self, (x, y, 100, 200), ("C", "", "H"), (COOL_MIN, COOL_MAX), (ASTART, ASTOP), ptype="short", pcolor=(180, 0, 0), slength=12, loffset=16, fontsize=12, **opts) self.period = period self.cooltemp = 0 self.obd = obdiface self.obd.cooltemp = self.obd.sensor(ObdIface.COOLTEMP_IDX) self.fnt = load_font("Anton.ttf", 18) self.pool.spawn_n(self.loop_temp)