Skip to content

Commit

Permalink
แก้ลิ้งรูปภาพ
Browse files Browse the repository at this point in the history
  • Loading branch information
Max committed Jul 28, 2019
1 parent d6ea6d9 commit aa1a526
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions blocks/block_iKB-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ Blockly.Blocks['ikb1_motor_forward'] = {
"message0": "%1 Move Forward at speed %2 %%",
"args0": [{
"type": "field_image",
"src": "/static/wheel-icon.png",
"src": require('path').dirname(Vue.prototype.$global.plugin.pluginInfo.plugins["block_iKB-1.js"].dir) + "/static/wheel-icon.png",
"width": 18,
"height": 16,
"alt": "*",
Expand All @@ -263,7 +263,7 @@ Blockly.Blocks['ikb1_motor_backward'] = {
"message0": "%1 Move Backward at speed %2 %%",
"args0": [{
"type": "field_image",
"src": "/static/wheel-icon.png",
"src": require('path').dirname(Vue.prototype.$global.plugin.pluginInfo.plugins["block_iKB-1.js"].dir) + "/static/wheel-icon.png",
"width": 20,
"height": 16,
"alt": "*",
Expand All @@ -289,7 +289,7 @@ Blockly.Blocks['ikb1_motor_forward2'] = {
"message0": "%1 Move Forward left wheel at speed %2 %% and right wheel at speed %3 %%",
"args0": [{
"type": "field_image",
"src": "/static/wheel-icon.png",
"src": require('path').dirname(Vue.prototype.$global.plugin.pluginInfo.plugins["block_iKB-1.js"].dir) + "/static/wheel-icon.png",
"width": 18,
"height": 16,
"alt": "*",
Expand Down Expand Up @@ -319,7 +319,7 @@ Blockly.Blocks['ikb1_motor_backward2'] = {
"message0": "%1 Move Backward left wheel at speed %2 %% and right wheel at speed %3 %%",
"args0": [{
"type": "field_image",
"src": "/static/wheel-icon.png",
"src": require('path').dirname(Vue.prototype.$global.plugin.pluginInfo.plugins["block_iKB-1.js"].dir) + "/static/wheel-icon.png",
"width": 18,
"height": 16,
"alt": "*",
Expand Down Expand Up @@ -349,7 +349,7 @@ Blockly.Blocks['ikb1_motor_turn_left'] = {
"message0": "%1 Turn Left at speed %2 %%",
"args0": [{
"type": "field_image",
"src": "/static/wheel-icon.png",
"src": require('path').dirname(Vue.prototype.$global.plugin.pluginInfo.plugins["block_iKB-1.js"].dir) + "/static/wheel-icon.png",
"width": 18,
"height": 16,
"alt": "*",
Expand All @@ -375,7 +375,7 @@ Blockly.Blocks['ikb1_motor_turn_right'] = {
"message0": "%1 Turn Right at speed %2 %%",
"args0": [{
"type": "field_image",
"src": "/static/wheel-icon.png",
"src": require('path').dirname(Vue.prototype.$global.plugin.pluginInfo.plugins["block_iKB-1.js"].dir) + "/static/wheel-icon.png",
"width": 18,
"height": 16,
"alt": "*",
Expand All @@ -401,7 +401,7 @@ Blockly.Blocks['ikb1_motor_spin_left'] = {
"message0": "%1 Spin Left at speed %2 %%",
"args0": [{
"type": "field_image",
"src": "/static/wheel-icon.png",
"src": require('path').dirname(Vue.prototype.$global.plugin.pluginInfo.plugins["block_iKB-1.js"].dir) + "/static/wheel-icon.png",
"width": 18,
"height": 16,
"alt": "*",
Expand All @@ -427,7 +427,7 @@ Blockly.Blocks['ikb1_motor_spin_right'] = {
"message0": "%1 Spin Right at speed %2 %%",
"args0": [{
"type": "field_image",
"src": "/static/wheel-icon.png",
"src": require('path').dirname(Vue.prototype.$global.plugin.pluginInfo.plugins["block_iKB-1.js"].dir) + "/static/wheel-icon.png",
"width": 18,
"height": 16,
"alt": "*",
Expand All @@ -453,7 +453,7 @@ Blockly.Blocks['ikb1_motor_stop'] = {
"message0": "%1 Stop Moving",
"args0": [{
"type": "field_image",
"src": "/static/wheel-icon.png",
"src": require('path').dirname(Vue.prototype.$global.plugin.pluginInfo.plugins["block_iKB-1.js"].dir) + "/static/wheel-icon.png",
"width": 18,
"height": 16,
"alt": "*",
Expand Down
12 changes: 6 additions & 6 deletions blocks/generator_iKB-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Blockly.JavaScript['ikb1_digital_read'] = function(block) {

Blockly.JavaScript['ikb1_digital_write'] = function(block) {
var dropdown_ch = block.getFieldValue('ch');
var value_value = Blockly.JavaScript.valueToCode(block, 'value', Blockly.JavaScript.ORDER_ATOMIC);
var value_value = Blockly.JavaScript.valueToCode(block, 'value', Blockly.JavaScript.ORDER_ATOMIC) || 0;
var code = 'ikb.digitalWrite(' + dropdown_ch + ', ' + value_value + ');\n';
return code;
};
Expand All @@ -51,15 +51,15 @@ Blockly.JavaScript['ikb1_motor'] = function(block) {

Blockly.JavaScript['ikb1_servo'] = function(block) {
var dropdown_ch = block.getFieldValue('ch');
var value_angle = Blockly.JavaScript.valueToCode(block, 'angle', Blockly.JavaScript.ORDER_ATOMIC);
var value_angle = Blockly.JavaScript.valueToCode(block, 'angle', Blockly.JavaScript.ORDER_ATOMIC) || 0;
var code = 'ikb.servo(' + dropdown_ch + ', ' + value_angle + ');\n';
return code;
};

Blockly.JavaScript['ikb1_servo2'] = function(block) {
var dropdown_ch = block.getFieldValue('ch');
var dropdown_dir = block.getFieldValue('dir');
var value_speed = Blockly.JavaScript.valueToCode(block, 'speed', Blockly.JavaScript.ORDER_ATOMIC);
var value_speed = Blockly.JavaScript.valueToCode(block, 'speed', Blockly.JavaScript.ORDER_ATOMIC) || 0;
var code = 'ikb.servo2(' + dropdown_ch + ', ' + dropdown_dir +', ' + value_speed + ');\n';
return code;
};
Expand All @@ -71,13 +71,13 @@ Blockly.JavaScript['ikb1_serial_config'] = function(block) {
};

Blockly.JavaScript['ikb1_serial_write'] = function(block) {
var value_data = Blockly.JavaScript.valueToCode(block, 'data', Blockly.JavaScript.ORDER_ATOMIC);
var value_data = Blockly.JavaScript.valueToCode(block, 'data', Blockly.JavaScript.ORDER_ATOMIC) || 0;
var code = 'ikb.Serial->print(' + value_data + ');\n';
return code;
};

Blockly.JavaScript['ikb1_serial_write_line'] = function(block) {
var value_data = Blockly.JavaScript.valueToCode(block, 'data', Blockly.JavaScript.ORDER_ATOMIC);
var value_data = Blockly.JavaScript.valueToCode(block, 'data', Blockly.JavaScript.ORDER_ATOMIC) || '';
var code = 'ikb.Serial->println(' + value_data + ');\n';
return code;
};
Expand Down Expand Up @@ -106,7 +106,7 @@ Blockly.JavaScript['ikb1_serial_read_string'] = function(block) {
};

Blockly.JavaScript['ikb1_serial_read_line'] = function(block) {
var code = 'ikb.Serial->readStringUntil(\'\n\')';
var code = 'ikb.Serial->readStringUntil(\'\\n\')';
return [code, Blockly.JavaScript.ORDER_NONE];
};

Expand Down

0 comments on commit aa1a526

Please sign in to comment.