Fipy Upload Failed: Timeout. Please Reboot Your Device Manually.
Your commencement Pymakr project
This guide will take y'all through how to setup your outset project with Pymakr and make the on-board RGB LED flash various colours.
Creating a project in Pymakr
-
Firstly yous volition demand to create a new, empty, directory on your computer.
For this instance we will create one called
RGB-Blink. -
Next you will need to open either Atom or Visual Studio Code depending on
which y'all setup previously.
-
Once the text editor has loaded you will need to click
File>Open, and open the directory you created in step 1
If you are using Atom, it is of import to cheque at this bespeak that Cantlet has successfully identified the project. The proper noun of the directory you created in stride one (RGB-Blink in this instance) should be shown in the Pymakr pane like so:
If this is non the case y'all tin printing alt-ctrl-r on Windows/Linux or ctrl-alt-cmd-l on macOS, in order to reload Atom and prepare the event.
- At present that you have a projection created, we need to add some files to it. A standard MicroPython projection has the following structure:
RGB-Blink |-lib | |- some_library.py |-boot.py |-main.py -
boot.pyThis is the get-go script that runs on your module when itturns on. This is frequently used to connect a module to a WiFi network and so that
Telnet and FTP tin can be used without connecting to the WiFi AP created by the
module and not cluttering upward the
principal.pyfile. Equally a beginner you practise notneed to use a
boot.py. -
main.pyThis script runs directly subsequentlykick.pyand should containthe main code you wish to run on your device.
-
libIt is oftentimes a skillful idea to split up out re-usable lawmaking into libraries.If you want to create or apply libraries created by others, you will need to
create a
libdirectory and put the library files in this. It is importantthat you put
.pyfiles directly intolibrather than creating a directorytree. By default MicroPython volition not detect any libraries within
sub-directories.
For this example, you will just demand to create a main.py file.
Now that the project construction is setup, you may wish to configure project specific settings for Pymakr e.m. Which serial port to employ. On Atom you need to click the ^ button on the Pymakr pane, and so click Project Settings. On Visual Studio Lawmaking you demand to click the All commands button on the bottom of the windows, then click Pymakr > Project Settings. This creates a file called pymakr.conf inside your project and populates it with default settings copied over from your global settings. A detailed explanation of these settings can exist establish here.
Controlling the on-board LED
At present that yous have setup and configured your project, we can move on to programming your module. The commencement affair we will need to exercise is import some libraries in order to collaborate with the on-board LED. The Pycom firmware comes with a big amount of libraries for standard functionality built-in. You can find out more most these in the API documentation. For this example you will need to open the main.py file and add the following code:
import pycom import time This volition import two libraries, Pycom which is responsible for Pycom specific features, such as the on-board LED and time which is a standard library used timing and delays.
You may accept noticed that when yous power up your Pycom module, the on-lath LED blinks blue on a regular footing. This "heartbeat" is used as a way of know that your module has powered upward and started correctly. Before we can alter the colour of this LED we demand to disable this heart vanquish. Beneath your imports you volition need to add together the post-obit:
pycom.heartbeat(Simulated) Now it's time to test your lawmaking. On the Pymakr pane/bottom of the window you will see a run push button. (If y'all haven't continued to your device all the same, you volition need to do that first). When yous click the run button, the code in the currently open file will be executed on the device, but it won't copy information technology to the device. Later running this code, you lot should encounter that that on-lath LED stops blinking blue.
At present that we can confirm the device is connected and Pymakr is able to run code on information technology, we can complete our script to blink the LED similar and so:
import pycom import time pycom.heartbeat(False) while True: pycom.rgbled(0xFF0000) # Red time.sleep(1) pycom.rgbled(0x00FF00) # Green time.sleep(1) pycom.rgbled(0x0000FF) # Blue time.sleep(1) Once you run the above script, information technology will run forever. You will discover this prevents you from accessing the interactive REPL on the device (You lot cannot see the >>> prompt). In order to finish the script, click onto the Pymakr concluding, and press ctrl-c on your keyboard. This should finish the script running and return you to the interactive REPL.
Uploading to your module
In the previous section we got lawmaking running on on your Pycom module using the run characteristic of Pymakr. This is useful for quick testing just has a couple of drawbacks. Firstly the code does not remain on the device permanently. If yous reboot the device, it will no longer be running your code. Secondly, it volition only work if y'all are using libraries built into the firmware. If yous need any extra libraries, these need to be copied to the device get-go. This is where the upload feature comes in. If instead of run you click upload, Pymakr will upload all the files in the project (so long equally their type is in the sync_file_types setting for your project). These then persist on your device even between reboots, and allows you to utilize libraries from the lib folder in your project.
If yous need to remove files from your device you lot take 2 options, either connect via FTP and manage your files that manner or format the device's internal flash like and so:
import os os.mkfs('/wink') results matching ""
No results matching ""
Source: https://pycom.github.io/pydocs/gettingstarted/programming/first-project.html
0 Response to "Fipy Upload Failed: Timeout. Please Reboot Your Device Manually."
Post a Comment