|
23 | 23 |
|
24 | 24 | pixels = NeoPixel(NEOPIXEL, 1) # Set up built-in NeoPixel |
25 | 25 |
|
26 | | -AQUA = const(0x00FFFF) # (0, 255, 255) |
27 | | -GREEN = const(0x00FF00) # (0, 255, 0) |
| 26 | +AQUA = const(0x00FFFF) # (0, 255, 255) |
| 27 | +GREEN = const(0x00FF00) # (0, 255, 0) |
28 | 28 | ORANGE = const(0xFF8000) # (255, 128, 0) |
29 | | -RED = const(0xFF0000) # (255, 0, 0) |
30 | | -BLUE = const(0x0000FF) # (0, 0, 255) |
| 29 | +RED = const(0xFF0000) # (255, 0, 0) |
| 30 | +BLUE = const(0x0000FF) # (0, 0, 255) |
31 | 31 |
|
32 | | -gradients = {'Off': [(0.0, RED), (0.75, ORANGE)], |
33 | | - 'On': [(0.0, GREEN), (1.0, AQUA)]} |
34 | | -palette = fancy.expand_gradient(gradients['Off'], 30) |
| 32 | +gradients = {"Off": [(0.0, RED), (0.75, ORANGE)], "On": [(0.0, GREEN), (1.0, AQUA)]} |
| 33 | +palette = fancy.expand_gradient(gradients["Off"], 30) |
35 | 34 |
|
36 | 35 | gamma_levels = (0.25, 0.3, 0.15) |
37 | 36 | color_index = 1 |
38 | 37 | fade_direction = 1 |
39 | 38 |
|
40 | | -TARGET = 'f0:74:72:60:87:d2' # CHANGE TO YOUR BLE ADDRESS |
| 39 | +TARGET = "f0:74:72:60:87:d2" # CHANGE TO YOUR BLE ADDRESS |
41 | 40 | target_address = TARGET.split(":") # Convert address string to list of bytes |
42 | 41 | target_address.reverse() # Reverse bytes to match Address class little-endian |
43 | | -target_address = unhexlify(''.join(target_address)) # Convert list to bytes |
| 42 | +target_address = unhexlify("".join(target_address)) # Convert list to bytes |
44 | 43 |
|
45 | 44 | button_packet = ButtonPacket("1", True) # Transmits pressed button 1 |
46 | 45 |
|
|
80 | 79 | # Color match |
81 | 80 | if fancy.CRGB(*packet.color).pack() == GREEN: |
82 | 81 | # Green indicates on state |
83 | | - palette = fancy.expand_gradient(gradients['On'], 30) |
| 82 | + palette = fancy.expand_gradient(gradients["On"], 30) |
84 | 83 | else: |
85 | 84 | # Otherwise red indicates off |
86 | | - palette = fancy.expand_gradient(gradients['Off'], 30) |
| 85 | + palette = fancy.expand_gradient(gradients["Off"], 30) |
87 | 86 |
|
88 | 87 | # NeoPixel color fading routing |
89 | 88 | color = fancy.palette_lookup(palette, color_index / 29) |
|
0 commit comments