Skip to content

Commit 0e68a75

Browse files
migrate to latest esp-idf and cmake
1 parent 5057bc7 commit 0e68a75

40 files changed

+202
-179
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
build
2-
main/esp32.js
32
sdkconfig.old*
3+
main/project.cpp

CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
3+
### CONFIGURATION OF ESP32 JAVASCRIPT PROJECT ###
4+
5+
# set BOARD_VARIANT to define your ESP32 board. Valid values
6+
# are the directory names below ./components/arduino-esp32/include/variants/
7+
# or esp32-javascript/include/variants/
8+
set(ENV{BOARD_VARIANT} "../esp32-javascript/include/variants/my")
9+
10+
# set ESP32_JS_PROJECT_NAME to define your project component name.
11+
# Place your component below ./components directory. Set to ""
12+
# if you don't have a project component yet.
13+
set(ENV{ESP32_JS_PROJECT_NAME} "")
14+
#################################################
15+
16+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
17+
project(esp32-javascript)
18+
19+
add_custom_target(cp_modules ALL
20+
COMMAND scripts/copy-modules.sh
21+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
22+
23+
spiffs_create_partition_image(storage build/modules FLASH_IN_PROJECT
24+
DEPENDS cp_modules)

main/main.h renamed to LICENSE

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/*
21
MIT License
32

4-
Copyright (c) 2019 Marcel Kottmann
3+
Copyright (c) 2020 Marcel Kottmann
54

65
Permission is hereby granted, free of charge, to any person obtaining a copy
76
of this software and associated documentation files (the "Software"), to deal
@@ -20,9 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2019
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2120
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2221
SOFTWARE.
23-
*/
24-
25-
#if !defined(EL_MAIN_H_INCLUDED)
26-
#define EL_MAIN_H_INCLUDED
27-
28-
#endif

Makefile

Lines changed: 0 additions & 47 deletions
This file was deleted.

README.md

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,73 @@ Install [esp-idf](http://esp-idf.readthedocs.io/en/latest/get-started/index.html
1818

1919
### First install
2020
Clone esp32-javascript inside your esp directory (normally ~/esp):
21-
21+
```shell
2222
cd ~/esp
2323
git clone https://github.com/pepe79/esp32-javascript.git
24+
```
2425

2526
Change into ~/esp/esp32-javascript.
26-
27+
```shell
2728
cd ~/esp/esp32-javascript
29+
```
2830

29-
Open the Makefile and change settings in the configuration section.
31+
Maybe you want to change the BOARD_VARIANT in the ./CMakeLists.txt file.
3032

31-
Connect your ESP32 Dev Board via USB and run
33+
First build the project with
34+
```shell
35+
idf.py build
36+
```
3237

33-
make flash monitor
38+
Connect your ESP32 Dev Board via USB and run
39+
```shell
40+
idf.py flash monitor
41+
```
3442

3543
Use the keyboard shortcut `AltGr + ]` to leave serial monitor.
3644

3745
Now you have installed the pre-configured boot script.
3846

39-
If this is your first install, your onboard LED should blink now. Blinking signals that
40-
your board has started a soft ap with the ssid "esp32". With your mobile or desktop connect
41-
to the WLAN SSID "esp32" and open http://192.168.4.1/setup (if you have not changed the default
42-
credentials your username / password is esp32 / esp32 ).
47+
If this is your first install, your onboard LED should blink now. Blinking signals that your board has started a soft ap with the ssid "esp32". With your mobile or desktop connect to the WLAN SSID "esp32" and open http://192.168.4.1/setup (if you have not changed the default credentials your username / password is esp32 / esp32 ).
4348

4449
On the Setup page you can configure your WLAN settings and an URL to download your JS main script from.
4550

4651
Please note that the script, does not need to have a main function, because its evaluated entirely.
4752
That means, to print out "Hello World", you only have to include one line in your script on the webserver:
4853

49-
console.log('Hello world!');
54+
```js
55+
console.log('Hello world!');
56+
```
57+
58+
### C/C++bindings
59+
60+
If you need to create your own C/C++ bindings for your JS code, this are the steps to perform:
61+
62+
1. Create a file named `project.cpp` in the `./main` directory
63+
2. Implement the esp32_javascript_main callback function inside this `project.ccp`:
64+
```c
65+
extern void esp32_javascript_main(duk_context *ctx)
66+
{
67+
// do your own duktape bindings here
68+
}
69+
```
70+
71+
See [Duktape Programmer's Guide](https://duktape.org/guide.html) for more information regarding Duktape bindings.
72+
73+
If you need more than this, you can create your own esp-idf component below `./components`. Then delegate the `esp32_javascript_main` function to this component.
74+
Additionally you have to set your component name in the top level `./CMakeLists.txt`. Refer to the documentation next to the setting `ESP32_JS_PROJECT_NAME`.
75+
See [ESP Build System](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html) for information on how to create a component with the esp-idf build system.
76+
77+
### Clean
78+
79+
You can clean the project with
80+
81+
```shell
82+
idf.py fullclean
83+
```
5084

5185
## Compatibility
5286

53-
Tested with release/v4.0 (ba0f4f17ed91c3372149beacdfbee6af58e4f634) of esp-idf.
87+
Tested with esp-idf (master branch commit hash 2e14149b).
5488

5589
## API
5690
[API documentation](api.md)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
idf_component_register(SRC_DIRS "." "./libb64"
2+
INCLUDE_DIRS "include" "$ENV{BOARD_VARIANT}"
3+
REQUIRES "nvs_flash" "app_update" "esp_adc_cal")

components/arduino-esp32/component.mk

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
idf_component_register(SRC_DIRS "."
2+
INCLUDE_DIRS "include" "../esp32-javascript/include/variants/my"
3+
REQUIRES "arduino-esp32")

components/arduino-spi/component.mk

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
idf_component_register(SRC_DIRS "."
2+
INCLUDE_DIRS "include"
3+
REQUIRES "duktape" "esp32-javascript"
4+
EMBED_TXTFILES "loader.js")

0 commit comments

Comments
 (0)