|
15 | 15 | from adafruit_ticks import ticks_ms, ticks_add, ticks_diff
|
16 | 16 | from rainbowio import colorwheel
|
17 | 17 |
|
18 |
| -COLOR = (255, 150, 0) # yellow |
| 18 | +COLOR = (255, 150, 0) # yellow |
19 | 19 | OFF = (0, 0, 0)
|
20 | 20 | PIXEL_PIN = board.A0
|
21 | 21 | NUM_PIXELS = 6
|
22 |
| -timers = [6, 10, 15, 20, 25, 30] # minutes |
23 |
| -color_time = 20 # milliseconds |
| 22 | +timers = [6, 10, 15, 20, 25, 30] # minutes |
| 23 | +color_time = 20 # milliseconds |
24 | 24 |
|
25 | 25 | # rotary encoder
|
26 | 26 | i2c = board.STEMMA_I2C()
|
|
36 | 36 | pixels.fill(OFF)
|
37 | 37 | pixels.show()
|
38 | 38 |
|
39 |
| -#display setup |
| 39 | +# display setup |
40 | 40 | displayio.release_displays()
|
41 | 41 |
|
42 | 42 | # oled
|
|
46 | 46 | HEIGHT = 64
|
47 | 47 | display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=WIDTH, height=HEIGHT)
|
48 | 48 |
|
49 |
| -font = bitmap_font.load_font('/Arial-14.bdf') |
| 49 | +font = bitmap_font.load_font("/Arial-14.bdf") |
50 | 50 | main_area = label.Label(font, text="6 Minutes", color=0xFFFFFF)
|
51 | 51 | main_area.anchor_point = (0.5, 0.0)
|
52 |
| -main_area.anchored_position = (display.width / 2, display.height/2) |
| 52 | +main_area.anchored_position = (display.width / 2, display.height / 2) |
53 | 53 | splash = displayio.Group()
|
54 | 54 | splash.append(main_area)
|
55 | 55 | display.root_group = splash
|
56 | 56 |
|
57 | 57 | timer_index = 0
|
58 | 58 | timer = timers[timer_index]
|
59 |
| -time_remaining = timer*60000 |
| 59 | +time_remaining = timer * 60000 |
60 | 60 | active_timer = False
|
61 | 61 | timer_clock = ticks_ms()
|
62 | 62 | color_clock = ticks_ms()
|
|
94 | 94 | remaining //= 60
|
95 | 95 | mins_remaining = remaining % 60
|
96 | 96 | if time_remaining > 0:
|
97 |
| - mapped_time = simpleio.map_range(time_remaining, 0, (timer*60000), 0, NUM_PIXELS+1) |
98 |
| - if mapped_time < 1 : |
| 97 | + mapped_time = simpleio.map_range( |
| 98 | + time_remaining, 0, (timer * 60000), 0, NUM_PIXELS + 1 |
| 99 | + ) |
| 100 | + if mapped_time < 1: |
99 | 101 | mapped_time = 1
|
100 | 102 | if int(mapped_time) != last_map:
|
101 | 103 | pixels.fill(OFF)
|
|
0 commit comments