Beispiel #1
0
def tick():
	global wheelColour, ledcount, sequence, ledpin

	pin = pyb.Pin(ledpin)
	neo = pyb.Neopix(pin)

	leds = [0x000000] * ledcount

	if (sequence == "rainbow"):
		wheelColour = (wheelColour + 8) & 255
		for ledNumber in range(0, ledcount):
			pos = ((ledNumber*8)+wheelColour)
			pos = pos & 255
			leds[ledNumber] = Wheel(pos).get_neo()
	elif (sequence == "matrix"):
		for ledNumber in range(0, ledcount):
			led_green = (pyb.rng() & 255)
			led_colour = Colour(0, led_green, 0)
			if led_green < 230:
				led_colour.set_g(int(led_green / 8))
			if led_green > 253:
				led_colour.set_hex('#ffffff')
			leds[ledNumber] = led_colour.get_neo()
	elif (sequence == "colour"):
		colour = database.database_get("led-colour", "#ffffff")
		tmp_colour = Colour()
		tmp_colour.set_hex(colour)
		leds = [tmp_colour.get_neo()] * ledcount
	neo.display(leds)
Beispiel #2
0
    def __init__(self, config):

        # If green LED is enabled, configure it
        if config.get('green_led'):
            self.__green = pyb.LED(2)
        else:
            self.__green = None

        # If torch LED is enabled, configure it
        if config.get('torch_led'):
            self.__torch = pyb.Pin("LED_TORCH")
        else:
            self.__torch = None

        # If Neopixel is enabled, configure it
        if config.get('neopixel'):
            self.__neo_colour = self.__build_neo_colour(config)
            self.__neo = pyb.Neopix(machine.Pin("PB13", machine.Pin.OUT))
        else:
            self.__neo = None
Beispiel #3
0
# Finds all locally installed apps that have an external.py
def get_external_hook_paths():
    return [
        "%s/external" % app.folder_path for app in get_local_apps()
        if is_file("%s/external.py" % app.folder_path)
    ]


def low_power():
    ugfx.backlight(0)
    ugfx.power_mode(ugfx.POWER_OFF)


ugfx.init()
imu = IMU()
neo = pyb.Neopix(pyb.Pin("PB13"))
neo.display(0x04040404)
ledg = pyb.LED(2)
ival = imu.get_acceleration()
if ival['y'] < 0:
    ugfx.orientation(0)
else:
    ugfx.orientation(180)

buttons.init()
if not onboard.is_splash_hidden():
    splashes = ["splash1.bmp"]
    for s in splashes:
        ugfx.display_image(0, 0, s)
        delay = 2000
        while delay: