Better management of data to display
This commit is contained in:
parent
4b9885d7a7
commit
c62ad455ba
@ -76,13 +76,6 @@ def on_message(client, userdata, msg):
|
||||
payload = msg.payload.decode()
|
||||
val = json.loads(payload)
|
||||
|
||||
#Is value consistent ?
|
||||
try:
|
||||
val['value'] = float(val['value'] )
|
||||
except:
|
||||
print("Value error: {}".format(val['value']))
|
||||
val['value'] = float('nan')
|
||||
|
||||
#Manage special character "degree"
|
||||
val['unit'] = val['unit'].replace('deg', '°')
|
||||
|
||||
@ -92,8 +85,19 @@ def on_message(client, userdata, msg):
|
||||
'AP' : (1, data2_line),
|
||||
'VBAT' : (inkyphat.WIDTH / 2 + 12, data2_line),
|
||||
}
|
||||
|
||||
print(val)
|
||||
if val['type'] in coord_type:
|
||||
|
||||
#Manage special character "degree"
|
||||
val['unit'] = val['unit'].replace('deg', '°')
|
||||
#Is value consistent ?
|
||||
try:
|
||||
val['value'] = float(val['value'] )
|
||||
except:
|
||||
print("Value error: {}".format(val['value']))
|
||||
val['value'] = float('nan')
|
||||
|
||||
#Erase old data
|
||||
inkyphat.rectangle(coord_type[val['type']] + (coord_type[val['type']][0] + inkyphat.WIDTH / 2 - 2,
|
||||
coord_type[val['type']][1] + 16),
|
||||
@ -104,13 +108,9 @@ def on_message(client, userdata, msg):
|
||||
font=data_font,
|
||||
fill=black)
|
||||
new_data_flag = True
|
||||
update_display()
|
||||
|
||||
# Print feather's date and time on epaper display
|
||||
elif subtopics[0] == "SYS":
|
||||
payload = msg.payload.decode()
|
||||
val = json.loads(payload)
|
||||
if val['type'] == "TIME":
|
||||
elif val['type'] == "TIME":
|
||||
try:
|
||||
#Check the date and time and offset to the right timezone
|
||||
dt_texte = datetime.strftime(datetime.strptime(val['value'], "%Y/%m/%d_%H:%M:%S") + TimeZone.utcoffset(None),
|
||||
@ -123,7 +123,7 @@ def on_message(client, userdata, msg):
|
||||
# and draw the new date
|
||||
inkyphat.text((0, 31), dt_texte, font=font12, fill=black)
|
||||
new_data_flag = True
|
||||
update_display()
|
||||
|
||||
|
||||
def on_message_camera(client, userdata, msg):
|
||||
"""Update display with info from camera (camera shooting new picture or name
|
||||
|
Loading…
Reference in New Issue
Block a user