Avatar for rsm

rsm

Member since Apr 2014 • Last active Mar 2015
  • 8 conversations
  • 22 comments

Most recent activity

    • 5 comments
    • 2,883 views
  • in JavaScript
    Avatar for rsm

    Just a clarification, where would you call Espruino.Core.Code.switchToBlockly() from?

    Also, the code in js/core/app.js has a TODO that you plan to load the splitster orientation from file. Just wondering if that has been implemented already.

    Thanks.

    • 2 comments
    • 2,580 views
  • in JavaScript
    Avatar for rsm

    I need some help writing a save() block in blockly. This code moves the servo on pin B14 to two positions 0.5 seconds apart then saves it to the microcontroller so the code executes next time I plug it in. This code works when I write it in the JavaScript window:

    setTimeout(function () {analogWrite(B14, 1.8 / 50.0, {freq:20});},500);
    setTimeout(function () {analogWrite(B14, 1.6 / 50.0, {freq:20});},1000);
    save();
    

    Similarly, this code works to call the first two lines from a Blockly block, so I know I'm doing all of that correctly:

    Blockly.Language.save = {
        category: 'Espruino',
        init: function() {
            this.appendDummyInput()
                .appendTitle('Save');
          this.setPreviousStatement(true);
          this.setNextStatement(true);
          this.setColour(100);
          this.setInputsInline(true);
          this.setTooltip('Save Code to Board');
        }
      };
    
    Blockly.JavaScript.save = function() {
      var move = "setTimeout(function () {analogWrite(B14, 1.8 / 50.0, {freq:20});},500);\n";
      var move2 = "setTimeout(function () {analogWrite(B14, 1.6 / 50.0, {freq:20});},1000);\n";
      var saveCmd = "save();\n";
      return move + move2;
    };
    

    But as soon as I call the save() command from Blockly by changing line 18 to:

    return move + move2 + saveCmd;
    

    then the block does nothing. Meaning, the servo doesn't move, and there's no indication that anything was sent to the board. The frustrating part is that when I click on the command prompt side of the IDE and press up to see the commands sent, I see all three of the commands that I wanted to see:

    setTimeout(function () {analogWrite(B14, 1.8 / 50.0, {freq:20});},500);
    setTimeout(function () {analogWrite(B14, 1.6 / 50.0, {freq:20});},1000);
    save();
    

    Please help,
    Rehman

  • in JavaScript
    Avatar for rsm

    Thanks Gordon :)

    Rehman

    • 2 comments
    • 2,891 views
  • in JavaScript
    Avatar for rsm

    I've downloaded the source for the web IDE and I would like to customize a few things. Specifically, I'm writing new Blockly blocks, so I would like to be able to:

    1. Default to Blockly view as opposed to JavaScript
    2. Have the blockly portion take up most or all of the screen by default.
    3. I've added my new blocks to new list items like "Variables" or "Espruino". Is it possible to
      (a) get rid of these lists all together and just show all of the blocks available?, or
      (b) display only a subset of the list, then do something in the IDE to reveal more list items? The idea is to have a teacher "unlock" new blocks as a student passes a level with a subset of blocks.

    Thanks,
    Rehman

  • in JavaScript
    Avatar for rsm

    Hi, I would like to group several Blockly blocks into a function, then have the ability to call that function by simply calling a single block. I've seen that functionality on other Blockly sites, so I'm curious to know why it isn't part of the Espruino Chrome extension.

    Thanks,
    Rehman

    • 6 comments
    • 3,021 views
Actions