WIO Terminal part 2 It’s hard to believe that this is the 24th MicroThisMicroThat! Time does fly when you are having fun (or just when you are old). Back in FCM#196, I wrote my first article on the Seeed Studio. Since MicroPython has upped their versions for all the various boards they support, I thought I’d try to update my little Wio terminal and re-test the program that I had written to see if it still worked. Just so you know, this was after the above-mentioned article, and I just never had a good chance to talk about it. Now, just a little background on writing to the Wio screen. It isn’t as easy as the normal screen output for, let’s say, a ssd1306. Remember, drivers try to be fairly generic in nature, while still being able to take as much advantage of the abilities of the display as possible. The driver for the ili9341 is no exception. As you saw in my article in FCM #196, this driver not only handles lines, circles, single pixels, and blocks, it also handles text. It even handles many font definitions for different text output to the screen.
Terminal WIO partie 2
Il est difficile de croire qu'il s'agit du 24e article de Micro-ci micro-là ! Le temps passe vite quand on s'amuse (ou quand on est vieux).
Dans le FCM n° 196, j'ai écrit mon premier article sur le Seeed Studio. Depuis que MicroPython a augmenté ses versions pour les différentes cartes qu'il supporte, j'ai pensé essayer de mettre à jour mon petit terminal WIO et de re-tester le programme que j'avais écrit pour voir s'il fonctionnait toujours. Pour votre information, c'était après l'article mentionné ci-dessus et je n'ai jamais eu l'occasion d'en parler.
Maintenant, un petit rappel concernant l'écriture sur l'écran WIO. Ce n'est pas aussi facile que la sortie écran normale pour, disons, un ssd1306.
Rappelez-vous que les pilotes essaient d'être assez génériques, tout en étant capables de tirer le meilleur parti possible des capacités de l'écran. Le pilote pour l'ili9341 ne fait pas exception. Comme vous l'avez vu dans mon article du FCM n° 196, ce pilote ne gère pas seulement les lignes, les cercles, les pixels simples et les blocs, il gère aussi le texte. Il gère même de nombreuses définitions de polices pour différentes sorties de texte à l'écran.
Start by updating your Micropython firmware to version v1.21.0. You can download it at https://micropython.org/download/SEEED_WIO_TERMINAL/ Next, make sure you have the latest version of the LCD driver. This you can get from https://github.com/rdagger/micropython-ili9341/blob/master/ili9341.py For this article, we’ll focus on demonstrating the 8×8 default Micropython font. We’ll look at using different fonts in a later article. We’ll name this program “demo_text8x8.py”. Of course, we need to do the imports (top right)… Now we must define the backlight pin (below) and the spi object. After that, we can initialize the display object. Notice, if you are going to use the demo programs from the ili9341 driver website, you will need to change the spi assignments as I’ve done here. Also notice that we start the display with a default rotation of 90. This puts the display in (what I consider) the correct orientation, which is with the USB Cable at the bottom of the Wio terminal. We will send other rotation orientations near the end of the demo.
Commencez par mettre à jour votre microprogramme Micropython à la version v1.21.0. Vous pouvez la télécharger à l'adresse suivante : https://micropython.org/download/SEEED_WIO_TERMINAL/
Ensuite, assurez-vous d'avoir la dernière version du pilote LCD. Vous pouvez l'obtenir à l'adresse suivante : https://github.com/rdagger/micropython-ili9341/blob/master/ili9341.py
Pour cet article, nous nous concentrerons sur la démonstration de la police 8×8 par défaut de Micropython. Nous aborderons l'utilisation d'autres polices dans un article ultérieur.
Nous nommerons ce programme « demo_text8x8.py ».
Bien sûr, nous devons faire les importations (en haut à droite).
Nous devons maintenant définir la broche de rétroéclairage (ci-dessous) et l'objet spi. Après cela, nous pouvons initialiser l'objet display. Notez que si vous utilisez les programmes de démonstration du site Web du pilote ili9341, vous devrez changer les assignations spi comme je l'ai fait ici. Notez également que nous démarrons l'affichage avec une rotation par défaut de 90 °. Cela place l'écran dans (ce que je considère être) l'orientation correcte, c'est-à-dire avec le câble USB en bas du terminal WIO. Nous proposerons d'autres orientations de rotation vers la fin de la démo.
Next, we need to do some startup assignments (next page, bottom left). Be sure to make a call to backlight.on(). Otherwise you won’t see anything on the display (and do a backlight.off() when everything is finished) . Now we can start sending text to the display through the draw_text8x8() method of the display driver (right). Finally, we set the time that the display will be on, call the cleanup() method of the display, and turn off the backlight. The last thing we do is call the test function. sleep(15) display.cleanup() backlight.off() test() That’s it. I’ve set up another repository at my github repository site https://github.com/gregwa1953/MTMT-FCM-199 . Until next time, as always; stay safe, healthy, positive and creative!
Ensuite, nous devons effectuer quelques tâches de démarrage (page suivante, en bas à gauche). Veillez à appeler backlight.on(). Sinon, vous ne verrez rien sur l'écran (et faites un backlight.off() lorsque tout est terminé).
Nous pouvons maintenant commencer à envoyer du texte à l'écran grâce à la méthode draw_text8x8() du pilote d'affichage (à droite).
Enfin, nous fixons la durée d'affichage, appelons la méthode cleanup() de l'écran et éteignons le rétroéclairage. La dernière chose que nous faisons est d'appeler la fonction de test :
sleep(15) display.cleanup() backlight.off()
test()
Voilà, c'est tout.
J'ai mis en place un autre dépôt sur mon site github https://github.com/gregwa1953/MTMT-FCM-199.
Jusqu'à la prochaine fois, comme toujours, restez en sécurité, en bonne santé, positifs et créatifs !
Encart p 35 en haut à droite ; lignes noires
Once we've sent out the base text, we can start drawing text at the 0,90,180,270 orientations of the display. Une fois que nous avons envoyé le texte de base, nous pouvons débuter le dessin du texte avec des orientations d'affichage de 0, 90,180, 270.
Next, the text is drawn with a background. Ensuite, le texte est dessiné avec un fond.