def __init__(self, pin_a, pin_b, pin_sw=None, **opts): """Connect A/B to digital pins and common to the GND. Options ~~~~~~~ min_pos - minimal rotary position (default=unlimited) max_pos - maximal rotary position (default=unlimited) position - initial rotary position debounce - debounce time (default=10)""" HilgaObject.__init__(self, **opts) # self.hm = HilgaMixer() self.min_pos = opts.get('min_pos', None) self.max_pos = opts.get('max_pos', None) self.position = opts.get('position', 0) self.pqueue = eventlet.Queue() self.pin_a = pin_a self.pin_b = pin_b self.pin_sw = pin_sw # Setup rotary pins GPIO.setup(self.pin_a, GPIO.IN, GPIO.PUD_UP) GPIO.setup(self.pin_b, GPIO.IN, GPIO.PUD_UP) self._levels = {pin_a: GPIO.input(self.pin_a), pin_b: GPIO.input(self.pin_b)} GPIO.add_event_detect(self.pin_a, GPIO.BOTH, callback=self.pin_pulse, bouncetime=self.opts.get('debounce', 10)) GPIO.add_event_detect(self.pin_b, GPIO.BOTH, callback=self.pin_pulse, bouncetime=self.opts.get('debounce', 10)) # Setup switch pin if self.pin_sw: GPIO.setup(self.pin_sw, GPIO.IN)#, GPIO.PUD_UP) GPIO.add_event_detect(self.pin_sw, GPIO.BOTH, callback=self.pin_switch, bouncetime=120)
def __init__(self, **opts): HilgaObject.__init__(self, **opts) self.screen = pygame.display.get_surface() self.clock = pygame.time.Clock() self.ticks = 0 fiface = FuelIface(**opts) self.fuel = FuelWidget(fiface, (660, 360), **opts) self.obd = obd = ObdIface(**opts) #port="/dev/pts/3", **opts) self.gps = gps = GpsIface(**opts) self.speed = GpsSpeedWidget(gps, (274, 20)) # self.rspeed = RpmSpeedWidget(obd, (359, 340)) self.rpm = RpmWidget(obd, (10, 120), **opts) self.coolant = CoolantWidget(obd, (580, 360), **opts) self.bat = BatteryWidget(obd, (580, 260), **opts) # Use GPS for time, system clock is unreliable self.clk = ClockWidget(obd, (580, 300), timefun=gps.time, **opts) self.gps.add_hook('gotclock', self.clk.set_system_time) # high beam / oil presure / brake self.hbeam = HighBeamWidget((94, 376), **opts) self.oil = OilWidget((654, 500), **opts) self.brk = BreakWidget((654, 540), **opts) d100iface = D100Iface(**opts) self.d100 = D100Widget(d100iface, (600, 100)) odoiface = OdoIface(gps, **opts) self.odo = OdoWidget(odoiface, (340, 340), **opts) self.pool.spawn_n(self.loop_ticks)
def __init__(self, addr='192.168.1.1', period=3, **opts): HilgaObject.__init__(self, **opts) self.status = {"pppState":-1, "evdoLevel":0, "sysinfo":[-1, -1, -1, -1, -1, -1]} self.script_name = "status.asp" self.d100_addr = addr self.period = period self.get_status() self.pool.spawn_n(self.loop_d100)
def __init__(self, pin, **opts): HilgaObject.__init__(self, **opts) self.pin = pin GPIO.setmode(GPIO.BCM) GPIO.setup(self.pin, GPIO.IN, GPIO.PUD_UP) self.level = GPIO.input(pin) self.toggled = True # print "LEVEL for", pin, "is", self.level GPIO.add_event_detect(self.pin, GPIO.BOTH, callback=self.pin_toggle, bouncetime=self.opts.get('debounce', 10))
def __init__(self, addr='192.168.1.1', period=3, **opts): HilgaObject.__init__(self, **opts) self.status = { "pppState": -1, "evdoLevel": 0, "sysinfo": [-1, -1, -1, -1, -1, -1] } self.script_name = "status.asp" self.d100_addr = addr self.period = period self.get_status() self.pool.spawn_n(self.loop_d100)
def __init__(self, period=0.5, nsamples=10, **opts): HilgaObject.__init__(self, **opts) self.period = period self.samples = [] self.analog = 0 # analog value [<TANK_EMPTY>..<TANK_FULL>] self.litres = 0 self.percents = 0 self.bus = smbus.SMBus(0) self.get_status() self.pool.spawn_n(self.loop_status)
def __init__(self, pin_a, pin_b, pin_sw=None, **opts): """Connect A/B to digital pins and common to the GND. Options ~~~~~~~ min_pos - minimal rotary position (default=unlimited) max_pos - maximal rotary position (default=unlimited) position - initial rotary position debounce - debounce time (default=10)""" HilgaObject.__init__(self, **opts) # self.hm = HilgaMixer() self.min_pos = opts.get('min_pos', None) self.max_pos = opts.get('max_pos', None) self.position = opts.get('position', 0) self.pqueue = eventlet.Queue() self.pin_a = pin_a self.pin_b = pin_b self.pin_sw = pin_sw # Setup rotary pins GPIO.setup(self.pin_a, GPIO.IN, GPIO.PUD_UP) GPIO.setup(self.pin_b, GPIO.IN, GPIO.PUD_UP) self._levels = { pin_a: GPIO.input(self.pin_a), pin_b: GPIO.input(self.pin_b) } GPIO.add_event_detect(self.pin_a, GPIO.BOTH, callback=self.pin_pulse, bouncetime=self.opts.get('debounce', 10)) GPIO.add_event_detect(self.pin_b, GPIO.BOTH, callback=self.pin_pulse, bouncetime=self.opts.get('debounce', 10)) # Setup switch pin if self.pin_sw: GPIO.setup(self.pin_sw, GPIO.IN) #, GPIO.PUD_UP) GPIO.add_event_detect(self.pin_sw, GPIO.BOTH, callback=self.pin_switch, bouncetime=120)
def __init__(self, control='PCM', **opts): HilgaObject.__init__(self, **opts) self.mixer_hndl = c_void_p() self.mixer_sid = c_void_p() ASND.snd_mixer_open(byref(self.mixer_hndl), 0) ASND.snd_mixer_attach(self.mixer_hndl, "hw:0") ASND.snd_mixer_selem_register(self.mixer_hndl, 0, 0) ASND.snd_mixer_load(self.mixer_hndl) ASND.snd_mixer_selem_id_malloc(byref(self.mixer_sid)) ASND.snd_mixer_selem_id_set_index(self.mixer_sid, 0) ASND.snd_mixer_selem_id_set_name(self.mixer_sid, control) self.mixer_elem = ASND.snd_mixer_find_selem(self.mixer_hndl, self.mixer_sid) pmin = c_long(0) pmax = c_long(0) ASND.snd_mixer_selem_get_playback_dB_range(self.mixer_elem, byref(pmin), byref(pmax)) self.db_min = pmin.value self.db_max = pmax.value
def __init__(self, port="/dev/usbobd", **opts): HilgaObject.__init__(self, **opts) self.portname = port self.connect()