-
-
The reason why I use
validate
is, when I don't choose any value in dropdown, so the default value should be set, but unfortunately it doesn't. The value wasundefined
when I don't select any value in dropdown!if(motorValid_ === false) { motor_ = 0; <----------------------- here because motorValid never got set } else { motor_ = block.getFieldValue("turnMotor_") <--- never gets called
So that
block.getFieldValue("turnMotor_")
line works well, because of validator.I can't think the way that
just check what's going on when creating the code in Blockly.JavaScript.*
.Can you explain with any examples?
-
Hi Gordon!
Thanks for reply.https://github.com/junguksim/project_codubot/blob/master/blockly/blockly_codubot.js
You can watch first block(codubot ready)'s code at first line.
Second block(motor_move)'s code is at line 178.If you want more, please give me reply.
-
Hello there.
I'm developing a site which can control an educational robot(by MDBT42Q).Here's my block code that I want to save and load.
(If you can't see photo, I attached at below.)
It looks simple. First dropdown has two options(LEFT, RIGHT) and LEFT is 0, RIGHT is 1.
Second dropdown has two also, CW is 0 , CCW is 1.It's a converted javascript code.
/* motor_move function code */ motor_move(1, 0, 0, 0, false); //motor_move's parameters : motor_move(motor, direction, velocity, angle, wait);
If I set 'RIGHT' motor at block code and save my code, and then I load it and convert, the code shows
motor_move(0,0,0,0,false);
So the loaded block code shows 'RIGHT' motor set, but actually robot moves 'LEFT' motor.
How can I save block code with right parameters that I set before?
Help me please!
-
Hi!
I have some problems.var ir_adc = [0, 0, 0, 0, 0]; var ir_adc_loop = setInterval(function() { i2c.writeTo(0x0A, [1, 10]); i2c.writeTo(0x0A, [14]); var ir_i2c = i2c.readFrom(0x0A, 10); ir_adc = [((ir_i2c[0] * 256) + ir_i2c[1]), ((ir_i2c[2] * 256) + ir_i2c [3]), ((ir_i2c[4] * 256) + ir_i2c [5]), ((ir_i2c[6] * 256) + ir_i2c [7]), ((ir_i2c[8] * 256) + ir_i2c [9])]; }, 10);
Here is my code for Espruino web ide. ( To get IR Sensor value)
So if I upload this code to robot,>ir_adc =[38,44,43,41,41]
I can get my ir_adc value.
But I want to get ir_adc value in my blockly_something.js.
Is there a solution to get IN-ROBOT value at my vscode SUPERCOOL?Thank you.
-
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+","+angle+","+time+","+"setTimeout("+MAGIC_CALLBACK_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 windowBut 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.ensureConnected(function() { Espruino.callProcessor("sending"); Espruino.callProcessor("transformForEspruino", uploadCode, function(code) { Espruino.Core.CodeWriter.writeToEspruino(code, function() { Espruino.Core.Terminal.typeCharacters(code); Espruino.Core.Terminal.addNotification("Uploaded!"); }); }); }); }
I know upload button use this function, so I add one line,
Espruino.Core.Terminal.typeCharacters(code);
But it doesn't work. Is it possible to see uploaded codes at web ide's terminal??
-
-
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?
Hi
I want to make a block which can load a txt file and can use the file's content.
I found helpful link to use file import block below
https://groups.google.com/forum/#!starred/blockly/grwyJKzRg60
I think it's possible in blockly, but I don't know how to use the block in that link in my espurino web ide project.
Can you help me?