Ligne 1 : |
Ligne 1 : |
| {{MicroPython-Hack-Prepare-NAV}} | | {{MicroPython-Hack-Prepare-NAV}} |
− |
| |
− | {{traduction}}
| |
| | | |
| == Utiliser la carte PyBoard == | | == Utiliser la carte PyBoard == |
Ligne 55 : |
Ligne 53 : |
| | | |
| == Charger du code sur le PyBoard == | | == Charger du code sur le PyBoard == |
− | For writing more complex code, there are two possibilities:
| + | Pour l'écriture de code plus complexe, il y a deux possibilités: |
| + | |
| + | # Editer le fichier sur la PyBoard puis le charger en mode REPL en utilisant la commande {{fname|import}} |
| + | # Editer les fichiers sur votre ordinateur puis faire un copier/coller en mode REPL |
| | | |
− | # edit the files on the pyboard, and load them into the REPL using import
| + | La première solution fonctionne bien, c'est la seule façon de de travailler si vous avez un code réparti dans différents modules. |
− | # edit the files on your computer, and paste them into the REPL
| |
| | | |
− | The first solution works fine and is the only way to work with code that is split into different modules.
| + | La seconde solution est peut être la plus simple mais vous ne pouvez pas envoyer trop de texte/code dans le mode REPL sans erreur. Vous aurrez besoin de passer en mode ''raw REPL'' (REPL brute) en pressant Ctrl-A, puis coller votre code, et finaliser le transfert en pressant Ctrl-D. Votre code sera exécuté sur la PyBoard. S'il ne se termine pas par lui même, vous pouvez stopper votre code en pressant Ctrl-C, puis pressez Ctrl-B pour sortir du mode ''raw REPL'' (afin de revenir au mode REPL utilisateur). Vous pouvez effectuer une réinitialisation logiciel de votre PyBoard en pressant Ctrl-D. |
| | | |
− | The second solution is perhaps easier, but you cannot paste too much text in the REPL without getting errors. You have to switch to the raw REPL by hitting Ctrl-A, pasting your code, and hitting Ctrl-D to finish the transfer. Your code will be running on the pyboard. Hit Ctrl-C to kill it if it does note terminate by itself, then hit Ctrl-B to exit the raw REPL and switch back to the friendly REPL. You can perform a soft reset of the pyboard by hitting Ctrl-D.
| |
| | | |
− | Note than when using minicom, you have to hit Ctrl-A twice to send a Ctrl-A to the REPL because Ctrl-A is by default the escape key of minicom. You can use the paste file command in minicom to send a file to the REPL. For this: | + | {{underline|Note pour les utilisateurs de minicom:}} vous aurez besoin de presser Ctrl-A deux fois pour envoyer un Ctrl-A au REPL parce que, par défaut, Ctrl-A est aussi la touche d'échappement de minicom. Vous pouvez utiliser la commande "paste file" dans minicom pour envoyer un fichier vers REPL. Pour réaliser cela avec Minicom: |
| | | |
− | # hit Ctrl-A twice to enter the raw REPL | + | # Presser Ctrl-A deux fois pour entrer en mode ''raw REPL'' |
− | # hit Ctrl-A Y to execute the paste file minicom command | + | # Presser Ctrl-A Y tpour exécuter la commande "paste file" dans minicom |
− | # navigate to your file in the file selection screen that appears and select it | + | # Naviguer dans vos fichier apparaissant à l'écran et sélectionner le fichier à envoyer |
− | # hit Ctrl-D to finish the transfer | + | # Presser Ctrl-D pour terminer le transfert |
| | | |
− | Your file is then loaded. If it contains just definitions, hit Ctrl-B to exit the rawREPL and use the definitions in the regular REPL.
| + | Votre fichier est alors chargé. S'il ne contient que des définitions, pressez Ctrl-B pour sortir du mode ''raw REPL'' et utiliser les différentes définitions dans le mode REPL standard. |
| | | |
| == pyboard.py == | | == pyboard.py == |
| | | |
− | Another way of executing code on the pyboard is to use the {{fname|pyboard.py}} script available in the tools directory of the MicroPython git repository. Exit minicom with Ctrl-A X, then load your file onto the pyboard with pyboard.py file_to_load.py. You can connect to the REPL by launching minicom again.
| + | {{ambox|text=Une fois maîtrisé, PyBoard.py est un outil plus que pratique. Vivement recommandé par MCHobby.}} |
| + | |
| + | Une autre façon d’exécuter du code sur votre pyboard est d'utiliser le script {{fname|pyboard.py}} disponible dans le répertoire ''tools'' du dépôt GIT MicroPython. |
| + | |
| + | Plutôt que d'utiliser minicom pour transférer le contenu un fichier sur la PyBoard, vous pouvez utiliser directement le script {{fname|pyboard.py}}. Rien ne vous empêche, par la suite, de réutiliser un programme terminal (comme minicom) pour vous reconnecter à nouveau en mode REPL. |
| | | |
− | You can modify the pyboard.py script to find the pyboard device automatically by changing the beginning of the main function as follows:
| + | Vous pouvez modifier le script {{fname|pyboard.py}} pour rechercher automatiquement le périphérique "pyboard" en modifiant la fonction {{fname|main()}} comme suit: |
| | | |
| <nowiki>def main(): | | <nowiki>def main(): |
Ligne 92 : |
Ligne 95 : |
| cmd_parser.add_argument('--device', default='/dev/' + ttymodems[0], help='the serial device of the pyboard')</nowiki> | | cmd_parser.add_argument('--device', default='/dev/' + ttymodems[0], help='the serial device of the pyboard')</nowiki> |
| | | |
− | An already patched version (may not be up to date with respect to the git repository) [http://wdi.supelec.fr/boulanger/downloads/MicroPython/pyboard.py is available].
| + | Si vous désirez utiliser le script original du script {{fname|pyboard.py}}, la commande à utiliser pour charger votre fichier "mon_fichier.py" sur ma pyboard est {{fname|1=./pyboard --device=/dev/ttyACM1 mon_fichier.py}} . /dev/ttyACM1 correspond à la connexion série associée à votre PyBoard. |
| + | |
| + | == Ampy == |
| + | Ampy est un outil développé par Adafruit industrie alors que Tony Dicola produisait de la documentation pour le Feather ESP8266 Huzza. |
| + | |
| + | Il permet de réaliser les différentes opérations décrites ci-dessus mais également {{underline|le transfert de fichier vers et depuis une carte MicroPython}} par l'intermédiaire '''d'une connexion série'''. |
| + | |
| + | Il s'agit d'un outil pratique car il vous permet de conduire vos développements sur PC avec votre éditeur de texte favoris; puis transférer vos fichiers sur la carte MicroPython avant de les exécuter via une session REPL. |
| + | |
| + | {{ttuto-begin}} |
| + | |
| + | {{ttuto |
| + | |label=Téléverser & Exécuter |
| + | |descr=Téléverser des fichiers et exécuter du code avec '''Ampy'''. Un flux simple de développement. |
| + | |img=tlogo-feather-load-file.jpg |
| + | |link=FEATHER-CHARGER-FICHIER-MICROPYTHON |
| + | }} |
| + | |
| + | {{ttuto-end}} |
| + | |
| + | == RShell == |
| + | Si [[FEATHER-CHARGER-FICHIER-MICROPYTHON|Ampy]] d'Adafruit est un outil pratique et simple, '''RShell''' est un outil nettement plus puissant. |
| + | |
| + | Tout comme Ampy, '''RShell''' permet de transférer des fichiers vers (et depuis) une carte MicroPython par l'intermédiaire d'une simple connexion série. C'est donc un outil puissant et pratique. |
| + | |
| + | Par contre, RShell, ne se présente pas comme une série de commande Linux mais comme {{underline|un vrai shell dédié à MicroPython}}. Il est par ailleurs capable de supporter plusieurs cartes MicroPython connectées en même temps. |
| + | |
| + | Chez MCHobby nous avons un faible un RSheel mais il faut bien reconnaître qu'il nécessite un peu plus d'investissement que [[FEATHER-CHARGER-FICHIER-MICROPYTHON|Ampy]] mais le jeu en faut largement la chandelle. |
| + | |
| + | {{ttuto-begin}} |
| + | |
| + | {{ttuto |
| + | |label=RSHell |
| + | |descr=Transférez des fichiers et contrôlez votre carte depuis une simple connexion série. ESP8266 compatible. |
| + | |img=tlogo-micropython-Debugger.jpg |
| + | |link=MicroPython-Hack-RShell |
| + | }} |
| | | |
− | Si vous desirez utiliser le script original du script, la commande à utiliser pour charger votre fichier mon_fichier.py sur ma pyboard est {{fname|./pyboard --device=/dev/ttyACM1 mon_fichier.py}} . /dev/ttyACM1 correspond à la connexion série associée à votre PyBoard.
| + | {{ttuto-end}} |
| | | |
| == Element Fritzing == | | == Element Fritzing == |
− | I use [http://fritzing.org/ Fritzing] to draw my sketches. I have made a [http://wdi.supelec.fr/boulanger/downloads/MicroPython/pyboard.fzpz Fritzing part for the pyboard]. You can also get the SVG pictures I made for the [http://wdi.supelec.fr/boulanger/downloads/MicroPython/pyboard_PCB.svg PCB], the [http://wdi.supelec.fr/boulanger/downloads/MicroPython/pyboard_schem.svg schematics] and the [http://wdi.supelec.fr/boulanger/downloads/MicroPython/pyboard.svg icon].
| + | Mr Boulanger utilise [http://fritzing.org/ Fritzing] pour dessiner ces montage. A cette fin, il a réalisé [http://wdi.supelec.fr/boulanger/downloads/MicroPython/pyboard.fzpz un composant PyBoard pour Fritzing]. Vous pouvez également obtenir le dessin SVG pour [http://wdi.supelec.fr/boulanger/downloads/MicroPython/pyboard_PCB.svg la carte], le [http://wdi.supelec.fr/boulanger/downloads/MicroPython/pyboard_schem.svg schéma] et l' [http://wdi.supelec.fr/boulanger/downloads/MicroPython/pyboard.svg icon]. |
| | | |
− | You can see how it looks on the example below:
| + | Vous pouvez voir le résultat dans l'exemple Fritzing ci-dessous: |
| | | |
| [[Fichier:MicroPython-Hack-Outil-01.png|320px]]<small><br />Source: [http://wdi.supelec.fr/boulanger/MicroPython/ Supelec.fr]</small> | | [[Fichier:MicroPython-Hack-Outil-01.png|320px]]<small><br />Source: [http://wdi.supelec.fr/boulanger/MicroPython/ Supelec.fr]</small> |