Skip to content

Commit 0b149bf

Browse files
authored
Merge pull request #53 from pimoroni/enviro-non-plus
Migrate to Python 3, Fix Assets
2 parents 02c9f28 + c8bf568 commit 0b149bf

36 files changed

+462
-121
lines changed

examples/adc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
import time
44
from enviroplus import gas

examples/all-in-one-no-pm.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
import time
44
import colorsys
@@ -18,6 +18,7 @@
1818
from PIL import Image
1919
from PIL import ImageDraw
2020
from PIL import ImageFont
21+
from fonts.ttf import RobotoMedium as UserFont
2122
import logging
2223

2324
logging.basicConfig(
@@ -52,7 +53,8 @@
5253
img = Image.new('RGB', (WIDTH, HEIGHT), color=(0, 0, 0))
5354
draw = ImageDraw.Draw(img)
5455
path = os.path.dirname(os.path.realpath(__file__))
55-
font = ImageFont.truetype(path + "/fonts/Asap/Asap-Bold.ttf", 20)
56+
font_size = 20
57+
font = ImageFont.truetype(UserFont, FontSize)
5658

5759
message = ""
5860

@@ -96,7 +98,7 @@ def get_cpu_temperature():
9698

9799
# Tuning factor for compensation. Decrease this number to adjust the
98100
# temperature down, and increase to adjust up
99-
factor = 0.8
101+
factor = 2.25
100102

101103
cpu_temps = [get_cpu_temperature()] * 5
102104

examples/all-in-one.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
import time
44
import colorsys
@@ -19,6 +19,7 @@
1919
from PIL import Image
2020
from PIL import ImageDraw
2121
from PIL import ImageFont
22+
from fonts.ttf import RobotoMedium as UserFont
2223
import logging
2324

2425
logging.basicConfig(
@@ -57,8 +58,8 @@
5758
# Set up canvas and font
5859
img = Image.new('RGB', (WIDTH, HEIGHT), color=(0, 0, 0))
5960
draw = ImageDraw.Draw(img)
60-
path = os.path.dirname(os.path.realpath(__file__))
61-
font = ImageFont.truetype(path + "/fonts/Asap/Asap-Bold.ttf", 20)
61+
font_size = 20
62+
font = ImageFont.truetype(UserFont, font_size)
6263

6364
message = ""
6465

@@ -102,7 +103,7 @@ def get_cpu_temperature():
102103

103104
# Tuning factor for compensation. Decrease this number to adjust the
104105
# temperature down, and increase to adjust up
105-
factor = 0.8
106+
factor = 2.25
106107

107108
cpu_temps = [get_cpu_temperature()] * 5
108109

examples/combined.py

100644100755
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
import time
44
import colorsys
@@ -19,6 +19,7 @@
1919
from PIL import Image
2020
from PIL import ImageDraw
2121
from PIL import ImageFont
22+
from fonts.ttf import RobotoMedium as UserFont
2223
import logging
2324

2425
logging.basicConfig(
@@ -57,9 +58,10 @@
5758
# Set up canvas and font
5859
img = Image.new('RGB', (WIDTH, HEIGHT), color=(0, 0, 0))
5960
draw = ImageDraw.Draw(img)
60-
path = os.path.dirname(os.path.realpath(__file__))
61-
font = ImageFont.truetype(path + "/fonts/Asap/Asap-Bold.ttf", 20)
62-
smallfont = ImageFont.truetype(path + "/fonts/Asap/Asap-Bold.ttf", 10)
61+
font_size_small = 10
62+
font_size_large = 20
63+
font = ImageFont.truetype(UserFont, font_size_large)
64+
smallfont = ImageFont.truetype(UserFont, font_size_small)
6365
x_offset = 2
6466
y_offset = 2
6567

@@ -166,7 +168,7 @@ def display_everything():
166168
draw.rectangle((0, 0, WIDTH, HEIGHT), (0, 0, 0))
167169
column_count = 2
168170
row_count = (len(variables)/column_count)
169-
for i in xrange(len(variables)):
171+
for i in range(len(variables)):
170172
variable = variables[i]
171173
data_value = values[variable][-1]
172174
unit = units[i]
@@ -175,7 +177,7 @@ def display_everything():
175177
message = "{}: {:.1f} {}".format(variable[:4], data_value, unit)
176178
lim = limits[i]
177179
rgb = palette[0]
178-
for j in xrange(len(lim)):
180+
for j in range(len(lim)):
179181
if data_value > lim[j]:
180182
rgb = palette[j+1]
181183
draw.text((x, y), message, font=smallfont, fill=rgb)
@@ -192,7 +194,7 @@ def get_cpu_temperature():
192194

193195
# Tuning factor for compensation. Decrease this number to adjust the
194196
# temperature down, and increase to adjust up
195-
factor = 1.95
197+
factor = 2.25
196198

197199
cpu_temps = [get_cpu_temperature()] * 5
198200

examples/compensated-temperature.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
import time
44
from bme280 import BME280
@@ -38,7 +38,7 @@ def get_cpu_temperature():
3838

3939
# Tuning factor for compensation. Decrease this number to adjust the
4040
# temperature down, and increase to adjust up
41-
factor = 0.8
41+
factor = 2.25
4242

4343
cpu_temps = [get_cpu_temperature()] * 5
4444

examples/fonts/Asap/Asap-Bold.ttf

-61.9 KB
Binary file not shown.
-64.5 KB
Binary file not shown.
-64.6 KB
Binary file not shown.
-61.3 KB
Binary file not shown.
-64.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)