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
Adds a webpack plugin to package interface as PROGMEM into a header file in the framework.
Adds a build flag to optionally enable serving from PROGMEM or SPIFFS as required
Adds documentation changes to describe changes
Copy file name to clipboardExpand all lines: README.md
+50-36Lines changed: 50 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,6 @@ You will need the following before you can get started.
30
30
31
31
*[PlatformIO](https://platformio.org/) - IDE for development
32
32
*[Node.js](https://nodejs.org) - For building the interface with npm
33
-
* Bash shell, or [Git Bash](https://gitforwindows.org/) if you are under windows
34
33
35
34
### Building and uploading the firmware
36
35
@@ -74,53 +73,61 @@ Alternatively run the 'upload' target:
74
73
platformio run -t upload
75
74
```
76
75
77
-
### Building the interface
76
+
### Building & uploading the interface
78
77
79
78
The interface has been configured with create-react-app and react-app-rewired so the build can customized for the target device. The large artefacts are gzipped and source maps and service worker are excluded from the production build. This reduces the production build to around ~200k, which easily fits on the device.
80
79
81
-
Change to the ['interface'](interface) directory with your bash shell (or Git Bash) and use the standard commands you would with any react app built with create-react-app:
82
-
83
-
#### Change to interface directory
80
+
The interface will be automatically built by PlatformIO before it builds the firmware. The project can be configured to serve the interface from either SPIFFS or PROGMEM as your project requires. The default configuration is to serve the content from SPIFFS which requires an additional upload step which is documented below.
84
81
85
-
```bash
86
-
cd interface
87
-
```
82
+
#### Uploading the file system image
88
83
89
-
#### Download and install the node modules
84
+
If service content from SPIFFS (default), build the project first. Then the compiled interface may be uploaded to the device by pressing the "Upload File System image" button:
> **Note**: The build command will also delete the previously built interface, in the ['data/www'](data/www) directory, replacing it with the freshly built one ready to upload to the device.
94
+
#### Serving the interface from PROGMEM
102
95
103
-
#### Uploading the file system image
96
+
You can configure the project to serve the interface from PROGMEM by uncommenting the -D PROGMEM_WWW build flag in ['platformio.ini'](platformio.ini) then re-building and uploading the firmware to the device.
104
97
105
-
The compiled user interface may be uploaded to the device by pressing the "Upload File System image" button:
98
+
Be aware that this will consume ~150k of program space which can be especially problematic if you already have a large build artefact or if you have added large javascript dependencies to the interface. The ESP32 binaries are large already, so this will be a problem if you are using one of these devices and require this type of setup.
A method for working around this issue can be to reduce the amount of space allocated to SPIFFS by configuring the device to use a differnt strategy partitioning. If you don't require SPIFFS other than for storing config one approach might be to configure a minimal SPIFFS partition.
108
101
109
-
Alternatively run the 'uploadfs' target:
102
+
For a ESP32 (4mb variant) there is a handy "min_spiffs.csv" partition table which can be enabled easily:
110
103
111
-
```bash
112
-
platformio run -t uploadfs
104
+
```yaml
105
+
[env:node32s]
106
+
board_build.partitions = min_spiffs.csv
107
+
platform = espressif32
108
+
board = node32s
113
109
```
114
110
111
+
This is largley left as an exersise for the reader as everyone's requirements will vary.
112
+
115
113
### Running the interface locally
116
114
117
-
You can run a local development server to allow you preview changes to the front end without the need to upload a file system image to the device after each change. Change to the interface directory and run the following command:
115
+
You can run a local development server to allow you preview changes to the front end without the need to upload a file system image to the device after each change.
116
+
117
+
Change to the ['interface'](interface) directory with your bash shell (or Git Bash) and use the standard commands you would with any react app built with create-react-app:
118
+
119
+
```bash
120
+
cd interface
121
+
```
122
+
123
+
Install the npm dependencies, if required and start the development server:
118
124
119
125
```bash
126
+
npm install
120
127
npm start
121
128
```
122
129
123
-
> **Note**: To run the interface locally you will need to modify the endpoint root path and enable CORS.
130
+
> **Note**: To run the interface locally you may need to modify the endpoint root path and enable CORS.
124
131
125
132
#### Changing the endpoint root
126
133
@@ -141,7 +148,9 @@ You can enable CORS on the back end by uncommenting the -D ENABLE_CORS build fla
141
148
142
149
## Device Configuration
143
150
144
-
As well as containing the interface, the SPIFFS image (in the ['data'](data) folder) contains a JSON settings file for each of the configurable features. The config files can be found in the ['data/config'](data/config) directory:
151
+
The SPIFFS image (in the ['data'](data) folder) contains a JSON settings file for each of the configurable features.
152
+
153
+
The config files can be found in the ['data/config'](data/config) directory:
145
154
146
155
File | Description
147
156
---- | -----------
@@ -173,30 +182,31 @@ It is recommended that you change the JWT secret and user credentials from their
173
182
174
183
This project supports ESP8266 and ESP32 platforms. To support OTA programming, enough free space to upload the new sketch and file system image will be required. It is recommended that a board with at least 2mb of flash is used.
175
184
176
-
By default, the target device is "esp12e". This is a common ESP8266 variant with 4mb of flash:
185
+
The pre-configured environments are "esp12e" and "node32s". These are common ESP8266/ESP32 variants with 4mb of flash:
The settings file ['platformio.ini'](platformio.ini) configures the platform and board:
189
+
The settings file ['platformio.ini'](platformio.ini) configures the supported environments. Modify these, or add new environments for the devides you need to support. The default environments are as follows:
181
190
182
-
```
191
+
```yaml
183
192
[env:esp12e]
184
193
platform = espressif8266
185
194
board = esp12e
186
-
```
187
-
188
-
If you want to build for an ESP32 device, all you need to do is re-configure ['platformio.ini'](platformio.ini) with your devices settings.
189
-
190
-

191
-
192
-
Building for the common esp32 "node32s" board for example requires the following configuration:
195
+
board_build.f_cpu = 160000000L
193
196
194
-
```
195
197
[env:node32s]
196
198
platform = espressif32
197
199
board = node32s
198
200
```
199
201
202
+
If you want to build for a different device, all you need to do is re-configure ['platformio.ini'](platformio.ini) and select an alternative environment by modifying the default_envs variable. Building for the common esp32 "node32s" board for example:
203
+
204
+
```yaml
205
+
[platformio]
206
+
;default_envs = esp12e
207
+
default_envs = node32s
208
+
```
209
+
200
210
## Customizing and theming
201
211
202
212
The framework, and MaterialUI allows for a reasonable degree of customization with little effort.
@@ -274,7 +284,11 @@ void setup() {
274
284
Serial.begin(SERIAL_BAUD_RATE);
275
285
276
286
// start the file system (must be done before starting the framework)
0 commit comments