WebIDE set time without send like in Apploader

Posted on
  • This is what the WebIDE is gererating and sending if When sending code, set Espruino's clock to the current time is checked.

    1. var time = new Date();
    2. code = "setTime("+(time.getTime()/1000)+");E.setTimeZone("+(-time.getTimezoneOffset()/60)+")\n"

    How to implement this feature into the WebIDE as a standalone function witn an icon like Set Espruino Time?

  • All you need to do is...

    • Copy _examplePlugin.js to a new JS file in the plugins folder
    • Replace the contents of the init function with something like:

      1. Espruino.Core.App.addIcon({
      2. id: "sendTime",
      3. icon: "star",
      4. title : "Send the current Time",
      5. order: 300,
      6. area: {
      7. name: "code",
      8. position: "bottom"
      9. },
      10. click: sendTime
      11. });

    Then add a sendTime function that calls:

    1. Espruino.Core.Serial.write(`\x03\x10setTime(....)\n`, false, function() {
    2. Espruino.Core.Notifications.success(`Sent the time`, true);
    3. });

    And I think you'll be done. It might be a nice thing to have as an option, so you could copy the code from https://github.com/espruino/EspruinoWebIDE/blob/master/js/plugins/codeLink.js which puts an option in Settings which shows/hides the icon when toggled

  • Great, just added a sendTime.js, looks like I missed something ....because the clock icon does not show here on http://mabecker.github.io/EspruinoWebIDE/

  • Looking atview-source:https://mabecker.github.io/EspruinoWebIDE/ you never include sendTime.js as a script there?

  • Ups, missed that one .... Thanks. Now it works. Let me know if you like to include this into the original WebIDE.

  • add screen shot


    1 Attachment

    • Bildschirmfoto 2023-11-02 um 12.53.09.JPG
  • Thanks! Well, someone asked a while ago (I think it was part of 'Projects'?) if there could be a way to upload some predefined commands from a menu, like setting time, reset(), load(), require("Storage").eraseAll() and I'm sure others.

    If a menu was added so you clicked a button and then clicked again on the command you wanted, do you think that'd be good enough for you?

    Also, if it was, what other commands would be useful?

  • Yes this is a feature the WebIDE lost, it was named snippets.

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

WebIDE set time without send like in Apploader

Posted by Avatar for MaBe @MaBe

Actions