mirror of
https://github.com/0x1d/esp8266-laser.git
synced 2025-12-14 18:15:22 +01:00
new api integrated
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,4 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
|
.pioenvs
|
||||||
|
.piolibdeps
|
||||||
|
.vscode/
|
||||||
|
|||||||
65
.travis.yml
Normal file
65
.travis.yml
Normal file
@@ -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
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"apMode": 0,
|
"apMode": 0,
|
||||||
"SSID": "",
|
"SSID": "tErAx1d",
|
||||||
"Password": ""
|
"Password": "ramalamadingdong"
|
||||||
}
|
}
|
||||||
@@ -94,13 +94,13 @@
|
|||||||
|
|
||||||
<div id="prototypControls">
|
<div id="prototypControls">
|
||||||
<label>L</label>
|
<label>L</label>
|
||||||
<input type="range" class="laser slider" value="0" max="128">
|
<input type="range" class="laser slider" value="1" min="1" max="128">
|
||||||
<label>M1</label>
|
<label>M1</label>
|
||||||
<input type="range" class="motor slider" value="0" max="128" data-motor-nr="1">
|
<input type="range" class="motor slider" value="1" min="1" max="128" data-motor-nr="1">
|
||||||
<label>M2</label>
|
<label>M2</label>
|
||||||
<input type="range" class="motor slider" value="0" max="128" data-motor-nr="2">
|
<input type="range" class="motor slider" value="1" min="1" max="128" data-motor-nr="2">
|
||||||
<label>M3</label>
|
<label>M3</label>
|
||||||
<input type="range" class="motor slider" value="0" max="128" data-motor-nr="3">
|
<input type="range" class="motor slider" value="1" min="1" max="128" data-motor-nr="3">
|
||||||
</div>
|
</div>
|
||||||
<div id="prototypControls">
|
<div id="prototypControls">
|
||||||
<text class="sectionDesc">last uri:</text>
|
<text class="sectionDesc">last uri:</text>
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ var $ = function(selector){
|
|||||||
let update = function(endpoint, method, props) {
|
let update = function(endpoint, method, props) {
|
||||||
Sui.http.ajax({
|
Sui.http.ajax({
|
||||||
method: method,
|
method: method,
|
||||||
endpoint: node.api[endpoint] + (props ? props.join('/') : ''),
|
endpoint: node.api[endpoint],
|
||||||
|
data: props,
|
||||||
cache: false
|
cache: false
|
||||||
}, actuator.onResponse || null);
|
}, actuator.onResponse || null);
|
||||||
};
|
};
|
||||||
@@ -107,7 +108,7 @@ var $ = function(selector){
|
|||||||
let handle = function(event) {
|
let handle = function(event) {
|
||||||
update.call(this,
|
update.call(this,
|
||||||
actuator.api,
|
actuator.api,
|
||||||
'GET',
|
actuator.method,
|
||||||
actuator.data ?
|
actuator.data ?
|
||||||
actuator.data.call(this) : [this.value]
|
actuator.data.call(this) : [this.value]
|
||||||
);
|
);
|
||||||
@@ -147,7 +148,7 @@ var $ = function(selector){
|
|||||||
if(!cache) {
|
if(!cache) {
|
||||||
data['_'] = new Date().getTime();
|
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 endPointUrl = (config.method === 'GET' || config.method === 'DELETE') && data ? config.endpoint+'?'+serializedData : config.endpoint;
|
||||||
var postData = config.method === 'POST' || config.method === 'PUT' ? serializedData : null;
|
var postData = config.method === 'POST' || config.method === 'PUT' ? serializedData : null;
|
||||||
|
|
||||||
@@ -166,23 +167,30 @@ var $ = function(selector){
|
|||||||
};
|
};
|
||||||
[{
|
[{
|
||||||
api: 'MOTOR',
|
api: 'MOTOR',
|
||||||
method: 'GET',
|
method: 'POST',
|
||||||
selector: '.motor.slider',
|
selector: '.motor.slider',
|
||||||
event: 'change',
|
event: 'change',
|
||||||
data: function() {
|
data: function() {
|
||||||
return [this.getAttribute('data-motor-nr'), this.value];
|
let payload = {};
|
||||||
|
payload['motor' + this.getAttribute('data-motor-nr')] = this.value;
|
||||||
|
return Sui.util.serialize(payload);
|
||||||
},
|
},
|
||||||
onResponse: debugResponse
|
onResponse: debugResponse
|
||||||
}, {
|
}, {
|
||||||
api: 'LASER',
|
api: 'LASER',
|
||||||
method: 'GET',
|
method: 'POST',
|
||||||
selector: '.laser.slider',
|
selector: '.laser.slider',
|
||||||
event: 'change',
|
event: 'change',
|
||||||
onResponse: debugResponse
|
onResponse: debugResponse,
|
||||||
|
data: function() {
|
||||||
|
return Sui.util.serialize({
|
||||||
|
laser: this.value
|
||||||
|
});
|
||||||
|
}
|
||||||
}].forEach(Sui.link({
|
}].forEach(Sui.link({
|
||||||
api: {
|
api: {
|
||||||
MOTOR: '/motor/', // {motorNr}/{value}
|
MOTOR: '/spirograph', // {motorNr}/{value}
|
||||||
LASER: '/laser/' // {value}
|
LASER: '/spirograph' // {value}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"apMode": 0,
|
"apMode": 0,
|
||||||
"SSID": "",
|
"SSID": "tErAx1d",
|
||||||
"Password": ""
|
"Password": "ramalamadingdong"
|
||||||
}
|
}
|
||||||
@@ -94,13 +94,13 @@
|
|||||||
|
|
||||||
<div id="prototypControls">
|
<div id="prototypControls">
|
||||||
<label>L</label>
|
<label>L</label>
|
||||||
<input type="range" class="laser slider" value="0" max="128">
|
<input type="range" class="laser slider" value="1" min="1" max="128">
|
||||||
<label>M1</label>
|
<label>M1</label>
|
||||||
<input type="range" class="motor slider" value="0" max="128" data-motor-nr="1">
|
<input type="range" class="motor slider" value="1" min="1" max="128" data-motor-nr="1">
|
||||||
<label>M2</label>
|
<label>M2</label>
|
||||||
<input type="range" class="motor slider" value="0" max="128" data-motor-nr="2">
|
<input type="range" class="motor slider" value="1" min="1" max="128" data-motor-nr="2">
|
||||||
<label>M3</label>
|
<label>M3</label>
|
||||||
<input type="range" class="motor slider" value="0" max="128" data-motor-nr="3">
|
<input type="range" class="motor slider" value="1" min="1" max="128" data-motor-nr="3">
|
||||||
</div>
|
</div>
|
||||||
<div id="prototypControls">
|
<div id="prototypControls">
|
||||||
<text class="sectionDesc">last uri:</text>
|
<text class="sectionDesc">last uri:</text>
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ var Sui = {
|
|||||||
let update = function(endpoint, method, props) {
|
let update = function(endpoint, method, props) {
|
||||||
Sui.http.ajax({
|
Sui.http.ajax({
|
||||||
method: method,
|
method: method,
|
||||||
endpoint: node.api[endpoint] + (props ? props.join('/') : ''),
|
endpoint: node.api[endpoint],
|
||||||
|
data: props,
|
||||||
cache: false
|
cache: false
|
||||||
}, actuator.onResponse || null);
|
}, actuator.onResponse || null);
|
||||||
};
|
};
|
||||||
@@ -20,7 +21,7 @@ var Sui = {
|
|||||||
let handle = function(event) {
|
let handle = function(event) {
|
||||||
update.call(this,
|
update.call(this,
|
||||||
actuator.api,
|
actuator.api,
|
||||||
'GET',
|
actuator.method,
|
||||||
actuator.data ?
|
actuator.data ?
|
||||||
actuator.data.call(this) : [this.value]
|
actuator.data.call(this) : [this.value]
|
||||||
);
|
);
|
||||||
@@ -60,7 +61,7 @@ var Sui = {
|
|||||||
if(!cache) {
|
if(!cache) {
|
||||||
data['_'] = new Date().getTime();
|
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 endPointUrl = (config.method === 'GET' || config.method === 'DELETE') && data ? config.endpoint+'?'+serializedData : config.endpoint;
|
||||||
var postData = config.method === 'POST' || config.method === 'PUT' ? serializedData : null;
|
var postData = config.method === 'POST' || config.method === 'PUT' ? serializedData : null;
|
||||||
|
|
||||||
|
|||||||
@@ -4,23 +4,30 @@ Sui.ready(() => {
|
|||||||
};
|
};
|
||||||
[{
|
[{
|
||||||
api: 'MOTOR',
|
api: 'MOTOR',
|
||||||
method: 'GET',
|
method: 'POST',
|
||||||
selector: '.motor.slider',
|
selector: '.motor.slider',
|
||||||
event: 'change',
|
event: 'change',
|
||||||
data: function() {
|
data: function() {
|
||||||
return [this.getAttribute('data-motor-nr'), this.value];
|
let payload = {};
|
||||||
|
payload['motor' + this.getAttribute('data-motor-nr')] = this.value;
|
||||||
|
return Sui.util.serialize(payload);
|
||||||
},
|
},
|
||||||
onResponse: debugResponse
|
onResponse: debugResponse
|
||||||
}, {
|
}, {
|
||||||
api: 'LASER',
|
api: 'LASER',
|
||||||
method: 'GET',
|
method: 'POST',
|
||||||
selector: '.laser.slider',
|
selector: '.laser.slider',
|
||||||
event: 'change',
|
event: 'change',
|
||||||
onResponse: debugResponse
|
onResponse: debugResponse,
|
||||||
|
data: function() {
|
||||||
|
return Sui.util.serialize({
|
||||||
|
laser: this.value
|
||||||
|
});
|
||||||
|
}
|
||||||
}].forEach(Sui.link({
|
}].forEach(Sui.link({
|
||||||
api: {
|
api: {
|
||||||
MOTOR: '/motor/', // {motorNr}/{value}
|
MOTOR: '/spirograph', // {motorNr}/{value}
|
||||||
LASER: '/laser/' // {value}
|
LASER: '/spirograph' // {value}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
36
lib/readme.txt
Normal file
36
lib/readme.txt
Normal file
@@ -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 <Foo.h>
|
||||||
|
#include <Bar.h>
|
||||||
|
|
||||||
|
// 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
|
||||||
19
platformio.ini
Normal file
19
platformio.ini
Normal file
@@ -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
|
||||||
@@ -126,7 +126,7 @@ void hWriteSpiro()
|
|||||||
String responseBuffer = String();
|
String responseBuffer = String();
|
||||||
StaticJsonBuffer<200> jsonBuffer;
|
StaticJsonBuffer<200> jsonBuffer;
|
||||||
JsonObject& root = jsonBuffer.createObject();
|
JsonObject& root = jsonBuffer.createObject();
|
||||||
JsonObject& data = root.createNestedObject("wificonfig");
|
JsonObject& data = root.createNestedObject("spirograph");
|
||||||
if (server.hasArg("laser") ) {
|
if (server.hasArg("laser") ) {
|
||||||
lmValues[0] = server.arg("laser").toInt();
|
lmValues[0] = server.arg("laser").toInt();
|
||||||
data["laser"] = (String)lmValues[0];
|
data["laser"] = (String)lmValues[0];
|
||||||
@@ -439,4 +439,3 @@ void loop(void) {
|
|||||||
server.handleClient();
|
server.handleClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user