Outils pour utilisateurs

Outils du site


issue196:micro-ci_micro-la

OHHHHH WIIIIO … WIOOOOOO Greetings again, fellow beings. It’s me again, broadcasting from across the known universe! Awwww, ok. Not from across the known universe. From Central Texas, but it sounded kinda cool, huh? First, you might be wondering what the heck the title of this month’s article is, or if you figured it out already, why am I butchering the Castle Guard chant from the Wizard of Oz? (Ronnie says: extra point if you can name the Metallica song that uses that chant). It’s talking about the Wio Terminal from Seeed Studio (YES with all the “e’s” in Seeed). It’s a REALLY neat little device that has a HUGE amount of potential and has recently gotten micropython support.

OHHHHH WIIIIO … WIOOOOOO

Je vous salue à nouveau, chers amis. C'est encore moi, diffusant depuis l'univers connu !

Awwww, ok. Pas de l'autre côté de l'univers connu. Je viens du Texas central, mais ça avait l'air plutôt cool, hein ?

Tout d'abord, vous vous demandez peut-être quel est le titre de l'article de ce mois-ci ou, si vous l'avez déjà compris, pourquoi j'écorche le chant de la garde du château du Magicien d'Oz ? (Ronnie dit : point supplémentaire si vous pouvez citer la chanson de Metallica qui utilise ce chant).

Il s'agit du terminal Wio de Seeed Studio (OUI avec tous les « e » de Seeed).

C'est un petit appareil VRAIMENT sympa qui a un énorme potentiel et qui a récemment obtenu le support de micropython.

If you look REALLY close at the top of the image, you will see three little blue bumps on the left side of the device. That’s three user defined buttons. At the bottom-right of the device, there’s a four-way thumb pad that also can be depressed for a fifth button for a total of 8 buttons. The screen is a 2.4” 320×240 touchscreen and there is an onboard IMU(LIS3DHTR), microphone, buzzer, microSD card slot, light sensor, infrared emitter(IR 940nm) and more! In addition to all of that, there is a Raspberry Pi 40-pin Compatible GPIO female header on the back that should allow you to use any RPi that that you might have, if you happen to have Micropython drivers for them. One more thing of note (at the moment), the Wio has 512KB of Program memory, 4MB of External Flash memory, and has 192KB of ram.

Si vous regardez VRAIMENT de près en haut de l'image, vous verrez trois petites bosses bleues sur le côté gauche de l'appareil. Ce sont trois boutons définis par l'utilisateur. En bas à droite de l'appareil, il y a un pad à quatre directions qui peut également être enfoncé pour un cinquième bouton, pour un total de 8 boutons.

L'écran est un écran tactile de 2,4 pouces 320 x 240 et il y a un IMU (LIS3DHTR), un microphone, un buzzer, un emplacement pour carte microSD, un capteur de lumière, un émetteur infrarouge (IR 940nm) et bien d'autres choses encore !

En plus de tout cela, il y a un connecteur femelle Raspberry Pi 40 broches compatible GPIO à l'arrière qui devrait vous permettre d'utiliser n'importe quel RPi que vous pourriez avoir, s'ils ont des pilotes Micropython. Une dernière chose à noter (pour le moment), le Wio a 512 Ko de mémoire de programme, 4 Mo de mémoire Flash externe, et 192 Ko de ram.

There is also WiFi and bluetooth. I must admit that I don’t think the touchscreen interface, WiFi and bluetooth are working quite yet. I have also seen some comments that I2C and SPI don’t work well at this point, but I haven’t had a chance to test those yet. All of this for about $45 USD makes this a great little device to test out. So, let’s get started! Loading Micropython Before we can get started, we need to load Micropython onto the device. Go to https://micropython.org/download/SEEED_WIO_TERMINAL/ and download the latest nightly build. Next, plug the device into your computer using the USB Type-C connector. In a terminal type $ ls /dev/tty* This should show you all the tty ports and you should (by this point) be able to figure out which one the Wio is plugged into.

Il y a aussi le WiFi et le bluetooth. Je dois avouer que je ne pense pas que l'interface de l'écran tactile, le WiFi et le bluetooth fonctionnent pour le moment. J'ai également vu des commentaires selon lesquels I2C et SPI ne fonctionnent pas bien à ce stade, mais je n'ai pas encore eu l'occasion de les tester.

Tout cela pour environ 45 $ US, ce qui en fait un excellent petit appareil à tester. Alors, c'est parti !

Chargement de Micropython

Avant de commencer, nous devons charger Micropython sur l'appareil. Rendez-vous sur https://micropython.org/download/SEEED_WIO_TERMINAL/ et téléchargez la dernière « nightly build » version.

Ensuite, branchez l'appareil sur votre ordinateur à l'aide du connecteur USB Type-C. Dans un terminal, tapez :

$ ls /dev/tty*

Cela devrait vous montrer tous les ports tty et vous devriez (à ce stade) être en mesure de déterminer celui sur lequel le Wio est branché.

Now, here is the difficult part. You need to put the Wio into bootloader mode. The power switch on the left side of the device has three positions. Up is off, middle position is on, and down is a momentary position for reset. Push the switch all the way down twice very quickly. It can take a number of seconds to “kick in”, but just like with the RPi Pico, you should see a new File browser window open. Now drag and drop the UF2 file you just downloaded into the File Browser window and wait about 10 seconds. Once the window disappears, you are ready to go. Now open Thonny and select the Generic Micropython on your USB port. In a moment, you should see the REPL show the Micropython version and prompt.

Maintenant, voici la partie difficile. Vous devez mettre le Wio en mode bootloader. L'interrupteur d'alimentation situé sur le côté gauche de l'appareil a trois positions. La position haute correspond à l'arrêt, la position centrale à l'allumage et la position basse est une position momentanée pour la réinitialisation. Poussez l'interrupteur à fond vers le bas deux fois très rapidement. Cela peut prendre quelques secondes pour se mettre en route, mais, comme avec le RPi Pico, vous devriez voir une nouvelle fenêtre de navigateur de fichiers s'ouvrir. Glissez-déposez le fichier UF2 que vous venez de télécharger dans la fenêtre du navigateur de fichiers et attendez environ 10 secondes. Une fois que la fenêtre disparaît, vous êtes prêt.

Ouvrez Thonny et sélectionnez le Generic Micropython sur votre port USB. Dans un instant, vous devriez voir la REPL afficher la version de Micropython et l'invite.

PROJECT 1 - LED There is a blue LED inside the Wio just to the left of the USB-C connector. In this simple project, we’ll make it flash. Copy this code (top right) into your Thonny code window and save it to the Wio as “wio_terminal_LED.py”. Now run it. If everything works, in a couple of seconds look at the bottom of the Wio just to the left of the USB connector. You should see the LED flashing. To get it to stop, you can reset the Wio, turn it off for a moment, or press the stop button in Thonny.

PROJET 1 - LED

Une LED bleue se trouve à l'intérieur du Wio, juste à gauche du connecteur USB-C. Dans ce projet simple, nous allons la faire clignoter.

Copiez ce code (en haut à droite) dans votre fenêtre de code Thonny et enregistrez-le sur le Wio sous « wio_terminal_LED.py ».

Lancez-le. Si tout fonctionne, dans quelques secondes, regardez en bas du Wio, juste à gauche du connecteur USB. Vous devriez voir la LED clignoter. Pour l'arrêter, vous pouvez réinitialiser le Wio, l'éteindre pendant un moment ou appuyer sur le bouton d'arrêt dans Thonny.

Project 2 - Button Test I REALLY wanted to call this section “Button, Button, Who pressed the button”, but I didn’t. Aren’t you glad? This next project will test all 8 of the user buttons, the three on the top, the four way thumb switch and the press of the thumb button. Get the code (bottom right)and name it “Wio_terminal_Buttons.py”. Copy it to the Wio memory. The first part of the program does the imports and creates a list with the names of the buttons. The WIO apparently has three ways to name the pins. First is a string like “BUTTON_3”, the second is a pin definition and the third is a pin definition using a scheme like the GPIO name, but named to the WIO specifications. The diagram (next page) is available at https://www.seeedstudio.com/Wio-Terminal-p-4509.html .

Projet 2 - Test des boutons

J'avais VRAIMENT envie d'appeler cette section « Bouton, bouton, qui a appuyé sur le bouton », mais je ne l'ai pas fait. Vous êtes content, n'est-ce pas ?

Ce prochain projet testera les 8 boutons de l'utilisateur : les trois du haut, l'interrupteur à quatre voies et l'appui sur le bouton poussoir.

Récupérez le code (en bas à droite) et nommez-le « Wio_terminal_Buttons.py ». Copiez-le dans la mémoire du Wio.

La première partie du programme fait les importations et crée une liste avec les noms des boutons. Le WIO a apparemment trois façons de nommer les broches. La première est une chaîne comme « BUTTON_3 », la deuxième est une définition de broche et la troisième est une définition de broche utilisant un schéma comme le nom GPIO, mais nommée selon les spécifications du WIO.

Le diagramme (page suivante) est disponible à l'adresse https://www.seeedstudio.com/Wio-Terminal-p-4509.html .

Anyway, the rest of the code (bottom left) handles setting up the actual pins, and then looping until a button is pressed. Then it will print a “1” for which of the 8 pins was pressed. The output in the REPL is a simple string of 8 zeros like this “00000000”. The far left position is the top left button, the next position is the top middle button, and so on, ending with the thumb pad press button. So when you run the program, the output in the REPL continually prints 0000000 Until one of the buttons is pressed. Then that position turns to a “1” until the button is released. Since the program polls all the button pins, you could see multiple “1”s in the string of zeros. For example, if you pressed all three of the top buttons at the same time, you would see 11100000

Quoi qu'il en soit, le reste du code (en bas à gauche) s'occupe de configurer les broches, puis de tourner en boucle jusqu'à ce qu'un bouton soit pressé. Il imprime alors un « 1 » pour indiquer laquelle des 8 broches a été pressée. La sortie dans le REPL est une simple chaîne de 8 zéros comme ceci « 00000000 ». La position la plus à gauche est le bouton en haut à gauche, la position suivante est le bouton en haut au milieu, et ainsi de suite, en terminant par le bouton poussoir du pad.

Ainsi, lorsque vous exécutez le programme, la sortie dans le REPL affiche continuellement

0000000

jusqu'à ce que l'un des boutons soit enfoncé. Cette position devient alors un « 1 » jusqu'à ce que le bouton soit relâché. Comme le programme interroge toutes les broches des boutons, vous pouvez voir plusieurs « 1 » dans la chaîne de zéros. Par exemple, si vous appuyez sur les trois boutons du haut en même temps, vous obtiendrez les résultats suivants

11100000

Project 3 - Graphics on the screen Now for the hard project. It is a series of coloured diamonds animated on the screen. For this, you need to download the screen driver from https://github.com/rdagger/micropython-ili9341/blob/master/ili9341.py. You can move up a level and get the entire zip from the same base site. Copy the ili9341.py file onto the Wio. Then you will want to copy the following code (top right) onto the Wio. This first part is simply the header and the import section. The next function (bottom right) (wheel565) takes a value and returns a RGB color value. Next (top right), the LED that we played with in Project 1 is used to signal things are working. The screen is a bit slow to turn on.

Projet 3 - Graphiques à l'écran

Passons maintenant au projet le plus difficile. Il s'agit d'une série animée de diamants colorés à l'écran. Pour cela, vous devez télécharger le pilote d'écran à partir de https://github.com/rdagger/micropython-ili9341/blob/master/ili9341.py. Vous pouvez monter d'un niveau et obtenir le zip complet à partir du même site de base. Copiez le fichier ili9341.py sur le Wio. Copiez ensuite le code suivant (en haut à droite) sur le Wio.

Cette première partie est simplement l'en-tête et la section d'importation.

La fonction suivante (en bas à droite) (wheel565) prend une valeur et renvoie une valeur de couleur RVB. Ensuite (en haut à droite), la LED avec laquelle nous avons joué dans le projet 1 est utilisée pour signaler que les choses fonctionnent. L'écran est un peu lent à s'allumer.

The next bit of code (bottom right) creates the coloured pixels and coloured rectangles, draws them on the screen and then keeps looping. Finally, if the program is ended, the backlight is turned off, the led is turned off, and the display itself is turned off. This code is from the website https://scruss.com/blog/2022/11/04/micropython-on-the-seeed-studio-wio-terminal-it-works/ . There is a small bug in the published code there, but the author left a comment near the bottom of the page on how to fix it. I’ve already put the fix in the above code and the code in my repository. Name the program “wio_terminal_screen.py”. When you run it, you will see something like this (and in MUCH better definition and animation).

Le morceau de code suivant (en bas à droite) crée les pixels et les rectangles colorés, les dessine sur l'écran et continue à tourner en boucle.

Enfin, si le programme est terminé, le rétroéclairage est éteint, les diodes sont éteintes et l'écran lui-même est éteint.

Ce code provient du site web : https://scruss.com/blog/2022/11/04/micropython-on-the-seeed-studio-wio-terminal-it-works/ . Il y a un petit bug dans le code publié, mais l'auteur a laissé un commentaire au bas de la page sur la façon de le corriger. J'ai déjà intégré la correction dans le code ci-dessus et dans le code dans mon dépôt.

Nommez le programme « wio_terminal_screen.py ». Lorsque vous l'exécuterez, vous verrez quelque chose comme ceci (et avec une bien meilleure définition et animation).

I’m running out of time and space here, so I’m going to leave you hanging on this for now. I haven’t really had much chance to test any more of the WIO either I2C support, WiFi support or any further into the Screen library. I’ll try to give you an update on my website (https://thedesignatedgeek.xyz ) and something updated next month. Until then, if you are interested in learning more about the WIO Terminal, here are some good links to get you started… https://wiki.seeedstudio.com/Wio-Terminal-Getting-Started/ https://wiki.seeedstudio.com/Wio_Terminal_Intro/ The next link is to a site with a number of good projects and is where I got the three projects for you. https://scruss.com/blog/2022/11/04/micropython-on-the-seeed-studio-wio-terminal-it-works/ https://www.youtube.com/watch?v=Q0sv9TyYHHQ

Je manque de temps et d'espace ici, donc je vais vous laisser dans l'attente pour l'instant. Je n'ai pas vraiment eu l'occasion de tester plus le WIO, que ce soit le support I2C, le support WiFi ou la bibliothèque Screen. J'essaierai de vous donner une mise à jour sur mon site web https://thedesignatedgeek.xyz) et quelque chose de nouveau le mois prochain.

D'ici là, si vous souhaitez en savoir plus sur le terminal WIO, voici quelques bons liens pour commencer :

https://wiki.seeedstudio.com/Wio-Terminal-Getting-Started/

https://wiki.seeedstudio.com/Wio_Terminal_Intro/

Le lien suivant mène à un site contenant un certain nombre de bons projets et c'est là que j'ai obtenu pour vous les trois projets. https://scruss.com/blog/2022/11/04/micropython-on-the-seeed-studio-wio-terminal-it-works/

https://www.youtube.com/watch?v=Q0sv9TyYHHQ

As I often try to do, I have put the three project files and the base screen driver in a github repository at https://github.com/gregwa1953/FCM196_MTMT . By the way, neither Full Circle Magazine nor I get paid or receive free products for any of the devices that I review here. Until then, as always; stay safe, healthy, positive and creative!

Comme j'essaie souvent de le faire, j'ai mis les trois fichiers du projet et le pilote de base de l'écran dans un dépôt de github à https://github.com/gregwa1953/FCM196_MTMT.

À ce propos, ni le Full Circle Magazine, ni moi, ne sommes payés ou recevons des produits gratuits pour aucun des dispositifs dont je fais la critique ici.

Comme d'habitude, restez en sécurité, en bonne santé, positifs et créatifs !

issue196/micro-ci_micro-la.txt · Dernière modification : 2023/08/29 17:05 de andre_domenech