Skip to content

Commit 426f1cb

Browse files
author
Kostadin
committed
Fixed graphing problem for PMS5003 results
The PMS5003 library returns integers. This causes the current formula for color scaling of the graph to not work properly because of integer division instead of float division. Converting the PMS5003 results from int to float solves the problem.
1 parent bca0449 commit 426f1cb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

examples/all-in-one.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def get_cpu_temperature():
201201
except pmsReadTimeoutError:
202202
logging.warn("Failed to read PMS5003")
203203
else:
204-
data = data.pm_ug_per_m3(1.0)
204+
data = float(data.pm_ug_per_m3(1.0))
205205
display_text(variables[mode], data, unit)
206206

207207
if mode == 8:
@@ -212,7 +212,7 @@ def get_cpu_temperature():
212212
except pmsReadTimeoutError:
213213
logging.warn("Failed to read PMS5003")
214214
else:
215-
data = data.pm_ug_per_m3(2.5)
215+
data = float(data.pm_ug_per_m3(2.5))
216216
display_text(variables[mode], data, unit)
217217

218218
if mode == 9:
@@ -223,7 +223,7 @@ def get_cpu_temperature():
223223
except pmsReadTimeoutError:
224224
logging.warn("Failed to read PMS5003")
225225
else:
226-
data = data.pm_ug_per_m3(10)
226+
data = float(data.pm_ug_per_m3(10))
227227
display_text(variables[mode], data, unit)
228228

229229
# Exit cleanly

0 commit comments

Comments
 (0)