snippets for the IDE

Posted on
  • this is what I find helpful for now :

    //Soft Reset        
    reset();
    //Details
    print("mem:"+JSON.stringify(process.memo­ry())+",version:"+process.env.VERSION+",­git_commit:"+process.env.GIT_COMMIT);
    //WiFi Status
    var wifi=require("Wifi");wifi.getStatus();
    //Hard Reset
    var esp=require("ESP8266");esp.reboot();
    

    let me know what you use

    looks like that in the EDI


    1 Attachment

    • Bildschirmfoto 2015-11-27 um 08.04.09.JPG
  • Cool - thanks for posting up! For others looking at this, the last 2 code snippets here are ESP8266-specific

  • I think there is a mistake here. The module names are case sensitive so Wi-Fi should be:

    var wifi = require ("Wifi")
    
  • Yup, the module name changed...

  • updated to work with 1v84.tve

  • What is the proper way of adding snippets? I'm editing the json in terminalsnippets.txt and feeling a little dirty.

  • Use the project icon to add snippets


    1 Attachment

    • Bildschirmfoto 2016-02-27 um 14.09.36.JPG
  • Thanks.

    Here are mine:

    {
      "Reset" : "reset();",
      "Memory" : "process.memory();",
      "ClearInterval" : "clearInterval();",
      "ClearCmdHistory" : "global['\\xFF'].history=[]",
      "Esp8266.printLog" : "require('ESP8266').printLog()",
      "Esp8266.reboot" : "require(\"ESP8266\").reboot()",
      "Esp8266.SocketInfo" : "require('ESP8266').dumpSocketInfo();req­uire('ESP8266').printLog();",
      "Esp8266.IdeDebug" : "require('ESP8266').setLog(2);",
      "Esp8266.JoinWifi" : "function join(ssid,password){wifi.connect(ssid,{p­assword:password},function(err,ipInfo){i­pInfo=wifi.getIP();print(\"Wifi IP: \"+JSON.stringify(ipInfo));wifi.save();}­);}"
    }
    

    For the wifi one, run the snippet to define the function, then join your network.

    join('your-ssid','your-password');
    

    The clear command history is used when you are running low on space, and want to free up some memory.

  • Nice. I like the ClearCmdHistory one. How much memory can this give back. I know it gets run if 'save()' fails, but never thought of it as something to use at runtime. Thanks!

  • Nice. I like the ClearCmdHistory one. How much memory can this give back? I know it gets run if 'save()' fails, but never thought of it as something to use at runtime. Thanks!

  • The 2nd one - process.memory() shows the space taken up by command history.

    On loading large bits of code, I sometimes use the clear cod history line to free up space will it is interpreting...

  • I like the ClearCmdHistory one. How much memory can this give back.

    I'm afraid that should be of no use at all. If Espruino starts to run out of memory it will automatically remove the command history one item at a time.... So it's unlikely that clearing it yourself will let something run that wouldn't have run otherwise.

    ... and if it does, that could well be a bug :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

snippets for the IDE

Posted by Avatar for MaBe @MaBe

Actions