初始化提交
This commit is contained in:
482
boards/default_src/micropython/blocks/actuator.js
Normal file
482
boards/default_src/micropython/blocks/actuator.js
Normal file
@@ -0,0 +1,482 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
const ACTUATOR_HUE = 100;
|
||||
|
||||
//Servo
|
||||
export const servo_move = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_SERVO)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendValueInput("DEGREE", Number)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_DEGREE_0_180);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_SERVO_MOVE);
|
||||
}
|
||||
};
|
||||
|
||||
//LED
|
||||
export const number = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["1", "1"],
|
||||
["2", "2"]
|
||||
]), 'op')
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const ledswitch = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_ESP32_ON, "1"],
|
||||
[Blockly.Msg.MIXLY_ESP32_OFF, "0"],
|
||||
[Blockly.Msg.MIXLY_ESP32_TOGGLE, "-1"]
|
||||
]), "flag");
|
||||
this.setOutput(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_INOUT_HIGHLOW);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_extern_led_bright = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SETTING)
|
||||
.appendField(Blockly.Msg.MIXLY_EXTERN_LED)
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendValueInput('bright')
|
||||
.appendField(Blockly.Msg.MIXLY_PULSEIN_STAT)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_EXTERN_LED_SETONOFF);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_extern_get_led_bright = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET)
|
||||
.appendField(Blockly.Msg.MIXLY_EXTERN_LED)
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_PULSEIN_STAT)
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_EXTERN_LED_GETONOFF);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_extern_led_brightness = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SETTING)
|
||||
.appendField(Blockly.Msg.MIXLY_EXTERN_LED)
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendValueInput('bright')
|
||||
.appendField(Blockly.Msg.MIXLY_BRIGHTNESS)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_EXTERN_LED_SETBRIGHT);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_led_bright = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SETTING);
|
||||
this.appendValueInput('led')
|
||||
.appendField(Blockly.Msg.MIXLY_BUILDIN_LED)
|
||||
this.appendValueInput('bright')
|
||||
.appendField(Blockly.Msg.MIXLY_PULSEIN_STAT)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_LED_SETONOFF);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_get_led_bright = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET);
|
||||
this.appendValueInput('led')
|
||||
.appendField(Blockly.Msg.MIXLY_BUILDIN_LED)
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_PULSEIN_STAT)
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_LED_GETONOFF);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_led_brightness = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SETTING);
|
||||
this.appendValueInput('led')
|
||||
.appendField(Blockly.Msg.MIXLY_BUILDIN_LED)
|
||||
this.appendValueInput('bright')
|
||||
.appendField(Blockly.Msg.MIXLY_BRIGHTNESS)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_LED_SETBRIGHT);
|
||||
}
|
||||
};
|
||||
|
||||
//music
|
||||
export const esp32_music_pitch = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_TONE)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendValueInput('pitch')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_FREQUENCY);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_TONE);
|
||||
}
|
||||
};
|
||||
|
||||
export const esp32_music_pitch_with_time = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_TONE)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendValueInput('pitch')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_FREQUENCY);
|
||||
this.appendValueInput('time')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_DURATION);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_TONE2);
|
||||
}
|
||||
};
|
||||
|
||||
export const esp32_music_stop = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_NOTONE)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const esp32_music_set_tempo = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendValueInput('TICKS')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_SET_TEMPO)
|
||||
.appendField(Blockly.Msg.MICROBIT_ACTUATOR_ticks);
|
||||
this.appendValueInput('BPM')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_SPEED);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_MUSIC_SET_TEMPO);
|
||||
}
|
||||
}
|
||||
|
||||
export const esp32_music_get_tempo = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_Get_current_tempo)
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_MUSIC_GET_TEMPO);
|
||||
}
|
||||
}
|
||||
|
||||
export const esp32_music_reset = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_Reset_music)
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_MUSIC_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
export const esp32_onboard_music_pitch = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_TONE);
|
||||
this.appendValueInput('pitch')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_FREQUENCY);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_TONE);
|
||||
}
|
||||
};
|
||||
|
||||
export const esp32_onboard_music_pitch_with_time = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_TONE);
|
||||
this.appendValueInput('pitch')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_FREQUENCY);
|
||||
this.appendValueInput('time')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_DURATION);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_TONE2);
|
||||
}
|
||||
};
|
||||
|
||||
export const esp32_onboard_music_stop = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_NOTONE);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const esp32_onboard_music_play_list = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendValueInput('LIST')
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_MUSIC_PLAY_LISTS)
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_MUSIC_PLAY_LISTS);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export const esp32_music_play_list = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendValueInput('LIST')
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_MUSIC_PLAY_LISTS)
|
||||
this.appendValueInput('PIN')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_MUSIC_PLAY_LISTS);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export const esp32_mixgo_music_play_list_show = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendValueInput('LIST')
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_MUSIC_PLAY_LISTS)
|
||||
this.appendValueInput('PIN')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN);
|
||||
// this.appendValueInput('DISPLAY')
|
||||
// .appendField(Blockly.Msg.MIXLY_ESP32_MIXGO_MUSIC_SHOW_IN);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_MIXGO_MUSIC_PLAY_TONE);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_MUSIC_PLAYSHOW)
|
||||
}
|
||||
}
|
||||
//RGB
|
||||
export const actuator_neopixel_init = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_RGB)
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
.setCheck("var");
|
||||
this.appendValueInput("PIN", Number)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN);
|
||||
this.appendValueInput("LEDCOUNT")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_COUNT);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_RGB_PIN_COUNT);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_neopixel_rgb = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_RGB)
|
||||
this.appendValueInput('SUB')
|
||||
.setCheck("var");
|
||||
// .appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
this.appendValueInput("_LED_")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_NUM);
|
||||
this.appendValueInput("RVALUE")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_R);
|
||||
this.appendValueInput("GVALUE")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_G);
|
||||
this.appendValueInput("BVALUE")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_B);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip('');
|
||||
this.setTooltip(Blockly.Msg.MIXLY_RGB_NUM_R_G_B);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_neopixel_write = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_RGB)
|
||||
// this.appendValueInput("PIN", Number)
|
||||
// .setCheck(Number)
|
||||
// .setAlign(Blockly.inputs.Align.RIGHT)
|
||||
// .appendField(Blockly.Msg.MIXLY_PIN);
|
||||
this.appendValueInput('SUB')
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_RGB_WRITE)
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip('');
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_MUSIC_WRI);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_onboard_neopixel_rgb = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_RGB)
|
||||
this.appendValueInput("_LED_")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_NUM);
|
||||
this.appendValueInput("RVALUE")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_R);
|
||||
this.appendValueInput("GVALUE")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_G);
|
||||
this.appendValueInput("BVALUE")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_B);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip('');
|
||||
this.setTooltip(Blockly.Msg.MIXLY_RGB_NUM_R_G_B);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_onboard_neopixel_rgb_all = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_RGB)
|
||||
this.appendValueInput("RVALUE")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_R);
|
||||
this.appendValueInput("GVALUE")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_G);
|
||||
this.appendValueInput("BVALUE")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_B);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip('');
|
||||
this.setTooltip(Blockly.Msg.MIXLY_RGB_NUM_R_G_B);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_onboard_neopixel_write = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_RGB)
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_RGB_WRITE)
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip('');
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_MUSIC_WRI);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const led_light = actuator_led_bright;
|
||||
export const get_led_bright = actuator_get_led_bright;
|
||||
export const led_brightness = actuator_led_brightness;
|
||||
947
boards/default_src/micropython/blocks/actuator_extern.js
Normal file
947
boards/default_src/micropython/blocks/actuator_extern.js
Normal file
@@ -0,0 +1,947 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
import { Profile } from 'mixly';
|
||||
|
||||
const ACTUATOR_EXTERN_HUE = '#74A55B';
|
||||
|
||||
//music
|
||||
export const esp32_music_pitch_init = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_MIDI)
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
.setCheck("var");
|
||||
this.appendValueInput("PIN", Number)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_RGB_PIN_COUNT);
|
||||
}
|
||||
};
|
||||
|
||||
export const esp32_music_pitch = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_TONE)
|
||||
this.appendValueInput('pitch')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_FREQUENCY);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_TONE);
|
||||
}
|
||||
};
|
||||
|
||||
export const esp32_music_pitch_with_time = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_TONE)
|
||||
this.appendValueInput('pitch')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_FREQUENCY);
|
||||
this.appendValueInput('time')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_DURATION);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_TONE2);
|
||||
}
|
||||
};
|
||||
|
||||
export const esp32_music_play_list = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendValueInput('LIST')
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_MUSIC_PLAY_LISTS)
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_MUSIC_PLAY_LISTS);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export const esp32_music_set_tempo_extern = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendValueInput('TICKS')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_SET_TEMPO)
|
||||
.appendField(Blockly.Msg.MICROBIT_ACTUATOR_ticks);
|
||||
this.appendValueInput('BPM')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_SPEED);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_MUSIC_SET_TEMPO);
|
||||
}
|
||||
}
|
||||
|
||||
export const esp32_music_get_tempo_extern = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_Get_current_tempo)
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_MUSIC_GET_TEMPO);
|
||||
}
|
||||
}
|
||||
|
||||
export const esp32_music_reset_extern = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_Reset_music)
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_MUSIC_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
export const esp32_music_stop = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_NOTONE)
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_extern_led_bright = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SETTING)
|
||||
.appendField(Blockly.Msg.MIXLY_EXTERN_LED)
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendValueInput('bright')
|
||||
.appendField(Blockly.Msg.MIXLY_PULSEIN_STAT)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_EXTERN_LED_SETONOFF);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_extern_get_led_bright = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET)
|
||||
.appendField(Blockly.Msg.MIXLY_EXTERN_LED)
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_BRIGHTNESS)
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_EXTERN_LED_GETONOFF);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_extern_get_led_state = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET)
|
||||
.appendField(Blockly.Msg.MIXLY_EXTERN_LED)
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_PULSEIN_STAT)
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_EXTERN_LED_GETONOFF);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_extern_led_brightness = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SETTING)
|
||||
.appendField(Blockly.Msg.MIXLY_EXTERN_LED)
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendValueInput('bright')
|
||||
.appendField(Blockly.Msg.MIXLY_BRIGHTNESS)
|
||||
this.appendDummyInput()
|
||||
.appendField('%')
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_EXTERN_LED_SETBRIGHT);
|
||||
}
|
||||
};
|
||||
|
||||
//Servo
|
||||
export const servo_init = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput("VAR")
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP + Blockly.Msg.MIXLY_SERVO)
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const servo_move = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_SERVO)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendValueInput("DEGREE", Number)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_DEGREE_0_180);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_SERVO_MOVE);
|
||||
}
|
||||
};
|
||||
|
||||
export const servo_speed_360 = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput("VAR")
|
||||
.appendField("360°" + Blockly.Msg.MIXLY_SERVO)
|
||||
this.appendValueInput("SPEED", Number)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_SETTING + Blockly.Msg.blockpy_turtle_rotate + Blockly.Msg.MIXLY_SPEED + " (-10~10)");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_SERVO_360_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
//Servo
|
||||
export const servo_set_angle = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField('180°' + Blockly.Msg.MIXLY_SERVO)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendValueInput("NUM", Number)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_SERVO_MOVE);
|
||||
}
|
||||
};
|
||||
|
||||
export const servo_set_speed = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField('360°' + Blockly.Msg.MIXLY_SERVO)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendValueInput("NUM", Number)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_SPEED);
|
||||
this.appendDummyInput()
|
||||
.appendField('%');
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_SERVO_SPEED_TOOLIPS);
|
||||
}
|
||||
};
|
||||
|
||||
export const servo_get_angle = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField('180°' + Blockly.Msg.MIXLY_SERVO)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET + Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const servo_get_speed = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField('360°' + Blockly.Msg.MIXLY_SERVO)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET + Blockly.Msg.MIXLY_SPEED);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_ms32006_init = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("初始化")
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField("电机驱动");
|
||||
this.appendDummyInput()
|
||||
.appendField("地址")
|
||||
.appendField(new Blockly.FieldDropdown([['A', 'ms32006.ADDRESS_A'], ['B', 'ms32006.ADDRESS_B']]), 'mode');
|
||||
this.appendValueInput('SUB1')
|
||||
.setCheck("var")
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField("通信");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip("初始化MS32006电机驱动,使用I2C通信");
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_ms32006_dcmotor = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("直流电机")
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_Direction)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.CLOCKWISE, "ms32006.MOT_CW"],
|
||||
[Blockly.Msg.ANTI_CLOCKWISE, "ms32006.MOT_CCW"],
|
||||
[Blockly.Msg.MOTOR_N, "ms32006.MOT_N"],
|
||||
[Blockly.Msg.MOTOR_P, "ms32006.MOT_P"]
|
||||
]), "direction");
|
||||
this.appendValueInput('speed')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_STEPPER_SET_SPEED);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip("设置直流电机的状态及转速(0-100)");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
export const actuator_ms32006_stepper = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("步进电机")
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField("选择")
|
||||
.appendField(new Blockly.FieldDropdown([['A', 'ms32006.MOT_A'], ['B', 'ms32006.MOT_B']]), 'mode');
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_Direction)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.CLOCKWISE, "ms32006.MOT_CW"],
|
||||
[Blockly.Msg.ANTI_CLOCKWISE, "ms32006.MOT_CCW"]
|
||||
]), "direction");
|
||||
this.appendValueInput('speed')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField("转速");
|
||||
this.appendValueInput('steps')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField("步数");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip("设置步进电机的状态、转速、步数(0-2047)");
|
||||
}
|
||||
};
|
||||
|
||||
//rgb
|
||||
export const actuator_neopixel_init = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_RGB)
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
.setCheck("var");
|
||||
this.appendValueInput("PIN", Number)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN);
|
||||
this.appendValueInput("LEDCOUNT")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_COUNT);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_RGB_PIN_COUNT);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_neopixel_rgb = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_RGB)
|
||||
this.appendValueInput('SUB')
|
||||
.setCheck("var");
|
||||
// .appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
this.appendValueInput("_LED_")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_NUM);
|
||||
this.appendValueInput("RVALUE")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_R);
|
||||
this.appendValueInput("GVALUE")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_G);
|
||||
this.appendValueInput("BVALUE")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_B);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip('');
|
||||
this.setTooltip(Blockly.Msg.MIXLY_RGB_NUM_R_G_B_MP);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_neopixel_rgb_all = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_RGB)
|
||||
this.appendValueInput('SUB')
|
||||
.setCheck("var");
|
||||
this.appendValueInput("RVALUE")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_R);
|
||||
this.appendValueInput("GVALUE")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_G);
|
||||
this.appendValueInput("BVALUE")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RGB_B);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip('');
|
||||
this.setTooltip(Blockly.Msg.MIXLY_RGB_ALL_R_G_B_MIXGOCC);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_neopixel_write = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_RGB)
|
||||
// this.appendValueInput("PIN", Number)
|
||||
// .setCheck(Number)
|
||||
// .setAlign(Blockly.inputs.Align.RIGHT)
|
||||
// .appendField(Blockly.Msg.MIXLY_PIN);
|
||||
this.appendValueInput('SUB')
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_RGB_WRITE)
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip('');
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_MUSIC_WRI);
|
||||
}
|
||||
};
|
||||
|
||||
export const actuator_use_uart_init = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.CONTROLS_FOR_INPUT_WITH + "uart")
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["uart1", "uart1"],
|
||||
["uart2", "uart2"]
|
||||
]), "key");
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP + Blockly.Msg.LISTS_SET_INDEX_INPUT_TO + 'SYN6288' + Blockly.Msg.MIXLY_AipSpeech_synthesis)
|
||||
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setFieldValue("LTR308", "key");
|
||||
}
|
||||
};
|
||||
|
||||
export const syn6288_set_voice = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField('SYN6288')
|
||||
this.appendValueInput('VOICE')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_SET_VOLUME);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_SET_VOLUME_TOOLTIP);
|
||||
}
|
||||
}
|
||||
|
||||
export const syn6288_get_voice = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField('SYN6288')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET_VOLUME)
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_SET_VOLUME_TOOLTIP);
|
||||
}
|
||||
}
|
||||
|
||||
export const syn6288_builtin_voice = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField('SYN6288')
|
||||
this.appendValueInput('VOICE')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PLAY_HINTS);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_PROGRAM_BLOCK)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_TURTLE_WRITE_MOVE_TRUE, 'True'], [Blockly.Msg.MIXLY_TURTLE_WRITE_MOVE_FALSE, 'False']]), 'mode');
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_PLAY_HINTS_TOOLTIP);
|
||||
}
|
||||
}
|
||||
|
||||
export const syn6288_tts_play = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField('SYN6288')
|
||||
this.appendValueInput('data')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.MIXLY_AipSpeech_synthesis);
|
||||
this.appendValueInput('VOICE')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_BACKGROUND_MUSIC);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_PROGRAM_BLOCK)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_TURTLE_WRITE_MOVE_TRUE, 'True'], [Blockly.Msg.MIXLY_TURTLE_WRITE_MOVE_FALSE, 'False']]), 'mode');
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_PLAY_TTS_TOOLTIP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//mixbot extern
|
||||
export const mixbot_addr_extern = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.extern_addr), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const robot_motor_extern = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ME_GO_MOTOR_EXTERN + Blockly.Msg.MIXLY_MOTOR)
|
||||
.appendField(Blockly.Msg.PIN_NUMBERING)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LEFT, "0"], [Blockly.Msg.MIXLY_RIGHT, "1"]]), "mode");
|
||||
this.appendValueInput('speed')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_SPEED);
|
||||
this.appendDummyInput()
|
||||
.appendField('%')
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MIXBOT_MOTOR_EXTERN_TOOLTIP);
|
||||
}
|
||||
}
|
||||
|
||||
export const robot_motor_extern_get_speed = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ME_GO_MOTOR_EXTERN + Blockly.Msg.MIXLY_MOTOR)
|
||||
.appendField(Blockly.Msg.PIN_NUMBERING)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LEFT, "0"], [Blockly.Msg.MIXLY_RIGHT, "1"]]), "mode");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_GET + Blockly.Msg.MIXLY_SPEED);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const robot_traffic_light_extern = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ME_GO_MOTOR_EXTERN + Blockly.Msg.MIXLY_TRAFFIC_LIGHT)
|
||||
.appendField(Blockly.Msg.PIN_NUMBERING)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LEFT, "0"], [Blockly.Msg.MIXLY_RIGHT, "1"]]), "mode");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.LISTS_SET_INDEX_SET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_MICROBIT_Turn_off_display, '0'],
|
||||
[Blockly.Msg.MIXLY_TRAFFIC_LIGHT_RED_ON, '1'],
|
||||
[Blockly.Msg.MIXLY_TRAFFIC_LIGHT_RED_BLINK, '2'],
|
||||
[Blockly.Msg.MIXLY_TRAFFIC_LIGHT_YELLOW_ON, '3'],
|
||||
[Blockly.Msg.MIXLY_TRAFFIC_LIGHT_YELLOW_BLINK, '4'],
|
||||
[Blockly.Msg.MIXLY_TRAFFIC_LIGHT_GREEN_ON, '5'],
|
||||
[Blockly.Msg.MIXLY_TRAFFIC_LIGHT_GREEN_BLINK, '6']
|
||||
]), "light");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const robot_led_extern = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ME_GO_MOTOR_EXTERN)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.COLOUR_RGB_WHITE, 'W'],
|
||||
[Blockly.Msg.COLOUR_RGB_RED, 'R'],
|
||||
[Blockly.Msg.COLOUR_RGB_YELLOW, 'Y'],
|
||||
[Blockly.Msg.COLOUR_RGB_GREEN, 'G'],
|
||||
[Blockly.Msg.COLOUR_RGB_BLUE, 'B']
|
||||
]), "color")
|
||||
.appendField("LED")
|
||||
.appendField(Blockly.Msg.PIN_NUMBERING)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LEFT, "0"], [Blockly.Msg.MIXLY_RIGHT, "1"]]), "mode");
|
||||
this.appendValueInput('value')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.BRIGHTNESS);
|
||||
this.appendDummyInput()
|
||||
.appendField('%')
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const robot_led_extern_get_value = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ME_GO_MOTOR_EXTERN)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.COLOUR_RGB_WHITE, 'W'],
|
||||
[Blockly.Msg.COLOUR_RGB_RED, 'R'],
|
||||
[Blockly.Msg.COLOUR_RGB_YELLOW, 'Y'],
|
||||
[Blockly.Msg.COLOUR_RGB_GREEN, 'G'],
|
||||
[Blockly.Msg.COLOUR_RGB_BLUE, 'B']
|
||||
]), "color")
|
||||
.appendField("LED")
|
||||
.appendField(Blockly.Msg.PIN_NUMBERING)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LEFT, "0"], [Blockly.Msg.MIXLY_RIGHT, "1"]]), "mode");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET + Blockly.Msg.BRIGHTNESS)
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const robot_servo_extern_get_status = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ME_GO_MOTOR_EXTERN + Blockly.Msg.MIXLY_SERVO_MOTOR)
|
||||
.appendField(Blockly.Msg.PIN_NUMBERING)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LEFT, "0"], [Blockly.Msg.MIXLY_RIGHT, "1"]]), "mode");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_MICROBIT_JS_BLE_POWER, '[0]'],
|
||||
[Blockly.Msg.MIXLY_SPEED, '[1]'],
|
||||
[Blockly.Msg.MATH_SINGLE_OP_ABSOLUTE + Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE, '[2]'],
|
||||
[Blockly.Msg.MIXLY_RELATIVE + Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE, '[3]'],
|
||||
[Blockly.Msg.MIXLY_MIXBOT_SERVO_BLOCK_OR_NOT, '[4]'],
|
||||
[Blockly.Msg.MIXLY_MIXBOT_SERVO_FINISH_OR_NOT, '[5]'],
|
||||
[Blockly.Msg.MIXLY_ALL, '']
|
||||
]), "status");
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const robot_servo_extern_stop_mode = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ME_GO_MOTOR_EXTERN + Blockly.Msg.MIXLY_SERVO_MOTOR)
|
||||
.appendField(Blockly.Msg.PIN_NUMBERING)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LEFT, "0"], [Blockly.Msg.MIXLY_RIGHT, "1"]]), "mode");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MIXBOT_SERVO_SET_STOP_MODE)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_MIXBOT_SERVO_STOP_MODE_KEEP, '0'],
|
||||
[Blockly.Msg.MIXLY_MIXBOT_SERVO_STOP_MODE_COAST, '1'],
|
||||
[Blockly.Msg.MIXLY_MIXBOT_SERVO_STOP_MODE_BRAKE, '2']
|
||||
]), "status");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const robot_servo_extern_stop = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ME_GO_MOTOR_EXTERN + Blockly.Msg.MIXLY_SERVO_MOTOR)
|
||||
.appendField(Blockly.Msg.PIN_NUMBERING)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LEFT, "0"], [Blockly.Msg.MIXLY_RIGHT, "1"]]), "mode");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_STOP)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const robot_servo_extern_absolute_run = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ME_GO_MOTOR_EXTERN + Blockly.Msg.MIXLY_SERVO_MOTOR)
|
||||
.appendField(Blockly.Msg.MATH_SINGLE_OP_ABSOLUTE + Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE + Blockly.Msg.MSG.run)
|
||||
.appendField(Blockly.Msg.PIN_NUMBERING)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LEFT, "0"], [Blockly.Msg.MIXLY_RIGHT, "1"]]), "mode");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MODE)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_SPEED + Blockly.Msg.MIXLY_MODE, '0'],
|
||||
[Blockly.Msg.MIXLY_MICROBIT_JS_BLE_POWER + Blockly.Msg.MIXLY_MODE, '1']
|
||||
]), "status");
|
||||
this.appendValueInput('speed')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_PARAMS);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField('%')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MIXBOT_SERVO_TURN_DIRECTION)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.CLOCKWISE, '0'],
|
||||
[Blockly.Msg.MIXLY_MIXBOT_SERVO_NEAREST_PATH, '1'],
|
||||
[Blockly.Msg.ANTI_CLOCKWISE, '2']
|
||||
]), "direction");
|
||||
this.appendValueInput('angle')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_ROTATE + Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MIXBOT_SERVO_ABSOLUTE_ANGLE_TOOLTIP);
|
||||
}
|
||||
}
|
||||
|
||||
export const robot_servo_extern_relative_origin = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ME_GO_MOTOR_EXTERN + Blockly.Msg.MIXLY_SERVO_MOTOR)
|
||||
.appendField(Blockly.Msg.MIXLY_RELATIVE + Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE + Blockly.Msg.MSG.run)
|
||||
.appendField(Blockly.Msg.PIN_NUMBERING)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LEFT, "0"], [Blockly.Msg.MIXLY_RIGHT, "1"]]), "mode");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MIXBOT_SERVO_RELATIVE_ORIGIN_PATH)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const robot_servo_extern_relative_run = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ME_GO_MOTOR_EXTERN + Blockly.Msg.MIXLY_SERVO_MOTOR)
|
||||
.appendField(Blockly.Msg.MIXLY_RELATIVE + Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE + Blockly.Msg.MSG.run)
|
||||
.appendField("(" + Blockly.Msg.MIXLY_MIXBOT_SERVO_LIKE_ENCODING_MOTOR + ")")
|
||||
.appendField(Blockly.Msg.PIN_NUMBERING)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LEFT, "0"], [Blockly.Msg.MIXLY_RIGHT, "1"]]), "mode");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MODE)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_SPEED + Blockly.Msg.MIXLY_MODE, '0'],
|
||||
[Blockly.Msg.MIXLY_MICROBIT_JS_BLE_POWER + Blockly.Msg.MIXLY_MODE, '1']
|
||||
]), "status");
|
||||
this.appendValueInput('speed')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_PARAMS);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField('%')
|
||||
this.appendValueInput('angle')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_ROTATE + Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MIXBOT_SERVO_RELATIVE_ANGLE_TOOLTIP);
|
||||
}
|
||||
}
|
||||
|
||||
export const robot_servo_extern_relative_continue = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ME_GO_MOTOR_EXTERN + Blockly.Msg.MIXLY_SERVO_MOTOR)
|
||||
.appendField(Blockly.Msg.MIXLY_RELATIVE + Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE + Blockly.Msg.MSG.run)
|
||||
.appendField("(" + Blockly.Msg.MIXLY_MIXBOT_SERVO_LIKE_ORDINARY_MOTOR + ")")
|
||||
.appendField(Blockly.Msg.PIN_NUMBERING)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LEFT, "0"], [Blockly.Msg.MIXLY_RIGHT, "1"]]), "mode");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MODE)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_SPEED + Blockly.Msg.MIXLY_MODE, '0'],
|
||||
[Blockly.Msg.MIXLY_MICROBIT_JS_BLE_POWER + Blockly.Msg.MIXLY_MODE, '1']
|
||||
]), "status");
|
||||
this.appendValueInput('speed')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_PARAMS);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField('%')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MIXBOT_SERVO_TURN_DIRECTION)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.CLOCKWISE, '0'],
|
||||
[Blockly.Msg.ANTI_CLOCKWISE, '2']
|
||||
]), "direction");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const mixbot_actuator_extern_get_addr = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXBOT)
|
||||
.appendField(Blockly.Msg.ME_GO_MOTOR_EXTERN)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_MOTOR, 'ext_motor'],
|
||||
[Blockly.Msg.MIXLY_TRAFFIC_LIGHT, 'ext_traffic'],
|
||||
[Blockly.Msg.COLOUR_RGB_WHITE + "LED", 'W_LED'],
|
||||
[Blockly.Msg.COLOUR_RGB_RED + "LED", 'R_LED'],
|
||||
[Blockly.Msg.COLOUR_RGB_YELLOW + "LED", 'Y_LED'],
|
||||
[Blockly.Msg.COLOUR_RGB_GREEN + "LED", 'G_LED'],
|
||||
[Blockly.Msg.COLOUR_RGB_BLUE + "LED", 'B_LED'],
|
||||
[Blockly.Msg.MIXLY_SERVO_MOTOR, 'ext_servo']
|
||||
]), "name")
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MIXBOT_EXTERN_GET_ADDR)
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const mixbot_actuator_extern_set_addr = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_EXTERN_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXBOT)
|
||||
.appendField(Blockly.Msg.ME_GO_MOTOR_EXTERN)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_MOTOR, 'ext_motor'],
|
||||
[Blockly.Msg.MIXLY_TRAFFIC_LIGHT, 'ext_traffic'],
|
||||
[Blockly.Msg.COLOUR_RGB_WHITE + "LED", 'W_LED'],
|
||||
[Blockly.Msg.COLOUR_RGB_RED + "LED", 'R_LED'],
|
||||
[Blockly.Msg.COLOUR_RGB_YELLOW + "LED", 'Y_LED'],
|
||||
[Blockly.Msg.COLOUR_RGB_GREEN + "LED", 'G_LED'],
|
||||
[Blockly.Msg.COLOUR_RGB_BLUE + "LED", 'B_LED'],
|
||||
[Blockly.Msg.MIXLY_SERVO_MOTOR, 'ext_servo']
|
||||
]), "name")
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MIXBOT_EXTERN_SET_ADDR)
|
||||
this.appendValueInput('old')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_CURRENT_GESTURE);
|
||||
this.appendValueInput('new')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_UPDATE);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
1001
boards/default_src/micropython/blocks/actuator_onboard.js
Normal file
1001
boards/default_src/micropython/blocks/actuator_onboard.js
Normal file
File diff suppressed because it is too large
Load Diff
68
boards/default_src/micropython/blocks/ai.js
Normal file
68
boards/default_src/micropython/blocks/ai.js
Normal file
@@ -0,0 +1,68 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
const AI_HUE = 205;
|
||||
|
||||
export const MICROPYTHON_AI_client = {
|
||||
init: function () {
|
||||
this.setColour(AI_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_AipSpeech_asr, "ASR"],
|
||||
[Blockly.Msg.MIXLY_AI_UNIT, "UNIT"]
|
||||
]), 'CTYPE')
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(Blockly.Msg.MIXLY_Client)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput('API_KEY')
|
||||
.appendField('API_KEY')
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput('SECRET_KEY')
|
||||
.appendField('SECRET_KEY')
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.setInputsInline(false);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
}
|
||||
};
|
||||
|
||||
export const MICROPYTHON_AI_Speech_unit = { // AI_TYPE_FUNC
|
||||
init: function () {
|
||||
this.setColour(AI_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(Blockly.Msg.MIXLY_AI_UNIT)
|
||||
.appendField(Blockly.Msg.MIXLY_Client)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput('ID')
|
||||
.appendField('ID')
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput('STR')
|
||||
.appendField(Blockly.Msg.OLED_STRING)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const MICROPYTHON_AI_Speech_asr = { // AI_TYPE_FUNC
|
||||
init: function () {
|
||||
this.setColour(AI_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(Blockly.Msg.MIXLY_AipSpeech_asr)
|
||||
.appendField(Blockly.Msg.MIXLY_Client)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput('FILE')
|
||||
.appendField(Blockly.Msg.MIXPY_AI_AUDIO_TIME)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_LANGUAGE)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_AI_LANGUAGE_CHINESE, "1537"],
|
||||
[Blockly.Msg.MIXLY_AI_LANGUAGE_ENGLISH, "1737"],
|
||||
[Blockly.Msg.MIXLY_AI_LANGUAGE_CANTONESE, "1637"]
|
||||
]), 'LANGUAGE')
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
746
boards/default_src/micropython/blocks/ai_sensor.js
Normal file
746
boards/default_src/micropython/blocks/ai_sensor.js
Normal file
@@ -0,0 +1,746 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
const AI_SENSOR_HUE = '#90A244'; //'#9e77c9'//40;
|
||||
|
||||
|
||||
export const ai_sensor_use_uart_init = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.CONTROLS_FOR_INPUT_WITH + "uart")
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["uart1", "uart1"],
|
||||
["uart2", "uart2"]
|
||||
]), "key");
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP + Blockly.Msg.LISTS_SET_INDEX_INPUT_TO + 'MixGo AI' + Blockly.Msg.MSG.catSensor)
|
||||
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_qrcode = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_QR_CODE + Blockly.Msg.MIXPY_OBJECT)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ALL_CODE_ANALYSIS);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.OLED_STRING, "info1"],
|
||||
[Blockly.Msg.MIXLY_POSITION_XY + "-xywh", "rect"],
|
||||
["x" + Blockly.Msg.MIXLY_POSITION_XY, "rect[0]"],
|
||||
["y" + Blockly.Msg.MIXLY_POSITION_XY, "rect[1]"],
|
||||
["w" + Blockly.Msg.MIXLY_POSITION_XY, "rect[2]"],
|
||||
["h" + Blockly.Msg.MIXLY_POSITION_XY, "rect[3]"],
|
||||
[Blockly.Msg.MICROPYTHON_HUSKYLENS_X_CENTERED + Blockly.Msg.MIXLY_POSITION_XY, "xc"],
|
||||
[Blockly.Msg.MICROPYTHON_HUSKYLENS_Y_CENTERED + Blockly.Msg.MIXLY_POSITION_XY, "yc"]
|
||||
]), "key");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_QR_CODE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_qrcode_lite = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_QR_CODE + Blockly.Msg.MIXPY_OBJECT, "qrcode"],
|
||||
[Blockly.Msg.MIXLY_BAR_CODE + Blockly.Msg.MIXPY_OBJECT, "barcode"],
|
||||
[Blockly.Msg.MIXLY_TAG + Blockly.Msg.MIXPY_OBJECT, "apriltag"]
|
||||
]), "TYPE");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ANALYSIS_RESULT);
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip();
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_find_qrcodes = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_QR_CODE_RECOGNTITION);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + "[qrcode]");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_QR_CODE_RECOGNTITION_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_config = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendValueInput("RX")
|
||||
.appendField(Blockly.Msg.MIXLY_SETTING + Blockly.Msg.MIXLY_ETHERNET_CLINET_PORT)
|
||||
.appendField("RX#")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("TX")
|
||||
.appendField("TX#")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.SOFT_RESET + Blockly.Msg.MIXLY_ESP32_RGB_WRITE)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_TURTLE_WRITE_MOVE_TRUE, 'True'], [Blockly.Msg.MIXLY_TURTLE_WRITE_MOVE_FALSE, 'False']]), 'mode')
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_CONFIG_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_rgb = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendValueInput("led1")
|
||||
.appendField(Blockly.Msg.MIXLY_SETTING)
|
||||
.appendField("RGB1")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("led2")
|
||||
.appendField("RGB2")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_CONFIG_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_barcode = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_BAR_CODE + Blockly.Msg.MIXPY_OBJECT)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ALL_CODE_ANALYSIS);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.OLED_STRING, "info1"],
|
||||
[Blockly.Msg.MIXLY_POSITION_XY + "-xywh", "rect"],
|
||||
["x" + Blockly.Msg.MIXLY_POSITION_XY, "rect[0]"],
|
||||
["y" + Blockly.Msg.MIXLY_POSITION_XY, "rect[1]"],
|
||||
["w" + Blockly.Msg.MIXLY_POSITION_XY, "rect[2]"],
|
||||
["h" + Blockly.Msg.MIXLY_POSITION_XY, "rect[3]"],
|
||||
[Blockly.Msg.MICROPYTHON_HUSKYLENS_X_CENTERED + Blockly.Msg.MIXLY_POSITION_XY, "xc"],
|
||||
[Blockly.Msg.MICROPYTHON_HUSKYLENS_Y_CENTERED + Blockly.Msg.MIXLY_POSITION_XY, "yc"]
|
||||
]), "key");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_BAR_CODE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_find_barcodes = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_BAR_CODE_RECOGNTITION);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + "[barcode]");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_BAR_CODE_RECOGNTITION_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_tag = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_TAG + Blockly.Msg.MIXPY_OBJECT)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ALL_CODE_ANALYSIS);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.OLED_STRING, "info1"],
|
||||
[Blockly.Msg.blockpy_turtle_rotate + Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE, "info2"],
|
||||
[Blockly.Msg.MIXLY_POSITION_XY + "-xywh", "rect"],
|
||||
["x" + Blockly.Msg.MIXLY_POSITION_XY, "rect[0]"],
|
||||
["y" + Blockly.Msg.MIXLY_POSITION_XY, "rect[1]"],
|
||||
["w" + Blockly.Msg.MIXLY_POSITION_XY, "rect[2]"],
|
||||
["h" + Blockly.Msg.MIXLY_POSITION_XY, "rect[3]"],
|
||||
[Blockly.Msg.MICROPYTHON_HUSKYLENS_X_CENTERED + Blockly.Msg.MIXLY_POSITION_XY, "xc"],
|
||||
[Blockly.Msg.MICROPYTHON_HUSKYLENS_Y_CENTERED + Blockly.Msg.MIXLY_POSITION_XY, "yc"]
|
||||
]), "key");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_TAG_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_find_tags = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_TAG_RECOGNTITION);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + "[tag]");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_TAG_RECOGNTITION_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_line = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_LINE + Blockly.Msg.MIXPY_OBJECT)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ALL_CODE_ANALYSIS);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_LINE_ANGLE, "info1"],
|
||||
[Blockly.Msg.MIXLY_POSITION_XY + "-x1x2y1y2", "rect"],
|
||||
["x1" + Blockly.Msg.MIXLY_POSITION_XY, "rect[0]"],
|
||||
["x2" + Blockly.Msg.MIXLY_POSITION_XY, "rect[1]"],
|
||||
["y1" + Blockly.Msg.MIXLY_POSITION_XY, "rect[2]"],
|
||||
["y2" + Blockly.Msg.MIXLY_POSITION_XY, "rect[3]"]
|
||||
]), "key");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_LINE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_find_lines = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_LINE_RECOGNTITION);
|
||||
this.appendValueInput("VAR1")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_THRESHOLD)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR2")
|
||||
.appendField(Blockly.Msg.MIXLY_LINE_RECOGNTITION_ANGLE)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR3")
|
||||
.appendField(Blockly.Msg.MIXLY_LINE_RECOGNTITION_SLOPE)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + "[line]");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_LINE_RECOGNTITION_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_circle = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_CIRCLE + Blockly.Msg.MIXPY_OBJECT)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ALL_CODE_ANALYSIS);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_CIRCLE_AREA, "info1"],
|
||||
[Blockly.Msg.MIXLY_POSITION_XY + "-xywh", "rect"],
|
||||
["x" + Blockly.Msg.MIXLY_POSITION_XY, "rect[0]"],
|
||||
["y" + Blockly.Msg.MIXLY_POSITION_XY, "rect[1]"],
|
||||
["w" + Blockly.Msg.MIXLY_POSITION_XY, "rect[2]"],
|
||||
["h" + Blockly.Msg.MIXLY_POSITION_XY, "rect[3]"],
|
||||
[Blockly.Msg.MICROPYTHON_HUSKYLENS_X_CENTERED + Blockly.Msg.MIXLY_POSITION_XY, "xc"],
|
||||
[Blockly.Msg.MICROPYTHON_HUSKYLENS_Y_CENTERED + Blockly.Msg.MIXLY_POSITION_XY, "yc"]
|
||||
]), "key");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_CIRCLE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_find_circles = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_CIRCLE_RECOGNTITION);
|
||||
this.appendValueInput("VAR1")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_THRESHOLD)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR2")
|
||||
.appendField(Blockly.Msg.MIXLY_CIRCLE_RECOGNTITION_MIN)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR3")
|
||||
.appendField(Blockly.Msg.MIXLY_CIRCLE_RECOGNTITION_MAX)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + "[circle]");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_CIRCLE_RECOGNTITION_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_rect = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_RECT + Blockly.Msg.MIXPY_OBJECT)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ALL_CODE_ANALYSIS);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_CIRCLE_AREA, "info1"],
|
||||
[Blockly.Msg.MIXLY_POSITION_XY + "-xywh", "rect"],
|
||||
["x" + Blockly.Msg.MIXLY_POSITION_XY, "rect[0]"],
|
||||
["y" + Blockly.Msg.MIXLY_POSITION_XY, "rect[1]"],
|
||||
["w" + Blockly.Msg.MIXLY_POSITION_XY, "rect[2]"],
|
||||
["h" + Blockly.Msg.MIXLY_POSITION_XY, "rect[3]"],
|
||||
[Blockly.Msg.MICROPYTHON_HUSKYLENS_X_CENTERED + Blockly.Msg.MIXLY_POSITION_XY, "xc"],
|
||||
[Blockly.Msg.MICROPYTHON_HUSKYLENS_Y_CENTERED + Blockly.Msg.MIXLY_POSITION_XY, "yc"]
|
||||
]), "key");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_RECT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_find_rects = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_RECT_RECOGNTITION);
|
||||
this.appendValueInput("VAR1")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_THRESHOLD)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + "[rect]");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_COLOR_RECOGNTITION_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_color = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.HTML_COLOUR + Blockly.Msg.MIXPY_OBJECT)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_COLOR_ANALYSIS);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
['RGB' + Blockly.Msg.HTML_COLOUR, "[0]"],
|
||||
['LAB' + Blockly.Msg.MIXLY_COLOR_LAB, "[1]"]
|
||||
]), "key");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_COLOR_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_find_colors = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_COLOR_RECOGNTITION);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + "color");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_COLOR_RECOGNTITION_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_color_chases_result = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_COLOR_CHASE + Blockly.Msg.MIXPY_OBJECT)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_COLOR_CHASE_ANALYSIS);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_CIRCLE_AREA, "info1"],
|
||||
[Blockly.Msg.MIXLY_POSITION_XY + "-xywh", "rect"],
|
||||
["x" + Blockly.Msg.MIXLY_POSITION_XY, "rect[0]"],
|
||||
["y" + Blockly.Msg.MIXLY_POSITION_XY, "rect[1]"],
|
||||
["w" + Blockly.Msg.MIXLY_POSITION_XY, "rect[2]"],
|
||||
["h" + Blockly.Msg.MIXLY_POSITION_XY, "rect[3]"],
|
||||
[Blockly.Msg.MICROPYTHON_HUSKYLENS_X_CENTERED + Blockly.Msg.MIXLY_POSITION_XY, "xc"],
|
||||
[Blockly.Msg.MICROPYTHON_HUSKYLENS_Y_CENTERED + Blockly.Msg.MIXLY_POSITION_XY, "yc"]
|
||||
]), "key");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_CIRCLE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_color_chases = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_COLOR_CHASE);
|
||||
this.appendValueInput("VAR1")
|
||||
.appendField('LAB' + Blockly.Msg.MIXLY_COLOR_LAB)
|
||||
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR2")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_THRESHOLD)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR3")
|
||||
.appendField(Blockly.Msg.MIXLY_COLOR_CHASE_MERGE)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + "[colors]");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_CIRCLE_RECOGNTITION_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_ailocal_train = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_LOCAL_TRAIN);
|
||||
this.appendValueInput("VAR1")
|
||||
.appendField(Blockly.Msg.MIXLY_OBJECT_LIST)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR2")
|
||||
.appendField(Blockly.Msg.MICROPYTHON_HUSKYLENS_SAVE_AS + Blockly.Msg.MIXLY_MODEL_NAME)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR3")
|
||||
.appendField(Blockly.Msg.MIXLY_TRAIN_TIME)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR4")
|
||||
.appendField(Blockly.Msg.MIXLY_AipNlp_Topic_Title)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_LOCAL_TRAIN_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_ailocal_class = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_LOCAL_CLASS);
|
||||
this.appendValueInput("VAR1")
|
||||
.appendField(Blockly.Msg.MIXLY_OBJECT_LIST)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR2")
|
||||
.appendField(Blockly.Msg.MIXLY_MODEL_NAME)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR4")
|
||||
.appendField(Blockly.Msg.MIXLY_AipNlp_Topic_Title)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + "[objects]");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_MODEL_NAME_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_ailocal_class_result = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_LOCAL_CLASS + Blockly.Msg.MIXPY_OBJECT)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_COLOR_CHASE_ANALYSIS);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
['ID', "info1"],
|
||||
[Blockly.Msg.MIXLY_CONFIDENCE_DEGREE, "info2"],
|
||||
]), "key");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_LOCAL_CLASS_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_audio_record = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MUSIC_RECORD);
|
||||
this.appendValueInput("VAR1")
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_THE_PATH)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR2")
|
||||
.appendField(Blockly.Msg.MIXPY_AI_AUDIO_TIME)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_MUSIC_RECORD_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_audio_play = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MUSIC_PLAY);
|
||||
this.appendValueInput("VAR1")
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_THE_PATH)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR2")
|
||||
.appendField(Blockly.Msg.MIXLY_MP3_VOL)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendDummyInput()
|
||||
.appendField('%')
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_yolo_recognize = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_YOLO_RECOGNIZE);
|
||||
this.appendValueInput("VAR1")
|
||||
.appendField(Blockly.Msg.MIXLY_ANCHOR)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR2")
|
||||
.appendField(Blockly.Msg.MIXLY_MODEL_PATH)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR4")
|
||||
.appendField(Blockly.Msg.MIXLY_AipNlp_Topic_Title)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + "[objects]");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_YOLO_RECOGNIZE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_yolo_recognize_result = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_YOLO_RECOGNIZE + Blockly.Msg.MIXPY_OBJECT)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_COLOR_CHASE_ANALYSIS);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
['ID', "info1"],
|
||||
[Blockly.Msg.MIXLY_CONFIDENCE_DEGREE, "info2"],
|
||||
[Blockly.Msg.MIXLY_POSITION_XY + "-xywh", "rect"],
|
||||
["x" + Blockly.Msg.MIXLY_POSITION_XY, "rect[0]"],
|
||||
["y" + Blockly.Msg.MIXLY_POSITION_XY, "rect[1]"],
|
||||
["w" + Blockly.Msg.MIXLY_POSITION_XY, "rect[2]"],
|
||||
["h" + Blockly.Msg.MIXLY_POSITION_XY, "rect[3]"],
|
||||
[Blockly.Msg.MICROPYTHON_HUSKYLENS_X_CENTERED + Blockly.Msg.MIXLY_POSITION_XY, "xc"],
|
||||
[Blockly.Msg.MICROPYTHON_HUSKYLENS_Y_CENTERED + Blockly.Msg.MIXLY_POSITION_XY, "yc"]
|
||||
]), "key");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_YOLO_RECOGNIZE_RESULT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_asr_recognize = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_AipSpeech_asr);
|
||||
this.appendValueInput("VAR1")
|
||||
.appendField(Blockly.Msg.MIXLY_AI_SENSOR_ASR_RECOGNISE_CORPUS)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("VAR2")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_THRESHOLD)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_ASR_RECOGNISE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_licenseplate = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_LICENSEPLATE + Blockly.Msg.MIXPY_OBJECT)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ALL_CODE_ANALYSIS);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
['ID', "info1"],
|
||||
[Blockly.Msg.MIXLY_POSITION_XY + "-xywh", "rect"],
|
||||
["x" + Blockly.Msg.MIXLY_POSITION_XY, "rect[0]"],
|
||||
["y" + Blockly.Msg.MIXLY_POSITION_XY, "rect[1]"],
|
||||
["w" + Blockly.Msg.MIXLY_POSITION_XY, "rect[2]"],
|
||||
["h" + Blockly.Msg.MIXLY_POSITION_XY, "rect[3]"]
|
||||
]), "key");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_LICENSEPLATE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_find_licenseplates = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_AipOcr_licensePlate);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + "[licensePlate]");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_LICENSEPLATE_RECOGNTITION_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_face = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_FACE + Blockly.Msg.MIXPY_OBJECT)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ALL_CODE_ANALYSIS);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["ID", "info1"],
|
||||
[Blockly.Msg.MIXLY_CONFIDENCE_DEGREE, "info2"],
|
||||
[Blockly.Msg.MIXLY_POSITION_XY + "-xywh", "rect"],
|
||||
["x" + Blockly.Msg.MIXLY_POSITION_XY, "rect[0]"],
|
||||
["y" + Blockly.Msg.MIXLY_POSITION_XY, "rect[1]"],
|
||||
["w" + Blockly.Msg.MIXLY_POSITION_XY, "rect[2]"],
|
||||
["h" + Blockly.Msg.MIXLY_POSITION_XY, "rect[3]"]
|
||||
]), "key");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_FACE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_classifier_faces = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_AipFace);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + "[face]");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_BAR_FACE_CLASSIFIER_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_20object = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_20OBJECTS + Blockly.Msg.MIXPY_OBJECT)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ALL_CODE_ANALYSIS);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
['ID', "info1"],
|
||||
[Blockly.Msg.MIXLY_CONFIDENCE_DEGREE, "info2"],
|
||||
[Blockly.Msg.MIXLY_POSITION_XY + "-xywh", "rect"],
|
||||
["x" + Blockly.Msg.MIXLY_POSITION_XY, "rect[0]"],
|
||||
["y" + Blockly.Msg.MIXLY_POSITION_XY, "rect[1]"],
|
||||
["w" + Blockly.Msg.MIXLY_POSITION_XY, "rect[2]"],
|
||||
["h" + Blockly.Msg.MIXLY_POSITION_XY, "rect[3]"]
|
||||
]), "key");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_20OBJECTS_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const ai_sensor_find_20objects = {
|
||||
init: function () {
|
||||
this.setColour(AI_SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_FIND_20OBJECTS);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + "[20objects]");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_AI_SENSOR_BAR_FIND_20OBJECTS_TOOLTIP);
|
||||
}
|
||||
};
|
||||
368
boards/default_src/micropython/blocks/blynk.js
Normal file
368
boards/default_src/micropython/blocks/blynk.js
Normal file
@@ -0,0 +1,368 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
/******************* Blynk *****************/
|
||||
const BLYNK_HUE = '#2FAD7A';
|
||||
|
||||
|
||||
// 自定义终端部件 Terminal Blynk
|
||||
export const mpython_blynk_terminal_widget_vpin = {
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
"inputsInline": true,
|
||||
"nextStatement": null,
|
||||
"previousStatement": null,
|
||||
"colour": BLYNK_HUE,
|
||||
"helpUrl": Blockly.Msg.MPYTHON_BLYNK_TERMINAL_WIDGET_VPIN_HELPURL,
|
||||
"tooltip": Blockly.Msg.MPYTHON_BLYNK_TERMINAL_WIDGET_VPIN_TOOLTIP,
|
||||
"message0": Blockly.Msg.MPYTHON_BLYNK_TERMINAL_WIDGET_VPIN_MESSAGE0,
|
||||
"args0": [
|
||||
{
|
||||
"check": Number,
|
||||
"type": "input_value",
|
||||
"name": "virtual_pin"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 同步虚拟管脚的状态 Blynk
|
||||
export const mpython_blynk_sync_virtual = {
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
"inputsInline": true,
|
||||
"nextStatement": null,
|
||||
"previousStatement": null,
|
||||
"colour": BLYNK_HUE,
|
||||
"helpUrl": Blockly.Msg.MPYTHON_BLYNK_SYNC_VIRTUAL_HELPURL,
|
||||
"tooltip": Blockly.Msg.MPYTHON_BLYNK_SYNC_VIRTUAL_TOOLTIP,
|
||||
"message0": Blockly.Msg.MPYTHON_BLYNK_SYNC_VIRTUAL_MESSAGE0,
|
||||
"args0": [
|
||||
{
|
||||
"check": Number,
|
||||
"type": "input_value",
|
||||
"name": "virtual_pin"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 斷開连接 Blynk
|
||||
export const mpython_blynk_on_disconnected = {
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
"inputsInline": true,
|
||||
// "nextStatement": null,
|
||||
// "previousStatement": null,
|
||||
"colour": BLYNK_HUE,
|
||||
"helpUrl": Blockly.Msg.MPYTHON_BLYNK_ON_DISCONNECTED_HELPURL,
|
||||
"tooltip": Blockly.Msg.MPYTHON_BLYNK_ON_DISCONNECTED_TOOLTIP,
|
||||
"message0": Blockly.Msg.MPYTHON_BLYNK_ON_DISCONNECTED_MESSAGE0
|
||||
});
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.CONTROLS_REPEAT_INPUT_DO);
|
||||
}
|
||||
};
|
||||
|
||||
// 连接上 Blynk
|
||||
export const mpython_blynk_on_connected = {
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
"inputsInline": true,
|
||||
// "nextStatement": null,
|
||||
// "previousStatement": null,
|
||||
"colour": BLYNK_HUE,
|
||||
"helpUrl": Blockly.Msg.MPYTHON_BLYNK_ON_CONNECTED_HELPURL,
|
||||
"tooltip": Blockly.Msg.MPYTHON_BLYNK_ON_CONNECTED_TOOLTIP,
|
||||
"message0": Blockly.Msg.MPYTHON_BLYNK_ON_CONNECTED_MESSAGE0
|
||||
});
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.CONTROLS_REPEAT_INPUT_DO);
|
||||
}
|
||||
};
|
||||
|
||||
// Blynk 定时器的进程生效并运行
|
||||
export const mpython_blynktimer_run = {
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
"inputsInline": true,
|
||||
"nextStatement": null,
|
||||
"previousStatement": null,
|
||||
"colour": BLYNK_HUE,
|
||||
"helpUrl": Blockly.Msg.MPYTHON_BLYNKTIMER_RUN_HELPURL,
|
||||
"tooltip": Blockly.Msg.MPYTHON_BLYNKTIMER_RUN_TOOLTIP,
|
||||
"message0": Blockly.Msg.MPYTHON_BLYNKTIMER_RUN_MESSAGE0
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Blynk 进程生效并运行
|
||||
export const mpython_blynk_run = {
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
"inputsInline": true,
|
||||
"nextStatement": null,
|
||||
"previousStatement": null,
|
||||
"colour": BLYNK_HUE,
|
||||
"helpUrl": Blockly.Msg.MPYTHON_BLYNK_RUN_HELPURL,
|
||||
"tooltip": Blockly.Msg.MPYTHON_BLYNK_RUN_TOOLTIP,
|
||||
"message0": Blockly.Msg.MPYTHON_BLYNK_RUN_MESSAGE0
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Blynk APP 显示通知
|
||||
export const mpython_blynk_app_notify = {
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
"inputsInline": true,
|
||||
"nextStatement": null,
|
||||
"previousStatement": null,
|
||||
"colour": BLYNK_HUE,
|
||||
"helpUrl": Blockly.Msg.MPYTHON_BLYNK_APP_NOTIFY_HELPURL,
|
||||
"tooltip": Blockly.Msg.MPYTHON_BLYNK_APP_NOTIFY_TOOLTIP,
|
||||
"message0": Blockly.Msg.MPYTHON_BLYNK_APP_NOTIFY_MESSAGE0,
|
||||
"args0": [
|
||||
{
|
||||
"check": String,
|
||||
"type": "input_value",
|
||||
"name": "notification"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 停止 Blynk 定时器 %1
|
||||
export const mpython_blynk_stop_timers = {
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
"inputsInline": true,
|
||||
"nextStatement": null,
|
||||
"previousStatement": null,
|
||||
// "output": null,
|
||||
"colour": BLYNK_HUE,
|
||||
"helpUrl": Blockly.Msg.MPYTHON_BLYNK_STOP_TIMERS_HELPURL,
|
||||
"tooltip": Blockly.Msg.MPYTHON_BLYNKTIMER_TOOLTIP,
|
||||
"message0": Blockly.Msg.MPYTHON_BLYNK_STOP_TIMERS_MESSAGE0,
|
||||
"args0": [
|
||||
{
|
||||
"check": Number,
|
||||
"type": "input_value",
|
||||
"name": "timer_num"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 给虚拟管脚添加 属性 %1 值 %2
|
||||
export const mpython_blynk_set_property = {
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
"inputsInline": true,
|
||||
"nextStatement": null,
|
||||
"previousStatement": null,
|
||||
// "output": null,
|
||||
"colour": BLYNK_HUE,
|
||||
"helpUrl": Blockly.Msg.MPYTHON_BLYNK_SET_PROPERTY_HELPURL,
|
||||
"tooltip": Blockly.Msg.MPYTHON_BLYNK_SET_PROPERTY_TOOLTIP,
|
||||
"message0": Blockly.Msg.MPYTHON_BLYNK_SET_PROPERTY_MESSAGE0,
|
||||
"args0": [
|
||||
{
|
||||
"check": String,
|
||||
"type": "input_value",
|
||||
"name": "attribute_name"
|
||||
}
|
||||
,
|
||||
{
|
||||
// "check":String,
|
||||
"type": "input_value",
|
||||
"name": "attribute_value"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 向 %1 发邮件 主题 %2 正文 %3
|
||||
export const mpython_blynk_email = {
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
"inputsInline": true,
|
||||
"nextStatement": null,
|
||||
"previousStatement": null,
|
||||
// "output": null,
|
||||
"colour": BLYNK_HUE,
|
||||
"helpUrl": Blockly.Msg.MPYTHON_BLYNK_EMAIL_HELPURL,
|
||||
"tooltip": Blockly.Msg.MPYTHON_BLYNK_EMAIL_TOOLTIP,
|
||||
"message0": Blockly.Msg.MPYTHON_BLYNK_EMAIL_MESSAGE0,
|
||||
"args0": [
|
||||
{
|
||||
"check": String,
|
||||
"type": "input_value",
|
||||
"name": "TargetEmail"
|
||||
}
|
||||
,
|
||||
{
|
||||
"check": String,
|
||||
"type": "input_value",
|
||||
"name": "subject"
|
||||
}
|
||||
,
|
||||
{
|
||||
"check": String,
|
||||
"type": "input_value",
|
||||
"name": "body"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 可用的 Blynk 定时器
|
||||
export const mpython_blynk_get_timers = {
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
"inputsInline": true,
|
||||
// "nextStatement": null,
|
||||
// "previousStatement": null,
|
||||
"output": null,
|
||||
"colour": BLYNK_HUE,
|
||||
"helpUrl": Blockly.Msg.MPYTHON_BLYNK_GET_TIMERS_HELPURL,
|
||||
"tooltip": Blockly.Msg.MPYTHON_BLYNK_GET_TIMERS_TOOLTIP,
|
||||
"message0": Blockly.Msg.MPYTHON_BLYNK_GET_TIMERS_MESSAGE0,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//blynk定时器
|
||||
export const mpython_blynktimer = {
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
"message0": Blockly.Msg.MPYTHON_BLYNKTIMER_MESSAGE0,
|
||||
// "nextStatement": null,
|
||||
// "previousStatement": null,
|
||||
"colour": BLYNK_HUE,
|
||||
"helpUrl": Blockly.Msg.MPYTHON_BLYNKTIMER_HELPURL,
|
||||
"tooltip": Blockly.Msg.MPYTHON_BLYNKTIMER_TOOLTIP,
|
||||
"args0": [
|
||||
{
|
||||
"check": Number,
|
||||
"type": "input_value",
|
||||
"name": "Num"
|
||||
}
|
||||
,
|
||||
{
|
||||
"options": [
|
||||
[Blockly.Msg.MIXLY_PYTHON_PERIODIC, 'False'],
|
||||
[Blockly.Msg.MIXLY_PYTHON_ONE_SHOT, 'True']
|
||||
],
|
||||
"type": "field_dropdown",
|
||||
"name": "Timer_mode"
|
||||
}
|
||||
,
|
||||
{
|
||||
"check": Number,
|
||||
"type": "input_value",
|
||||
"name": "period"
|
||||
}
|
||||
]
|
||||
});
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.CONTROLS_REPEAT_INPUT_DO);
|
||||
}
|
||||
};
|
||||
|
||||
// 发送数据 %1 到 Bylnk APP 的虚拟管脚 %2
|
||||
export const mpython_blynk_sensor_data_to_app = {
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
"inputsInline": true,
|
||||
"nextStatement": null,
|
||||
"previousStatement": null,
|
||||
"colour": BLYNK_HUE,
|
||||
"helpUrl": Blockly.Msg.MPYTHON_BLYNK_SENSOR_DATA_TO_APP_HELPURL,
|
||||
"tooltip": Blockly.Msg.MPYTHON_BLYNK_SENSOR_DATA_TO_APP_TOOLTIP,
|
||||
"message0": Blockly.Msg.MPYTHON_BLYNK_SENSOR_DATA_TO_APP_MESSAGE0,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "sensor_data"
|
||||
}
|
||||
,
|
||||
{
|
||||
"check": Number,
|
||||
"type": "input_value",
|
||||
"name": "virtual_pin"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 从 Bylnk APP 获取虚拟管脚 %1 的值
|
||||
export const mpython_blynk_app_data = {
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
"inputsInline": true,
|
||||
// "nextStatement": null,
|
||||
// "previousStatement": null,
|
||||
// "output":null,
|
||||
"colour": BLYNK_HUE,
|
||||
"helpUrl": Blockly.Msg.MPYTHON_BLYNK_APP_DATA_HELPURL,
|
||||
"tooltip": Blockly.Msg.MPYTHON_BLYNK_SENSOR_DATA_TO_APP_TOOLTIP,
|
||||
"message0": Blockly.Msg.MPYTHON_BLYNK_APP_DATA_MESSAGE0,
|
||||
"args0": [
|
||||
{
|
||||
"check": Number,
|
||||
"type": "input_value",
|
||||
"name": "virtual_pin"
|
||||
}
|
||||
,
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "virtual_pin_val"
|
||||
}
|
||||
]
|
||||
});
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.CONTROLS_REPEAT_INPUT_DO);
|
||||
}
|
||||
};
|
||||
|
||||
// Bylnk设置
|
||||
export const mpython_blynk_setup = {
|
||||
init: function () {
|
||||
this.jsonInit({
|
||||
// "inputsInline": true,
|
||||
"nextStatement": null,
|
||||
"previousStatement": null,
|
||||
"colour": BLYNK_HUE,
|
||||
"helpUrl": Blockly.Msg.MPYTHON_BLYNK_SETUP_HELPURL,
|
||||
"tooltip": Blockly.Msg.MPYTHON_BLYNK_SETUP_TOOLTIP,
|
||||
"message0": Blockly.Msg.MPYTHON_BLYNK_SETUP_MESSAGE0,
|
||||
"args0": [
|
||||
{
|
||||
"type": "input_dummy"
|
||||
},
|
||||
{
|
||||
"check": String,
|
||||
"type": "input_value",
|
||||
"name": "server"
|
||||
},
|
||||
{
|
||||
"check": Number,
|
||||
"type": "input_value",
|
||||
"name": "port"
|
||||
},
|
||||
{
|
||||
"check": String,
|
||||
"type": "input_value",
|
||||
"name": "auth"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
81
boards/default_src/micropython/blocks/cc_g1.js
Normal file
81
boards/default_src/micropython/blocks/cc_g1.js
Normal file
@@ -0,0 +1,81 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
const CCG1_HUE = 40;
|
||||
|
||||
export const cc_g1_init = {
|
||||
init: function () {
|
||||
this.setColour(CCG1_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP + " CC_G1");
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('key');
|
||||
var TOOLTIPS = {
|
||||
"temperature": Blockly.Msg.MIXLY_MICROBIT_SENSOR_SHT_temperature_TOOLTIP,
|
||||
"relative_humidity": Blockly.Msg.MIXLY_MICROBIT_SENSOR_SHT_HUM_TOOLTIP
|
||||
};
|
||||
return TOOLTIPS[mode]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const cc_g1_read_bat = {
|
||||
init: function () {
|
||||
this.setColour(CCG1_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_GET_BATTERY);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const cc_g1_read_joystick = {
|
||||
init: function () {
|
||||
this.setColour(CCG1_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET_JOYSTICK)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["x", "[0]"],
|
||||
["y", "[1]"],
|
||||
["(x,y)", ""]
|
||||
]), "VAR");
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_DATA);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const cc_g1_read_key = {
|
||||
init: function () {
|
||||
this.setColour(CCG1_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_BUTTON)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["A", "0"],
|
||||
["B", "1"],
|
||||
["C", "2"],
|
||||
["D", "3"],
|
||||
["POWER", "4"],
|
||||
["SELECT", "5"]
|
||||
]), "VAR");
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.WHETHER_IS_PRESSED);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const cc_g1_turnoff = {
|
||||
init: function () {
|
||||
this.setColour(CCG1_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_HANDLE_SHUTDOWN);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
318
boards/default_src/micropython/blocks/ce_go.js
Normal file
318
boards/default_src/micropython/blocks/ce_go.js
Normal file
@@ -0,0 +1,318 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
const MEGO_HUE = 100;
|
||||
|
||||
//LED
|
||||
export const ce_go_light_number = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXGO_LEFT_FRONT + Blockly.Msg.COLOUR_RGB_GREEN + Blockly.Msg.MIXLY_EXTERN_LED, "GLED[0]"],
|
||||
[Blockly.Msg.MIXGO_RIGHT_FRONT + Blockly.Msg.COLOUR_RGB_GREEN + Blockly.Msg.MIXLY_EXTERN_LED, "GLED[1]"],
|
||||
[Blockly.Msg.MIXGO_LEFT_BACK + Blockly.Msg.COLOUR_RGB_GREEN + Blockly.Msg.MIXLY_EXTERN_LED, "GLED[3]"],
|
||||
[Blockly.Msg.MIXGO_RIGHT_BACK + Blockly.Msg.COLOUR_RGB_GREEN + Blockly.Msg.MIXLY_EXTERN_LED, "GLED[2]"],
|
||||
[Blockly.Msg.MIXGO_LEFT_FRONT + Blockly.Msg.COLOUR_RGB_RED + Blockly.Msg.MIXLY_EXTERN_LED, "RLED[0]"],
|
||||
[Blockly.Msg.MIXGO_RIGHT_FRONT + Blockly.Msg.COLOUR_RGB_RED + Blockly.Msg.MIXLY_EXTERN_LED, "RLED[1]"],
|
||||
[Blockly.Msg.MIXGO_LEFT_BACK + Blockly.Msg.COLOUR_RGB_RED + Blockly.Msg.MIXLY_EXTERN_LED, "RLED[3]"],
|
||||
[Blockly.Msg.MIXGO_RIGHT_BACK + Blockly.Msg.COLOUR_RGB_RED + Blockly.Msg.MIXLY_EXTERN_LED, "RLED[2]"],
|
||||
[Blockly.Msg.ME_GO_LIGHT_HEADLIGHT, "WLED"]
|
||||
]), 'op')
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const ce_go_led_bright = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SETTING);
|
||||
this.appendValueInput('led')
|
||||
.appendField('ME GO')
|
||||
this.appendValueInput('bright')
|
||||
.appendField(Blockly.Msg.MIXLY_PULSEIN_STAT)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_LED_SETONOFF);
|
||||
}
|
||||
};
|
||||
|
||||
export const ce_go_get_led_bright = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET);
|
||||
this.appendValueInput('led')
|
||||
.appendField('ME GO')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_BRIGHTNESS)
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_LED_GETONOFF);
|
||||
}
|
||||
};
|
||||
|
||||
export const ce_go_get_led_state = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET);
|
||||
this.appendValueInput('led')
|
||||
.appendField('ME GO')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_PULSEIN_STAT)
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_LED_GETONOFF);
|
||||
}
|
||||
};
|
||||
|
||||
export const ce_go_led_brightness = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SETTING);
|
||||
this.appendValueInput('led')
|
||||
.appendField('ME GO')
|
||||
this.appendValueInput('bright')
|
||||
.appendField(Blockly.Msg.MIXLY_BRIGHTNESS)
|
||||
this.appendDummyInput("")
|
||||
.appendField("%")
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_SETTING + Blockly.Msg.MIXLY_BUILDIN_LED + Blockly.Msg.MIXLY_BRIGHTNESS + '(0-10)');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const ce_go_stepper_keep = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("ME GO")
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.blockpy_forward, "F"],
|
||||
[Blockly.Msg.blockpy_backward, "B"],
|
||||
[Blockly.Msg.blockpy_left, "L"],
|
||||
[Blockly.Msg.blockpy_right, "R"]
|
||||
]), "VAR");
|
||||
this.appendValueInput('speed')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_STEPPER_SET_SPEED);
|
||||
this.appendDummyInput("")
|
||||
.appendField("%")
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const ce_go_stepper_stop = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("ME GO")
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MOTOR_P, "P"],
|
||||
[Blockly.Msg.MOTOR_N, "N"]
|
||||
]), "VAR");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const ce_go_dc_motor = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("ME GO")
|
||||
.appendField(Blockly.Msg.MOTOR_DC)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLYCAR_WHEEL_LEFT, "0"],
|
||||
[Blockly.Msg.MIXLYCAR_WHEEL_RIGHT, "1"],
|
||||
[Blockly.Msg.ME_GO_MOTOR_EXTERN, "2"]
|
||||
]), "wheel");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_Direction)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.ROTATION_FORWARD, "CW"],
|
||||
[Blockly.Msg.ROTATION_BACKWARD, "CCW"],
|
||||
[Blockly.Msg.MOTOR_P, "P"],
|
||||
[Blockly.Msg.MOTOR_N, "N"]
|
||||
]), "direction");
|
||||
this.appendValueInput('speed')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_STEPPER_SET_SPEED);
|
||||
this.appendDummyInput("")
|
||||
.appendField("%")
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const ce_go_hall_attachInterrupt = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_INTERRUPT)
|
||||
.appendField(Blockly.Msg.ME_GO_HALL_SENSOR)
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.TEXT_TRIM_LEFT, "A"], [Blockly.Msg.TEXT_TRIM_RIGHT, "B"]]), "mode");
|
||||
this.appendValueInput('DO')
|
||||
.appendField(Blockly.Msg.MIXLY_DO)
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const ce_go_hall_initialize = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.ME_GO_HALL_SENSOR)
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.TEXT_TRIM_LEFT, "A"], [Blockly.Msg.TEXT_TRIM_RIGHT, "B"]]), "mode");
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([['turns', "turns"], ['distance', "distance"], ['turns,distance', 'all']]), "args");
|
||||
this.appendValueInput('num')
|
||||
.setCheck(Number)
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const ce_go_hall_data = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.ME_GO_HALL_SENSOR)
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.TEXT_TRIM_LEFT, "A"], [Blockly.Msg.TEXT_TRIM_RIGHT, "B"]]), "mode");
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET)
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([['turns', "turns"], ['distance', "distance"], ['speed', 'speed']]), "args");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const ce_go_pin_near_line = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.TEXT_TRIM_LEFT, "[0]"],
|
||||
[Blockly.Msg.MIXGO_LEFT_MID, "[1]"],
|
||||
[Blockly.Msg.MIXGO_RIGHT_MID, "[2]"],
|
||||
[Blockly.Msg.TEXT_TRIM_RIGHT, "[3]"],
|
||||
[Blockly.Msg.MIXLY_ALL, ""]
|
||||
]), "key")
|
||||
.appendField(Blockly.Msg.MIXGO_LINE_SENSOR_VAL);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(function () {
|
||||
var mode0 = Blockly.Msg.MIXLY_ESP32_SENSOR_MIXGO_PIN_NEAR_TOOLTIP;
|
||||
var mode1 = Blockly.Msg.MIXLY_ESP32_NEAR;
|
||||
return mode0 + mode1
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const ce_go_pin_near = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXGO_LEFT_FRONT, "[0]"],
|
||||
[Blockly.Msg.MIXGO_RIGHT_FRONT, "[1]"],
|
||||
[Blockly.Msg.MIXGO_LEFT_BACK, "[3]"],
|
||||
[Blockly.Msg.MIXGO_RIGHT_BACK, "[2]"],
|
||||
[Blockly.Msg.MIXLY_ALL, ""]
|
||||
]), "key")
|
||||
.appendField(Blockly.Msg.MIXGO_PROXIMITY_SENSOR);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(function () {
|
||||
var mode0 = Blockly.Msg.MIXLY_ESP32_SENSOR_MIXGO_PIN_NEAR_TOOLTIP;
|
||||
var mode1 = Blockly.Msg.MIXLY_ESP32_NEAR;
|
||||
return mode0 + mode1
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const ce_go_pin_near_state_change = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MIXGO_CAR_SENSOR_ONBOARD_CHANGE)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_ME_GO_CAR_SENSOR_ONBOARD_AUTO_CHANGE, "AS"],
|
||||
[Blockly.Msg.MIXLY_MIXGO_CAR_USE_LINE_ONLY, "LP"],
|
||||
[Blockly.Msg.MIXLY_MIXGO_CAR_USE_PROXIMITY_ONLY, "OA"],
|
||||
[Blockly.Msg.MIXLY_ME_GO_CAR_LIGHT_SEEKING_ONLY, "LS"],
|
||||
[Blockly.Msg.ME_GO_SENSOR_MODE_OFF, "CL"]
|
||||
]), "key");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mixgome_eulerangles = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_GET_GESTURE)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.ME_GO_PITCH, '[0]'],
|
||||
[Blockly.Msg.ME_GO_ROLL, '[1]'],
|
||||
[Blockly.Msg.ME_GO_PITCH + ', ' + Blockly.Msg.ME_GO_ROLL, '']
|
||||
]), 'angle');
|
||||
// this.appendDummyInput("")
|
||||
// .appendField(Blockly.Msg.BOARD_DIRECTION)
|
||||
// .appendField(new Blockly.FieldDropdown([
|
||||
// [Blockly.Msg.OLED_VER,'True'],
|
||||
// [Blockly.Msg.OLED_HOR,'False'],
|
||||
// ]),'dir');
|
||||
this.appendDummyInput("")
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
export const ce_go_pin_light = {
|
||||
init: function () {
|
||||
this.setColour(MEGO_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.TEXT_TRIM_LEFT, "[0]"],
|
||||
[Blockly.Msg.MIXGO_LEFT_MID, "[1]"],
|
||||
[Blockly.Msg.MIXGO_RIGHT_MID, "[2]"],
|
||||
[Blockly.Msg.TEXT_TRIM_RIGHT, "[3]"],
|
||||
[Blockly.Msg.MIXLY_ALL, ""]
|
||||
]), "key")
|
||||
.appendField(Blockly.Msg.MIXLY_ME_GO_CAR_LIGHT_SEEKING_SENSOR);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(function () {
|
||||
var mode0 = Blockly.Msg.MIXLY_ESP32_SENSOR_MIXGO_PIN_NEAR_TOOLTIP;
|
||||
var mode1 = Blockly.Msg.MIXLY_ME_GO_CAR_LIGHT_SEEKING_SENSOR;
|
||||
return mode0 + mode1
|
||||
});
|
||||
}
|
||||
};
|
||||
1178
boards/default_src/micropython/blocks/communicate.js
Normal file
1178
boards/default_src/micropython/blocks/communicate.js
Normal file
File diff suppressed because it is too large
Load Diff
621
boards/default_src/micropython/blocks/control.js
Normal file
621
boards/default_src/micropython/blocks/control.js
Normal file
@@ -0,0 +1,621 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
const LOOPS_HUE = 120//'#EB8045';
|
||||
|
||||
export const base_setup = {
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP);
|
||||
this.appendStatementInput('DO')
|
||||
.appendField('');
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_CONTROL_SETUP);
|
||||
}
|
||||
};
|
||||
|
||||
export const controls_delay = {
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_DELAY)
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_SECOND, "s"], [Blockly.Msg.MIXLY_mSecond, "ms"], [Blockly.Msg.MIXLY_uSecond, "us"]]), 'Time');
|
||||
this.appendValueInput("DELAY_TIME", Number)
|
||||
.setCheck(Number);
|
||||
this.setFieldValue('ms', 'Time')
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_CONTROL_DELAY);
|
||||
}
|
||||
};
|
||||
|
||||
export const Panic_with_status_code = {
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendValueInput("STATUS_CODE", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_Panic_with_status_code)
|
||||
.setCheck(Number);
|
||||
this.setPreviousStatement(true, null);
|
||||
// this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_Panic_with_status_code);
|
||||
}
|
||||
};
|
||||
|
||||
export const reset = {
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_Reset_micro);
|
||||
this.setPreviousStatement(true);
|
||||
// this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_Reset_micro);
|
||||
}
|
||||
};
|
||||
|
||||
export const controls_for = {
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.LANG_CONTROLS_FOR_INPUT_WITH)
|
||||
.appendField(new Blockly.FieldTextInput('i'), 'VAR');
|
||||
this.appendValueInput('FROM')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.LANG_CONTROLS_FOR_INPUT_FROM);
|
||||
this.appendValueInput('TO')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.LANG_CONTROLS_FOR_INPUT_TO);
|
||||
this.appendValueInput('STEP')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_STEP);
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.Msg.MIXLY_DO);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
return Blockly.Msg.CONTROLS_FOR_TOOLTIP.replace('%1',
|
||||
thisBlock.getFieldValue('VAR'));
|
||||
});
|
||||
},
|
||||
getVars: function () {
|
||||
return [this.getFieldValue('VAR')];
|
||||
},
|
||||
renameVar: function (oldName, newName) {
|
||||
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
|
||||
this.setTitleValue(newName, 'VAR');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const controls_whileUntil = {
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendValueInput('BOOL')
|
||||
.setCheck([Boolean, Number])
|
||||
.appendField(Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TITLE_REPEAT)
|
||||
.appendField(new Blockly.FieldDropdown(this.OPERATORS), 'MODE');
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.Msg.MIXLY_DO);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var op = thisBlock.getFieldValue('MODE');
|
||||
var TOOLTIPS = {
|
||||
'WHILE': Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE,
|
||||
'UNTIL': Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL
|
||||
};
|
||||
return TOOLTIPS[op];
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
controls_whileUntil.OPERATORS = [
|
||||
[Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_WHILE, 'WHILE'],
|
||||
[Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL, 'UNTIL']
|
||||
];
|
||||
|
||||
export const controls_flow_statements = {
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
var dropdown = new Blockly.FieldDropdown(this.OPERATORS);
|
||||
this.appendDummyInput()
|
||||
.appendField(dropdown, 'FLOW')
|
||||
.appendField(Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_INPUT_OFLOOP);
|
||||
this.setPreviousStatement(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var op = thisBlock.getFieldValue('FLOW');
|
||||
var TOOLTIPS = {
|
||||
'BREAK': Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK,
|
||||
'CONTINUE': Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE
|
||||
};
|
||||
return TOOLTIPS[op];
|
||||
});
|
||||
},
|
||||
onchange: function () {
|
||||
if (!this.workspace) {
|
||||
// Block has been deleted.
|
||||
return;
|
||||
}
|
||||
var legal = false;
|
||||
// Is the block nested in a control statement?
|
||||
var block = this;
|
||||
do {
|
||||
if (block.type == 'controls_repeat' ||
|
||||
block.type == 'controls_for' ||
|
||||
block.type == 'controls_forEach' ||
|
||||
block.type == 'controls_repeat_ext' ||
|
||||
block.type == 'controls_whileUntil') {
|
||||
legal = true;
|
||||
break;
|
||||
}
|
||||
block = block.getSurroundParent();
|
||||
} while (block);
|
||||
if (legal) {
|
||||
this.setWarningText(null);
|
||||
} else {
|
||||
this.setWarningText(Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_WARNING);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
controls_flow_statements.OPERATORS = [
|
||||
[Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK, 'BREAK'],
|
||||
[Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE, 'CONTINUE']
|
||||
];
|
||||
|
||||
export const controls_millis = {
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_RUNTIME);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_mSecond, "ms"], [Blockly.Msg.MIXLY_uSecond, "us"]]), 'Time');
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_RUNTIME);
|
||||
}
|
||||
};
|
||||
|
||||
export const controls_if = {
|
||||
/**
|
||||
* Block for if/elseif/else condition.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
//this.setHelpUrl(Blockly.Msg.CONTROLS_IF_HELPURL);
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendValueInput('IF0')
|
||||
.setCheck([Boolean, Number])
|
||||
.appendField(Blockly.Msg.CONTROLS_IF_MSG_IF);
|
||||
this.appendStatementInput('DO0')
|
||||
.appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setHelpUrl("https://mixly.readthedocs.io/zh_CN/latest/arduino/03.Control.html#if");
|
||||
this.setMutator(new Blockly.icons.MutatorIcon(['controls_if_elseif',
|
||||
'controls_if_else'], this));
|
||||
// Assign 'this' to a variable for use in the tooltip closure below.
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
if (!thisBlock.elseifCount_ && !thisBlock.elseCount_) {
|
||||
return Blockly.Msg.CONTROLS_IF_TOOLTIP_1;
|
||||
} else if (!thisBlock.elseifCount_ && thisBlock.elseCount_) {
|
||||
return Blockly.Msg.CONTROLS_IF_TOOLTIP_2;
|
||||
} else if (thisBlock.elseifCount_ && !thisBlock.elseCount_) {
|
||||
return Blockly.Msg.CONTROLS_IF_TOOLTIP_3;
|
||||
} else if (thisBlock.elseifCount_ && thisBlock.elseCount_) {
|
||||
return Blockly.Msg.CONTROLS_IF_TOOLTIP_4;
|
||||
}
|
||||
return '';
|
||||
});
|
||||
this.elseifCount_ = 0;
|
||||
this.elseCount_ = 0;
|
||||
},
|
||||
/**
|
||||
* Create XML to represent the number of else-if and else inputs.
|
||||
* @return {Element} XML storage element.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
mutationToDom: function () {
|
||||
if (!this.elseifCount_ && !this.elseCount_) {
|
||||
return null;
|
||||
}
|
||||
var container = document.createElement('mutation');
|
||||
if (this.elseifCount_) {
|
||||
container.setAttribute('elseif', this.elseifCount_);
|
||||
}
|
||||
if (this.elseCount_) {
|
||||
container.setAttribute('else', 1);
|
||||
}
|
||||
return container;
|
||||
},
|
||||
/**
|
||||
* Parse XML to restore the else-if and else inputs.
|
||||
* @param {!Element} xmlElement XML storage element.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
domToMutation: function (xmlElement) {
|
||||
var containerBlock = this;
|
||||
var valueConnections = [];
|
||||
var statementConnections = [];
|
||||
// var elseStatementConnection = null;
|
||||
if (this.elseCount_) {
|
||||
// if (containerBlock.getInputTargetBlock('ELSE') && containerBlock.getInputTargetBlock('ELSE').previousConnection)
|
||||
// elseStatementConnection = containerBlock.getInputTargetBlock('ELSE').previousConnection;
|
||||
this.removeInput('ELSE');
|
||||
}
|
||||
for (var i = this.elseifCount_; i > 0; i--) {
|
||||
if (containerBlock.getInputTargetBlock('IF' + i) && containerBlock.getInputTargetBlock('IF' + i).previousConnection)
|
||||
valueConnections[i] = (containerBlock.getInputTargetBlock('IF' + i).previousConnection);
|
||||
else
|
||||
valueConnections[i] = null;
|
||||
this.removeInput('IF' + i);
|
||||
if (containerBlock.getInputTargetBlock('DO' + i) && containerBlock.getInputTargetBlock('DO' + i).previousConnection)
|
||||
statementConnections[i] = (containerBlock.getInputTargetBlock('DO' + i).previousConnection);
|
||||
else
|
||||
statementConnections[i] = null;
|
||||
this.removeInput('DO' + i);
|
||||
}
|
||||
this.elseifCount_ = parseInt(xmlElement.getAttribute('elseif'), 10);
|
||||
this.elseCount_ = parseInt(xmlElement.getAttribute('else'), 10);
|
||||
//this.compose(containerBlock);
|
||||
for (var i = 1; i <= this.elseifCount_; i++) {
|
||||
this.appendValueInput('IF' + i)
|
||||
.setCheck([Boolean, Number])
|
||||
.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF);
|
||||
this.appendStatementInput('DO' + i)
|
||||
.appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);
|
||||
}
|
||||
if (this.elseCount_) {
|
||||
this.appendStatementInput('ELSE')
|
||||
.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE);
|
||||
}
|
||||
for (var i = valueConnections.length - 2; i > 0; i--) {
|
||||
if (valueConnections[i])
|
||||
valueConnections[i].reconnect(this, 'IF' + i);
|
||||
}
|
||||
for (var i = statementConnections.length - 2; i > 0; i--) {
|
||||
if (statementConnections[i])
|
||||
statementConnections[i].reconnect(this, 'DO' + i);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Populate the mutator's dialog with this block's components.
|
||||
* @param {!Blockly.Workspace} workspace Mutator's workspace.
|
||||
* @return {!Blockly.Block} Root block in mutator.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
decompose: function (workspace) {
|
||||
var containerBlock = workspace.newBlock('controls_if_if');
|
||||
containerBlock.initSvg();
|
||||
var connection = containerBlock.getInput('STACK').connection;
|
||||
for (var i = 1; i <= this.elseifCount_; i++) {
|
||||
var elseifBlock = workspace.newBlock('controls_if_elseif');
|
||||
elseifBlock.initSvg();
|
||||
connection.connect(elseifBlock.previousConnection);
|
||||
connection = elseifBlock.nextConnection;
|
||||
}
|
||||
if (this.elseCount_) {
|
||||
var elseBlock = workspace.newBlock('controls_if_else');
|
||||
elseBlock.initSvg();
|
||||
connection.connect(elseBlock.previousConnection);
|
||||
}
|
||||
return containerBlock;
|
||||
},
|
||||
/**
|
||||
* Reconfigure this block based on the mutator dialog's components.
|
||||
* @param {!Blockly.Block} containerBlock Root block in mutator.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
compose: function (containerBlock) {
|
||||
// Disconnect the else input blocks and remove the inputs.
|
||||
if (this.elseCount_) {
|
||||
this.removeInput('ELSE');
|
||||
}
|
||||
this.elseCount_ = 0;
|
||||
// Disconnect all the elseif input blocks and remove the inputs.
|
||||
for (var i = this.elseifCount_; i > 0; i--) {
|
||||
this.removeInput('IF' + i);
|
||||
this.removeInput('DO' + i);
|
||||
}
|
||||
this.elseifCount_ = 0;
|
||||
// Rebuild the block's optional inputs.
|
||||
var clauseBlock = containerBlock.getInputTargetBlock('STACK');
|
||||
var valueConnections = [null];
|
||||
var statementConnections = [null];
|
||||
var elseStatementConnection = null;
|
||||
while (clauseBlock) {
|
||||
switch (clauseBlock.type) {
|
||||
case 'controls_if_elseif':
|
||||
this.elseifCount_++;
|
||||
valueConnections.push(clauseBlock.valueConnection_);
|
||||
statementConnections.push(clauseBlock.statementConnection_);
|
||||
break;
|
||||
case 'controls_if_else':
|
||||
this.elseCount_++;
|
||||
elseStatementConnection = clauseBlock.statementConnection_;
|
||||
break;
|
||||
default:
|
||||
throw Error('Unknown block type: ' + clauseBlock.type);
|
||||
}
|
||||
clauseBlock = clauseBlock.nextConnection &&
|
||||
clauseBlock.nextConnection.targetBlock();
|
||||
}
|
||||
|
||||
this.updateShape_();
|
||||
// Reconnect any child blocks.
|
||||
this.reconnectChildBlocks_(valueConnections, statementConnections, elseStatementConnection);
|
||||
|
||||
},
|
||||
/**
|
||||
* Store pointers to any connected child blocks.
|
||||
* @param {!Blockly.Block} containerBlock Root block in mutator.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
saveConnections: function (containerBlock) {
|
||||
var clauseBlock = containerBlock.getInputTargetBlock('STACK');
|
||||
var i = 1;
|
||||
while (clauseBlock) {
|
||||
switch (clauseBlock.type) {
|
||||
case 'controls_if_elseif':
|
||||
var inputIf = this.getInput('IF' + i);
|
||||
var inputDo = this.getInput('DO' + i);
|
||||
clauseBlock.valueConnection_ =
|
||||
inputIf && inputIf.connection.targetConnection;
|
||||
clauseBlock.statementConnection_ =
|
||||
inputDo && inputDo.connection.targetConnection;
|
||||
i++;
|
||||
break;
|
||||
case 'controls_if_else':
|
||||
var inputDo = this.getInput('ELSE');
|
||||
clauseBlock.statementConnection_ =
|
||||
inputDo && inputDo.connection.targetConnection;
|
||||
break;
|
||||
default:
|
||||
throw 'Unknown block type.';
|
||||
}
|
||||
clauseBlock = clauseBlock.nextConnection &&
|
||||
clauseBlock.nextConnection.targetBlock();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Reconstructs the block with all child blocks attached.
|
||||
*/
|
||||
rebuildShape_: function () {
|
||||
var valueConnections = [null];
|
||||
var statementConnections = [null];
|
||||
var elseStatementConnection = null;
|
||||
|
||||
if (this.getInput('ELSE')) {
|
||||
elseStatementConnection = this.getInput('ELSE').connection.targetConnection;
|
||||
}
|
||||
var i = 1;
|
||||
while (this.getInput('IF' + i)) {
|
||||
var inputIf = this.getInput('IF' + i);
|
||||
var inputDo = this.getInput('DO' + i);
|
||||
console.log(inputIf.connection.targetConnection);
|
||||
valueConnections.push(inputIf.connection.targetConnection);
|
||||
statementConnections.push(inputDo.connection.targetConnection);
|
||||
i++;
|
||||
}
|
||||
this.updateShape_();
|
||||
this.reconnectChildBlocks_(valueConnections, statementConnections, elseStatementConnection);
|
||||
},
|
||||
/**
|
||||
* Modify this block to have the correct number of inputs.
|
||||
* @this Blockly.Block
|
||||
* @private
|
||||
*/
|
||||
updateShape_: function () {
|
||||
// Delete everything.
|
||||
if (this.getInput('ELSE')) {
|
||||
this.removeInput('ELSE');
|
||||
}
|
||||
var i = 1;
|
||||
while (this.getInput('IF' + i)) {
|
||||
this.removeInput('IF' + i);
|
||||
this.removeInput('DO' + i);
|
||||
i++;
|
||||
}
|
||||
// Rebuild block.
|
||||
for (var i = 1; i <= this.elseifCount_; i++) {
|
||||
this.appendValueInput('IF' + i)
|
||||
.setCheck([Number, Boolean])
|
||||
.appendField(Blockly.Msg['CONTROLS_IF_MSG_ELSEIF']);
|
||||
this.appendStatementInput('DO' + i)
|
||||
.appendField(Blockly.Msg['CONTROLS_IF_MSG_THEN']);
|
||||
}
|
||||
if (this.elseCount_) {
|
||||
this.appendStatementInput('ELSE')
|
||||
.appendField(Blockly.Msg['CONTROLS_IF_MSG_ELSE']);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Reconnects child blocks.
|
||||
* @param {!Array<?Blockly.RenderedConnection>} valueConnections List of value
|
||||
* connectsions for if input.
|
||||
* @param {!Array<?Blockly.RenderedConnection>} statementConnections List of
|
||||
* statement connections for do input.
|
||||
* @param {?Blockly.RenderedConnection} elseStatementConnection Statement
|
||||
* connection for else input.
|
||||
*/
|
||||
reconnectChildBlocks_: function (valueConnections, statementConnections,
|
||||
elseStatementConnection) {
|
||||
for (var i = 1; i <= this.elseifCount_; i++) {
|
||||
valueConnections[i] && Blockly.Mutator.reconnect(this, 'IF' + i);
|
||||
statementConnections[i] && statementConnections[i].reconnect(this, 'DO' + i);
|
||||
}
|
||||
elseStatementConnection && elseStatementConnection.reconnect(this, 'ELSE');
|
||||
}
|
||||
};
|
||||
|
||||
export const controls_if_if = {
|
||||
/**
|
||||
* Mutator block for if container.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.CONTROLS_IF_IF_TITLE_IF);
|
||||
this.appendStatementInput('STACK');
|
||||
this.setTooltip(Blockly.Msg.CONTROLS_IF_IF_TOOLTIP);
|
||||
this.contextMenu = false;
|
||||
}
|
||||
};
|
||||
|
||||
export const controls_if_elseif = {
|
||||
/**
|
||||
* Mutator bolck for else-if condition.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP);
|
||||
this.contextMenu = false;
|
||||
}
|
||||
};
|
||||
|
||||
export const controls_if_else = {
|
||||
/**
|
||||
* Mutator block for else condition.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE);
|
||||
this.setPreviousStatement(true);
|
||||
this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP);
|
||||
this.contextMenu = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const controls_end_program = {
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_CONTROL_END_PROGRAM);
|
||||
this.setPreviousStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_CONTROL_END_PROGRAM);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const controls_forEach = {
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendValueInput('LIST')
|
||||
.setCheck(['List', String])
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.CONTROLS_FOREACH_INPUT);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.CONTROLS_FOREACH_INPUT_ITEM)
|
||||
.appendField(new Blockly.FieldTextInput('i'), 'VAR');
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.Msg.MIXLY_DO);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
return Blockly.Msg.CONTROLS_FOR_TOOLTIP.replace('%1',
|
||||
thisBlock.getFieldValue('VAR'));
|
||||
});
|
||||
},
|
||||
getVars: function () {
|
||||
return [this.getFieldValue('VAR')];
|
||||
},
|
||||
renameVar: function (oldName, newName) {
|
||||
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
|
||||
this.setTitleValue(newName, 'VAR');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const raw_block = {
|
||||
// Container.
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.appendDummyInput()
|
||||
.appendField('Code Block:');
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldMultilineInput('12345'), 'TEXT');
|
||||
}
|
||||
};
|
||||
|
||||
export const base_type = {
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendValueInput("DATA")
|
||||
.appendField(Blockly.Msg.MICROBIT_PYTHON_TYPE);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
this.setTooltip(Blockly.Msg.MICROBIT_PYTHON_TYPE);
|
||||
}
|
||||
};
|
||||
|
||||
export const controls_TypeLists = {
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_CONTORL_GET_TYPE)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.LANG_MATH_INT, "int"],
|
||||
[Blockly.Msg.MIXLY_MICROBIT_TYPE_FLOAT, "float"],
|
||||
[Blockly.Msg.MIXLY_MICROBIT_TYPE_STRING, "str"],
|
||||
[Blockly.Msg.MIXLY_MICROBIT_TYPE_LIST, "list"],
|
||||
[Blockly.Msg.MIXLY_MICROBIT_TYPE_TUPLE, "tuple"],
|
||||
[Blockly.Msg.MIXLY_MICROBIT_TYPE_DICT, "dict"],
|
||||
[Blockly.Msg.blockpy_SET_CREATE_WITH_CONTAINER_TITLE_ADD, "set"],
|
||||
// [Blockly.Msg.MIXLY_MICROBIT_IMAGE,"image"],
|
||||
[Blockly.Msg.LOGIC_NULL, "NoneType"]]), "type");
|
||||
//整数、浮点数、字符串、列表、元组、字典、集合、图像不太对, unfinished
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('type');
|
||||
var mode0 = Blockly.Msg.MICROBIT_controls_TypeLists;
|
||||
var TOOLTIPS = {
|
||||
'int': Blockly.Msg.LANG_MATH_INT,
|
||||
'float': Blockly.Msg.MIXLY_MICROBIT_TYPE_FLOAT,
|
||||
'str': Blockly.Msg.MIXLY_MICROBIT_TYPE_STRING,
|
||||
'list': Blockly.Msg.MIXLY_MICROBIT_TYPE_LIST,
|
||||
'tuple': Blockly.Msg.MIXLY_MICROBIT_TYPE_TUPLE,
|
||||
'dict': Blockly.Msg.MIXLY_MICROBIT_TYPE_DICT,
|
||||
'set': Blockly.Msg.blockpy_SET_CREATE_WITH_CONTAINER_TITLE_ADD,
|
||||
'image': Blockly.Msg.MIXLY_MICROBIT_IMAGE,
|
||||
'NoneType': Blockly.Msg.LOGIC_NULL
|
||||
};
|
||||
return mode0 + TOOLTIPS[mode];
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const controls_uname = {
|
||||
init: function () {
|
||||
this.setColour(LOOPS_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_CONTORL_UNAME);
|
||||
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
this.setTooltip(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + Blockly.Msg.MIXLY_MICROBIT_PY_CONTORL_UNAME);
|
||||
}
|
||||
};
|
||||
1833
boards/default_src/micropython/blocks/display.js
Normal file
1833
boards/default_src/micropython/blocks/display.js
Normal file
File diff suppressed because it is too large
Load Diff
1774
boards/default_src/micropython/blocks/display_extern.js
Normal file
1774
boards/default_src/micropython/blocks/display_extern.js
Normal file
File diff suppressed because it is too large
Load Diff
1441
boards/default_src/micropython/blocks/display_onboard.js
Normal file
1441
boards/default_src/micropython/blocks/display_onboard.js
Normal file
File diff suppressed because it is too large
Load Diff
286
boards/default_src/micropython/blocks/factory.js
Normal file
286
boards/default_src/micropython/blocks/factory.js
Normal file
@@ -0,0 +1,286 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
const FACTORY_HUE = "#777777"//65;
|
||||
|
||||
export const factory_from_import = {
|
||||
init: function () {
|
||||
this.setColour(FACTORY_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField("from ")
|
||||
.appendField(new Blockly.FieldTextInput('ESP32'), 'path')
|
||||
.appendField(" import ")
|
||||
.appendField(new Blockly.FieldTextInput('*'), 'module');
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const factory_import = {
|
||||
init: function () {
|
||||
this.setColour(FACTORY_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField("import ")
|
||||
.appendField(new Blockly.FieldTextInput('module'), 'module');
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const factory_function_noreturn = {
|
||||
init: function () {
|
||||
//console.log('init');
|
||||
this.setColour(FACTORY_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldTextInput('my_function'), 'NAME');
|
||||
this.itemCount_ = 1;
|
||||
this.arguments_ = ['x'];//add
|
||||
this.updateShape_();
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setMutator(new Blockly.icons.MutatorIcon(['factory_create_with_item'], this));
|
||||
},
|
||||
mutationToDom: function () {
|
||||
//console.log('mutationToDom');
|
||||
var container = document.createElement('mutation');
|
||||
container.setAttribute('items', this.itemCount_);
|
||||
//add
|
||||
for (var i = 0; i < this.arguments_.length; i++) {
|
||||
var parameter = document.createElement('arg');
|
||||
parameter.setAttribute('name', this.arguments_[i]);
|
||||
container.appendChild(parameter);
|
||||
}
|
||||
return container;
|
||||
},
|
||||
domToMutation: function (xmlElement) {
|
||||
//console.log('domToMutation');
|
||||
this.arguments_ = [];//add
|
||||
//add
|
||||
for (var i = 0; xmlElement.childNodes[i]; i++) {
|
||||
let childNode = xmlElement.childNodes[i];
|
||||
if (childNode.nodeName.toLowerCase() == 'arg') {
|
||||
this.arguments_.push(childNode.getAttribute('name'));
|
||||
}
|
||||
}
|
||||
this.itemCount_ = parseInt(xmlElement.getAttribute('items'), 10);
|
||||
this.updateShape_();
|
||||
},
|
||||
decompose: function (workspace) {
|
||||
//console.log('decompose');
|
||||
var containerBlock =
|
||||
workspace.newBlock('factory_create_with_container');
|
||||
containerBlock.initSvg();
|
||||
var connection = containerBlock.getInput('STACK')
|
||||
.connection;
|
||||
for (var i = 0; i < this.itemCount_; i++) {
|
||||
var itemBlock = workspace.newBlock('factory_create_with_item');
|
||||
itemBlock.initSvg();
|
||||
itemBlock.setFieldValue(this.arguments_[i], 'NAME');//add
|
||||
connection.connect(itemBlock.previousConnection);
|
||||
connection = itemBlock.nextConnection;
|
||||
}
|
||||
return containerBlock;
|
||||
},
|
||||
compose: function (containerBlock) {
|
||||
//console.log('compose');
|
||||
this.arguments_ = [];//add
|
||||
var itemBlock = containerBlock.getInputTargetBlock('STACK');
|
||||
// Count number of inputs.
|
||||
var connections = [];
|
||||
var i = 0;
|
||||
while (itemBlock) {
|
||||
this.arguments_.push(itemBlock.getFieldValue('NAME'));//add
|
||||
connections[i] = itemBlock.valueConnection_;
|
||||
itemBlock = itemBlock.nextConnection &&
|
||||
itemBlock.nextConnection.targetBlock();
|
||||
i++;
|
||||
}
|
||||
this.itemCount_ = i;
|
||||
this.updateShape_();
|
||||
// Reconnect any child blocks.
|
||||
for (var i = 0; i < this.itemCount_; i++) {
|
||||
if (connections[i]) {
|
||||
this.getInput('ADD' + i).connection.connect(connections[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
saveConnections: function (containerBlock) {
|
||||
//console.log('saveConnections');
|
||||
var itemBlock = containerBlock.getInputTargetBlock('STACK');
|
||||
var i = 0;
|
||||
while (itemBlock) {
|
||||
var input = this.getInput('ADD' + i);
|
||||
itemBlock.valueConnection_ = input && input.connection.targetConnection;
|
||||
i++;
|
||||
itemBlock = itemBlock.nextConnection &&
|
||||
itemBlock.nextConnection.targetBlock();
|
||||
}
|
||||
},
|
||||
updateShape_: function () {
|
||||
//console.log('updateShape_');
|
||||
// Delete everything.
|
||||
if (this.getInput('EMPTY')) {
|
||||
this.removeInput('EMPTY');
|
||||
} else {
|
||||
var i = 0;
|
||||
while (this.getInput('ADD' + i)) {
|
||||
this.removeInput('ADD' + i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// Rebuild block.
|
||||
for (var i = 0; i < this.itemCount_; i++) {
|
||||
this.appendValueInput('ADD' + i)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(this.arguments_[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const factory_create_with_container = {
|
||||
init: function () {
|
||||
this.setColour(FACTORY_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_PARAMS);
|
||||
this.appendStatementInput('STACK');
|
||||
this.contextMenu = false;
|
||||
}
|
||||
};
|
||||
|
||||
export const factory_create_with_item = {
|
||||
init: function () {
|
||||
this.setColour(FACTORY_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TITLE + ':')
|
||||
.appendField(new Blockly.FieldTextInput('x'), 'NAME');
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.contextMenu = false;
|
||||
}
|
||||
};
|
||||
|
||||
export const factory_function_return = {
|
||||
init: function () {
|
||||
this.setColour(FACTORY_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldTextInput('my_function'), 'NAME');
|
||||
this.itemCount_ = 1;
|
||||
this.arguments_ = ['x'];//add
|
||||
this.updateShape_();
|
||||
this.setOutput(true);
|
||||
this.setMutator(new Blockly.icons.MutatorIcon(['factory_create_with_item'], this));
|
||||
},
|
||||
mutationToDom: factory_function_noreturn.mutationToDom,
|
||||
domToMutation: factory_function_noreturn.domToMutation,
|
||||
decompose: factory_function_noreturn.decompose,
|
||||
compose: factory_function_noreturn.compose,
|
||||
saveConnections: factory_function_noreturn.saveConnections,
|
||||
updateShape_: factory_function_noreturn.updateShape_
|
||||
};
|
||||
|
||||
export const factory_declare = {
|
||||
init: function () {
|
||||
this.setColour(FACTORY_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldTextInput('test'), 'NAME')
|
||||
.appendField("=")
|
||||
.appendField(new Blockly.FieldTextInput('Test'), 'TYPE')
|
||||
.appendField("()");
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const factory_callMethod_noreturn = {
|
||||
init: function () {
|
||||
this.setColour(FACTORY_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldTextInput('test'), 'NAME')
|
||||
.appendField('.')
|
||||
.appendField(new Blockly.FieldTextInput('callMethod'), 'METHOD');
|
||||
this.itemCount_ = 1;
|
||||
this.arguments_ = ['x'];//add
|
||||
this.updateShape_();
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setMutator(new Blockly.icons.MutatorIcon(['factory_create_with_item'], this));
|
||||
},
|
||||
mutationToDom: factory_function_noreturn.mutationToDom,
|
||||
domToMutation: factory_function_noreturn.domToMutation,
|
||||
decompose: factory_function_noreturn.decompose,
|
||||
compose: factory_function_noreturn.compose,
|
||||
saveConnections: factory_function_noreturn.saveConnections,
|
||||
updateShape_: factory_function_noreturn.updateShape_
|
||||
};
|
||||
|
||||
export const factory_callMethod_return = {
|
||||
init: function () {
|
||||
this.setColour(FACTORY_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldTextInput('test'), 'NAME')
|
||||
.appendField('.')
|
||||
.appendField(new Blockly.FieldTextInput('callMethod'), 'METHOD');
|
||||
this.itemCount_ = 1;
|
||||
this.arguments_ = ['x'];//add
|
||||
this.updateShape_();
|
||||
this.setOutput(true);
|
||||
this.setMutator(new Blockly.icons.MutatorIcon(['factory_create_with_item'], this));
|
||||
},
|
||||
mutationToDom: factory_function_noreturn.mutationToDom,
|
||||
domToMutation: factory_function_noreturn.domToMutation,
|
||||
decompose: factory_function_noreturn.decompose,
|
||||
compose: factory_function_noreturn.compose,
|
||||
saveConnections: factory_function_noreturn.saveConnections,
|
||||
updateShape_: factory_function_noreturn.updateShape_
|
||||
};
|
||||
|
||||
export const factory_block = {
|
||||
init: function () {
|
||||
this.setColour(FACTORY_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldTextInput('display.scroll("Hello World!")'), 'VALUE');
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const factory_block_return = {
|
||||
init: function () {
|
||||
this.setColour(FACTORY_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldTextInput('test'), 'VALUE');
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const factory_block_with_textarea = {
|
||||
init: function () {
|
||||
this.setColour(FACTORY_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldMultilineInput('display.scroll("Hello World!")\ndisplay.scroll("Hello Mixly!")'), 'VALUE');
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const factory_block_return_with_textarea = {
|
||||
init: function () {
|
||||
this.setColour(FACTORY_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldMultilineInput('Hello\nMixly'), 'VALUE');
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const folding_block = {
|
||||
init: function () {
|
||||
this.setColour(FACTORY_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldTextInput(Blockly.Msg.FOLDING_BLOCK), "peien");
|
||||
this.appendStatementInput('DO')
|
||||
.appendField('');
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.FOLDING_BLOCK_HELP);
|
||||
}
|
||||
};
|
||||
359
boards/default_src/micropython/blocks/inout.js
Normal file
359
boards/default_src/micropython/blocks/inout.js
Normal file
@@ -0,0 +1,359 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
const BASE_HUE = 20//'#ae3838';//40;
|
||||
|
||||
export const inout_highlow = {
|
||||
init: function () {
|
||||
this.setColour(BASE_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_HIGH, "HIGH"], [Blockly.Msg.MIXLY_LOW, "LOW"]]), 'BOOL')
|
||||
this.setOutput(true, Boolean);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_HIGHLOW_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_digital_write = {
|
||||
init: function () {
|
||||
this.setColour(BASE_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_Digital_PINMODEOUT)
|
||||
.setCheck(Number);
|
||||
this.appendValueInput("STAT")
|
||||
.appendField(Blockly.Msg.MIXLY_STAT)
|
||||
.setCheck([Number, Boolean]);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_DIGITAL_WRITE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_digital_read = {
|
||||
init: function () {
|
||||
this.setColour(BASE_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET)
|
||||
.appendField(Blockly.Msg.MIXLY_Digital_PINMODEIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_MACHINE_VALUE)
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true, [Boolean, Number]);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_DIGITAL_READ_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_pwm_analog_write = {
|
||||
init: function () {
|
||||
this.setColour(BASE_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField("PWM" + Blockly.Msg.MIXLY_Analog_PINMODEOUT)
|
||||
.setCheck(Number);
|
||||
this.appendValueInput("NUM", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_VALUE2)
|
||||
.setCheck(Number);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_PWM_ANALOG_WRITE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_analog_write = {
|
||||
init: function () {
|
||||
this.setColour(BASE_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField("DAC" + Blockly.Msg.MIXLY_Analog_PINMODEOUT)
|
||||
.setCheck(Number);
|
||||
this.appendValueInput("NUM", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_VALUE2)
|
||||
.setCheck(Number);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_ANALOG_WRITE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_analog_write_set = {
|
||||
init: function () {
|
||||
this.setColour(BASE_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_Analog_PINMODEOUT)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_PERIOD_MIL)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_mSecond, "period"],
|
||||
[Blockly.Msg.MIXLY_uSecond, "period_microseconds"]
|
||||
]), "key");
|
||||
this.appendValueInput("NUM", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_STAT)
|
||||
.setCheck(Number);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_ANALOG_WRITE_SET_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_pwm_analog_write_set_freq = {
|
||||
init: function () {
|
||||
this.setColour(BASE_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField("PWM" + Blockly.Msg.MIXLY_Analog_PINMODEOUT)
|
||||
.setCheck(Number);
|
||||
this.appendValueInput("NUM", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_FREQUENCY + Blockly.Msg.MIXLY_STAT)
|
||||
.setCheck(Number);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_PWM_ANALOG_WRITE_SET_FREQ_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_analog_read = {
|
||||
init: function () {
|
||||
this.setColour(BASE_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET)
|
||||
.appendField(Blockly.Msg.MIXLY_Analog_PINMODEIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_MACHINE_VALUE)
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true, Number);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_ANALOG_READ_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_analog_atten = {
|
||||
init: function () {
|
||||
this.setColour(BASE_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_Analog_PINMODEIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_REF_VOLTAGE + Blockly.Msg.MIXLY_STAT)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["3.3V", "machine.ADC.ATTN_11DB"],
|
||||
["2.2V", "machine.ADC.ATTN_6DB"],
|
||||
["1.5V", "machine.ADC.ATTN_2_5DB"],
|
||||
["1.2V", "machine.ADC.ATTN_0DB"]
|
||||
]), "atten");
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_ANALOG_ATTEN_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const inout_pin_pressed = {
|
||||
init: function () {
|
||||
this.setColour(BASE_HUE);
|
||||
this.appendValueInput('pin')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET)
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_TOUCH_SENSOR);
|
||||
// this.appendDummyInput()
|
||||
// .appendField(Blockly.Msg.MIXLY_IS_TOUCHED);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_MACHINE_VALUE)
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_PIN_PRESSED_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_pin_attachInterrupt = {
|
||||
init: function () {
|
||||
this.setColour(20);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_ATTACHINTERRUPT_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_MODE)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_RISING, "machine.Pin.IRQ_RISING"], [Blockly.Msg.MIXLY_FALLING, "machine.Pin.IRQ_FALLING"], [Blockly.Msg.MIXLY_CHANGE, "(machine.Pin.IRQ_RISING | machine.Pin.IRQ_FALLING)"]]), "mode");
|
||||
this.appendValueInput('DO')
|
||||
.appendField(Blockly.Msg.MIXLY_DO)
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_PIN_ATTACHINTERRUPT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_digital_init = {
|
||||
init: function () {
|
||||
this.setColour(20);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
.appendField(new Blockly.FieldTextInput('pin#'), 'PIN_OBJ');
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_AS)
|
||||
// .appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_MODE+Blockly.Msg.LISTS_SET_INDEX_INPUT_TO)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_Digital_PINMODEOUT, "machine.Pin.OUT"],
|
||||
[Blockly.Msg.MIXLY_Digital_PINMODEIN, "machine.Pin.IN"],
|
||||
[Blockly.Msg.MIXLY_PINMODEPULLUP, "machine.Pin.IN, machine.Pin.PULL_UP"],
|
||||
[Blockly.Msg.MIXLY_PINMODEPULLDOWN, "machine.Pin.IN, machine.Pin.PULL_DOWN"]
|
||||
]), "MODE")
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_DIGITAL_INIT_TOOLTIP);
|
||||
},
|
||||
getVars: function () {
|
||||
return [this.getFieldValue('PIN_OBJ') == 'pin#' ? null : this.getFieldValue('PIN_OBJ')];
|
||||
},
|
||||
renameVar: function (oldName, newName) {
|
||||
if (Blockly.Names.equals(oldName, this.getFieldValue('PIN_OBJ'))) {
|
||||
this.setTitleValue(newName, 'PIN_OBJ');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_pwm_analog_write_init = {
|
||||
init: function () {
|
||||
this.setColour(BASE_HUE);
|
||||
// this.appendValueInput("PIN", Number)
|
||||
// .appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
// .appendField("PWM"+Blockly.Msg.MIXLY_Analog_PINMODEOUT)
|
||||
// .appendField('pwm')
|
||||
// .setCheck(Number);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
.appendField(new Blockly.FieldTextInput('pwm#'), 'PIN_OBJ')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_AS)
|
||||
this.appendDummyInput("")
|
||||
.appendField("PWM" + Blockly.Msg.MIXLY_Analog_PINMODEOUT)
|
||||
// .appendField('pwm')
|
||||
// .appendField(new Blockly.FieldDropdown(profile.default.pwm_pin),"PIN")
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_PWM_ANALOG_WRITE_INIT_TOOLTIP);
|
||||
},
|
||||
getVars: function () {
|
||||
return [this.getFieldValue('PIN_OBJ') == 'pwm#' ? null : this.getFieldValue('PIN_OBJ')];
|
||||
},
|
||||
renameVar: function (oldName, newName) {
|
||||
if (Blockly.Names.equals(oldName, this.getFieldValue('PIN_OBJ'))) {
|
||||
this.setTitleValue(newName, 'PIN_OBJ');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_analog_write_init = {
|
||||
init: function () {
|
||||
this.setColour(BASE_HUE);
|
||||
// this.appendValueInput("PIN", Number)
|
||||
// .appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
// .appendField("PWM"+Blockly.Msg.MIXLY_Analog_PINMODEOUT)
|
||||
// .appendField('pwm')
|
||||
// .setCheck(Number);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
.appendField(new Blockly.FieldTextInput('dac#'), 'PIN_OBJ')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_AS)
|
||||
this.appendDummyInput("")
|
||||
.appendField("DAC" + Blockly.Msg.MIXLY_Analog_PINMODEOUT)
|
||||
// .appendField('dac')
|
||||
// .appendField(new Blockly.FieldDropdown(profile.default.dac_pin),"PIN")
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_ANALOG_WRITE_INIT_TOOLTIP);
|
||||
},
|
||||
getVars: function () {
|
||||
return [this.getFieldValue('PIN_OBJ') == 'dac#' ? null : this.getFieldValue('PIN_OBJ')];
|
||||
},
|
||||
renameVar: function (oldName, newName) {
|
||||
if (Blockly.Names.equals(oldName, this.getFieldValue('PIN_OBJ'))) {
|
||||
this.setTitleValue(newName, 'PIN_OBJ');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_analog_read_init = {
|
||||
init: function () {
|
||||
this.setColour(BASE_HUE);
|
||||
// this.appendValueInput("PIN", Number)
|
||||
// .appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
// .appendField("PWM"+Blockly.Msg.MIXLY_Analog_PINMODEOUT)
|
||||
// .appendField('pwm')
|
||||
// .setCheck(Number);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
.appendField(new Blockly.FieldTextInput('adc#'), 'PIN_OBJ')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_AS)
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_Analog_PINMODEIN)
|
||||
// .appendField('adc')
|
||||
// .appendField(new Blockly.FieldDropdown(profile.default.adc_pin),"PIN")
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_ANALOG_READ_INIT_TOOLTIP);
|
||||
},
|
||||
getVars: function () {
|
||||
return [this.getFieldValue('PIN_OBJ') == 'adc#' ? null : this.getFieldValue('PIN_OBJ')];
|
||||
},
|
||||
renameVar: function (oldName, newName) {
|
||||
if (Blockly.Names.equals(oldName, this.getFieldValue('PIN_OBJ'))) {
|
||||
this.setTitleValue(newName, 'PIN_OBJ');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_pin_pressed_init = {
|
||||
init: function () {
|
||||
this.setColour(BASE_HUE);
|
||||
// this.appendValueInput("PIN", Number)
|
||||
// .appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
// .appendField("PWM"+Blockly.Msg.MIXLY_Analog_PINMODEOUT)
|
||||
// .appendField('pwm')
|
||||
// .setCheck(Number);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
.appendField(new Blockly.FieldTextInput('tc#'), 'PIN_OBJ')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_AS)
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_TOUCH_SENSOR)
|
||||
// .appendField('tc')
|
||||
// .appendField(new Blockly.FieldDropdown(profile.default.tc_pin),"PIN")
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_INOUT_PIN_PRESSED_INIT_TOOLTIP);
|
||||
},
|
||||
getVars: function () {
|
||||
return [this.getFieldValue('PIN_OBJ') == 'tc#' ? null : this.getFieldValue('PIN_OBJ')];
|
||||
},
|
||||
renameVar: function (oldName, newName) {
|
||||
if (Blockly.Names.equals(oldName, this.getFieldValue('PIN_OBJ'))) {
|
||||
this.setTitleValue(newName, 'PIN_OBJ');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_pinMode = inout_digital_init;
|
||||
export const inout_analog_write_set_freq = inout_pwm_analog_write_set_freq;
|
||||
export const pin_pressed_init = inout_pin_pressed_init;
|
||||
export const pin_pressed = inout_pin_pressed;
|
||||
export const controls_pin_attachInterrupt = inout_pin_attachInterrupt;
|
||||
624
boards/default_src/micropython/blocks/iot.js
Normal file
624
boards/default_src/micropython/blocks/iot.js
Normal file
@@ -0,0 +1,624 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
import * as Mixly from 'mixly';
|
||||
|
||||
const IOT_HUE = '#526FC3';
|
||||
//'#2FAD7A';
|
||||
|
||||
export const iot_wifi_connect = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_IOT_CONNECT_WIFI);
|
||||
this.appendValueInput('WIFINAME')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.HTML_NAME);
|
||||
this.appendValueInput('PASSWORD')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.HTML_PASSWORD);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_IOT_WIFI_CONNECT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_onenet_connect = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
.appendField("OneNET" + Blockly.Msg.TUPLE_JOIN);
|
||||
this.appendValueInput('CLIENT')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_ONENET_CLIENT);
|
||||
this.appendValueInput('SERVER')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_ONENET_SERVER);
|
||||
this.appendValueInput('USERNAME')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_ONENET_USERNAME);
|
||||
this.appendValueInput('PASSWORD')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_ONENET_PASSWORD);
|
||||
this.appendValueInput('TOPIC')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_ONENET_TOPIC);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_ONENET_SUB);
|
||||
//this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_IOT_ONENET_CONNECT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_onenet_disconnect = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
.appendField("OneNET")
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_DISCONNECT_ONENET);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_IOT_ONENET_DISCONNECT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_onenet_check = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
.appendField("OneNET")
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_CHECK_ONENET);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_IOT_ONENET_CHECK_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_onenet_publish_dict = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
.appendField("OneNET")
|
||||
this.appendValueInput('DICT')
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_PUBLISH_ONENET);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_IOT_ONENET_PRINT_DATA)
|
||||
.appendField(new Blockly.FieldCheckbox('TRUE'), 'is_print');
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_IOT_ONENET_PUBLISH_DICT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_onenet_publish = {
|
||||
/**
|
||||
* Block for creating a list with any number of elements of any type.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
.appendField("OneNET")
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldLabel(Blockly.Msg.MIXLY_ESP32_PUBLISH_ONENET), 'TIP')
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
this.itemCount_ = 2;
|
||||
this.updateShape_();
|
||||
this.setInputsInline(false);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setMutator(new Blockly.icons.MutatorIcon(['iot_publish_item'], this));
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_IOT_ONENET_PUBLISH_TOOLTIP);
|
||||
},
|
||||
/**
|
||||
* Create XML to represent list inputs.
|
||||
* @return {Element} XML storage element.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
mutationToDom: function () {
|
||||
var container = document.createElement('mutation');
|
||||
container.setAttribute('items', this.itemCount_);
|
||||
return container;
|
||||
},
|
||||
/**
|
||||
* Parse XML to restore the list inputs.
|
||||
* @param {!Element} xmlElement XML storage element.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
domToMutation: function (xmlElement) {
|
||||
this.itemCount_ = parseInt(xmlElement.getAttribute('items'), 10);
|
||||
this.updateShape_();
|
||||
},
|
||||
/**
|
||||
* Populate the mutator's dialog with this block's components.
|
||||
* @param {!Blockly.Workspace} workspace Mutator's workspace.
|
||||
* @return {!Blockly.Block} Root block in mutator.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
decompose: function (workspace) {
|
||||
var containerBlock =
|
||||
workspace.newBlock('iot_publish_container');
|
||||
containerBlock.initSvg();
|
||||
var connection = containerBlock.getInput('STACK').connection;
|
||||
for (var i = 0; i < this.itemCount_; i++) {
|
||||
var itemBlock = workspace.newBlock('iot_create_with_item');
|
||||
itemBlock.initSvg();
|
||||
connection.connect(itemBlock.previousConnection);
|
||||
connection = itemBlock.nextConnection;
|
||||
}
|
||||
return containerBlock;
|
||||
},
|
||||
/**
|
||||
* Reconfigure this block based on the mutator dialog's components.
|
||||
* @param {!Blockly.Block} containerBlock Root block in mutator.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
compose: function (containerBlock) {
|
||||
var itemBlock = containerBlock.getInputTargetBlock('STACK');
|
||||
// Count number of inputs.
|
||||
var connections = [];
|
||||
let i = 0;
|
||||
while (itemBlock) {
|
||||
connections[i] = itemBlock.valueConnection_;
|
||||
itemBlock = itemBlock.nextConnection &&
|
||||
itemBlock.nextConnection.targetBlock();
|
||||
i++;
|
||||
}
|
||||
this.itemCount_ = i;
|
||||
this.updateShape_();
|
||||
// Reconnect any child blocks.
|
||||
for (let i = 0; i < this.itemCount_; i++) {
|
||||
if (connections[i]) {
|
||||
this.getInput('ADD' + i).connection.connect(connections[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Store pointers to any connected child blocks.
|
||||
* @param {!Blockly.Block} containerBlock Root block in mutator.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
saveConnections: function (containerBlock) {
|
||||
var itemBlock = containerBlock.getInputTargetBlock('STACK');
|
||||
var i = 0;
|
||||
while (itemBlock) {
|
||||
var input = this.getInput('ADD' + i);
|
||||
itemBlock.valueConnection_ = input && input.connection.targetConnection;
|
||||
i++;
|
||||
itemBlock = itemBlock.nextConnection &&
|
||||
itemBlock.nextConnection.targetBlock();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Modify this block to have the correct number of inputs.
|
||||
* @private
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
updateShape_: function () {
|
||||
// Delete everything.
|
||||
if (this.getInput('EMPTY')) {
|
||||
this.removeInput('EMPTY');
|
||||
}
|
||||
var keyNames = [];
|
||||
for (let i = 0; this.getInput('ADD' + i); i++) {
|
||||
//this.getInput('VALUE' + i).removeField("KEY"+i);
|
||||
keyNames.push(this.getFieldValue("KEY" + i))
|
||||
this.removeInput('ADD' + i);
|
||||
}
|
||||
// Rebuild block.
|
||||
if (this.itemCount_ == 0) {
|
||||
//this.getField('TIP')
|
||||
//.setText(Blockly.Msg.MIXLY_ESP32_PUBLISH_ONENET_EMPTY);
|
||||
this.setFieldValue(Blockly.Msg.MIXLY_ESP32_PUBLISH_ONENET_EMPTY, 'TIP');
|
||||
} else {
|
||||
//this.getField('TIP')
|
||||
//.setText(Blockly.Msg.MIXLY_ESP32_PUBLISH_ONENET);
|
||||
this.setFieldValue(Blockly.Msg.MIXLY_ESP32_PUBLISH_ONENET, 'TIP');
|
||||
for (let i = 0; i < this.itemCount_; i++) {
|
||||
this.appendValueInput('ADD' + i)
|
||||
.setCheck(null)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(
|
||||
new Blockly.FieldTextInput(
|
||||
keyNames.length > i
|
||||
? keyNames[i]
|
||||
: '"key' + (i + 1) + '"'),
|
||||
'KEY' + i)
|
||||
.appendField(":")
|
||||
}
|
||||
}
|
||||
}, getVars: function () {
|
||||
return [this.getFieldValue('VAR')];
|
||||
},
|
||||
renameVar: function (oldName, newName) {
|
||||
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
|
||||
this.setTitleValue(newName, 'VAR');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_publish_container = {
|
||||
/**
|
||||
* Mutator block for list container.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_TYPE_DICT);
|
||||
this.appendStatementInput('STACK');
|
||||
this.setTooltip(Blockly.Msg.DICTS_CREATE_WITH_CONTAINER_TOOLTIP);
|
||||
this.contextMenu = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const iot_publish_item = {
|
||||
/**
|
||||
* Mutator bolck for adding items.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.DICTS_CREATE_WITH_ITEM_TITLE);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.DICTS_CREATE_WITH_ITEM_TOOLTIP);
|
||||
this.contextMenu = false;
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_create_with_item = {
|
||||
/**
|
||||
* Mutator bolck for adding items.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.DICTS_CREATE_WITH_ITEM_TITLE);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.DICTS_CREATE_WITH_ITEM_TOOLTIP);
|
||||
this.contextMenu = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const iot_mixio_connect = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_CREATE_MQTT_CLIENT_AND_CONNECT);
|
||||
this.appendValueInput('SERVER')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.MIXLY_EMQX_SERVER)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
this.appendValueInput('USERNAME')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.MIXLY_WIFI_USERNAME)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
this.appendValueInput('PASSWORD')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.MIXLY_IOT_PASSWORD)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
this.appendValueInput('PROJECT')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.MIXLY_EMQX_PROJECT)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const IOT_MIXIO_PUBLISH = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("MixIO")
|
||||
this.appendValueInput('TOPIC')
|
||||
.appendField(Blockly.Msg.MIXLY_EMQX_PUBLISH_NEW)
|
||||
.appendField(Blockly.Msg.MIXLY_EMQX_PUBLISH_TOPIC);
|
||||
this.appendValueInput('MSG')
|
||||
.appendField(Blockly.Msg.HTML_BODY);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_IOT_EMQX_PUBLISH_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const IOT_MIXIO_SUBSCRIBE = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("MixIO")
|
||||
this.appendValueInput('TOPIC')
|
||||
.appendField(Blockly.Msg.MIXLY_EMQX_SUBSCRIBE + Blockly.Msg.MIXLY_MICROBIT_MSG)
|
||||
.appendField(Blockly.Msg.MIXLY_EMQX_PUBLISH_TOPIC);
|
||||
this.appendValueInput('METHOD')
|
||||
.appendField(Blockly.Msg.MIXLY_EMQX_SET_METHOD);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_IOT_EMQX_SUBSCRIBE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_mixio_disconnect = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("MixIO")
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_DISCONNECT_ONENET);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
// this.setTooltip(Blockly.Msg.MIXLY_ESP32_IOT_ONENET_DISCONNECT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_mixio_connect_only = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("MixIO")
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_EMQX_CONNECT);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
// this.setTooltip(Blockly.Msg.MIXLY_ESP32_IOT_ONENET_DISCONNECT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_mixio_check = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("MixIO")
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_CHECK_ONENET);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
// this.setTooltip(Blockly.Msg.MIXLY_ESP32_IOT_ONENET_CHECK_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_mixio_format_topic = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_FORMAT)
|
||||
.appendField(Blockly.Msg.MQTT_Topic);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_mixio_format_msg = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_FORMAT)
|
||||
.appendField(Blockly.Msg.MIXLY_EMQX_PUBLISH_MSG);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const IOT_FORMATTING = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_IOT_MAP_FORMATING);
|
||||
this.setOutput(true);
|
||||
// this.setTooltip();
|
||||
}
|
||||
};
|
||||
|
||||
export const IOT_FORMAT_STRING = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_FORMAT + '(Json)');
|
||||
this.setOutput(true);
|
||||
// this.setTooltip();
|
||||
}
|
||||
};
|
||||
|
||||
export const IOT_EMQX_PING = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
// this.appendValueInput('VAR')
|
||||
// .setCheck("var")
|
||||
this.appendDummyInput()
|
||||
.appendField("MixIO")
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_EMQX_PING);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_IOT_EMQX_PING_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const IOT_MIXIO_NTP = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
// this.appendValueInput('VAR')
|
||||
// .setCheck("var")
|
||||
this.appendDummyInput()
|
||||
.appendField("MixIO")
|
||||
.appendField(Blockly.Msg.MIXLY_GET_NTP)
|
||||
this.appendValueInput('addr')
|
||||
.appendField(Blockly.Msg.blynk_SERVER_ADD);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const IOT_EMQX_INIT_AND_CONNECT_BY_SHARE_CODE = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_CREATE_MQTT_CLIENT_AND_CONNECT);
|
||||
this.appendValueInput('SERVER')
|
||||
.appendField(Blockly.Msg.MIXLY_EMQX_SERVER)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput('KEY')
|
||||
.appendField(Blockly.Msg.CONTROLS_FOR_INPUT_WITH + Blockly.Msg.MIXLY_MIXIO_SHARE_KEY)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const IOT_EMQX_INIT_AND_CONNECT_BY_MIXLY_CODE = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_CREATE_MQTT_CLIENT_AND_CONNECT);
|
||||
this.appendValueInput('SERVER')
|
||||
.appendField(Blockly.Msg.MIXLY_EMQX_SERVER)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput('KEY')
|
||||
.appendField(Blockly.Msg.CONTROLS_FOR_INPUT_WITH + "Mixly Key")
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const iot_mixly_key = {
|
||||
init: function () {
|
||||
this.VISITOR_ID = Mixly.Config.BOARD.visitorId.str32.substring(0, 8).toUpperCase();
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldTextInput(this.visitorId), 'VISITOR_ID');
|
||||
this.setOutput(true, null);
|
||||
},
|
||||
onchange: function () {
|
||||
const nowVisitorId = this.getFieldValue('VISITOR_ID');
|
||||
if (this.VISITOR_ID !== nowVisitorId)
|
||||
this.setFieldValue(this.VISITOR_ID, 'VISITOR_ID');
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_client_onboard = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField('MixIO')
|
||||
.appendField(Blockly.Msg.MSG.catEthernet_clinet);
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_http_client = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
// this.appendValueInput('VAR')
|
||||
// .setCheck("var")
|
||||
this.appendDummyInput()
|
||||
.appendField("HTTP" + Blockly.Msg.MIXLY_Client)
|
||||
this.appendValueInput('addr')
|
||||
.appendField(Blockly.Msg.DISPLAY_IMAGE_LET2);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_REQUESTS_GET)
|
||||
.appendField(Blockly.Msg.MIXLY_GET_CURRENT_TIME)
|
||||
.appendField(Blockly.Msg.MIXLY_OPEN_DEBUG)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_TURTLE_WRITE_MOVE_TRUE, "True"],
|
||||
[Blockly.Msg.MIXLY_TURTLE_WRITE_MOVE_FALSE, "False"]
|
||||
]), "key");
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_http_data = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("HTTP" + Blockly.Msg.MIXLY_Client)
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_REQUESTS_LEN, "client_len"],
|
||||
[Blockly.Msg.MIXLY_REQUESTS_GET_LEN, "server_len"],
|
||||
[Blockly.Msg.MIXLY_REQUESTS_MESSAGE, "text"]
|
||||
]), "key");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_mqtt_client = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
// this.appendValueInput('VAR')
|
||||
// .setCheck("var")
|
||||
this.appendDummyInput()
|
||||
.appendField("MQTT" + Blockly.Msg.MIXLY_Client)
|
||||
this.appendValueInput('addr')
|
||||
.appendField(Blockly.Msg.MIXLY_CONNECTTO);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_INIT_SUBSCRIBE)
|
||||
.appendField(Blockly.Msg.MQTT_Topic)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_GET_CURRENT_TIME, ""],
|
||||
]), "key")
|
||||
.appendField(Blockly.Msg.MIXLY_OPEN_DEBUG)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_TURTLE_WRITE_MOVE_TRUE, "True"],
|
||||
[Blockly.Msg.MIXLY_TURTLE_WRITE_MOVE_FALSE, "False"]
|
||||
]), "key2");
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_mqtt_data = {
|
||||
init: function () {
|
||||
this.setColour(IOT_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("MQTT" + Blockly.Msg.MIXLY_Client)
|
||||
.appendField(Blockly.Msg.MIXLY_GET)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_REQUESTS_LEN, "client_len"],
|
||||
[Blockly.Msg.MIXLY_REQUESTS_GET_LEN, "server_len"],
|
||||
[Blockly.Msg.MIXLY_REQUESTS_MESSAGE, "time_msg()"]
|
||||
]), "key");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
export const iot_wificonnect = iot_wifi_connect;
|
||||
export const iot_onenetconnect = iot_onenet_connect;
|
||||
export const iot_onenetdisconnect = iot_onenet_disconnect;
|
||||
export const iot_checkonenet = iot_onenet_check;
|
||||
export const iot_publish = iot_onenet_publish;
|
||||
516
boards/default_src/micropython/blocks/network.js
Normal file
516
boards/default_src/micropython/blocks/network.js
Normal file
@@ -0,0 +1,516 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
const NETWORK_HUE = 225;
|
||||
|
||||
export const network_init = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var");
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_NETWORK_INIT)
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_NETWORK_MODE)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
['STA', "STA"],
|
||||
['AP', "AP"]
|
||||
]), "mode");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_INIT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const network_open = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_NETWORK_WIFI_OPEN, "True"],
|
||||
[Blockly.Msg.MIXLY_NETWORK_WIFI_CLOSE, "False"]
|
||||
]), "op");
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_NETWORK_WIFI_FLAG)
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('op');
|
||||
var mode0 = Blockly.Msg.MIXLY_ESP32_NETWORK_OPEN_TOOLTIP;
|
||||
var TOOLTIPS = {
|
||||
'True': Blockly.Msg.MIXLY_NETWORK_WIFI_OPEN,
|
||||
'False': Blockly.Msg.MIXLY_NETWORK_WIFI_CLOSE,
|
||||
};
|
||||
return TOOLTIPS[mode] + mode0
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const network_is_active = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_NETWORK_WIFI_IS_ACTIVE)
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_NETWORK_WIFI_IS_ACTIVE);
|
||||
}
|
||||
};
|
||||
|
||||
export const network_scan = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_NETWORK_WIFI_SCAN)
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(function () {
|
||||
var mode = 'all';
|
||||
var mode0 = Blockly.Msg.MIXLY_ESP32_NETWORK_SCAN_TOOLTIP
|
||||
var TOOLTIPS = {
|
||||
'0': "ssid",
|
||||
'1': 'bssid',
|
||||
'2': "channel",
|
||||
'3': "RSSI",
|
||||
'4': "authmode",
|
||||
'5': "hidden",
|
||||
'all': Blockly.Msg.MIXLY_NETWORK_WIFI_SCAN_ATTRIBUTE,
|
||||
};
|
||||
return mode0 + TOOLTIPS[mode]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const network_connect = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_NETWORK_CONNECT);
|
||||
this.appendValueInput('id')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.HTML_NAME);
|
||||
this.appendValueInput('password')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.HTML_PASSWORD);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_CONNECT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const network_wifi_connect = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_NETWORK_WIFI_CONNECT);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_SYMBOL_QUESTION);
|
||||
this.setOutput(true, Boolean);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_WIFI_CONNECT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const network_get_connect = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_NETWORK_GET_WIFI);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_ESP32_NETWORK_IP, "0"],
|
||||
[Blockly.Msg.MIXLY_ESP32_NETWORK_MASK, "1"],
|
||||
[Blockly.Msg.MIXLY_ESP32_NETWORK_GATEWAY, "2"],
|
||||
["DNS", "3"]
|
||||
]), "mode");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('mode');
|
||||
var mode0 = Blockly.Msg.MIXLY_ESP32_NETWORK_GET_WIFI_TOOLTIP
|
||||
var TOOLTIPS = {
|
||||
'0': Blockly.Msg.MIXLY_ESP32_NETWORK_IP,
|
||||
'1': Blockly.Msg.MIXLY_ESP32_NETWORK_MASK,
|
||||
'2': Blockly.Msg.MIXLY_ESP32_NETWORK_GATEWAY,
|
||||
'3': "DNS",
|
||||
};
|
||||
return mode0 + TOOLTIPS[mode]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const network_stop = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_NETWORK_STOP_CONNECT);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_STOP_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const network_get_wifi = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_NETWORK_GET_WIFI);
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_NETWORK_WIFI_ESSID, "essid"],
|
||||
[Blockly.Msg.MIXLY_NETWORK_WIFI_CHANNEL, "channel"]
|
||||
]), "op");
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_GET_WIFI_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const network_ap_connect = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.LISTS_SET_INDEX_SET);
|
||||
this.appendValueInput('essid')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.MIXLY_NETWORK_WIFI_ESSID);
|
||||
this.appendValueInput('channel')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_NETWORK_WIFI_CHANNEL);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_AP_CONNECT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const network_server = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_NETWORK_SERVER1);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_NETWORK_SERVER2);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_SOCKET_CLOSE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const network_socket_init = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_INIT)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_TYPE)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
['TCP', "TCP"],
|
||||
['UDP', "UDP"]
|
||||
]), "mode");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('mode');
|
||||
var mode0 = Blockly.Msg.MIXLY_ESP32_NETWORK_SOCKET_INIT_TOOLTIP
|
||||
var TOOLTIPS = {
|
||||
'TCP': 'TCP',
|
||||
'UDP': 'UDP',
|
||||
};
|
||||
return mode0 + TOOLTIPS[mode]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const network_socket_bind = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_LET_SOCKET)
|
||||
this.appendValueInput('address')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_BIND_TO_ADDRESS);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_SOCKET_BIND_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const network_socket_connect = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_LET_SOCKET)
|
||||
this.appendValueInput('address')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_CONNECT_TO_ADDRESS);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_SOCKET_CONNECT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const network_socket_listen = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
this.appendValueInput('queue')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_LISTEN)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_QUEUE);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_SOCKET_LISTEN_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const network_socket_accept = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_ACCEPT);
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_SOCKET_ACCEPT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const network_socket_receive = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
.appendField("TCP")
|
||||
this.appendValueInput('size')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_RECEIVE)
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_SOCKET_RECEIVE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const network_socket_send = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
// .appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE)
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
.appendField("TCP")
|
||||
this.appendValueInput('content')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_SEND)
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_SOCKET_SEND_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const network_socket_receive_from = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
.appendField("UDP")
|
||||
this.appendValueInput('size')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_RECEIVE)
|
||||
this.setOutput(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_SOCKET_RECEIVE_FROM_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const network_socket_send_to = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
// .appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE)
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
.appendField("UDP")
|
||||
this.appendValueInput('content')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_SEND)
|
||||
this.appendValueInput('address')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_TO);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_SOCKET_SEND_TO_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const network_socket_close = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck("var")
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_CLOSE);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_NETWORK_SOCKET_CLOSE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const requests_get = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendValueInput("DOMAIN")
|
||||
.appendField(Blockly.Msg.DISPLAY_IMAGE_LET2)
|
||||
.setCheck(String);
|
||||
this.appendDummyInput("")
|
||||
|
||||
.appendField(Blockly.Msg.blockpy_REQUESTS_GET)
|
||||
.appendField(new Blockly.FieldTextInput('response'), 'VAR')
|
||||
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.blockpy_REQUESTS_GET_TOOLTIP);
|
||||
},
|
||||
getVars: function () {
|
||||
return [this.getFieldValue('VAR')];
|
||||
},
|
||||
renameVar: function (oldName, newName) {
|
||||
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
|
||||
this.setTitleValue(newName, 'VAR');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export const requests_attribute = {
|
||||
init: function () {
|
||||
this.appendValueInput('VAL')
|
||||
|
||||
var attr =
|
||||
[[Blockly.Msg.blockpy_REQUESTS_GET_ATTR_STATUS_CODE, 'status_code'], [Blockly.Msg.blockpy_REQUESTS_GET_ATTR_TEXT, 'text']
|
||||
, [Blockly.Msg.blockpy_REQUESTS_GET_ATTR_COOKIES, 'cookies'], [Blockly.Msg.blockpy_REQUESTS_GET_ATTR_CONTENT, 'content']];
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_GET)
|
||||
.appendField(new Blockly.FieldDropdown(attr), 'ATTR')
|
||||
|
||||
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true, String);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('DIR');
|
||||
var TOOLTIPS = {
|
||||
'clear': Blockly.Msg.MIXLY_TOOLTIP_TURTEL_CLEAR,
|
||||
'reset': Blockly.Msg.MIXLY_TOOLTIP_TURTEL_RESET,
|
||||
'home': Blockly.Msg.MIXLY_TOOLTIP_TURTEL_HOME
|
||||
};
|
||||
return TOOLTIPS[mode];
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
export const requests_method = {
|
||||
init: function () {
|
||||
this.appendValueInput("VAR")
|
||||
.appendField(Blockly.Msg.DISPLAY_IMAGE_LET2)
|
||||
.setCheck(String);
|
||||
var method = [
|
||||
['post', 'post'], ['put', 'put'],
|
||||
['delete', 'delete'], ['head', 'head'],
|
||||
['option', 'option']
|
||||
];
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.blockpy_CONDUCT)
|
||||
.appendField(new Blockly.FieldDropdown(method), 'DIR')
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.blockpy_REQUESTS)
|
||||
|
||||
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('DIR');
|
||||
var TOOLTIPS = {
|
||||
'forward': Blockly.Msg.MIXLY_TOOLTIP_TURTEL_FORWARD,
|
||||
'backward': Blockly.Msg.MIXLY_TOOLTIP_TURTEL_BACKWARD
|
||||
};
|
||||
return TOOLTIPS[mode];
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const ntptime_time = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_GET_NTP + '(NTP)')
|
||||
this.appendValueInput("data")
|
||||
.appendField(Blockly.Msg.blynk_SERVER_ADD)
|
||||
this.setOutput(true, 'Tuple');
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const ntptime_address = {
|
||||
init: function () {
|
||||
this.setColour(NETWORK_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
['ntp.aliyun.com', "ntp.aliyun.com"],
|
||||
['ntp1.aliyun.com', "ntp1.aliyun.com"],
|
||||
['ntp2.aliyun.com', "ntp2.aliyun.com"],
|
||||
['ntp3.aliyun.com', "ntp3.aliyun.com"],
|
||||
['ntp4.aliyun.com', "ntp4.aliyun.com"],
|
||||
['ntp5.aliyun.com', "ntp5.aliyun.com"],
|
||||
['ntp6.aliyun.com', "ntp6.aliyun.com"],
|
||||
['ntp7.aliyun.com', "ntp7.aliyun.com"],
|
||||
['time1.cloud.tencent.com', "time1.cloud.tencent.com"],
|
||||
['time2.cloud.tencent.com', "time2.cloud.tencent.com"],
|
||||
['time3.cloud.tencent.com', "time3.cloud.tencent.com"],
|
||||
['time4.cloud.tencent.com', "time4.cloud.tencent.com"],
|
||||
['time5.cloud.tencent.com', "time5.cloud.tencent.com"]
|
||||
]), 'op')
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
84
boards/default_src/micropython/blocks/nova_g1.js
Normal file
84
boards/default_src/micropython/blocks/nova_g1.js
Normal file
@@ -0,0 +1,84 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
import * as Mixly from 'mixly';
|
||||
|
||||
const NOVAG1_HUE = 100;
|
||||
|
||||
export const get_potential_num = {
|
||||
init: function () {
|
||||
var version = Mixly.Boards.getSelectedBoardKey().split(':')[2]
|
||||
if (version == "mixgo_nova") { var name = 'Nova G1' }
|
||||
this.setColour(NOVAG1_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(name)
|
||||
.appendField(Blockly.Msg.MIXLY_MIXGO_NOVA_POTENTIAL_NUM);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const nova_g1_motor = {
|
||||
init: function () {
|
||||
var version = Mixly.Boards.getSelectedBoardKey().split(':')[2]
|
||||
if (version == "mixgo_nova") { var name = 'Nova G1' }
|
||||
this.setColour(NOVAG1_HUE);
|
||||
this.appendValueInput('PIN')
|
||||
.appendField(name)
|
||||
.appendField(Blockly.Msg.MOTOR_DC)
|
||||
.appendField(Blockly.Msg.LCD_NUMBERING)
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_Direction)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.CLOCKWISE, "CW"],
|
||||
[Blockly.Msg.ANTI_CLOCKWISE, "CCW"],
|
||||
[Blockly.Msg.MOTOR_P, "P"],
|
||||
[Blockly.Msg.MOTOR_N, "N"]
|
||||
]), "direction");
|
||||
this.appendValueInput('speed')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_STEPPER_SET_SPEED);
|
||||
this.appendDummyInput("")
|
||||
.appendField("%")
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const nova_g1_usb = {
|
||||
init: function () {
|
||||
var version = Mixly.Boards.getSelectedBoardKey().split(':')[2]
|
||||
if (version == "mixgo_nova") { var name = 'Nova G1' }
|
||||
this.setColour(NOVAG1_HUE);
|
||||
this.appendValueInput('PIN')
|
||||
.appendField(name)
|
||||
.appendField(Blockly.Msg.SET_USB);
|
||||
this.appendValueInput('percent')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_POWER_SUPPLY);
|
||||
this.appendDummyInput("")
|
||||
.appendField("%")
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const nova_g1_spk_en = {
|
||||
init: function () {
|
||||
var version = Mixly.Boards.getSelectedBoardKey().split(':')[2]
|
||||
if (version == "mixgo_nova") { var name = 'Nova G1' }
|
||||
this.setColour(NOVAG1_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(name)
|
||||
.appendField(Blockly.Msg.MIXLY_SPK_STATE)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_ON, "True"],
|
||||
[Blockly.Msg.MIXLY_OFF, "False"]
|
||||
]), "state");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
182
boards/default_src/micropython/blocks/pe_g1.js
Normal file
182
boards/default_src/micropython/blocks/pe_g1.js
Normal file
@@ -0,0 +1,182 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
import * as Mixly from 'mixly';
|
||||
|
||||
const PEG1_HUE = 100;
|
||||
|
||||
export const pe_g1_use_i2c_init = {
|
||||
init: function () {
|
||||
var version = Mixly.Boards.getSelectedBoardKey().split(':')[2]
|
||||
if (version == "mixgo_ce") { var name = 'CE G6' }
|
||||
else if (version == "mixgo_pe") { var name = 'PE G1' }
|
||||
this.setColour(PEG1_HUE);
|
||||
this.appendValueInput('I2CSUB')
|
||||
.appendField(Blockly.Msg.CONTROLS_FOR_INPUT_WITH + "I2C")
|
||||
.setCheck("var");
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP + Blockly.Msg.LISTS_SET_INDEX_INPUT_TO)
|
||||
.appendField(name);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
}
|
||||
};
|
||||
|
||||
export const pe_g1_battery_left = {
|
||||
init: function () {
|
||||
var version = Mixly.Boards.getSelectedBoardKey().split(':')[2]
|
||||
if (version == "mixgo_ce") { var name = 'CE G6' }
|
||||
else if (version == "mixgo_pe") { var name = 'PE G1' }
|
||||
this.setColour(PEG1_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(name)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MIXGO_CAR_BATTERY_LEFT);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const pe_g1_dc_motor = {
|
||||
init: function () {
|
||||
var version = Mixly.Boards.getSelectedBoardKey().split(':')[2]
|
||||
if (version == "mixgo_ce") { var name = 'CE G6' }
|
||||
else if (version == "mixgo_pe") { var name = 'PE G1' }
|
||||
this.setColour(PEG1_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(name)
|
||||
.setCheck("var");
|
||||
this.appendValueInput('PIN')
|
||||
.appendField(Blockly.Msg.MOTOR_DC)
|
||||
.appendField(Blockly.Msg.LCD_NUMBERING)
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_Direction)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.CLOCKWISE, "CW"],
|
||||
[Blockly.Msg.ANTI_CLOCKWISE, "CCW"],
|
||||
[Blockly.Msg.MOTOR_P, "P"],
|
||||
[Blockly.Msg.MOTOR_N, "N"]
|
||||
]), "direction");
|
||||
this.appendValueInput('speed')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_STEPPER_SET_SPEED);
|
||||
this.appendDummyInput("")
|
||||
.appendField("%")
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const pe_g1_dc_motor_speed = {
|
||||
init: function () {
|
||||
var version = Mixly.Boards.getSelectedBoardKey().split(':')[2]
|
||||
if (version == "mixgo_ce") { var name = 'CE G6' }
|
||||
else if (version == "mixgo_pe") { var name = 'PE G1' }
|
||||
this.setColour(PEG1_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(name)
|
||||
.setCheck("var");
|
||||
this.appendValueInput('PIN')
|
||||
.appendField(Blockly.Msg.MOTOR_DC)
|
||||
.appendField(Blockly.Msg.LCD_NUMBERING)
|
||||
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_STEPPER_GET_SPEED);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
}
|
||||
|
||||
export const pe_g1_servo_set_angle = {
|
||||
init: function () {
|
||||
var version = Mixly.Boards.getSelectedBoardKey().split(':')[2]
|
||||
if (version == "mixgo_ce") { var name = 'CE G6' }
|
||||
else if (version == "mixgo_pe") { var name = 'PE G1' }
|
||||
this.setColour(PEG1_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(name)
|
||||
.setCheck("var");
|
||||
this.appendValueInput('PIN')
|
||||
.appendField('180°' + Blockly.Msg.MIXLY_SERVO)
|
||||
.appendField(Blockly.Msg.LCD_NUMBERING)
|
||||
|
||||
this.appendValueInput("NUM", Number)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_SERVO_MOVE);
|
||||
}
|
||||
};
|
||||
|
||||
export const pe_g1_servo_set_speed = {
|
||||
init: function () {
|
||||
var version = Mixly.Boards.getSelectedBoardKey().split(':')[2]
|
||||
if (version == "mixgo_ce") { var name = 'CE G6' }
|
||||
else if (version == "mixgo_pe") { var name = 'PE G1' }
|
||||
this.setColour(PEG1_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(name)
|
||||
.setCheck("var");
|
||||
this.appendValueInput('PIN')
|
||||
.appendField('360°' + Blockly.Msg.MIXLY_SERVO)
|
||||
.appendField(Blockly.Msg.LCD_NUMBERING)
|
||||
|
||||
this.appendValueInput("NUM", Number)
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_SPEED);
|
||||
this.appendDummyInput()
|
||||
.appendField('%');
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_SERVO_SPEED_TOOLIPS);
|
||||
}
|
||||
};
|
||||
|
||||
export const pe_g1_servo_get_angle = {
|
||||
init: function () {
|
||||
var version = Mixly.Boards.getSelectedBoardKey().split(':')[2]
|
||||
if (version == "mixgo_ce") { var name = 'CE G6' }
|
||||
else if (version == "mixgo_pe") { var name = 'PE G1' }
|
||||
this.setColour(PEG1_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(name)
|
||||
.setCheck("var");
|
||||
this.appendValueInput('PIN')
|
||||
.appendField('180°' + Blockly.Msg.MIXLY_SERVO)
|
||||
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET + Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const pe_g1_servo_get_speed = {
|
||||
init: function () {
|
||||
var version = Mixly.Boards.getSelectedBoardKey().split(':')[2]
|
||||
if (version == "mixgo_ce") { var name = 'CE G6' }
|
||||
else if (version == "mixgo_pe") { var name = 'PE G1' }
|
||||
this.setColour(PEG1_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(name)
|
||||
.setCheck("var");
|
||||
this.appendValueInput('PIN')
|
||||
.appendField('360°' + Blockly.Msg.MIXLY_SERVO)
|
||||
.appendField(Blockly.Msg.LCD_NUMBERING)
|
||||
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET + Blockly.Msg.MIXLY_SPEED);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
338
boards/default_src/micropython/blocks/pins.js
Normal file
338
boards/default_src/micropython/blocks/pins.js
Normal file
@@ -0,0 +1,338 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
import { Profile } from 'mixly';
|
||||
|
||||
const PINS_HUE = 230;
|
||||
|
||||
export const pins_digital = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.digital), 'PIN');
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_digital_pin = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.digital_pin), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_input_pin = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.input_pin), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_output_pin = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.output_pin), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pwm_input = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.pwm_input), 'PIN');
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const analog_input = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.analog_input), 'PIN');
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const pwm_output = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.pwm_output), 'PIN');
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const analog_output = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.analog_output), 'PIN');
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const espnow_channel = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.espnow_channel), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const i2c_A_pin = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.i2c_A_pin), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const i2c_B_pin = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.i2c_B_pin), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const spi_A_pin = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.spi_A_pin), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const spi_B_pin = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.spi_B_pin), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const spi_C_pin = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.spi_C_pin), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const spi_D_pin = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.spi_D_pin), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_analog = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.analog), 'PIN');
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_analog_pin = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.analog_pin), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_dac = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.dac), 'PIN');
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_dac_pin = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.dac_pin), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_button = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.button), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_pwm = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.pwm), 'PIN');
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_pwm_pin = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.pwm_pin), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_touch_pin = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.touch_pin), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_touch = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.touch), 'PIN');
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_serial = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.serial_pin), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_builtinimg = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.builtinimg), 'PIN');
|
||||
this.setOutput(true, "esp32_image");
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_imglist = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.imglist), 'PIN');
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_playlist = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.playlist), 'PIN');
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_exlcdh = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.exlcdh), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_exlcdv = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.exlcdv), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_axis = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.axis), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
export const pins_brightness = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.brightness), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_tone_notes = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.tone_notes), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_radio_power = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.radio_power), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_radio_datarate = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.radio_datarate), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_one_more = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.one_more), 'PIN');
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_digital_dot = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(Profile.default.digital_dot), 'PIN');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
870
boards/default_src/micropython/blocks/sensor.js
Normal file
870
boards/default_src/micropython/blocks/sensor.js
Normal file
@@ -0,0 +1,870 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
import { sensor_LTR308 } from './sensor_onboard';
|
||||
|
||||
const SENSOR_HUE = 40; //'#9e77c9'//40;
|
||||
|
||||
export const sensor_mixgo_button_is_pressed = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('btn')
|
||||
.appendField(Blockly.Msg.MIXLY_BUTTON)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_IS_PRESSED);
|
||||
this.setOutput(true, Boolean);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_SENOR_IS_PRESSED);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mixgo_button_was_pressed = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('btn')
|
||||
.appendField(Blockly.Msg.MIXLY_BUTTON)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_WAS_PRESSED);
|
||||
this.setOutput(true, Boolean);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_SENOR_WAS_PRESSED);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mixgo_button_get_presses = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('btn')
|
||||
.appendField(Blockly.Msg.MIXLY_BUTTON)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET_PRESSES);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_GET_PRESSES_TIME);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + Blockly.Msg.MIXLY_BUTTON + Blockly.Msg.MIXLY_GET_PRESSES);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mixgo_button_attachInterrupt = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput("btn")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_INTERRUPT)
|
||||
.appendField(Blockly.Msg.MIXLY_BUTTON)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_MODE)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_RISING, "machine.Pin.IRQ_RISING"], [Blockly.Msg.MIXLY_FALLING, "machine.Pin.IRQ_FALLING"], [Blockly.Msg.MIXLY_CHANGE, "(machine.Pin.IRQ_RISING or machine.Pin.IRQ_FALLING)"]]), "mode");
|
||||
this.appendValueInput('DO')
|
||||
.appendField(Blockly.Msg.MIXLY_DO)
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_INOUT_ATTACHINTERRUPT);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const sensor_mixgo_extern_button_is_pressed = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_BUTTON)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_IS_PRESSED);
|
||||
this.appendValueInput("STAT")
|
||||
.appendField(Blockly.Msg.MIXLY_ELECLEVEL);
|
||||
this.setOutput(true, Boolean);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_SENOR_IS_PRESSED);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mixgo_extern_button_was_pressed = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_BUTTON)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_WAS_PRESSED);
|
||||
this.appendValueInput("STAT")
|
||||
.appendField(Blockly.Msg.MIXLY_ELECLEVEL);
|
||||
this.setOutput(true, Boolean);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_SENOR_WAS_PRESSED);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mixgo_extern_button_get_presses = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_BUTTON)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GET_PRESSES);
|
||||
this.appendValueInput('VAR')
|
||||
.setCheck(Number)
|
||||
.appendField(Blockly.Msg.MIXLY_GET_PRESSES_TIME);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + Blockly.Msg.MIXLY_BUTTON + Blockly.Msg.MIXLY_GET_PRESSES);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mixgo_extern_button_attachInterrupt = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_BUTTON)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_MODE)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_RISING, "machine.Pin.IRQ_RISING"], [Blockly.Msg.MIXLY_FALLING, "machine.Pin.IRQ_FALLING"], [Blockly.Msg.MIXLY_CHANGE, "(machine.Pin.IRQ_RISING or machine.Pin.IRQ_FALLING)"]]), "mode");
|
||||
this.appendValueInput('DO')
|
||||
.appendField(Blockly.Msg.MIXLY_DO)
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_INOUT_ATTACHINTERRUPT);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mpu9250_attachGestureInterrupt = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("MPU9250")
|
||||
.setCheck("var");
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_CURRENT_GESTURE)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_MICROBIT_shake, "shake"], [Blockly.Msg.MIXLY_UP, "up"], [Blockly.Msg.MIXLY_DOWN, "down"], [Blockly.Msg.MIXLY_LEFT, "left"], [Blockly.Msg.MIXLY_RIGHT, "right"], [Blockly.Msg.MIXLY_MICROBIT_face_up, "face up"], [Blockly.Msg.MIXLY_MICROBIT_face_down, "face down"], [Blockly.Msg.MIXLY_MICROBIT_freefall, "freefall"], ["3g", "3g"], ["6g", "6g"], ["8g", "8g"]]), "gesture");
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.Msg.MIXLY_DO);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('gesture');
|
||||
var mode0 = Blockly.Msg.MIXLY_MICROBIT_JS_CURRENT;
|
||||
var mode1 = Blockly.Msg.MSG.catSensor;
|
||||
var mode2 = Blockly.Msg.MIXLY_MICROBIT_JS_STATE;
|
||||
var mode3 = Blockly.Msg.MIXLY_MICROBIT_PERFORMANCE
|
||||
var TOOLTIPS = {
|
||||
'shake': Blockly.Msg.MIXLY_MICROBIT_shake,
|
||||
'up': Blockly.Msg.MIXLY_UP,
|
||||
'down': Blockly.Msg.MIXLY_DOWN,
|
||||
'left': Blockly.Msg.MIXLY_LEFT,
|
||||
'right': Blockly.Msg.MIXLY_RIGHT,
|
||||
'face up': Blockly.Msg.MIXLY_MICROBIT_face_up,
|
||||
'face down': Blockly.Msg.MIXLY_MICROBIT_face_down,
|
||||
'freefall': Blockly.Msg.MIXLY_MICROBIT_freefall,
|
||||
'3g': '3g',
|
||||
'6g': '6g',
|
||||
'8g': '8g'
|
||||
};
|
||||
return mode0 + mode1 + mode2 + TOOLTIPS[mode] + mode3;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mpu9250_gesture = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("MPU9250")
|
||||
.setCheck("var");
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_CURRENT_GESTURE)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_MICROBIT_shake, "shake"], [Blockly.Msg.MIXLY_UP, "up"], [Blockly.Msg.MIXLY_DOWN, "down"], [Blockly.Msg.MIXLY_LEFT, "left"], [Blockly.Msg.MIXLY_RIGHT, "right"], [Blockly.Msg.MIXLY_MICROBIT_face_up, "face up"], [Blockly.Msg.MIXLY_MICROBIT_face_down, "face down"]]), "gesture");
|
||||
this.setOutput(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('gesture');
|
||||
var mode0 = Blockly.Msg.MIXLY_MICROBIT_JS_CURRENT;
|
||||
var mode1 = Blockly.Msg.MSG.catSensor;
|
||||
var mode2 = Blockly.Msg.MIXLY_MICROBIT_JS_STATE;
|
||||
var mode3 = Blockly.Msg.MIXLY_MICROBIT_PERFORMANCE
|
||||
var TOOLTIPS = {
|
||||
'shake': Blockly.Msg.MIXLY_MICROBIT_shake,
|
||||
'up': Blockly.Msg.MIXLY_UP,
|
||||
'down': Blockly.Msg.MIXLY_DOWN,
|
||||
'left': Blockly.Msg.MIXLY_LEFT,
|
||||
'right': Blockly.Msg.MIXLY_RIGHT,
|
||||
'face up': Blockly.Msg.MIXLY_MICROBIT_face_up,
|
||||
'face down': Blockly.Msg.MIXLY_MICROBIT_face_down,
|
||||
// 'freefall':Blockly.Msg.MIXLY_MICROBIT_freefall,
|
||||
// '3g': '3g',
|
||||
// '6g': '6g',
|
||||
// '8g': '8g'
|
||||
};
|
||||
return mode0 + mode1 + mode2 + TOOLTIPS[mode] + mode3;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mpu9250_get_acceleration = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("MPU9250")
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_ACCELERATION)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["x", "x"],
|
||||
["y", "y"],
|
||||
["z", "z"],
|
||||
["(x,y,z)", "values"]
|
||||
]), "key");
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_JS_ACCELERATION);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('key');
|
||||
var mode0 = Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET;
|
||||
var mode1 = Blockly.Msg.MIXLY_MICROBIT_Direction;
|
||||
var mode2 = Blockly.Msg.MIXLY_MICROBIT_JS_ACCELERATION1;
|
||||
var TOOLTIPS = {
|
||||
'x': 'x',
|
||||
'y': 'y',
|
||||
'z': 'z',
|
||||
'(x,y,z)': Blockly.Msg.MIXLY_MICROBIT_Shiliang_Direction,
|
||||
};
|
||||
return mode0 + TOOLTIPS[mode] + mode1 + mode2;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const sensor_adxl345_get_acceleration = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(Blockly.Msg.MIXLY_ADXL345)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_ACCELERATION)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["x", "x"],
|
||||
["y", "y"],
|
||||
["z", "z"],
|
||||
["(x,y,z)", "values"]
|
||||
]), "key");
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_JS_ACCELERATION);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('key');
|
||||
var mode0 = Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET;
|
||||
var mode1 = Blockly.Msg.MIXLY_MICROBIT_Direction;
|
||||
var mode2 = Blockly.Msg.MIXLY_MICROBIT_JS_ACCELERATION1;
|
||||
var TOOLTIPS = {
|
||||
'x': 'x',
|
||||
'y': 'y',
|
||||
'z': 'z',
|
||||
'(x,y,z)': Blockly.Msg.MIXLY_MICROBIT_Shiliang_Direction,
|
||||
};
|
||||
return mode0 + TOOLTIPS[mode] + mode1 + mode2;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const sensor_light_level = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_LIGHT_LEVEL)
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_SENSOR_LIGHT_LEVEL_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mpu9250_calibrate_compass = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("MPU9250")
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_CALIBRATE_COMPASS)
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_JS_CALIBRATE_COMPASS);
|
||||
}
|
||||
};
|
||||
// export const sensor_mpu9250_is_compass_calibrated = {
|
||||
// init: function(){
|
||||
// this.setColour(SENSOR_HUE);
|
||||
// this.appendValueInput('SUB')
|
||||
// .setCheck("var");
|
||||
// this.appendDummyInput()
|
||||
// .appendField(Blockly.Msg.MIXLY_MICROBIT_JS_IS_COMPASS_CALIBRATED)
|
||||
// this.setOutput(true, Number);
|
||||
// this.setInputsInline(true);
|
||||
// this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_JS_IS_COMPASS_CALIBRATED1);
|
||||
// }
|
||||
// };
|
||||
// export const sensor_mpu9250_compass_heading = {
|
||||
// init: function(){
|
||||
// this.setColour(SENSOR_HUE);
|
||||
// this.appendValueInput('SUB')
|
||||
// .setCheck("var");
|
||||
// this.appendDummyInput()
|
||||
// .appendField(Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE)
|
||||
// this.setOutput(true, Number);
|
||||
// this.setInputsInline(true);
|
||||
// }
|
||||
// };
|
||||
|
||||
export const sensor_mpu9250_temperature = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("MPU9250")
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_GETTEMPERATUE)
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
|
||||
this.setTooltip(Blockly.Msg.MIXLY_GETTEMPERATUE);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mpu9250_field_strength = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("MPU9250")
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_GET_COMPASS)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_MICROBIT_JS_FIELD_STRENGTH, 'strength'], [Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE, 'heading']]), 'compass');
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('compass');
|
||||
var mode0 = Blockly.Msg.MIXLY_MICROBIT_JS_GET_COMPASS;
|
||||
var TOOLTIPS = {
|
||||
'strength': Blockly.Msg.MIXLY_MICROBIT_JS_FIELD_STRENGTH,
|
||||
'heading': Blockly.Msg.MIXLY_MICROBIT_JS_BY_ANGLE
|
||||
};
|
||||
return mode0 + TOOLTIPS[mode];
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_distance_hrsc04 = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_CHAOSHENGBO)
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_CHAOSHENGBO);
|
||||
}
|
||||
};
|
||||
|
||||
//传感器-实时时钟块_获取时间
|
||||
export const RTC_get_time = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("RTC")
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RTCGETTIME);
|
||||
// this.appendDummyInput("").setAlign(Blockly.inputs.Align.RIGHT).appendField('myRTC');
|
||||
// this.appendDummyInput("").setAlign(Blockly.inputs.Align.RIGHT).appendField(new Blockly.FieldDropdown(RTC_TIME_TYPE), "TIME_TYPE");
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true, Number);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_RTC_GET_TIME_TOOLTIP);
|
||||
// var thisBlock = this;
|
||||
// this.setTooltip(function() {
|
||||
// var mode = thisBlock.getFieldValue('TIME_TYPE');
|
||||
// var mode0 = Blockly.Msg.MIXLY_RTCGETTIME;
|
||||
// var TOOLTIPS = {
|
||||
// 'Year':Blockly.Msg.MIXLY_YEAR,
|
||||
// 'Month':Blockly.Msg.MIXLY_MONTH,
|
||||
// 'Day':Blockly.Msg.MIXLY_DAY,
|
||||
// 'Hour':Blockly.Msg.MIXLY_HOUR,
|
||||
// 'Minute':Blockly.Msg.MIXLY_MINUTE,
|
||||
// 'Second':Blockly.Msg.MIXLY_SECOND,
|
||||
// 'Week':Blockly.Msg.MIXLY_WEEK,
|
||||
// 'Mix1':Blockly.Msg.MIXLY_MIX1,
|
||||
// 'Mix2':Blockly.Msg.MIXLY_MIX2
|
||||
// };
|
||||
// return mode0 +TOOLTIPS[mode];
|
||||
// });
|
||||
}
|
||||
};
|
||||
|
||||
export const RTC_set_time = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendDummyInput("")
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RTCSETTIME)
|
||||
.appendField('myRTC');
|
||||
this.appendValueInput("hour")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(" " + Blockly.Msg.MIXLY_HOUR);
|
||||
this.appendValueInput("minute")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(" " + Blockly.Msg.MIXLY_MINUTE);
|
||||
this.appendValueInput("second")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(" " + Blockly.Msg.MIXLY_SECOND);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(false);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_RTCSETTIME + Blockly.Msg.MIXLY_MIX2);
|
||||
}
|
||||
};
|
||||
|
||||
export const RTC_set_date = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendDummyInput("")
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_RTCSETDATE)
|
||||
.appendField('myRTC');
|
||||
this.appendValueInput("year")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(" " + Blockly.Msg.MIXLY_YEAR);
|
||||
this.appendValueInput("month")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(" " + Blockly.Msg.MIXLY_MONTH);
|
||||
this.appendValueInput("day")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(" " + Blockly.Msg.MIXLY_DAY);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_RTCSETDATE + Blockly.Msg.MIXLY_MIX1);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_compass_reset = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("MPU9250")
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_Reset_COMPASS)
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_Reset_COMPASS);
|
||||
}
|
||||
};
|
||||
|
||||
export const HCSR04 = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_CHAOSHENGBO);
|
||||
this.appendValueInput("PIN1", Number)
|
||||
.appendField('Trig #')
|
||||
.setCheck(Number);
|
||||
this.appendValueInput("PIN2", Number)
|
||||
.appendField('Echo #')
|
||||
.setCheck(Number);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true, Number);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_CHAOSHENGBO);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export const sensor_dht11 = {
|
||||
init: function () {
|
||||
var WHAT = [[Blockly.Msg.MIXLY_GETTEMPERATUE, 'temperature'], [Blockly.Msg.MIXLY_GETHUMIDITY, 'relative_humidity'], [Blockly.Msg.MIXLY_DHT11_T_H, 'tempandhum']];
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(new Blockly.FieldDropdown([['DHT11', 'dht11']
|
||||
, ['DHT22', 'dht22']//, ['DHT21', '21'], ['DHT33', '33'], ['DHT44', '44']
|
||||
]), 'TYPE')
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown(WHAT), "WHAT");
|
||||
this.setOutput(true, Number);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var op = thisBlock.getFieldValue('WHAT');
|
||||
var TOOLTIPS = {
|
||||
'temperature': Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_GET_TEM,
|
||||
'relative_humidity': Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_GET_HUM,
|
||||
'tempandhum': Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_GET_TEM_HUM
|
||||
};
|
||||
return TOOLTIPS[op];
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const sensor_mixgo_extern_light = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_EXTERN_LIGHT);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_EXTERN_VALUE);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.ESP32_SENSOR_NIXGO_LIGHT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mixgo_extern_sound = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_EXTERN_SOUND);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_EXTERN_VALUE);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.ESP32_SENSOR_NIXGO_SOUND_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const number1 = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([["1", "touch1"], ["2", "touch2"]]), 'op')
|
||||
this.setOutput(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_INOUT_HIGHLOW);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mixgo_pin_pressed = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput("button")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_TOUCH_SENSOR)
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_IS_TOUCHED);
|
||||
this.setOutput(true, Boolean);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_sensor_pin_pressed);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mixgo_extern_pin_near = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_EXTERN_NEAR);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_EXTERN_VALUE);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_SENSOR_MIXGO_PIN_NEAR_TOOLTIP + Blockly.Msg.MIXLY_ESP32_NEAR);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const sensor_mixgo_pin_near = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.TEXT_TRIM_LEFT, "left"], [Blockly.Msg.TEXT_TRIM_RIGHT, "right"]]), "direction")
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_NEAR);
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('direction');
|
||||
var mode0 = Blockly.Msg.MIXLY_ESP32_SENSOR_MIXGO_PIN_NEAR_TOOLTIP;
|
||||
var mode1 = Blockly.Msg.MIXLY_ESP32_NEAR;
|
||||
var TOOLTIPS = {
|
||||
'left': Blockly.Msg.TEXT_TRIM_LEFT,
|
||||
'right': Blockly.Msg.TEXT_TRIM_RIGHT,
|
||||
};
|
||||
return mode0 + TOOLTIPS[mode] + mode1
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const RTC_set_datetime = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
// this.appendDummyInput()
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("RTC")
|
||||
.appendField(Blockly.Msg.MIXLY_RTC_TIME)
|
||||
.setCheck("var");
|
||||
this.appendValueInput('year')
|
||||
.setCheck(Number)
|
||||
.appendField(" " + Blockly.Msg.MIXLY_YEAR);
|
||||
this.appendValueInput('month')
|
||||
.setCheck(Number)
|
||||
.appendField(" " + Blockly.Msg.MIXLY_MONTH);
|
||||
this.appendValueInput('day')
|
||||
.setCheck(Number)
|
||||
.appendField(" " + Blockly.Msg.MIXLY_DAY);
|
||||
this.appendValueInput('weekday')
|
||||
.setCheck(Number)
|
||||
.appendField(" " +
|
||||
Blockly.Msg.MIXLY_WEEK2);
|
||||
this.appendValueInput('hour')
|
||||
.setCheck(Number)
|
||||
.appendField(" " + Blockly.Msg.MIXLY_HOUR);
|
||||
this.appendValueInput('minute')
|
||||
.setCheck(Number)
|
||||
.appendField(" " + Blockly.Msg.MIXLY_MINUTE);
|
||||
this.appendValueInput('second')
|
||||
.setCheck(Number)
|
||||
.appendField(" " + Blockly.Msg.MIXLY_SECOND);
|
||||
this.appendValueInput('millisecond')
|
||||
.setCheck(Number)
|
||||
.appendField(" " + Blockly.Msg.MIXLY_MILLISECOND);
|
||||
this.setInputsInline(false);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_RTC_SET_DATATIME_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_rtc_init = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField("RTC")
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
.setCheck("var");
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_SENSOR_RTC_INT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_use_i2c_init = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('I2CSUB')
|
||||
.appendField(Blockly.Msg.CONTROLS_FOR_INPUT_WITH + "I2C")
|
||||
.setCheck("var");
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE)
|
||||
.setCheck("var");
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP + Blockly.Msg.LISTS_SET_INDEX_INPUT_TO)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["MPU9250", "MPU9250"],
|
||||
["BMP280", "BMP280"],
|
||||
["SHT20", "SHT20"],
|
||||
["ADXL345", "ADXL345"]
|
||||
]), "key");
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setFieldValue("MPU9250", "key");
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('key');
|
||||
var mode0 = Blockly.Msg.MIXLY_ESP32_SENSOR_USE_I2C_TOOLTIP;
|
||||
var TOOLTIPS = {
|
||||
"MPU9250": "MPU9250",
|
||||
"SHT20": "SHT20",
|
||||
"BMP280": "BMP280",
|
||||
"ADXL345": "ADXL345"
|
||||
};
|
||||
return mode0 + TOOLTIPS[mode]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_bmp = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("BMP280")
|
||||
.setCheck("var");
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_GETTEMPERATUE, "get_BMP_temperature()"],
|
||||
[Blockly.Msg.MIXLY_GETPRESSURE, "get_BMP_pressure()"]
|
||||
]), "key");
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('key');
|
||||
var TOOLTIPS = {
|
||||
"get_BMP_temperature()": Blockly.Msg.MIXLY_MICROBIT_SENSOR_BMP_temperature_TOOLTIP,
|
||||
"get_BMP_pressure()": Blockly.Msg.MIXLY_MICROBIT_SENSOR_BMP_press_TOOLTIP,
|
||||
};
|
||||
return TOOLTIPS[mode]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_sht = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("SHT20")
|
||||
.setCheck("var");
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_GETTEMPERATUE, "get_SHT_temperature()"],
|
||||
[Blockly.Msg.MIXLY_GETHUMIDITY, "get_SHT_relative_humidity()"]
|
||||
]), "key");
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('key');
|
||||
var TOOLTIPS = {
|
||||
"get_SHT_temperature()": Blockly.Msg.MIXLY_MICROBIT_SENSOR_SHT_temperature_TOOLTIP,
|
||||
"get_SHT_relative_humidity()": Blockly.Msg.MIXLY_MICROBIT_SENSOR_SHT_HUM_TOOLTIP,
|
||||
};
|
||||
return TOOLTIPS[mode]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_ds18x20 = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField("DS18x20 " + Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_GETTEMPERATUE);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true, Number);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_SENSOR_DS18X20_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mpu9250_get_magnetic = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("MPU9250")
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_GET + Blockly.Msg.MIXLY_MICROBIT_JS_FIELD_STRENGTH)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["x", "x"],
|
||||
["y", "y"],
|
||||
["z", "z"],
|
||||
["(x,y,z)", "values"]
|
||||
]), "key");
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('key');
|
||||
var mode0 = Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET;
|
||||
var mode1 = Blockly.Msg.MIXLY_MICROBIT_Direction;
|
||||
var mode2 = Blockly.Msg.MIXLY_MICROBIT_JS_FIELD_STRENGTH;
|
||||
var TOOLTIPS = {
|
||||
'x': 'x',
|
||||
'y': 'y',
|
||||
'z': 'z',
|
||||
'(x,y,z)': Blockly.Msg.MIXLY_MICROBIT_Shiliang_Direction,
|
||||
};
|
||||
return mode0 + TOOLTIPS[mode] + mode1 + mode2;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_mpu9250_get_gyro = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendValueInput('SUB')
|
||||
.appendField("MPU9250")
|
||||
.setCheck("var");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET + Blockly.Msg.MIXLY_ESP32_SENOR_GYRO)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["x", "x"],
|
||||
["y", "y"],
|
||||
["z", "z"],
|
||||
["(x,y,z)", "values"]
|
||||
]), "key");
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
var mode = thisBlock.getFieldValue('key');
|
||||
var mode0 = Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET;
|
||||
var mode1 = Blockly.Msg.MIXLY_MICROBIT_Direction;
|
||||
var mode2 = Blockly.Msg.MIXLY_ESP32_SENOR_GYRO;
|
||||
var TOOLTIPS = {
|
||||
'x': 'x',
|
||||
'y': 'y',
|
||||
'z': 'z',
|
||||
'(x,y,z)': Blockly.Msg.MIXLY_MICROBIT_Shiliang_Direction,
|
||||
};
|
||||
return mode0 + TOOLTIPS[mode] + mode1 + mode2;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_lm35 = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField("LM35" + Blockly.Msg.MIXLY_TEMP);
|
||||
this.appendValueInput("PIN", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_PIN)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_GETTEMPERATUE);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true, Number);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_LM35);
|
||||
}
|
||||
};
|
||||
|
||||
export const sensor_button_is_pressed = sensor_mixgo_button_is_pressed;
|
||||
export const sensor_button_was_pressed = sensor_mixgo_button_was_pressed;
|
||||
export const sensor_button_get_presses = sensor_mixgo_button_get_presses;
|
||||
export const sensor_pin_pressed = sensor_mixgo_pin_pressed;
|
||||
export const sensor_pin_near = sensor_mixgo_pin_near;
|
||||
export const sensor_mixgo_light = sensor_LTR308;
|
||||
export const sensor_light = sensor_mixgo_light;
|
||||
export const sensor_get_acceleration = sensor_mpu9250_get_acceleration;
|
||||
export const dht11 = sensor_dht11;
|
||||
export const sensor_field_strength = sensor_mpu9250_field_strength;
|
||||
export const sensor_temperature = sensor_mpu9250_temperature
|
||||
1733
boards/default_src/micropython/blocks/sensor_extern.js
Normal file
1733
boards/default_src/micropython/blocks/sensor_extern.js
Normal file
File diff suppressed because it is too large
Load Diff
1367
boards/default_src/micropython/blocks/sensor_onboard.js
Normal file
1367
boards/default_src/micropython/blocks/sensor_onboard.js
Normal file
File diff suppressed because it is too large
Load Diff
383
boards/default_src/micropython/blocks/serial.js
Normal file
383
boards/default_src/micropython/blocks/serial.js
Normal file
@@ -0,0 +1,383 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
const SERIAL_HUE = 65; //'#58a8de'//65;
|
||||
|
||||
export const serial_print_byte = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendValueInput("CONTENT", String)
|
||||
.appendField("Serial")
|
||||
.appendField(new Blockly.FieldDropdown([['uart1', '1'], ['uart2', '2']]), 'mode')
|
||||
.appendField(Blockly.Msg.MIXLY_SERIAL_WRITE + '(' + Blockly.Msg.LANG_MATH_BYTE + ')');
|
||||
//this.setFieldValue('1','mode')
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.TEXT_PRINT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const serial_print = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendValueInput("CONTENT", String)
|
||||
.appendField("Serial")
|
||||
.appendField(new Blockly.FieldDropdown([['uart1', '1'], ['uart2', '2']]), 'mode')
|
||||
.appendField(Blockly.Msg.MIXLY_SERIAL_PRINT);
|
||||
//this.setFieldValue('1','mode')
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.TEXT_PRINT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const serial_println = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendValueInput("CONTENT", String)
|
||||
.appendField("Serial")
|
||||
.appendField(new Blockly.FieldDropdown([['uart1', '1'], ['uart2', '2']]), 'mode')
|
||||
.appendField(Blockly.Msg.MIXLY_SERIAL_PRINTLN);
|
||||
//this.setFieldValue('1','mode')
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.TEXT_PRINT_Huanhang_TOOLTIP + Blockly.Msg.TEXT_PRINT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
//打印16进制数
|
||||
export const serial_print_hex = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("Serial")
|
||||
.appendField(new Blockly.FieldDropdown([['uart1', '1'], ['uart2', '2']]), 'mode')
|
||||
.appendField(Blockly.Msg.MIXLY_SERIAL_PRINTLN);
|
||||
this.appendValueInput("CONTENT", Number)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MATH_BIN, "bin"], [Blockly.Msg.MATH_OCT, "oct"], [Blockly.Msg.MATH_DEC, "int"], [Blockly.Msg.MATH_HEX, "hex"]]), "STAT")
|
||||
.setCheck(Number);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setFieldValue('hex', 'STAT')
|
||||
this.setTooltip(Blockly.Msg.TEXT_PRINT_HEX_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const serial_receive_data_event = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendValueInput('char_marker')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_SERIAL_WHEN_CONTAIN_DATA)
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.Msg.MIXLY_DO);
|
||||
}
|
||||
};
|
||||
|
||||
export const serial_readstr = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("Serial")
|
||||
.appendField(new Blockly.FieldDropdown([['uart1', '1'], ['uart2', '2']]), 'mode')
|
||||
.appendField(Blockly.Msg.MIXLY_SERIAL_READSTR);
|
||||
//this.setFieldValue('1','mode')
|
||||
this.setOutput(true, String);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_SERIAL_READ_STR);
|
||||
}
|
||||
};
|
||||
|
||||
export const serial_any = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("Serial")
|
||||
.appendField(new Blockly.FieldDropdown([['uart1', '1'], ['uart2', '2']]), 'mode')
|
||||
.appendField(Blockly.Msg.MIXLY_SERIAL_AVAILABLE);
|
||||
//this.setFieldValue('1','mode')
|
||||
this.setOutput(true, Boolean);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_SERIAL_AVAILABLE1);
|
||||
}
|
||||
};
|
||||
|
||||
export const serial_readline = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("Serial")
|
||||
.appendField(new Blockly.FieldDropdown([['uart1', '1'], ['uart2', '2']]), 'mode')
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_READ_LINE);
|
||||
//this.setFieldValue('1','mode')
|
||||
this.setOutput(true, String);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_JS_SERIAL_READ_LINE1);
|
||||
}
|
||||
};
|
||||
|
||||
export const serial_readstr_until = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("Serial " + Blockly.Msg.MIXLY_SERIAL_READSTR_UNTIL)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["new line", "serial.delimiters(Delimiters.NewLine)"],
|
||||
[",", "serial.delimiters(Delimiters.Comma)"],
|
||||
["$", "serial.delimiters(Delimiters.Dollar)"],
|
||||
[":", "serial.delimiters(Delimiters.Colon)"],
|
||||
[".", "serial.delimiters(Delimiters.Fullstop)"],
|
||||
["#", "serial.delimiters(Delimiters.Hash)"]
|
||||
]), "char_marker");
|
||||
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true, String);
|
||||
}
|
||||
};
|
||||
|
||||
export const serial_softserial_new = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendValueInput("RX")
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
.appendField(new Blockly.FieldDropdown([['uart1', '1'], ['uart2', '2']]), 'mode')
|
||||
.appendField("RX#")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendValueInput("TX")
|
||||
.appendField("TX#")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SERIAL_BEGIN)
|
||||
.appendField(new Blockly.FieldDropdown([['115200', '115200'], ['57600', '57600'], ['37400', '38400'], ['31250', '31250'], ['28800', '28800'], ['19200', '19200'], ['14400', '14400'], ['9600', '9600'], ['4800', '4800'], ['2400', '2400'], ['1200', '1200'], ['300', '300']]), 'baudrate');
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_SERIAL_softserial);
|
||||
}
|
||||
};
|
||||
|
||||
export const serial_softserial = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
.appendField(new Blockly.FieldDropdown([['uart1 (RX=23,TX=19)', '1'], ['uart2 (RX=5,TX=18)', '2']]), 'mode');
|
||||
//this.setFieldValue('1','mode')
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SERIAL_BEGIN)
|
||||
.appendField(new Blockly.FieldDropdown([['115200', '115200'], ['57600', '57600'], ['37400', '38400'], ['31250', '31250'], ['28800', '28800'], ['19200', '19200'], ['14400', '14400'], ['9600', '9600'], ['4800', '4800'], ['2400', '2400'], ['1200', '1200'], ['300', '300']]), 'baudrate');
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_SERIAL_softserial);
|
||||
}
|
||||
};
|
||||
|
||||
export const serial_begin = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("Serial " + Blockly.Msg.MIXLY_SERIAL_BEGIN)
|
||||
.appendField(new Blockly.FieldDropdown([['115200', '115200'], ['57600', '57600'], ['37400', '38400'], ['31250', '31250'], ['28800', '28800'], ['19200', '19200'], ['14400', '14400'], ['9600', '9600'], ['4800', '4800'], ['2400', '2400'], ['1200', '1200'], ['300', '300']]), 'baudrate');
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.LISTS_SET_INDEX_SET + Blockly.Msg.MIXLY_SERIAL_BEGIN);
|
||||
}
|
||||
};
|
||||
|
||||
export const system_input = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendValueInput("VAR")
|
||||
.appendField(Blockly.Msg.blockpy_inout_raw_input)
|
||||
.setCheck(String);
|
||||
this.setOutput(true);
|
||||
this.setTooltip(Blockly.Msg.INOUT_input_TOOLTIP);
|
||||
}
|
||||
}
|
||||
|
||||
export const system_print = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendValueInput("VAR")
|
||||
.appendField(Blockly.Msg.MIXLY_SERIAL_PRINTLN);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.BLOCKPY_PRINT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const system_print_inline = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendValueInput("VAR")
|
||||
.appendField(Blockly.Msg.MIXLY_SERIAL_PRINT);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.TEXT_PRINT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const system_print_end = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendValueInput("VAR")
|
||||
.appendField(Blockly.Msg.MIXLY_SERIAL_PRINT);
|
||||
this.appendValueInput("END")
|
||||
.appendField(Blockly.Msg.MIXLY_ENDSWITH);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_PYTHON_INOUT_PRINT_END_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const system_print_many = {
|
||||
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
|
||||
this.itemCount_ = 2;
|
||||
this.updateShape_();
|
||||
this.setPreviousStatement(false);
|
||||
this.setNextStatement(false);
|
||||
this.setInputsInline(true);
|
||||
this.setMutator(new Blockly.icons.MutatorIcon(['system_print_item'], this));
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MIXPY_INOUT_PRINT_MANY_TOOLTIP);
|
||||
},
|
||||
|
||||
mutationToDom: function () {
|
||||
var container = document.createElement('mutation');
|
||||
container.setAttribute('items', this.itemCount_);
|
||||
return container;
|
||||
},
|
||||
|
||||
domToMutation: function (xmlElement) {
|
||||
this.itemCount_ = parseInt(xmlElement.getAttribute('items'), 10);
|
||||
this.updateShape_();
|
||||
},
|
||||
|
||||
decompose: function (workspace) {
|
||||
var containerBlock =
|
||||
workspace.newBlock('system_print_container');
|
||||
containerBlock.initSvg();
|
||||
var connection = containerBlock.getInput('STACK').connection;
|
||||
for (var i = 0; i < this.itemCount_; i++) {
|
||||
var itemBlock = workspace.newBlock('system_print_item');
|
||||
itemBlock.initSvg();
|
||||
connection.connect(itemBlock.previousConnection);
|
||||
connection = itemBlock.nextConnection;
|
||||
}
|
||||
return containerBlock;
|
||||
},
|
||||
|
||||
compose: function (containerBlock) {
|
||||
var itemBlock = containerBlock.getInputTargetBlock('STACK');
|
||||
// Count number of inputs.
|
||||
var connections = [];
|
||||
var i = 0;
|
||||
while (itemBlock) {
|
||||
connections[i] = itemBlock.valueConnection_;
|
||||
itemBlock = itemBlock.nextConnection &&
|
||||
itemBlock.nextConnection.targetBlock();
|
||||
i++;
|
||||
}
|
||||
this.itemCount_ = i;
|
||||
this.updateShape_();
|
||||
// Reconnect any child blocks.
|
||||
for (var i = 0; i < this.itemCount_; i++) {
|
||||
if (connections[i]) {
|
||||
this.getInput('ADD' + i)
|
||||
.connection.connect(connections[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
saveConnections: function (containerBlock) {
|
||||
var itemBlock = containerBlock.getInputTargetBlock('STACK');
|
||||
var i = 0;
|
||||
while (itemBlock) {
|
||||
var input = this.getInput('ADD' + i);
|
||||
itemBlock.valueConnection_ = input && input.connection.targetConnection;
|
||||
i++;
|
||||
itemBlock = itemBlock.nextConnection &&
|
||||
itemBlock.nextConnection.targetBlock();
|
||||
}
|
||||
},
|
||||
|
||||
updateShape_: function () {
|
||||
// Delete everything.
|
||||
if (this.getInput('EMPTY')) {
|
||||
this.removeInput('EMPTY');
|
||||
} else {
|
||||
var i = 0;
|
||||
while (this.getInput('ADD' + i)) {
|
||||
this.removeInput('ADD' + i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// Rebuild block.
|
||||
if (this.itemCount_ == 0) {
|
||||
this.appendDummyInput('EMPTY')
|
||||
.appendField(Blockly.Msg.MIXLY_MIXPY_INOUT_PRINT_EMPTY);
|
||||
} else {
|
||||
for (var i = 0; i < this.itemCount_; i++) {
|
||||
var input = this.appendValueInput('ADD' + i);
|
||||
if (i == 0) {
|
||||
input.appendField(Blockly.Msg.MIXLY_SERIAL_PRINTLN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
export const system_print_container = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SERIAL_PRINTLN);
|
||||
this.appendStatementInput('STACK');
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MIXPY_INOUT_PRINT_MANY_CONTAINER_TOOLTIP);
|
||||
this.contextMenu = false;
|
||||
}
|
||||
};
|
||||
|
||||
export const system_print_item = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TITLE);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MIXPY_INOUT_PRINT_MANY_ITEM_TOOLTIP);
|
||||
this.contextMenu = false;
|
||||
}
|
||||
};
|
||||
|
||||
export const serial_send_to_ai = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendValueInput("CONTENT")
|
||||
.appendField("Serial")
|
||||
.appendField(new Blockly.FieldDropdown([['uart1', '1'], ['uart2', '2']]), 'mode')
|
||||
.appendField(Blockly.Msg.MIXLY_EMQX_PUBLISH);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.LANG_CONTROLS_FOR_INPUT_TO + Blockly.Msg.MIXLY_OTHER + 'MP' + Blockly.Msg.MIXLY_DEVICE)
|
||||
.appendField(Blockly.Msg.LANG_CONTROLS_WHILEUNTIL_TITLE_REPEAT)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_TURTLE_WRITE_MOVE_TRUE, 'True'], [Blockly.Msg.MIXLY_TURTLE_WRITE_MOVE_FALSE, 'False']]), 'STAT')
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
}
|
||||
};
|
||||
|
||||
export const serial_read_from_ai = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("Serial")
|
||||
.appendField(new Blockly.FieldDropdown([['uart1', '1'], ['uart2', '2']]), 'mode')
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_READ + Blockly.Msg.MIXLY_OTHER + 'MP' + Blockly.Msg.MIXLY_DEVICE + Blockly.Msg.MIXLY_SD_DATA);
|
||||
this.setOutput(true, Boolean);
|
||||
}
|
||||
};
|
||||
242
boards/default_src/micropython/blocks/system.js
Normal file
242
boards/default_src/micropython/blocks/system.js
Normal file
@@ -0,0 +1,242 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
|
||||
const SYSTEM_HUE = 120; //'#EB8045';
|
||||
|
||||
export const controls_delay_new = {
|
||||
init: function () {
|
||||
this.setColour(SYSTEM_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_DELAY)
|
||||
this.appendValueInput("DELAY_TIME", Number)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_SECOND, "s"], [Blockly.Msg.MIXLY_mSecond, "ms"], [Blockly.Msg.MIXLY_uSecond, "us"]]), 'Time');
|
||||
this.setFieldValue('s', 'Time')
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_CONTROL_DELAY);
|
||||
}
|
||||
};
|
||||
|
||||
export const controls_delay = {
|
||||
init: function () {
|
||||
this.setColour(SYSTEM_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_DELAY)
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_SECOND, "s"], [Blockly.Msg.MIXLY_mSecond, "ms"], [Blockly.Msg.MIXLY_uSecond, "us"]]), 'Time');
|
||||
this.appendValueInput("DELAY_TIME", Number)
|
||||
.setCheck(Number);
|
||||
this.setFieldValue('ms', 'Time')
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_CONTROL_DELAY);
|
||||
}
|
||||
};
|
||||
|
||||
export const Panic_with_status_code = {
|
||||
init: function () {
|
||||
this.setColour(SYSTEM_HUE);
|
||||
this.appendValueInput("STATUS_CODE", Number)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_Panic_with_status_code)
|
||||
.setCheck(Number);
|
||||
this.setPreviousStatement(true, null);
|
||||
// this.setNextStatement(true, null);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_Panic_with_status_code);
|
||||
}
|
||||
};
|
||||
|
||||
export const reset = {
|
||||
init: function () {
|
||||
this.setColour(SYSTEM_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_Reset_micro);
|
||||
this.setPreviousStatement(true);
|
||||
// this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_Reset_micro);
|
||||
}
|
||||
};
|
||||
|
||||
export const controls_millis = {
|
||||
init: function () {
|
||||
this.setColour(SYSTEM_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_RUNTIME);
|
||||
this.appendDummyInput("")
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_mSecond, "ms"], [Blockly.Msg.MIXLY_uSecond, "us"]]), 'Time');
|
||||
this.setOutput(true, Number);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_CONTROLS_MILLIS_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const raw_block = {
|
||||
// Container.
|
||||
init: function () {
|
||||
this.setColour(SYSTEM_HUE);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.appendDummyInput()
|
||||
.appendField('Code Block:');
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldMultilineInput('12345'), 'TEXT');
|
||||
}
|
||||
};
|
||||
|
||||
export const controls_uname = {
|
||||
init: function () {
|
||||
this.setColour(SYSTEM_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_CONTORL_UNAME);
|
||||
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
this.setTooltip(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN + Blockly.Msg.MIXLY_MICROBIT_PY_CONTORL_UNAME);
|
||||
}
|
||||
};
|
||||
|
||||
export const timer = {
|
||||
init: function () {
|
||||
this.setColour(SYSTEM_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField("Timer")
|
||||
.setCheck("var");
|
||||
this.appendValueInput('period')
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
// .appendField("Timer")
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_PERIOD_MIL);
|
||||
this.appendValueInput('mode')
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_MODE);
|
||||
this.appendValueInput('callback')
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO);
|
||||
// this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_TIMER_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const system_timer = {
|
||||
init: function () {
|
||||
this.setColour(SYSTEM_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
.appendField("Timer")
|
||||
.setCheck("var");
|
||||
// .appendField("I2C " + Blockly.Msg.MIXLY_SETUP)
|
||||
this.appendValueInput("period")
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_PERIOD_MIL)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_mSecond)
|
||||
.appendField(Blockly.Msg.MIXLY_MODE)
|
||||
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_PYTHON_ONE_SHOT, "ONE_SHOT"], [Blockly.Msg.MIXLY_PYTHON_PERIODIC, "PERIODIC"]]), "mode");
|
||||
this.appendValueInput('callback')
|
||||
.appendField(Blockly.Msg.MIXLY_DO)
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_SYSTEM_TIMER_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const system_ticks_diff = {
|
||||
init: function () {
|
||||
this.setColour(SYSTEM_HUE);
|
||||
this.appendValueInput('END')
|
||||
// .setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_TIME_TICKS_DIFF);
|
||||
this.appendValueInput('START')
|
||||
// .setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_ESP32_TIME_MINUS);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_SYSTEM_TICKS_DIFF_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const system_timer_init = {
|
||||
init: function () {
|
||||
this.setColour(SYSTEM_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField("Timer")
|
||||
this.appendValueInput('SUB')
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_ESP32_SYSTEM_TIMER_INIT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const system_wdt_init = {
|
||||
init: function () {
|
||||
this.setColour(SYSTEM_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_MACHINE_WDT)
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP)
|
||||
this.appendValueInput('period')
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_MACHINE_WDT_TIMEOUT)
|
||||
.setCheck(Number);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_mSecond)
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MACHINE_WDT_INIT_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const system_wdt_feed = {
|
||||
init: function () {
|
||||
this.setColour(SYSTEM_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_MACHINE_WDT)
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_MACHINE_FEED)
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MACHINE_WDT_FEED_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const system_machine_reset = {
|
||||
init: function () {
|
||||
this.setColour(SYSTEM_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.MIXLY_MACHINE_RESET)
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MIXLY_MACHINE_RESET_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const system_bitbot_shutdown = {
|
||||
init: function () {
|
||||
this.setColour(SYSTEM_HUE);
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.BITBOT)
|
||||
this.appendDummyInput("")
|
||||
.appendField(Blockly.Msg.SHUTDOWN)
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.MICROPYTHON_BITBOT_SHUTDOWN_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
export const Timer_init = system_timer_init;
|
||||
export const timer2 = system_timer;
|
||||
export const time_ticks_diff = system_ticks_diff;
|
||||
export const base_delay = controls_delay;
|
||||
64
boards/default_src/micropython/blocks/weather.js
Normal file
64
boards/default_src/micropython/blocks/weather.js
Normal file
@@ -0,0 +1,64 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
const WEATHER_HUE = '#27b6ac';
|
||||
|
||||
export const WEATHER_NOW = {
|
||||
init: function () {
|
||||
this.setColour(WEATHER_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MSG.catweather)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_WEB_DATA_SENIVERSE_GET_WEATHER_NOW, "weather_now"],
|
||||
[Blockly.Msg.MIXLY_WEB_DATA_SENIVERSE_GET_WEATHER_ALARM, "weather_alarm"],
|
||||
[Blockly.Msg.MIXLY_WEB_DATA_SENIVERSE_GET_AIR_NOW, "air_now"],
|
||||
[Blockly.Msg.MIXLY_WEB_DATA_SENIVERSE_GET_TIDE_DAILY, "tide_daily"],
|
||||
[Blockly.Msg.MIXLY_WEB_PLACE + Blockly.Msg.HTML_SEARCH, "location_search"]
|
||||
]), "mode");
|
||||
this.appendValueInput('key')
|
||||
.appendField(Blockly.Msg.MIXLY_API_PRIVATE_KEY);
|
||||
this.appendValueInput('addr')
|
||||
.appendField(Blockly.Msg.MIXLY_GEOGRAPHIC_LOCATION);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const WEATHER_DAILY = {
|
||||
init: function () {
|
||||
this.setColour(WEATHER_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MSG.catweather)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.MIXLY_WEB_DATA_SENIVERSE_GET_WEATHER_DAILY, "weather_daily"],
|
||||
[Blockly.Msg.MIXLY_WEB_DATA_SENIVERSE_GET_LIFE_SUGGESTION, "life_suggestion"],
|
||||
[Blockly.Msg.MIXLY_WEB_DATA_SENIVERSE_GET_AIR_DAILY, "air_daily"],
|
||||
[Blockly.Msg.MIXLY_WEB_DATA_SENIVERSE_GET_GEO_SUN, "geo_sun"],
|
||||
[Blockly.Msg.MIXLY_WEB_DATA_SENIVERSE_GET_GEO_MOON, "geo_moon"]
|
||||
]), "mode");
|
||||
this.appendValueInput('key')
|
||||
.appendField(Blockly.Msg.MIXLY_API_PRIVATE_KEY);
|
||||
this.appendValueInput('addr')
|
||||
.appendField(Blockly.Msg.MIXLY_GEOGRAPHIC_LOCATION);
|
||||
this.appendValueInput('day')
|
||||
.appendField(Blockly.Msg.MIXLY_WEB_DAILY);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const WEATHER_HOUR = {
|
||||
init: function () {
|
||||
this.setColour(WEATHER_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MSG.catweather)
|
||||
.appendField(Blockly.Msg.MIXLY_WEB_DATA_SENIVERSE_GET_WEATHER_HOURS);
|
||||
this.appendValueInput('key')
|
||||
.appendField(Blockly.Msg.MIXLY_API_PRIVATE_KEY);
|
||||
this.appendValueInput('addr')
|
||||
.appendField(Blockly.Msg.MIXLY_GEOGRAPHIC_LOCATION);
|
||||
this.appendValueInput('hour')
|
||||
.appendField(Blockly.Msg.MIXLY_WEB_HOURS);
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user