Ejemplo n.º 1
0
    except AttributeError:
        print("Pibrella not initialized!")
    except NameError:
        print("Pibrella not initialized!")


atexit.register(pibrella_exit)
#atexit.register(lambda: pibrella.exit())

# Instance our Pibrella class
pibrella = Pibrella()

try:

    # Create an object containing our lights
    pibrella.light = ObjectCollection()
    pibrella.light._add(red=Light(PB_PIN_LIGHT_RED))
    pibrella.light._add(yellow=Light(PB_PIN_LIGHT_YELLOW))
    pibrella.light._add(green=Light(PB_PIN_LIGHT_GREEN))
    pibrella.light._alias(amber='yellow')
    pibrella.lights = pibrella.light

    # Create an object containing our inputs
    pibrella.input = ObjectCollection()
    pibrella.input._add(a=Input(PB_PIN_INPUT_A))
    pibrella.input._add(b=Input(PB_PIN_INPUT_B))
    pibrella.input._add(c=Input(PB_PIN_INPUT_C))
    pibrella.input._add(d=Input(PB_PIN_INPUT_D))
    pibrella.inputs = pibrella.input

    # Create an object contianing our outputs
Ejemplo n.º 2
0
_cap1208._write_byte(captouch.R_CONFIGURATION2,  0b01100000)
_cap1208.set_touch_delta(10)
    
import analog as _analog
if _analog.adc_available:
    print("Explorer HAT Pro detected...")
    explorer_pro = True
else:    
    print("Explorer HAT Basic detected...")
    print("If this is incorrect, please check your i2c settings!")
    explorer_pro = False

atexit.register(explorerhat_exit)

try:
    settings = ObjectCollection()
    settings._add(touch = CapTouchSettings())
 
    light = ObjectCollection()
    light._add(blue   = Light(LED1))
    light._add(yellow = Light(LED2))
    light._add(red    = Light(LED3))
    light._add(green  = Light(LED4))
    light._alias(amber = 'yellow')

    output = ObjectCollection()
    output._add(one   = Output(OUT1))
    output._add(two   = Output(OUT2))
    output._add(three = Output(OUT3))
    output._add(four  = Output(OUT4))
Ejemplo n.º 3
0
    def speed(self, speed=100):
        if speed > 100 or speed < -100:
            raise ValueError("Speed must be between -100 and 100")

        self._speed = speed
        if speed > 0:
            self.pwm_bw.ChangeDutyCycle(0)
            self.pwm_fw.ChangeDutyCycle(speed)
        if speed < 0:
            self.pwm_fw.ChangeDutyCycle(0)
            self.pwm_bw.ChangeDutyCycle(abs(speed))
        if speed == 0:
            self.pwm_fw.ChangeDutyCycle(0)
            self.pwm_bw.ChangeDutyCycle(0)

        return speed

    def stop(self):
        self.speed(0)

    def _add(self, **kwargs):
        for name in kwargs:
            self._add_single(name, kwargs[name])

    forward = forwards
    backward = backwards
    reverse = invert

motor = ObjectCollection()
motor._add(one=Motor(M1F, M1B))
motor._add(two=Motor(M2F, M2B))
Ejemplo n.º 4
0
if not _cap1208._get_product_id() == CAP_PRODUCT_ID:
    exit("Explorer HAT not found...\nHave you enabled i2c?")

import analog as _analog
if _analog.adc_available:
    print("Explorer HAT Pro detected...")
    explorer_pro = True
else:
    print("Explorer HAT Basic detected...")
    print("If this is incorrect, please check your i2c settings!")
    explorer_pro = False

atexit.register(explorerhat_exit)

try:
    settings = ObjectCollection()
    settings._add(touch=CapTouchSettings())

    light = ObjectCollection()
    light._add(blue=Light(LED1))
    light._add(yellow=Light(LED2))
    light._add(red=Light(LED3))
    light._add(green=Light(LED4))
    light._alias(amber='yellow')

    output = ObjectCollection()
    output._add(one=Output(OUT1))
    output._add(two=Output(OUT2))
    output._add(three=Output(OUT3))
    output._add(four=Output(OUT4))
Ejemplo n.º 5
0
_cap1208 = Cap1208()
if not _cap1208._get_product_id() == CAP_PRODUCT_ID:
    exit("Explorer HAT not found...\nHave you enabled i2c?")

if ads1015.adc_available:
    print("Explorer HAT Pro detected...")
    explorer_pro = True
else:
    print("Explorer HAT Basic detected...")
    print("If this is incorrect, please check your i2c settings!")
    explorer_pro = False

atexit.register(explorerhat_exit)

try:
    settings = ObjectCollection()
    settings._add(touch=CapTouchSettings())

    light = ObjectCollection()
    light._add(blue=Light(LED1))
    light._add(yellow=Light(LED2))
    light._add(red=Light(LED3))
    light._add(green=Light(LED4))
    light._alias(amber='yellow')

    output = ObjectCollection()
    output._add(one=Output(OUT1))
    output._add(two=Output(OUT2))
    output._add(three=Output(OUT3))
    output._add(four=Output(OUT4))