What I do on my sense hat is get the value just before I show it in the message. Then wash rinse and repeat.
while True:
dateString = "%A %B %-d %-I:%M:%p"
msg = "It is %s" % (datetime.datetime.now().strftime(dateString))
sense.show_message(msg, scroll_speed=s, text_colour=(w, 255, 255))
t = sense.get_temperature()
t = round(t)
if t <= 0:
tc = [w, w, 255] # Blue
elif t > 0 and t < 13:
tc = [255, 255, w] # Yellow
elif t >= 13 and t <= 25:
tc = [w, 255, w] # Green
elif t > 25 and t < 30:
tc = [255, o, w] # Orange
elif t >= 30:
tc = [255, w, w] # Red
msg = "and %sc" % (t)
sense.show_message(msg, scroll_speed=s, text_colour=tc)
h = sense.get_humidity()
h = round(h)
if h < 0:
h = 0
if h > 100:
h = 100
if h < 30:
hc = [255, w, w] # Red
elif h >= 30 and h <= 60:
hc = [w, 255, w] # Green
elif h > 60 and h < 80:
hc = [255, 255, w] # Yellow
elif h >= 80:
hc = [255, w, w] # Red
msg = "with %s%% Humidity" % (h)
sense.show_message(msg, scroll_speed=s, text_colour=hc)
p = sense.get_pressure()
p = round(p)
if p > 0 and p < 982:
pc = [255, w, w] # Red
msg = "- Barometer is Very Low @ %smb - Storm Watch" % (p)
sense.show_message(msg, scroll_speed=s, text_colour=pc)
elif p >= 982 and p < 1004:
pc = [255, 255, w] # Yellow
msg = "- Barometer is Low @ %smb - Possible Percipitation" % (p)
sense.show_message(msg, scroll_speed=s, text_colour=pc)
elif p >= 1004 and p < 1026:
pc = [w, 255, w] # Green
msg = "- Barometer is Mid Range @ %smb" % (p)
sense.show_message(msg, scroll_speed=s, text_colour=pc)
elif p >= 1026 and p < 1048:
pc = [w, w, 255] # Blue
msg = "- Barometer is High @ %smb" % (p)
sense.show_message(msg, scroll_speed=s, text_colour=pc)
elif p >= 1048:
pc = [255, w, w] # Red
msg = "- Barometer is Very High @ %smb - Expect Dry Conditions" % (p)
sense.show_message(msg, scroll_speed=s, text_colour=pc)
For me, the next message won’t start until the current one ends. They just run one after the other, and being in the while true just endlessly repeats them. When it gets to the end of the last one, it starts over again from the top. My individual readings are taken right before the first if statement.