Skip to content

Commit 9994021

Browse files
committed
a few fixes
1 parent 9e35273 commit 9994021

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

CLUE_BBQ/clue_bbq.py

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Adafruit BBQ display works with ibbq protocol-based BLE temperature probes
22

3-
43
import time
54

65
import displayio
@@ -18,19 +17,19 @@
1817
temperatures_screen = displayio.Group(max_size=2)
1918

2019
# define custom colors
21-
GREEN = 0x00d929
22-
BLUE = 0x0000ff
23-
RED = 0xff0000
24-
ORANGE = 0xff6a00
25-
YELLOW = 0xffff00
26-
PURPLE = 0xe400ff
27-
BLACK = 0x000000
28-
WHITE = 0xffffff
29-
BURNT = 0xbb4e00
20+
GREEN = 0x00D929
21+
BLUE = 0x0000FF
22+
RED = 0xFF0000
23+
ORANGE = 0xFF6A00
24+
YELLOW = 0xFFFF00
25+
PURPLE = 0xE400FF
26+
BLACK = 0x000000
27+
WHITE = 0xFFFFFF
28+
BURNT = 0xBB4E00
3029

3130
unit_mode = False # set the temperature unit_mode. True = centigrade, False = farenheit
3231

33-
# background fill
32+
# Setup homescreen
3433
color_bitmap = displayio.Bitmap(120, 120, 1)
3534
color_palette = displayio.Palette(1)
3635
color_palette[0] = BURNT
@@ -44,33 +43,33 @@
4443

4544

4645
title_font = bitmap_font.load_font("/font/GothamBlack-50.bdf")
47-
title_font.load_glyphs("BQLUE".encode('utf-8'))
46+
title_font.load_glyphs("BQLUE".encode("utf-8"))
4847
title_label = label.Label(title_font, text="BBQLUE", color=clue.ORANGE, max_glyphs=15)
4948
title_label.x = 12
5049
title_label.y = 120
5150
homescreen_screen.append(title_label)
5251

5352
clue.display.show(homescreen_screen)
5453

55-
54+
# Setup temperatures screen
5655
temp_font = bitmap_font.load_font("/font/GothamBlack-25.bdf")
57-
temp_font.load_glyphs("0123456789FC.-<".encode('utf-8'))
56+
temp_font.load_glyphs("0123456789FC.-<".encode("utf-8"))
5857

59-
my_labels_config = [(0, "", GREEN, 2, 100),
60-
(1, "", BLUE, 2, 150),
61-
(2, "", RED, 2, 200),
62-
(3, "", ORANGE, 135, 100),
63-
(4, "", YELLOW, 135, 150),
64-
(5, "", PURPLE, 135, 200)
65-
]
58+
my_labels_config = [
59+
(0, "", GREEN, 2, 100),
60+
(1, "", BLUE, 2, 150),
61+
(2, "", RED, 2, 200),
62+
(3, "", ORANGE, 135, 100),
63+
(4, "", YELLOW, 135, 150),
64+
(5, "", PURPLE, 135, 200),
65+
]
6666

6767
my_labels = {} # dictionary of configured my_labels
6868

6969
text_group = displayio.Group(max_size=8, scale=1)
7070

7171
for label_config in my_labels_config:
7272
(name, text, color, x, y) = label_config # unpack a tuple into five var names
73-
# old way sould have been: name = label_config[0], text = label_config[1]
7473
templabel = label.Label(temp_font, text=text, color=color, max_glyphs=15)
7574
templabel.x = x
7675
templabel.y = y
@@ -79,7 +78,9 @@
7978

8079
temperatures_screen.append(text_group)
8180

82-
temp_title_label = label.Label(title_font, text="BBQLUE", color=clue.ORANGE, max_glyphs=15)
81+
temp_title_label = label.Label(
82+
title_font, text="BBQLUE", color=clue.ORANGE, max_glyphs=15
83+
)
8384
temp_title_label.x = 12
8485
temp_title_label.y = 30
8586
temperatures_screen.append(temp_title_label)
@@ -122,27 +123,28 @@
122123

123124
temps = ibbq_service.temperatures
124125
batt = ibbq_service.battery_level
125-
if temps is not None:
126+
if temps != None:
126127
probe_count = len(temps) # check how many probes there are
127128
for i in range(probe_count):
128-
if (temps[i] is not 0 and temps[i] < 1000): # unplugged probes
129+
if temps[i] is not 0 and temps[i] < 1000: # unplugged probes
129130
if unit_mode:
130131
clue.pixel.fill((50, 0, 0))
131132
temp = temps[i]
132133
my_labels[i].text = "{} C".format(temp)
133134
clue.pixel.fill((0, 0, 0))
134-
print("Probe", i+1, "Temperature:", temp,"C",)
135+
print("Probe", i + 1, "Temperature:", temp, "C")
135136
else: # F
136137
clue.pixel.fill((50, 0, 0))
137138
temp = temps[i] * 9 / 5 + 32
138139
my_labels[i].text = "{} F".format(temp)
139140
clue.pixel.fill((0, 0, 0))
140-
print("Probe", i+1, "Temperature:", temp,"F",)
141+
print("Probe", i + 1, "Temperature:", temp, "F")
141142
else:
142-
print("Probe", i+1, "is unplugged",)
143-
my_labels[i].text = (" ---")
143+
print(
144+
"Probe", i + 1, "is unplugged",
145+
)
146+
my_labels[i].text = " ---"
144147
clue.display.show(temperatures_screen)
145148

146149
except _bleio.ConnectionError:
147-
# Redisplay splash screen here, or put it at top of while True:
148150
continue

0 commit comments

Comments
 (0)