Ligne 121 : |
Ligne 121 : |
| | | |
| Vous pouvez également noter l'importation de quelques éléments de la bibliothèque'' '''P'''ython '''I'''maging '''L'''ibrary'' comme '''Image''', '''ImageDraw''' et '''ImageFont'''. Comme vous pouvez l'imaginer, ces éléments servirons a dessiner des images, des formes et du texte/font! | | Vous pouvez également noter l'importation de quelques éléments de la bibliothèque'' '''P'''ython '''I'''maging '''L'''ibrary'' comme '''Image''', '''ImageDraw''' et '''ImageFont'''. Comme vous pouvez l'imaginer, ces éléments servirons a dessiner des images, des formes et du texte/font! |
| + | |
| + | Ci dessous les différentes valeurs de configuration et classe pour les afficheurs OLED. Il y a 4 variantes d'afficheur OLED, avec 128x32 pixels ou 128x64 pixels -ET- avec I2C ou avec SPI. |
| | | |
| <syntaxhighlight lang="python"> | | <syntaxhighlight lang="python"> |
Ligne 156 : |
Ligne 158 : |
| </syntaxhighlight> | | </syntaxhighlight> |
| | | |
− | Below the configuration values is the display class setup. There are 4 variants of OLED displays, with 128x32 pixels or 128x64 pixels, and with I2C or with SPI.
| + | Etant donné que l'afficheur PiOLED est un afficheur OLED 128x32 sur bus (uniquement), vous devez uniquement utiliser le code: |
| | | |
− | However since the PiOLED is a 128x32 I2C display ''only'' you should only use the
| + | <syntaxhighlight lang="python"> |
− | | + | # afficheur 128x32 avec bus I2C matériel: |
− | <code># 128x32 display with hardware I2C:</code><br><code>disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST)</code> | + | disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST) |
| + | </syntaxhighlight> |
| | | |
− | variant for creating the display object! The rest can remain commented out.
| + | Le restant du code peut rester en commentaire. |
| | | |
− | Note that above, we initialize <code>RST = None</code> because the PiOLED does not require a reset pin.
| + | Notez que ci-dessus, nous avons initialisé {{fname|RST = None}} parce que le PiOLED ne nécessite pas l'utilisation de la broche "reset". |
| | | |
| <syntaxhighlight lang="python"> | | <syntaxhighlight lang="python"> |
− | # Initialize library. | + | # initialiser la bibliothèque d'affichage. |
| disp.begin() | | disp.begin() |
| | | |
− | # Clear display. | + | # Effacer l'affichage. |
| disp.clear() | | disp.clear() |
| disp.display() | | disp.display() |
| | | |
− | # Create blank image for drawing. | + | # Créer une image vierge pour dessiner dessus. |
− | # Make sure to create image with mode '1' for 1-bit color. | + | # L'image doit être créé avec mode '1' (couleur 1-bit). |
| width = disp.width | | width = disp.width |
| height = disp.height | | height = disp.height |
| image = Image.new('1', (width, height)) | | image = Image.new('1', (width, height)) |
| | | |
− | # Get drawing object to draw on image. | + | # Obtenir un objet ImageDraw (dessiner sur l'image) |
| + | # pour l'image. |
| draw = ImageDraw.Draw(image) | | draw = ImageDraw.Draw(image) |
| | | |
− | # Draw a black filled box to clear the image. | + | # Dessiner un rectangle noir (rempli) pour effacer |
| + | # le fond de l'image (sinon cela allumera les Pixels). |
| draw.rectangle((0,0,width,height), outline=0, fill=0) | | draw.rectangle((0,0,width,height), outline=0, fill=0) |
| </syntaxhighlight> | | </syntaxhighlight> |
| | | |
| + | {{traduction}} |
| The next bit of code will initialize the display library with <code>begin()</code> and clear the display with <code>clear()</code>and <code>display()</code>. | | The next bit of code will initialize the display library with <code>begin()</code> and clear the display with <code>clear()</code>and <code>display()</code>. |
| | | |