) # MAIN LOOP ---------------------------------------------------------------- LAST_POSITION = ENCODER.position MODE = 1 while True: POSITION = ENCODER.position if POSITION != LAST_POSITION: MOVE = POSITION - LAST_POSITION if cp.switch: FPS = max(MIN_FPS, min(FPS + MOVE, MAX_FPS)) SPEED = 1.0 / FPS CRYSTAL_COMET.speed = SPEED #RAINBOW.speed = SPEED #CP_RAINBOW.speed = SPEED print("crystal speed = ", SPEED) else: BRIGHTNESS = max(MIN_BRIGHTNESS, min(BRIGHTNESS + MOVE, MAX_BRIGHTNESS)) LEVEL = BRIGHTNESS * 0.1 if LEVEL > 2: LEVEL = 2 cp.pixels.brightness = LEVEL/2 PIXEL_MAP_RINGS.brightness = LEVEL/2 PIXEL_MAP_CRYSTALS.brightness = LEVEL print("ring brightness = ", LEVEL/2, "crystal brightness = ", LEVEL) LAST_POSITION = POSITION if not BUTTON_VALUE and BUTTON_STATE is None:
) # MAIN LOOP ---------------------------------------------------------------- LAST_POSITION = ENCODER.position MODE = 1 while True: POSITION = ENCODER.position if POSITION != LAST_POSITION: MOVE = POSITION - LAST_POSITION if cp.switch: FPS = max(MIN_FPS, min(FPS + MOVE, MAX_FPS)) SPEED = 1.0 / FPS COMET.speed = SPEED print("comet speed = ", SPEED) else: BRIGHTNESS = max(MIN_BRIGHTNESS, min(BRIGHTNESS + MOVE, MAX_BRIGHTNESS)) LEVEL = BRIGHTNESS * 0.1 if LEVEL > 1: LEVEL = 1 cp.pixels.brightness = LEVEL PIXELS.brightness = LEVEL print("brightness = ", LEVEL) LAST_POSITION = POSITION if not BUTTON_VALUE and BUTTON_STATE is None: BUTTON_STATE = "pressed" if BUTTON_VALUE and BUTTON_STATE == "pressed": print("Button pressed.")