Skip to content

Commit b30c184

Browse files
committed
amg88xx_rpi_thermal_cam_console.py reformated
1 parent 336be94 commit b30c184

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

examples/amg88xx_rpi_thermal_cam_console.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,39 @@
3636
# create the array of colors
3737
COLORS = [(int(c.red * 255), int(c.green * 255), int(c.blue * 255)) for c in COLORS]
3838
CONSOLE_COLORS = [
39-
17, 18, 19, 20, 21, 57, 93, 129, 165, 201, 200,
40-
199, 198, 197, 196, 202, 208, 214, 220]
39+
17,
40+
18,
41+
19,
42+
20,
43+
21,
44+
57,
45+
93,
46+
129,
47+
165,
48+
201,
49+
200,
50+
199,
51+
198,
52+
197,
53+
196,
54+
202,
55+
208,
56+
214,
57+
220,
58+
]
59+
4160

4261
def map_value(x_value, in_min, in_max, out_min, out_max):
4362
"""Maps value of the temperature to color"""
4463
return (x_value - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
4564

65+
4666
def print_there(console_x, console_y, text, color):
4767
""" Outputs a colored text to console at coordinates """
4868
sys.stdout.write("\x1b7\x1b[48;5;%dm" % (color))
4969
sys.stdout.write("\x1b7\x1b[%d;%df%s\x1b8" % (console_x, console_y, text))
5070

71+
5172
# let the sensor initialize
5273
time.sleep(0.1)
5374

@@ -73,12 +94,12 @@ def print_there(console_x, console_y, text, color):
7394
for jx, pixel in enumerate(row):
7495
color_index = 0
7596
if COLOR_RANGE != 0:
76-
color_index = int(round((pixel-MINPIXEL)/COLOR_RANGE))
97+
color_index = int(round((pixel - MINPIXEL) / COLOR_RANGE))
7798
if color_index < 0:
7899
color_index = 0
79-
if color_index > len(CONSOLE_COLORS)-1:
80-
color_index = len(CONSOLE_COLORS)-1
81-
print_there(x_console, Y_CONSOLE*2-2, ' ', CONSOLE_COLORS[color_index])
100+
if color_index > len(CONSOLE_COLORS) - 1:
101+
color_index = len(CONSOLE_COLORS) - 1
102+
print_there(x_console, Y_CONSOLE * 2 - 2, " ", CONSOLE_COLORS[color_index])
82103
if pixel > MAXPIXEL:
83104
MAXPIXEL = pixel
84105
if pixel < MINPIXEL:

0 commit comments

Comments
 (0)