Modifications

Sauter à la navigation Sauter à la recherche
1 876 octets ajoutés ,  26 août 2015 à 13:57
Ligne 387 : Ligne 387 :     
     sense.show_message(msg, scroll_speed=0.05)</nowiki>
 
     sense.show_message(msg, scroll_speed=0.05)</nowiki>
 +
 +
'''2.''' Click "File -- Save As", give your program a name e.g. {{fname|env.py}}, then press '''F5''' to run.
 +
 +
'''3.''' You could now use some colour to let the astronauts know whether conditions are within sensible ranges.
 +
 +
According to some [http://wsn.spaceflight.esa.int/docs/Factsheets/30%20ECLSS%20LR.pdf online documentation] (''ESA, anglais''), the International Space Station maintains these conditions at the following levels:
 +
* Temperature (18.3 - 26.7 Celsius)
 +
* Pressure (979 - 1027 millibars)
 +
* Humidity (around 60%)
 +
 +
You could use an if statement in your code to check these conditions, and set a background colour for the scroll:
 +
 +
<nowiki>if t > 18.3 and t < 26.7:
 +
    bg = [0, 100, 0] # green
 +
else:
 +
    bg = [100, 0, 0] # red</nowiki>
 +
 +
Your complete program would look like this:
 +
 +
<nowiki>from sense_hat import SenseHat
 +
sense = SenseHat()
 +
 +
while True:
 +
    t = sense.get_temperature()
 +
    p = sense.get_pressure()
 +
    h = sense.get_humidity()
 +
 +
    t = round(t, 1)
 +
    p = round(p, 1)
 +
    h = round(h, 1)
 +
 +
    if t > 18.3 and t < 26.7:
 +
        bg = [0, 100, 0]  # green
 +
    else:
 +
        bg = [100, 0, 0]  # red
 +
 +
    msg = "Temperature = %s, Pressure=%s, Humidity=%s" % (t, p, h)
 +
 +
    sense.show_message(msg, scroll_speed=0.05, back_colour=bg)</nowiki>
 +
 +
'''4.''' Click "File -- Save As", give your program a name e.g. {{fname|scrolling_env.py}}, then press "F5" to run.
 +
 +
=== Idées ===
 +
* Currently, the scrolling program only warns about abnormal temperature. Can you add the same behaviour for pressure and humidity?
 +
* You could create a simple graphical thermometer which outputs different colours / patterns depending on the temperature.
 +
* If you haven't done so already, experiment with a bottle and the pressure sensor.
 +
 +
== Détecter les mouvements ==
 +
[[Fichier:hat-sense-banner-05.jpg]]
 +
 +
== Tout mettre ensemble ==
 +
[[Fichier:hat-sense-banner-06.jpg]]
 +
 
{{RASP-SENSE-HAT-ASTRO-PI-TRAILER}}
 
{{RASP-SENSE-HAT-ASTRO-PI-TRAILER}}
29 917

modifications

Menu de navigation