Chat freely about the open source Javascript projects for ESP8266

User avatar
By jankop
#30906 It's not easy. No documentation, examples of dysfunctional and nearly none.
But first program in smart.js I wrote. It cost me a few hours of my time, because everything is different than declaring Cesanta.
Tested with smart.js APLHA2:
Code: Select all// JavaScript - blinkig LED on GPIO0
// test GPIO.setmode(), GPIO.write() and GPIO.read()
var led =1;
var pin =0; // GPIO0 = 0, GPIO1 = 1 (blueLED)... etc
var mod =0; // 0 = I/O, 1 = INP, 2 = OUT, 3 = Interrupt
var pul =1; // 0 = floating, 1 = pullup, 2 = pulldown resistor
GPIO.setmode(pin, mod, pul)
function blink() { GPIO.write(pin,led);
    if (led==1) {led=0} else {led=1}; print(pin,mod,pul,GPIO.read(pin));
     setTimeout(blink, 1000);}
blink()


Note: for start of program aply File.eval('file-name.js')
Last edited by jankop on Thu Oct 08, 2015 3:53 pm, edited 3 times in total.
User avatar
By kolban
#30908 I had a go at writing the same app in Espruino JavaScript running on the ESP8266 and came up with:

Code: Select allvar led = true;
var pin = new Pin(0);

function blink() {
  digitalWrite(pin, led);
  print("Pin" + pin + " = " + led);
  led = !led;
  setTimeout(blink, 1000);
}
blink();


As an alternative to calling:

Code: Select alldigitalWrite(pin, led);


one can also call:

Code: Select allpin.write(led);
User avatar
By Sergey Lyubka
#33963
jankop wrote:It's not easy. No documentation, examples of dysfunctional and nearly none.
Note: for start of program aply File.eval('file-name.js')


Speaking on behalf of Cesanta - I am the CTO of the company.
We were at alpha stage, and yes - rough and unstable at that moment.
However, we've improved things a lot, and work is in progress!

Examples, including blink example, at https://www.cesanta.com/developer/smart ... nk_example
I'd appreciate the feedback.