Différences entre versions de « Hack-pycom-lopy-Pymakr »

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche
Ligne 102 : Ligne 102 :
 
{{ambox-stop|text=If your board is running code at boot time, you might need to boot it in safe mode.}}
 
{{ambox-stop|text=If your board is running code at boot time, you might need to boot it in safe mode.}}
  
[https://docs.pycom.io/pycom_esp32/pycom_esp32/toolsandfeatures.html#pymakr-ide https://docs.pycom.io/pycom_esp32/pycom_esp32/toolsandfeatures.html#pymakr-ide]
+
== Console Pycom ==
 +
To start coding, simply go to the Pycom Console and type your code. Lets try to make the LED light up.
 +
 
 +
<syntaxhighlight lang="python">
 +
import pycom # we need this module to control the LED
 +
pycom.heartbeat(False) # disable the blue blinking
 +
pycom.rgbled(0x00ff00) # make the LED light up in green color
 +
</syntaxhighlight>
 +
 
 +
Change the color by adjusting the hex RGB value
 +
 
 +
<syntaxhighlight lang="python">
 +
pycom.rgbled(0xff0000) # now make the LED light up in red color
 +
</syntaxhighlight>
 +
 
 +
The console can be used to run any python code, also functions or loops. Simply copy-paste it into the console or type it manually. Note that after writing or pasting any indented code like a function or a while loop, you’ll have to press enter up to three times to tell MicroPython that you’re closing the code (this is standard MicroPython behavior).
 +
 
 +
[[Fichier:Hack-pycom-lopy-Pymakr-30.png]]
 +
 
 +
Use {{fname|print()}} to output contents of variables to the console for you to read. Returned values from functions will also be displayed if they are not caught in a variable. This will not happen for code running from the main or boot files. Here you need to use print() to output to the console.
 +
 
 +
A few pycom-console features you can use:
 +
 
 +
* '''Input history''': use arrow up and arrow down to scroll through the history
 +
* '''Tab completion''': press tab to auto-complete variables or module names
 +
* '''Stop any running code''': with ctrl-c
 +
* '''Copy/paste code or output''': ctrl-c and ctrl-v (cmd-c and cmd-v for mac)
 +
 
 +
== Connectez pymakr sur vos cartes ==
 +
# Connect your computer to the WiFi network named after your board (e.g. {{fname|lopy-wlan-xxxx}}, {{fname|wipy-wlan-xxxx}} ). The password is {{fname|www.pycom.io}}
 +
# Open Pymakr.
 +
# In the menu, go to "Settings > Preferences" ("Pymakr > Preferences" on macOS).
 +
# In the left list look for Pycom Device.
 +
# For device, type down {{fname|192.168.4.1}} . The default username and password are {{fname|micro}} and {{fname|python}}, respectively.
 +
# Click OK
 +
 
 +
{{ambox|text=Pymakr also supports wired connections. Instead of typing the IP address, you can click on the combo box arrow and select the proper serial port from the list. Our boards don’t require any username or password for the serial connection, so you can leave those fields empty.}}
 +
 
 +
 
  
Placer ici la section pymakr-ide de la page "toolsandfeatures"
 
  
 
{{LOPY-TRAILER}}
 
{{LOPY-TRAILER}}

Version du 13 mars 2017 à 15:07


MCHobby investit du temps et de l'argent dans la réalisation de traduction et/ou documentation. C'est un travail long et fastidieux réalisé dans l'esprit Open-Source... donc gratuit et librement accessible.
SI vous aimez nos traductions et documentations ALORS aidez nous à en produire plus en achetant vos produits chez MCHobby.

Pymakr - présentation

Pymarkr est un Environnement de développement (IDE) pour LoPy, WiPys et autres plateformes. Cet environnement est disponible sous Windows, Linux Debian, Linux Red Hat et MAC OS X.

Si vous n'avez pas encore eu l'occasion de faire du hacking électronique avec les cartes Pycom, vous devriez télécharger la dernière version de l'IDE pour découvrir les fonctionnalités offertes par Pymark.

Hack-pycom-lopy-Pymakr-00.png
Cliquer pour agrandir

Parmi les fonctionnalités, vous retrouverez:

  1. Synchronisation de projets.
  2. Téléversement automatique du code sur votre carte.
  3. Détection des nouveaux Firmware & mise-à-jour de la carte.
  4. Clique pour exécution (Run) d'un fichier.

Pymark c'est...

Un environnement de développement complet qui se connecte automatiquement sur vos cartes Pycom via Telnet (ou le port série), exécute du code à la volée, gère le système de fichier interne, synchronise votre code instantanément et l'exécute à l'aide d'un simple clique.

Il prend soin de vérifier que le firmware de la carte Pycom soit bien à jour et propose une console qui s'interface avec le mode REPL de MicroPython.

Pymakr est également une plateforme développée pour supporter les développements avec LoPy (Carte pour réseau Lora).

N'hésitez à rejoindre les Forums Pycom pour en apprendre plus sur le Pymakr et le plateformes PyCom.

Ressources

Liens de téléchargement:

Vous pouvez également trouver le code source sur Github:

Pymakr dispose d'une système de greffons (plugin) et dispose déjà d'un premier greffons pour Pymaker.

Créer un projet

Pymakr has a feature to sync and run your code on your device. This is mostly done using projects. The following steps will get you started.

  • In Pymakr, go to Project > New project.
  • Give it a name and select a folder for your project, either a new of existing one.
  • Create two files: main.py and boot.py, if you don’t already have those.

The boot.py file should always have the following code on the top, so we can run our python scripts over serial or telnet:

from machine import UART
import os
uart = UART(0, 115200)
os.dupterm(uart)

Most users, especially WiPy users, would want a wifi script in the boot.py file. A basic wifi script but also more advanced WLAN examples, like fixed IP and multiple networks, can be found in the Wifi Examples chapter.

Besides the neccesary main.py and boot.py files, you can create any folders and python files or libraries that you want to include in your main file. Pymakr will synchronize all files in the project to the board when using the sync button.

Ajouter des fichiers

If you create any files (and folder) to your project directory from outside of pymakr, they won’t appear in your project files. To add them, right-click on the left sidebar in the Project-Viewer when you have your project open, and click ‘Add source files’.

Hack-pycom-lopy-Pymakr-10.png

In the popup that appears, click the folder icon next to the ‘Source files’ input and select one or more files to be included.

Hack-pycom-lopy-Pymakr-11.png

Adding a folder works in the exact same way, using the ‘Add source directory’ after right-clicking in the project sidebar. All files inside the chosen directories will be added as well.

Sans créer de projet

If you just want to test some code on the module without creating a Project, you can create a new file or open an existing one and press the ‘run’ button.

Note that the changes you make to your file won’t be automatically saved to the device on execution.

Un exemple simple

For fun, lets try to build a traffic light. Add the following code to the main.py file:

import pycom
import time
pycom.heartbeat(False)
for cycles in range(10): # stop after 10 cycles
    pycom.rgbled(0x007f00) # green
    time.sleep(5)
    pycom.rgbled(0x7f7f00) # yellow
    time.sleep(1.5)
    pycom.rgbled(0x7f0000) # red
    time.sleep(4)
  • Make sure the connection to your board is open in the Pycom Console
  • Press the sync button on the top toolbar. Any progress will be shown in the console.

Here is the expected result:

Hack-pycom-esp 32-60.gif

You now have a traffic light in your hands. To stop a running program, use ctrl-c or do a right click on the console and press Reset. You can also reboot the board by pressing the physical reset button.

Console Pycom

To start coding, simply go to the Pycom Console and type your code. Lets try to make the LED light up.

import pycom # we need this module to control the LED
pycom.heartbeat(False) # disable the blue blinking
pycom.rgbled(0x00ff00) # make the LED light up in green color

Change the color by adjusting the hex RGB value

pycom.rgbled(0xff0000) # now make the LED light up in red color

The console can be used to run any python code, also functions or loops. Simply copy-paste it into the console or type it manually. Note that after writing or pasting any indented code like a function or a while loop, you’ll have to press enter up to three times to tell MicroPython that you’re closing the code (this is standard MicroPython behavior).

Hack-pycom-lopy-Pymakr-30.png

Use print() to output contents of variables to the console for you to read. Returned values from functions will also be displayed if they are not caught in a variable. This will not happen for code running from the main or boot files. Here you need to use print() to output to the console.

A few pycom-console features you can use:

  • Input history: use arrow up and arrow down to scroll through the history
  • Tab completion: press tab to auto-complete variables or module names
  • Stop any running code: with ctrl-c
  • Copy/paste code or output: ctrl-c and ctrl-v (cmd-c and cmd-v for mac)

Connectez pymakr sur vos cartes

  1. Connect your computer to the WiFi network named after your board (e.g. lopy-wlan-xxxx, wipy-wlan-xxxx ). The password is www.pycom.io
  2. Open Pymakr.
  3. In the menu, go to "Settings > Preferences" ("Pymakr > Preferences" on macOS).
  4. In the left list look for Pycom Device.
  5. For device, type down 192.168.4.1 . The default username and password are micro and python, respectively.
  6. Click OK




Tutoriel PyCom Getting started (ESP_32) sous copyright de Damien George et contributeurs en ce qui concerne MicroPython et/ou PyCom en ce qui concerne les informations relatives a WiPy et LoPy.

Tutoriel traduit par Meurisse D. pour MCHobby.be

Traduit avec l'autorisation de micropython.org - Translated with the authorisation of micropython.org

Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : «  Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.

L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.