Avatar for L0cutus

L0cutus

Member since Sep 2017 • Last active Oct 2017
  • 3 conversations
  • 8 comments

Most recent activity

  • in General
    Avatar for L0cutus

    are this:
    Capacitors: http://ebay.eu/2yWBy9u
    Quarz: http://ebay.eu/2hJBupe

    correct for espruino pico ?

    • 6 comments
    • 160 views
  • in Interfacing
    Avatar for L0cutus

    Great!
    Waiting for news ;-)

  • in Interfacing
    Avatar for L0cutus

    Ahem no, i'm too much noob to be able to make a library!
    I'm still learning javascript with the help of espruino ;-)
    Thanks anyway for now!

  • in Interfacing
    Avatar for L0cutus

    Hi!
    someone know if this display:

    https://www.waveshare.com/wiki/2.7inch_e­-PaperHAT(B)

    is supported by espruino ?
    if yes, which library ?

    Thanks !

  • in General
    Avatar for L0cutus

    Yes, i'm uploading via the code editor panel, after uploading it i write to the console the onInit(); command and it does connect and show me the IP, the "GET" version of this code does work without problems but NOT the "POST" one.

    This code:

        if (r.method == "POST" && r.query && r.query.led)
          digitalWrite([LED2,LED1], r.query.led);
        console.log(r.method);
    

    Line 1 (if ) never exeute the digitlWrite since it find always "GET" as the method and never the "POST"
    line 3 ALWAYS return "GET" not "POST" .
    maybe it is because of i'm loading this server in local ?

    Thanks !

  • in General
    Avatar for L0cutus

    Hello,
    I'm trying some code from page 246 (Espruino Pico+ESP8266):

    // Test ESP8266
    var WIFI_NAME = "MYSSID";
    var WIFI_KEY =  "WIFIPWD";
    var wifi;
    var json;
    
    var homepage = '<html><body>'+
    '<h1>My Espruino</h1>'+
    '<a href="/getTemp">Temperature</a></br>'+
    '<form action="/?led=0" method="post">'+
    '<input type="submit" value="LEDS OFF"/></form>'+
    '<form action="/?led=1" method="post">'+
    '<input type="submit" value="LED RED ON"/></form>'+
    '<form action="/?led=2" method="post">'+
    '<input type="submit" value="LED GREEN ON"/></form>'+
    '<form action="/?led=3" method="post">'+
    '<input type="submit" value="LED RED+GREEN ON"/>d</form>'+
    '</body></html>';
    
    
    function onInit() {
      USB.setConsole(true);
      Serial1.setup(115200, { tx:B6, rx: B7});
      wifi = require("ESP8266WiFi_0v25").connect(Seri­al1, function(err) {
        if(err) throw err;
        console.log("Connecting to WiFi");
        wifi.connect(WIFI_NAME, WIFI_KEY, function(err) {
          if(err) {
            console.log("Connection error: "+err);
            return;
          }
          onConnected();
        });
      });
    }
    
    function onConnected() {
      console.log("Connected");
      require("http").createServer(onPageReque­st).listen(80);
      wifi.getIP(function(err,ip){
        console.log("Your IP address is http://" + ip);
      });
    }
    
    function onPageRequest(req, res) {
      console.log("Serving " + req.url);
      var r = url.parse(req.url, true);
      if (r.pathname == "/") {
        // controllo passaggio parametri
        if (r.method == "POST" && r.query && r.query.led)
          digitalWrite([LED2,LED1], r.query.led);
        console.log(r.method);
        // Onora la richiesta della pagina
        res.writeHead(200, {"Content-Type!": "text/html"});
        res.end(homepage);
      } else if (r.pathname == "/getTemp"){
        res.writeHead(200, {"Content-Type!": "text/html"});
        res.end('<html><head>'+
                '<meta http-equiv="refresh" content="2">'+
                '</head><body>'+E.getTemperature().toFix­ed(2)+
                '</body></html>');
      } else {
        res.writeHead(404);
        res.end("404 - Not Found");
      }
    }
    

    Unfortunately it doesn't work as it 'see' only GET as a method, not the POST, sorry for my english and my worst HTML knowledge ;-)

Actions