You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+52-25Lines changed: 52 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,39 @@
1
1
# Arduino Tools for MicroPython
2
2
3
3
This package adds functionalities for
4
+
4
5
* MicroPython apps framework
5
6
* file system helpers
6
7
* WiFi network management
7
8
9
+
## Installation
10
+
11
+
### Using `mpremote`
12
+
13
+
We must specify the target especially if the framework is already installed and a default app is present, since `mpremote mip` will use the current path to look for or create the `lib` folder.
14
+
We want to make sure the tools are accessible from every application/location.
A set of tools and helpers to implement, create and manage MicroPython Apps.
11
32
12
33
A new approach to enabling a MicroPython board to host/store multiple projects with the choice of running one as default, as well as have a mechanism of fallback to a default launcher.
13
34
It does not interfere with the canonical `boot.py` > `main.py` run paradigm, and allows users to easily activate this functionality on top of any stock MicroPython file-system.
14
35
15
-
The Arduino MicroPython App framework relies on the creation of well structured projects/apps enclosed in their own folders named "app_{app-name}", which in turn contain a set of files (`main.py`, `lib/`, `app.json`, etc.).
36
+
The Arduino MicroPython App framework relies on the creation of aptly structured projects/apps enclosed in their own folders named "app_{app-name}", which in turn contain a set of files (`main.py`, `lib/`, `app.json`, etc.).
16
37
These are the conditions for a project/app to be considered "valid".
17
38
Other files can be added to user's discretion, for instance to store assets or log/save data.
18
39
@@ -23,44 +44,50 @@ The framework exploits the standard behaviour of MicroPython at start/reset/soft
23
44
24
45
The framework's boot.py only requires two lines for the following operations:
25
46
26
-
- import the minimum required parts of arduino_tools (common) from the board's FileSystem (preferrably installed as a module in /lib/arduino_tools)
27
-
- call a method to enter the default app's path and apply some temporary settings to configure the running environment (search paths and launch configuration changes) which will be reset at the next start.
47
+
* import the minimum required parts of arduino_tools (common) from the board's File System (installed as a package in [flash]/lib/arduino_tools)
48
+
* invoke the method`load_app()` to enter the default app's path and apply some temporary settings to configure the running environment (search paths and launch configuration changes) which will be reset at the next start.
28
49
29
50
If no default app is set, it will fall back to the `main.py` in the board's root if present.
30
-
No error condition will be generated, as MicroPython is capable of handling the absence of `boot.py` and/or `main.py`.
51
+
No error condition will be generated, as MicroPython is capable of handling the absence of `boot.py` and/or `main.py` at C level.
31
52
32
-
If a default app is set, the `enter_default_app()` will issue an `os.chdir()` command and enter the app's folder.
53
+
If a default app is set, the `load_app()` will issue an `os.chdir()` command and enter the app's folder.
33
54
MicroPython will automatically run the main.py it finds in its Current Working Directory.
34
55
35
56
**NOTES:**
36
57
37
-
- each app can contain a `.hidden` file that will hide the app from AMP, effectively preventing listing or deletion.
58
+
* each app can contain a `.hidden` file that will hide the app from AMP, effectively preventing listing or deletion.
38
59
The `list_apps()` command accepts a `skip_hidden = False` parameter to return every app, not just the visible ones.
39
60
40
-
- each app should contain a metadata file named `app.json`
41
-
{
42
-
"name": "",
43
-
"author": "",
44
-
"created": 0,
45
-
"modified": 0,
46
-
"version": "x.y.z",
47
-
"origin_url": "",
48
-
"tools_version": "x.y.z"
49
-
}
50
-
- while some fields should be mandatory ("name", "hidden") others could not be a requirement, especially for students apps who do not care about versions or source URL.
51
-
We should also handle if extra fields are added not to break legacy
52
-
53
-
- AMP can replace/update an app with the content of a `.tar` archive.
54
-
This is useful for updating versions of apps/launcher/demos.
61
+
* each app should contain a metadata file named `app.json`
62
+
63
+
```json
64
+
{
65
+
"name": "",
66
+
"friendly_name": "",
67
+
"author": "",
68
+
"created": 0,
69
+
"modified": 0,
70
+
"version": "M.m.p",
71
+
"origin_url": "https://arduino.cc",
72
+
"tools_version": "M.m.p"
73
+
}
74
+
```
75
+
76
+
* while some fields should be mandatory ("name", "tools_version") others could not be required, especially for students apps who do not care about versions or source URL.
77
+
We should also handle if extra fields are added not to break legacy.
78
+
Still WIP.
79
+
80
+
* AMP can replace/update an app with the contents of a properly structured `.tar` archive.
81
+
This is useful for updating versions of apps/launcher.
55
82
An app launcher could be delegated to checking for available updates to any of the other apps it manages.
56
83
57
84
### How to setup
58
85
59
86
**NOTE:** The API is not yet final, hence subject to changes.
60
-
Same goes for the name of the module(s)
87
+
Same goes for the name of modules.
61
88
62
89
The only requirement is that all the files in `arduino_tools` should be transferred to the board using one's preferred method.
63
-
Best practice is to copy all the files in the board's `/lib/arduino_tools`, which is what happens when installing with the `mip` tool.
90
+
Best practice is to copy all the files in the board's `[flash]/lib/arduino_tools`, which is what happens when installing with the `mip` tool (or `mpremote mip`).
64
91
65
92
Enter a REPL session
66
93
@@ -101,7 +128,7 @@ Note: creating an app and giving it a name with unallowed characters will replac
101
128
Enable AMP and create a few apps
102
129
103
130
```shell
104
-
>>> from arduino_tools.app_manager import *
131
+
>>> from arduino_tools.apps_manager import *
105
132
>>> enable_apps()
106
133
107
134
>>> create_app('abc')
@@ -138,7 +165,7 @@ Type "help()" for more information.
138
165
139
166
### Advanced Usage
140
167
141
-
#### Restore script
168
+
#### Restore script (very experimental)
142
169
143
170
The restore script allows to have a way of restoring a default app at boot.
144
171
This script may respond to a hardware condition such as a pressed pin in order to set the default app to run.
0 commit comments