Compare commits

...

5 Commits

  1. 2
      examples/demo/.wiot/.gitignore
  2. 1
      examples/demo/.wiot/__hash
  3. 1
      examples/demo/.wiot/compiled_files/27e4c
  4. 1
      examples/demo/.wiot/compiled_files/3beaa
  5. 1
      examples/demo/.wiot/compiled_files/cc54c
  6. 28
      examples/demo/config.json
  7. 98
      examples/demo/index.js
  8. 2913
      examples/demo/package-lock.json
  9. 5
      examples/demo/package.json
  10. 2546
      examples/demo/yarn.lock
  11. 2
      package.json
  12. 5
      src/compiler/index.js

@ -0,0 +1,2 @@
cache/
compiled_files/

@ -0,0 +1 @@
c3019891ee712237f10b5e16f840edaf4ad8d2ea62ffcfc134e2b1d95314e5ee

@ -0,0 +1 @@
gpio.mode(2,gpio.INPUT);_b=0;F_b=_b;_l=500;F_l=_l;_c=1;F_c=_c;_g=0;F_g=_g;_o=0;_d=0;F_d=_d;_e=0;F_e=_e;_f=0;F_f=_f;_p=0;_q=0;pwm.setup(4,_l,_b);pwm.setduty(4,_b);_o=function()_b=_c*_g;end;_p=function()print(_c,_d,_e,_f);end;tmr.create():alarm(10,tmr.ALARM_AUTO,function()if not(F_b==_b)then pwm.setduty(4,_b);msg.send('cc54c','_b',_b);msg.send('3beaa','_b',_b);FR_b=nil;end;F_b=_b;if not(F_l==_l)then pwm.setclock(4,_l);end;F_l=_l;if not(F_c==_c)then _o();_p();end;F_c=_c;if not(F_g==_g)then _o();end;F_g=_g;if not(F_d==_d)then _p();_c=(_c+1)%2;end;F_d=_d;if not(F_e==_e)then _p();_q=31;end;F_e=_e;if not(F_f==_f)then _p();_c=((_f=='play')and{1}or{((_f=='stop')and{0}or{_c})[1]})[1];end;F_f=_f;if not(_q==0)then _q=_q-1;end;if _q==1 then _d=_e;end;_e=gpio.read(2);end);msg.onSend('_b',function(from,body)_b=body;FR_b=from;end);

@ -0,0 +1 @@
_b=0;F_b=_b;_n=500;F_n=_n;pwm.setup(4,_n,_b);pwm.setduty(4,_b);tmr.create():alarm(10,tmr.ALARM_AUTO,function()if not(F_b==_b)then pwm.setduty(4,_b);end;F_b=_b;if not(F_n==_n)then pwm.setclock(4,_n);end;F_n=_n;end);msg.onSend('_b',function(from,body)_b=body;FR_b=from;end);

@ -0,0 +1 @@
_b=0;F_b=_b;_m=500;F_m=_m;pwm.setup(4,_m,_b);pwm.setduty(4,_b);tmr.create():alarm(10,tmr.ALARM_AUTO,function()if not(F_b==_b)then pwm.setduty(4,_b);end;F_b=_b;if not(F_m==_m)then pwm.setclock(4,_m);end;F_m=_m;end);msg.onSend('_b',function(from,body)_b=body;FR_b=from;end);

@ -0,0 +1,28 @@
{
"name": "demo",
"entrance": "index.js",
"director": "https://wiot-director.yimian.xyz/",
"nodes": {
"27e4c": {
"nickname": "node1",
"msgport": 6789,
"wifiIndex": 0
},
"cc54c": {
"nickname": "node2",
"msgport": 6789,
"wifiIndex": 0
},
"3beaa": {
"nickname": "node3",
"msgport": 6789,
"wifiIndex": 0
}
},
"wifi": [
{
"ssid": "yimian-iot",
"pwd": "1234567890."
}
]
}

@ -0,0 +1,98 @@
//import wiot compiler
const wiot = require('wiot');
//node ID array
let nids = ['27e4c', 'cc54c', '3beaa'];
//node object array constructed from the above node IDs
let nodes = nids.map(nid=>new wiot.node.nodemcu(nid));
//create a virtual wire
let w = new wiot.wire(0),
w1 = new wiot.wire(1),
w2 = new wiot.wire(),
w3 = new wiot.wire(),
w4 = new wiot.wire(),
w5 = new wiot.wire(),
w6 = new wiot.wire(),
w7 = new wiot.wire(),
w8 = new wiot.wire(),
w9 = new wiot.wire();
wiot.pwm(nodes[0], nodes[0].D4, w, new wiot.wire(500));
wiot.pwm(nodes[1], nodes[1].D4, w, new wiot.wire(500));
wiot.pwm(nodes[2], nodes[2].D4, w, new wiot.wire(500));
wiot.operate(nodes[0], `$1*$2`, w, w1, w5);
wiot.print(nodes[0], w1, w2, w3, w4)
wiot.operate(nodes[0], `($0+1)%2`, w1, w2);
wiot.buffer(nodes[0], w2, w3, 0.3);
wiot.gpio(nodes[0], wiot.INPUT, nodes[0].D2, w3);
wiot.operate(nodes[0], `${wiot.if(`$1=='play'`, 1, wiot.if(`$1=='stop'`, 0, `$0`))}`, w1, w4);
wiot.bigiot(nodes[0], 21249, 'ee37b3a2a', w4);
wiot.buffer(nodes[0], w5, w6, .8);
wiot.operate(nodes[0], wiot.if(`$1>$0+100 or $1<$0-100`, `$1`, `$0`), w6, w7);
wiot.adc(nodes[0], w7);
wiot.operate(nodes[1], `${wiot.if(`$1==1`, `'on'`, `'off'`)}`, w8, w1);
wiot.operate(nodes[1], `${wiot.if(`$1=='true'`, 1, 0)}`, w1, w9);
wiot.webpage(nodes[1], '122f3169fa7e12989bd7f1ed1c571b64', [{
id: 'b',
name: 'Brightness'
},{
id: 's',
name: 'Switch'
},{
id: 'l',
name: 'LED'
},{
id: 'w',
name: 'web button',
type: 'button'
}], {
w: w9
}, {
b: w5,
s: w2,
l: w8
});
let w10 = new wiot.wire(0),
w11 = new wiot.wire(1),
w12 = new wiot.wire(),
w13 = new wiot.wire();
wiot.pwm(nodes[2], nodes[2].D6, w10, new wiot.wire(500));
wiot.pwm(nodes[2], nodes[2].D8, w10, new wiot.wire(1000));
wiot.operate(nodes[2], `(($1+1)%2)*$2`, w10, w11, w13);
wiot.buffer(nodes[2], w11, w12, 5);
wiot.gpio(nodes[2], wiot.INPUT, nodes[2].D2, w12);
wiot.breathing(nodes[2], 1, w13);
let wire_en = new wiot.wire(0);
wiot.operate(nodes[2], wiot.if(`$1==0`, 0, 1), wire_en, w10);
wiot.mail(nodes[2], wire_en, new wiot.wire(`'i@iotcat.me'`),
new wiot.wire(`'Warning from IR sensor!!'`), new wiot.wire(`'Warning!!!!'`));
wiot.memobird(nodes[2], "9e55121803474371bfa25d20e554b31d",
"1133807", "b3ee06a8bd9b49e1", wire_en, new wiot.wire(`'Warning!!!!'`));

File diff suppressed because it is too large Load Diff

@ -0,0 +1,5 @@
{
"dependencies": {
"wiot": "^0.3.9"
}
}

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
{
"name": "wiot",
"version": "0.3.9",
"version": "0.4.1",
"description": "A software-defined IoT Network OS for NodeMCU",
"main": "src/compiler/index.js",
"repository": "git@github.com:iotcat/wIoT",

@ -22,4 +22,7 @@ require(__dirname + '/operators/strIndexOf.js')(wiot)
require(__dirname + '/operators/strSubStr.js')(wiot)
/* modules */
require(__dirname + '/modules/breathing.js')(wiot)
require(__dirname + '/modules/breathing.js')(wiot)
module.exports = wiot;

Loading…
Cancel
Save