Avatar for user110706

user110706

Member since Mar 2020 • Last active Mar 2020
  • 1 conversations
  • 3 comments

Most recent activity

  • in JavaScript
    Avatar for user110706

    Thank you Gordon!

    Blockly.JavaScript.robot_move_angle = function () {
        var dir = Blockly.JavaScript.valueToCode(this, 'dir', Blockly.JavaScript.ORDER_ASSIGNMENT) || '""';
        var vel = Blockly.JavaScript.valueToCode(this, 'vel', Blockly.JavaScript.ORDER_ASSIGNMENT) || '""';
        var angle = Blockly.JavaScript.valueToCode(this, 'angle', Blockly.JavaScript.ORDER_ASSIGNMENT) || '""';
        var time = Blockly.JavaScript.valueToCode(this, 'time', Blockly.JavaScript.ORDER_ASSIGNMENT) || '""';
        return "robot_move_angle("+dir+","+vel+","+angl­e+","+time+","+"setTimeout("+MAGIC_CALLB­ACK_CODE+", 1000*"+time+")\n;"
    }
    

    I wrote my code like this, and I know that NEXT_BLOCK works well.
    But it has an error.
    error said :
    You have more open brackets than close brackets. Please see the hints in the Editor window

    But I changed front-end for my project, so I can't use editor window.
    So I want to see codes when I push upload button at my terminal.

    /upload.html

      function sendUploadedCode() {
        Espruino.Core.MenuPortSelector.ensureCon­nected(function() {
          Espruino.callProcessor("sending");
          Espruino.callProcessor("transformForEspr­uino", uploadCode, function(code) {
            Espruino.Core.CodeWriter.writeToEspruino­(code, function() {
              Espruino.Core.Terminal.typeCharacters(co­de);
              Espruino.Core.Terminal.addNotification("­Uploaded!");
            });
          });
        });
      }
    

    I know upload button use this function, so I add one line,

    Espruino.Core.Terminal.typeCharacters(co­de);
    

    But it doesn't work. Is it possible to see uploaded codes at web ide's terminal??

  • in JavaScript
    Avatar for user110706

    Thanks for reply, Gordon!
    Shamefully, I don't understand..
    If you can, can you explain it by code?

    Everything will be fine if there is a method that can verify if there is a nextBlock...

  • in JavaScript
    Avatar for user110706

    Hello.
    My board is MDBT42Q, and it has some motors, IR sensor by i2c.
    Everything is fine. Motors move well, IR sensors too.
    But, my robot should move synchronous.

    For example,

    Blockly.Blocks.robot_move_angle = {
        category: 'CoduBot',
        init: function () {
            this.appendDummyInput()
                .appendField('로봇 각도로 움직이기');
            this.appendValueInput('dir')
                .setCheck(['Number'])
                .appendField('방향');
            this.appendValueInput('vel')
                .setCheck(['Number'])
                .appendField('속도');
            this.appendValueInput('angle')
                .setCheck(['Number'])
                .appendField('각도');
            this.appendValueInput('time')
                .setCheck(['Number'])
                .appendField('시간');
            this.setColour(150);
            this.setPreviousStatement(true);
            this.setNextStatement(true);
        }
    }
    
    Blockly.JavaScript.robot_move_angle = function () {
        var dir = Blockly.JavaScript.valueToCode(this, 'dir', Blockly.JavaScript.ORDER_ASSIGNMENT) || '""';
        var vel = Blockly.JavaScript.valueToCode(this, 'vel', Blockly.JavaScript.ORDER_ASSIGNMENT) || '""';
        var angle = Blockly.JavaScript.valueToCode(this, 'angle', Blockly.JavaScript.ORDER_ASSIGNMENT) || '""';
        var time = Blockly.JavaScript.valueToCode(this, 'time', Blockly.JavaScript.ORDER_ASSIGNMENT) || '""';
        return `robot_move_angle(${dir}, ${vel}, ${angle}, ${time})`;
    }
    

    It is my code.
    There's a block for initialize, and it's compressed by memory problem.
    So just init once, and return function execution code.
    (I don't know this is the best.)

    Anyway, If there are two 'robot_move_angle' blocks, and time is 2 sec and 4sec,
    user will think that it will move 2 sec, and after 2 sec, it will move 4 sec.

    But unfortunately, there's a crack, because of javascript's asynchronous.
    Is there a solution?

Actions