diff --git a/.gitignore b/.gitignore index 40b878d..01a853a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ -node_modules/ \ No newline at end of file +node_modules/ +.pioenvs +.piolibdeps +.vscode/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2c4ff5c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,65 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < http://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < http://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < http://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choice one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to by used as a library with examples +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/config/wifi.json b/config/wifi.json index ad497e0..99ce372 100644 --- a/config/wifi.json +++ b/config/wifi.json @@ -1,5 +1,5 @@ { "apMode": 0, - "SSID": "", - "Password": "" + "SSID": "tErAx1d", + "Password": "ramalamadingdong" } \ No newline at end of file diff --git a/data/index.html b/data/index.html index 4db761d..d76c8e6 100644 --- a/data/index.html +++ b/data/index.html @@ -94,13 +94,13 @@
- + - + - + - +
last uri: diff --git a/data/scripts.js b/data/scripts.js index 4554c40..6c1f911 100644 --- a/data/scripts.js +++ b/data/scripts.js @@ -99,7 +99,8 @@ var $ = function(selector){ let update = function(endpoint, method, props) { Sui.http.ajax({ method: method, - endpoint: node.api[endpoint] + (props ? props.join('/') : ''), + endpoint: node.api[endpoint], + data: props, cache: false }, actuator.onResponse || null); }; @@ -107,7 +108,7 @@ var $ = function(selector){ let handle = function(event) { update.call(this, actuator.api, - 'GET', + actuator.method, actuator.data ? actuator.data.call(this) : [this.value] ); @@ -147,7 +148,7 @@ var $ = function(selector){ if(!cache) { data['_'] = new Date().getTime(); } - var serializedData = Sui.util.serialize(data); + var serializedData = data; //Sui.util.serialize(data); var endPointUrl = (config.method === 'GET' || config.method === 'DELETE') && data ? config.endpoint+'?'+serializedData : config.endpoint; var postData = config.method === 'POST' || config.method === 'PUT' ? serializedData : null; @@ -166,23 +167,30 @@ var $ = function(selector){ }; [{ api: 'MOTOR', - method: 'GET', + method: 'POST', selector: '.motor.slider', event: 'change', - data: function(){ - return [this.getAttribute('data-motor-nr'), this.value]; + data: function() { + let payload = {}; + payload['motor' + this.getAttribute('data-motor-nr')] = this.value; + return Sui.util.serialize(payload); }, onResponse: debugResponse }, { api: 'LASER', - method: 'GET', + method: 'POST', selector: '.laser.slider', event: 'change', - onResponse: debugResponse + onResponse: debugResponse, + data: function() { + return Sui.util.serialize({ + laser: this.value + }); + } }].forEach(Sui.link({ api: { - MOTOR: '/motor/', // {motorNr}/{value} - LASER: '/laser/' // {value} + MOTOR: '/spirograph', // {motorNr}/{value} + LASER: '/spirograph' // {value} } })); }); \ No newline at end of file diff --git a/data/wifi.json b/data/wifi.json index bfe4195..99ce372 100644 --- a/data/wifi.json +++ b/data/wifi.json @@ -1,5 +1,5 @@ { "apMode": 0, - "SSID": "", - "Password": "" -} + "SSID": "tErAx1d", + "Password": "ramalamadingdong" +} \ No newline at end of file diff --git a/frontend/pages/index.html b/frontend/pages/index.html index 4db761d..d76c8e6 100644 --- a/frontend/pages/index.html +++ b/frontend/pages/index.html @@ -94,13 +94,13 @@
- + - + - + - +
last uri: diff --git a/frontend/scripts/sui.js b/frontend/scripts/sui.js index 363e974..a86f9d5 100644 --- a/frontend/scripts/sui.js +++ b/frontend/scripts/sui.js @@ -12,7 +12,8 @@ var Sui = { let update = function(endpoint, method, props) { Sui.http.ajax({ method: method, - endpoint: node.api[endpoint] + (props ? props.join('/') : ''), + endpoint: node.api[endpoint], + data: props, cache: false }, actuator.onResponse || null); }; @@ -20,7 +21,7 @@ var Sui = { let handle = function(event) { update.call(this, actuator.api, - 'GET', + actuator.method, actuator.data ? actuator.data.call(this) : [this.value] ); @@ -60,7 +61,7 @@ var Sui = { if(!cache) { data['_'] = new Date().getTime(); } - var serializedData = Sui.util.serialize(data); + var serializedData = data; //Sui.util.serialize(data); var endPointUrl = (config.method === 'GET' || config.method === 'DELETE') && data ? config.endpoint+'?'+serializedData : config.endpoint; var postData = config.method === 'POST' || config.method === 'PUT' ? serializedData : null; diff --git a/frontend/scripts/zMain.js b/frontend/scripts/zMain.js index 9603fea..306a7cb 100644 --- a/frontend/scripts/zMain.js +++ b/frontend/scripts/zMain.js @@ -4,23 +4,30 @@ Sui.ready(() => { }; [{ api: 'MOTOR', - method: 'GET', + method: 'POST', selector: '.motor.slider', event: 'change', - data: function(){ - return [this.getAttribute('data-motor-nr'), this.value]; + data: function() { + let payload = {}; + payload['motor' + this.getAttribute('data-motor-nr')] = this.value; + return Sui.util.serialize(payload); }, onResponse: debugResponse }, { api: 'LASER', - method: 'GET', + method: 'POST', selector: '.laser.slider', event: 'change', - onResponse: debugResponse + onResponse: debugResponse, + data: function() { + return Sui.util.serialize({ + laser: this.value + }); + } }].forEach(Sui.link({ api: { - MOTOR: '/motor/', // {motorNr}/{value} - LASER: '/laser/' // {value} + MOTOR: '/spirograph', // {motorNr}/{value} + LASER: '/spirograph' // {value} } })); }); \ No newline at end of file diff --git a/lib/readme.txt b/lib/readme.txt new file mode 100644 index 0000000..dbadc3d --- /dev/null +++ b/lib/readme.txt @@ -0,0 +1,36 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organized `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +More information about PlatformIO Library Dependency Finder +- http://docs.platformio.org/page/librarymanager/ldf.html diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..e6f003c --- /dev/null +++ b/platformio.ini @@ -0,0 +1,19 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/page/projectconf.html + +[env:nodemcu] +platform = espressif8266 +board = nodemcu +framework = arduino +monitor_baud = 115200 +build_flags = -Wl,-Tesp8266.flash.4m.ld +board_f_flash = 80000000L +board_flash_mode = dio +upload_resetmethod = nodemcu \ No newline at end of file diff --git a/esp8266-laser.ino b/src/esp8266-laser.ino similarity index 99% rename from esp8266-laser.ino rename to src/esp8266-laser.ino index 04cd5eb..cb20be9 100644 --- a/esp8266-laser.ino +++ b/src/esp8266-laser.ino @@ -126,7 +126,7 @@ void hWriteSpiro() String responseBuffer = String(); StaticJsonBuffer<200> jsonBuffer; JsonObject& root = jsonBuffer.createObject(); - JsonObject& data = root.createNestedObject("wificonfig"); + JsonObject& data = root.createNestedObject("spirograph"); if (server.hasArg("laser") ) { lmValues[0] = server.arg("laser").toInt(); data["laser"] = (String)lmValues[0]; @@ -439,4 +439,3 @@ void loop(void) { server.handleClient(); } -