Modifications

Sauter à la navigation Sauter à la recherche
Ligne 89 : Ligne 89 :  
== Afficher la température sur la matrice LED ==
 
== Afficher la température sur la matrice LED ==
   −
Think about how you could show the temperature information on the LED matrix in some way (see the LED Matrix guide for more information). The obvious choice would be to use the show_message function, but, while this would work, there are probably better ways to do it. For example, you could:
+
Think about how you could show the temperature information on the LED matrix in some way (voyez [[RASP-SENSE-HAT-ASTRO-PI-Matrice|le guide consacré à la Matrice LED pour plus d'information]]). The obvious choice would be to use the show_message function, but, while this would work, there are probably better ways to do it. For example, you could:
    
* Use the {{fname|clear}} function to display some predefined colours based on ranges that the temperature falls in. For example 0 to 5 degrees could be blue?
 
* Use the {{fname|clear}} function to display some predefined colours based on ranges that the temperature falls in. For example 0 to 5 degrees could be blue?
Ligne 114 : Ligne 114 :  
           for y in range(temp, 8):
 
           for y in range(temp, 8):
 
               sense.set_pixel(x, y, 0, 0, 0)</nowiki>
 
               sense.set_pixel(x, y, 0, 0, 0)</nowiki>
 +
 +
It works by subtracting the minimum value from the measured value which should give a number between 0 and 8. We then use two nested {{fname|for}} loops. The outer loop is for the {{fname|x}} axis and the two inner loops are for the {{fname|y}} axis. We use two loops here because we want to turn all the LEDs below the measurement red with {{fname|set_pixel}} and those above it off. That way the bar will appear to move up and down the y axis following the measured temperature.
 +
 +
Remember that you can use {{fname|sense.set_rotation(n)}} (where n is 0, 90, 180 or 270) at the start of the program just after {{fname|sense.clear()}} if you want to change the orientation of the bar.
    
{{RASP-SENSE-HAT-ASTRO-PI-TRAILER}}
 
{{RASP-SENSE-HAT-ASTRO-PI-TRAILER}}
29 918

modifications

Menu de navigation