初始化提交

This commit is contained in:
王立帮
2024-07-19 10:16:00 +08:00
parent 4c7b571f20
commit 4a2d56dcc4
7084 changed files with 741212 additions and 63 deletions

View File

@@ -0,0 +1,273 @@
import * as Blockly from 'blockly/core';
import { Profile } from 'mixly';
const HANDBIT_HUE = 65;
const ACTUATOR_HUE = 100;
export const handbit_button_is_pressed = {
init: function () {
this.setColour(HANDBIT_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_BUTTON);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.button), 'btn');
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 handbit_light = {
init: function () {
this.setColour(HANDBIT_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_ESP32_LIGHT);
this.setOutput(true, Number);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.ESP32_SENSOR_NIXGO_LIGHT_TOOLTIP);
}
};
export const handbit_sound = {
init: function () {
this.setColour(HANDBIT_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_ESP32_SOUND);
this.setOutput(true, Number);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.ESP32_SENSOR_NIXGO_SOUND_TOOLTIP);
}
};
export const inout_touchRead = {
init: function () {
this.setColour(HANDBIT_HUE);
this.appendValueInput("PIN", Number)
.appendField(Blockly.Msg.MIXLY_ESP32_TOUCH + Blockly.Msg.MIXLY_PIN)
.setCheck(Number);
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 touchAttachInterrupt = {
init: function () {
this.setColour(HANDBIT_HUE);
this.appendValueInput("PIN", Number)
.appendField(Blockly.Msg.MIXLY_TOUCHATTACHINTERRUPT_PIN)
.setCheck(Number);
this.appendValueInput("threshold", Number)
.appendField(Blockly.Msg.MIXLY_ESP32_THRESHOLD)
.setCheck(Number);
this.appendDummyInput("");
this.appendStatementInput('DO')
.appendField(Blockly.Msg.MIXLY_DO);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_INOUT_ATTACHINTERRUPT);
}
};
var HANDBIT_MSA300_GETAB = [
[Blockly.Msg.MixGo_MPU9250_AX, "msa.getX()"],
[Blockly.Msg.MixGo_MPU9250_AY, "msa.getY()"],
[Blockly.Msg.MixGo_MPU9250_AZ, "msa.getZ()"],
];
var HANDBIT_MSA300_ACTION = [
[Blockly.Msg.HANDBIT_FORWARD, "msa.getX()>1500&&msa.getX()<2000&&msa.getZ()>-1000&&msa.getZ()<0"],
[Blockly.Msg.HANDBIT_BACKWARD, "msa.getX()>1500&&msa.getX()<2000&&msa.getZ()>0&&msa.getZ()<1500"],
[Blockly.Msg.HANDBIT_LEFT, "msa.getY()<1000&&msa.getY()>0"],
[Blockly.Msg.HANDBIT_RIGHT, "msa.getY()<0&&msa.getY()>-1000"],
[Blockly.Msg.HANDBIT_UP, "msa.getX()>-400&&msa.getX()<400&&msa.getY()>-400&&msa.getY()<400&&msa.getZ()>-1800&&msa.getZ()<-1400"],
[Blockly.Msg.HANDBIT_DOWN, "msa.getX()>-400&&msa.getX()<400&&msa.getY()>-400&&msa.getY()<400&&msa.getZ()>2000&&msa.getZ()<2400"],
];
//传感器_重力感应
export const handbit_MSA300 = {
init: function () {
this.setColour(HANDBIT_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MixGo_MPU9250);
this.appendDummyInput("")
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(new Blockly.FieldDropdown(HANDBIT_MSA300_GETAB), "HANDBIT_MSA300_GETAB");
this.setInputsInline(true);
this.setOutput(true);
this.setTooltip("");
this.setHelpUrl('');
}
};
export const handbit_MSA300_action = {
init: function () {
this.setColour(HANDBIT_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.Handbit);
this.appendDummyInput("")
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(new Blockly.FieldDropdown(HANDBIT_MSA300_ACTION), "HANDBIT_MSA300_ACTION");
this.setInputsInline(true);
this.setOutput(true);
this.setTooltip("");
this.setHelpUrl('');
}
};
export const handbit_rgb_rainbow1 = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendValueInput("WAIT")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_RGBdisplay_rgb_rainbow1);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};
var DISPLAY_RAINBOW_TYPE = [
[Blockly.Msg.MIXLY_RGB_DISPLAY_RAINBOW_TYPE_1, "normal"],
[Blockly.Msg.MIXLY_RGB_DISPLAY_RAINBOW_TYPE_2, "change"]
];
export const handbit_rgb_rainbow3 = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(DISPLAY_RAINBOW_TYPE), "TYPE");
this.appendValueInput("rainbow_color")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_RGB_display_rgb_rainbow3);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};
export const handbit_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.appendDummyInput("")
.appendField(Blockly.Msg.HTML_COLOUR);
this.appendValueInput("COLOR", Number)
.setCheck(Number);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('');
}
};
export const handbit_rgb2 = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB_NUM + "1" + Blockly.Msg.HTML_COLOUR);
this.appendValueInput("COLOR1", Number)
.setCheck(Number);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB_NUM + "2" + Blockly.Msg.HTML_COLOUR);
this.appendValueInput("COLOR2", Number)
.setCheck(Number);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB_NUM + "3" + Blockly.Msg.HTML_COLOUR);
this.appendValueInput("COLOR3", Number)
.setCheck(Number);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};
export const handbit_rgb_Brightness = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendValueInput("Brightness")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_BRIGHTNESS);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('');
}
};
export const handbit_rgb_show = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB_SHOW)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};
export const handbit_motor_move = {
init: function () {
this.appendDummyInput()
.appendField("掌控宝" + Blockly.Msg.MIXLY_MOTOR)
.appendField(new Blockly.FieldDropdown([["M1", "0x01"], ["M2", "0x10"]]), "type");
this.appendValueInput("speed")
.setCheck(null)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_SPEED + "(-100~100)");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(ACTUATOR_HUE);
this.setTooltip("");
this.setHelpUrl("");
}
};
export const handbit_RGB_color_HSV = {
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("H")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.HSV_H);
this.appendValueInput("S")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.HSV_S);
this.appendValueInput("V")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.HSV_V);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('色调范围0-65536;饱和度范围0-255;明度范围0-255');
}
};

View File

@@ -0,0 +1,523 @@
import * as Blockly from 'blockly/core';
import { Profile } from 'mixly';
const ACTUATOR_HUE = 100;
const DISPLAY_HUE = 180;
//执行器_点阵屏显示_字符显示
export const HT16K33_TEXT = {
init: function () {
this.setColour(DISPLAY_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_MAX7219_PUTSTR);
this.appendValueInput("TEXT", String)
.setCheck([Number, String])
.setAlign(Blockly.inputs.Align.RIGHT);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
this.setTooltip("");
}
};
//执行器_点阵屏显示_画点显示
export const HT16K33_POS = {
init: function () {
//执行器_点阵屏显示_画点变量
var MixGo_DrawPixel_NUM = [
[Blockly.Msg.MIXLY_4DIGITDISPLAY_ON, "LED_ON"],
[Blockly.Msg.MIXLY_4DIGITDISPLAY_OFF, "LED_OFF"]
];
this.setColour(DISPLAY_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_MICROBIT_monitor);
this.appendValueInput('XVALUE')
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_X);
this.appendValueInput("YVALUE")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_Y);
this.appendDummyInput("")
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_SHOWPOINT)
.appendField(new Blockly.FieldDropdown(MixGo_DrawPixel_NUM), "DrawPixel_TYPE");
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip("");
}
};
//执行器_点阵屏显示_显示图案
export const HT16K33_DisplayChar = {
init: function () {
this.setColour(DISPLAY_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_MICROBIT_monitor);
this.appendValueInput("Chars")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_PICARRAY);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip();
}
};
//执行器_点阵屏显示_图案数组
export const HT16K33_LedArray = {
init: function () {
this.setColour(DISPLAY_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_ARRAYVAR)
.appendField(new Blockly.FieldTextInput("LedArray1"), "VAR");
this.appendDummyInput("")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a81")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a82")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a83")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a84")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a85")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a86")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a87")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a88")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a89")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a810")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a811")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a812")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a813")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a814")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a815")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a816");
this.appendDummyInput("")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a71")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a72")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a73")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a74")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a75")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a76")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a77")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a78")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a79")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a710")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a711")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a712")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a713")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a714")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a715")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a716");
this.appendDummyInput("")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a61")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a62")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a63")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a64")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a65")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a66")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a67")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a68")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a69")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a610")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a611")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a612")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a613")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a614")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a615")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a616");
this.appendDummyInput("")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a51")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a52")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a53")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a54")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a55")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a56")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a57")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a58")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a59")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a510")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a511")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a512")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a513")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a514")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a515")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a516");
this.appendDummyInput("")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a41")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a42")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a43")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a44")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a45")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a46")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a47")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a48")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a49")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a410")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a411")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a412")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a413")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a414")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a415")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a416");
this.appendDummyInput("")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a31")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a32")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a33")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a34")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a35")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a36")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a37")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a38")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a39")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a310")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a311")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a312")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a313")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a314")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a315")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a316");
this.appendDummyInput("")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a21")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a22")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a23")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a24")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a25")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a26")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a27")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a28")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a29")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a210")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a211")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a212")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a213")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a214")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a215")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a216");
this.appendDummyInput("")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a11")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a12")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a13")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a14")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a15")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a16")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a17")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a18")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a19")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a110")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a111")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a112")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a113")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a114")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a115")
.appendField(new Blockly.FieldCheckbox("FALSE"), "a116");
this.setOutput(true, Number);
this.setTooltip();
}
};
//物联网_点阵屏_清除显示
export const HT16K33_Displayclear = {
init: function () {
this.setColour(DISPLAY_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_MICROBIT_monitor);
this.appendDummyInput("")
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_MICROBIT_Clear_display);
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip();
}
};
export const HT16K33_show_image = {
init: function () {
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_ESP32_SHOW_IMAGE_OR_STRING_OR_ANIMATION)
.appendField(new Blockly.FieldDropdown([
["❤", "0100038007c00fe01ff01ff00ee00640"],
["♥", "00000100038007c00fe00ee004400000"],
["▲", "00003ffc1ff80ff007e003c001800000"],
["▼", "0000018003c007e00ff01ff83ffc0000"],
["◄", "100030007000f000f000700030001000"],
// ["↓", "18181818db7e3c18"],
// ["←", "103060ffff603010"],
// ["→", "080c06ffff060c08"],
// ["►", "080c0e0f0f0e0c08"],
// ["△", "182442ff00000000"],
// ["▽", "00000000ff422418"],
// ["☺", "3c42a581a599423c"],
// ["○", "3c4281818181423c"],
// ["◑", "3c4e8f8f8f8f4e3c"],
// ["◐", "3c72f1f1f1f1723c"],
// ["¥", "4224ff08ff080808"],
// ["Χ", "8142241818244281"],
// ["✓", "0000010204885020"],
// ["□", "007e424242427e00"],
// ["▣", "007e425a5a427e00"],
// ["◇", "1824428181422418"],
// ["♀", "3844444438107c10"],
// ["♂", "0f030579d888d870"],
// ["♪", "0c0e0b080878f860"],
// ["✈", "203098ffff983020"],
// //["卍", "00f21212fe90909e"],
// //["卐", "009e9090fe1212f2"],
// ["︱", "1010101010101010"],
// ["—", "000000ff00000000"],
// ["", "0102040810204080"],
// ["", "8040201008040201"],
// ["大", "1010fe1010284482"],
// ["中", "1010fe9292fe1010"],
// ["小", "1010105454921070"],
// ["米", "00925438fe385492"],
// ["正", "00fe10105e5050fc"],
// ["囧", "ffa5a5c3bda5a5ff"]
]), "img_");
this.setOutput(true);
this.setTooltip('');
this.setColour(DISPLAY_HUE);
this.setTooltip(Blockly.Msg.OLED_BITMAP_OR_STRING);
this.setHelpUrl('');
}
};
export const HT16K33_blink_rate = {
init: function () {
this.setColour(DISPLAY_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_MICROBIT_monitor);
this.appendValueInput('x')
.setCheck(Number)
.appendField(Blockly.Msg.MIXLY_ESP32_JS_MONITOR_SET_BLINK_RATE)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.MIXLY_ESP32_JS_MONITOR_SET_BLINK_RATE);
}
};
export const HT16K33_brightness = {
init: function () {
this.setColour(DISPLAY_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_MICROBIT_monitor);
this.appendValueInput("Brightness")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_BRIGHTNESS);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.MIXLY_ESP32_JS_MONITOR_SET_SCREEN_BRIGHTNESS);
}
};
export const mixgo_button_is_pressed = {
init: function () {
this.setColour(Blockly.Msg['SENSOR_HUE']);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_BUTTON);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.button), 'PIN');
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_light = {
init: function () {
this.setColour(Blockly.Msg['SENSOR_HUE']);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_ESP32_LIGHT);
this.setOutput(true, Number);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.ESP32_SENSOR_NIXGO_LIGHT_TOOLTIP);
}
};
export const sensor_mixgo_sound = {
init: function () {
this.setColour(Blockly.Msg['SENSOR_HUE']);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_ESP32_SOUND);
this.setOutput(true, Number);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.ESP32_SENSOR_NIXGO_SOUND_TOOLTIP);
}
};
export const mixgo_touch_pin = {
init: function () {
this.setColour(Blockly.Msg['SENSOR_HUE']);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_ESP32_TOUCH)
.appendField(Blockly.Msg.MIXLY_PIN)
.appendField(new Blockly.FieldDropdown(Profile.default.touch), 'touch_pin');
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_pin_near = {
init: function () {
this.setColour(Blockly.Msg['SENSOR_HUE']);
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.TEXT_TRIM_LEFT, "34"], [Blockly.Msg.TEXT_TRIM_RIGHT, "36"]]), "direction")
.appendField(Blockly.Msg.MIXLY_ESP32_NEAR);
this.setOutput(true, Boolean);
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 mixGo_led = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_SETTING)
.appendField(Blockly.Msg.MIXLY_BUILDIN_LED)
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LEFT, "0"], [Blockly.Msg.MIXLY_RIGHT, "5"]]), 'STAT');
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 mixGo_led_brightness = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_SETTING)
.appendField(Blockly.Msg.MIXLY_BUILDIN_LED)
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_LEFT, "0"], [Blockly.Msg.MIXLY_RIGHT, "5"]]), 'STAT');
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 MixGo_rgb_rainbow1 = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendValueInput("WAIT")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_RGBdisplay_rgb_rainbow1);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};
var DISPLAY_RAINBOW_TYPE = [
[Blockly.Msg.MIXLY_RGB_DISPLAY_RAINBOW_TYPE_1, "normal"],
[Blockly.Msg.MIXLY_RGB_DISPLAY_RAINBOW_TYPE_2, "change"]
];
export const MixGo_rgb_rainbow3 = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(DISPLAY_RAINBOW_TYPE), "TYPE");
this.appendValueInput("rainbow_color")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_RGB_display_rgb_rainbow3);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};
export const MixGo_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.appendDummyInput("")
.appendField(Blockly.Msg.HTML_COLOUR);
this.appendValueInput("COLOR", Number)
.setCheck(Number);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('');
}
};
export const MixGo_rgb2 = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendDummyInput("")
.appendField("1")
.appendField(Blockly.Msg.HTML_COLOUR);
this.appendValueInput("COLOR1", Number)
.setCheck(Number);
this.appendDummyInput("")
.appendField("2")
.appendField(Blockly.Msg.HTML_COLOUR);
this.appendValueInput("COLOR2", Number)
.setCheck(Number);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};
export const MixGo_rgb_Brightness = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendValueInput("Brightness")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_BRIGHTNESS);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('');
}
};
export const MixGo_rgb_show = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB_SHOW)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};

View File

@@ -0,0 +1,229 @@
import * as Blockly from 'blockly/core';
import { Profile } from 'mixly';
const DISPLAY_HUE = 180;
const SENSOR_HUE = 40;
const ACTUATOR_HUE = 100;
var MIXEPI_ADXL345_ACTION = [
[Blockly.Msg.HANDBIT_FORWARD, "accel.getAcceleration().x>-4.7&&accel.getAcceleration().x<0&&accel.getAcceleration().y<1&&accel.getAcceleration().y>-1&&accel.getAcceleration().z<-8&&accel.getAcceleration().z>-9.8"],
[Blockly.Msg.HANDBIT_BACKWARD, "accel.getAcceleration().x>0&&accel.getAcceleration().x<4.7&&accel.getAcceleration().y<1&&accel.getAcceleration().y>-1&&accel.getAcceleration().z<-8&&accel.getAcceleration().z>-9.8"],
[Blockly.Msg.HANDBIT_LEFT, "accel.getAcceleration().y>0&&accel.getAcceleration().y<5.5&&accel.getAcceleration().z<-7.5&&accel.getAcceleration().z>-9.8"],
[Blockly.Msg.HANDBIT_RIGHT, "accel.getAcceleration().y<0&&accel.getAcceleration().y>-4.7&&accel.getAcceleration().z<-7.5&&accel.getAcceleration().z>-9.8"],
[Blockly.Msg.HANDBIT_UP, "accel.getAcceleration().z>-9.8&&accel.getAcceleration().z<-8"],
[Blockly.Msg.HANDBIT_DOWN, "accel.getAcceleration().z>8&&accel.getAcceleration().z<9.8"]
];
var BRIGHTNESS_SELECT = [["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"]];
export const brightness_select = {
init: function () {
this.setColour(DISPLAY_HUE);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(BRIGHTNESS_SELECT), 'STAT');
this.setOutput(true, Number);
}
};
export const mixePi_button_is_pressed = {
init: function () {
this.setColour(SENSOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_BUTTON);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.button), 'btn');
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 mixepi_light = {
init: function () {
this.setColour(SENSOR_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_ESP32_LIGHT);
this.setOutput(true, Number);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.ESP32_SENSOR_NIXGO_LIGHT_TOOLTIP);
}
};
export const mixepi_sound = {
init: function () {
this.setColour(SENSOR_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_ESP32_SOUND);
this.setOutput(true, Number);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.ESP32_SENSOR_NIXGO_SOUND_TOOLTIP);
}
};
export const mixepi_inout_touchRead = {
init: function () {
this.setColour(SENSOR_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_ESP32_TOUCH)
.appendField(Blockly.Msg.MIXLY_PIN)
.appendField(new Blockly.FieldDropdown(Profile.default.touch), 'touch_pin');
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 mixepi_ADXL345_action = {
init: function () {
this.setColour(SENSOR_HUE);
this.appendDummyInput("")
.appendField("MIXEPI");
this.appendDummyInput("")
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(new Blockly.FieldDropdown(MIXEPI_ADXL345_ACTION), "MIXEPI_ADXL345_ACTION");
this.setInputsInline(true);
this.setOutput(true);
this.setTooltip("");
this.setHelpUrl('');
}
};
export const mixepi_rgb_rainbow1 = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendValueInput("WAIT")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_RGBdisplay_rgb_rainbow1);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};
var DISPLAY_RAINBOW_TYPE = [
[Blockly.Msg.MIXLY_RGB_DISPLAY_RAINBOW_TYPE_1, "normal"],
[Blockly.Msg.MIXLY_RGB_DISPLAY_RAINBOW_TYPE_2, "change"]
];
export const mixepi_rgb_rainbow3 = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(DISPLAY_RAINBOW_TYPE), "TYPE");
this.appendValueInput("rainbow_color")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_RGB_display_rgb_rainbow3);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};
export const RGB_color_seclet = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(new Blockly.FieldColour("ff0000"), "COLOR");
this.setInputsInline(true);
this.setOutput(true, Number);
this.setTooltip(Blockly.Msg.OLED_DRAW_PIXE_TOOLTIP);
}
};
export const RGB_color_rgb = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendValueInput("R")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_RGB_R);
this.appendValueInput("G")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_RGB_G);
this.appendValueInput("B")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_RGB_B);
this.setInputsInline(true);
this.setOutput(true);
this.setTooltip('');
}
};
export const mixepi_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.appendDummyInput("")
.appendField(Blockly.Msg.HTML_COLOUR);
this.appendValueInput("COLOR", Number)
.setCheck(Number);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('');
}
};
export const mixepi_rgb2 = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendDummyInput("")
.appendField("1")
.appendField(Blockly.Msg.HTML_COLOUR);
this.appendValueInput("COLOR1", Number)
.setCheck(Number);
this.appendDummyInput("")
.appendField("2")
.appendField(Blockly.Msg.HTML_COLOUR);
this.appendValueInput("COLOR2", Number)
.setCheck(Number);
this.appendDummyInput("")
.appendField("3")
.appendField(Blockly.Msg.HTML_COLOUR);
this.appendValueInput("COLOR3", Number)
.setCheck(Number);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};
export const mixepi_rgb_Brightness = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendValueInput("Brightness")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_BRIGHTNESS);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('');
}
};

View File

@@ -0,0 +1,167 @@
import * as Blockly from 'blockly/core';
import { Profile } from 'mixly';
import { sensor_mixgo_pin_near } from './MixGo';
const SENSOR_HUE = 40;
const ACTUATOR_HUE = 100;
export const mixgo_button_is_pressed = {
init: function () {
this.setColour(SENSOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_BUTTON);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.button), 'PIN');
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_sound = {
init: function () {
this.setColour(SENSOR_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_ESP32_SOUND);
this.setOutput(true, Number);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.ESP32_SENSOR_NIXGO_SOUND_TOOLTIP);
}
};
export const mixgo_touch_pin = {
init: function () {
this.setColour(SENSOR_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_ESP32_TOUCH)
.appendField(Blockly.Msg.MIXLY_PIN)
.appendField(new Blockly.FieldDropdown(Profile.default.touch), 'touch_pin');
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_light = {
init: function () {
this.setColour(SENSOR_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_ESP32_LIGHT)
.appendField(new Blockly.FieldDropdown([["A", "39"], ["B", "36"]]), "direction");
this.setOutput(true, Number);
this.setInputsInline(true);
}
};
//NTC电阻
export const NTC_TEMP = {
init: function () {
this.setColour(SENSOR_HUE);
this.appendDummyInput("")
.appendField("NTC")
.appendField(Blockly.Msg.MIXLY_TEMP);
this.setInputsInline(false);
this.setOutput(true, Number);
this.setTooltip();
}
};
export const MPU9250_update = {
init: function () {
this.setColour(SENSOR_HUE);
this.appendDummyInput("")
.appendField("MPU9250" + Blockly.Msg.MIXLY_update_data);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setInputsInline(true);
}
};
export const Pocket_rgb = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendDummyInput("")
.appendField(Blockly.Msg.HTML_COLOUR);
this.appendValueInput("COLOR", Number)
.setCheck(Number);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('');
}
};
export const Pocket_rgb2 = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendDummyInput("")
.appendField(Blockly.Msg.HTML_COLOUR);
this.appendValueInput("COLOR1", Number)
.setCheck(Number);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};
export const Pocket_rgb_Brightness = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendValueInput("Brightness")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_BRIGHTNESS);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('');
}
};
export const Pocket_rgb_show = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB_SHOW)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};
export const pocket_RGB_color_HSV = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_RGB);
this.appendValueInput("H")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.HSV_H);
this.appendValueInput("S")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.HSV_S);
this.appendValueInput("V")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.HSV_V);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('色调范围0-65536;饱和度范围0-255;明度范围0-255');
}
};
export const sensor_button_is_pressed = mixgo_button_is_pressed;
export const sensor_pin_near = sensor_mixgo_pin_near;
export const sensor_light = sensor_mixgo_light;
export const sensor_sound = sensor_mixgo_sound;

View File

@@ -0,0 +1,157 @@
import * as Blockly from 'blockly/core';
const ACTUATOR_HUE = 100;
export const controls_tone = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_TONE);
this.appendValueInput("PIN")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_PIN);
this.appendValueInput('CHANNEL')
.setCheck(Number)
.appendField(Blockly.Msg.MIXLY_CHANNEL);
this.appendValueInput('FREQUENCY')
.setCheck(Number)
.appendField(Blockly.Msg.MIXLY_FREQUENCY);
this.appendValueInput('DELAY_TIME')
.setCheck(Number)
.appendField(Blockly.Msg.MIXLY_DELAY);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_MILLIS);
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_TONE);
}
};
export const controls_notone = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_NOTONE);
this.appendValueInput("PIN")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_PIN);
this.appendValueInput('CHANNEL')
.setCheck(Number)
.appendField(Blockly.Msg.MIXLY_CHANNEL);
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_NOTONE);
}
};
export const onboard_tone = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_TONE);
this.appendValueInput('CHANNEL')
.setCheck(Number)
.appendField(Blockly.Msg.MIXLY_CHANNEL);
this.appendValueInput('FREQUENCY')
.setCheck(Number)
.appendField(Blockly.Msg.MIXLY_FREQUENCY);
this.appendValueInput('DELAY_TIME')
.setCheck(Number)
.appendField(Blockly.Msg.MIXLY_DELAY);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_MILLIS);
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_TONE);
}
};
export const onboard_notone = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_NOTONE);
this.appendValueInput('CHANNEL')
.setCheck(Number)
.appendField(Blockly.Msg.MIXLY_CHANNEL);
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_NOTONE);
}
};
export const motor_id = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown([
["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"]
]), "CHANNEL");
this.setOutput(true);
}
};
export const HR8833_Motor_Setup = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MOTOR_HR8833 + Blockly.Msg.MIXLY_SETUP);
this.appendValueInput('MOTOR_ID')
.setCheck(Number)
.appendField(Blockly.Msg.MOTOR_HR8833_TEAM_NO);
this.appendValueInput("PIN1")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_PIN + "1");
this.appendValueInput("PIN2")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_PIN + "2");
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_MOTOR_SETUP);
}
};
export const HR8833_Motor_Speed = {
init: function () {
this.setColour(ACTUATOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MOTOR_HR8833 + Blockly.Msg.MIXLY_SETTING);
this.appendValueInput('MOTOR_ID')
.setCheck(Number)
.appendField(Blockly.Msg.MOTOR_HR8833_TEAM_NO);
this.appendValueInput('SPEED')
.setCheck(Number)
.appendField(Blockly.Msg.MIXLY_MOTOR_SPEED);
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
}
};
export const handbit_motor_move = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_MOTOR)
.appendField(new Blockly.FieldDropdown([["M1", "0x01"], ["M2", "0x10"]]), "type");
this.appendValueInput("speed")
.setCheck(null)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.MIXLY_SPEED + "(-100~100)");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(100);
this.setTooltip("");
this.setHelpUrl("");
}
};

View File

@@ -0,0 +1,47 @@
import * as Blockly from 'blockly/core';
const COMMUNICATE_HUE = 140;
export const serialBT_Init = {
init: function () {
this.setColour(COMMUNICATE_HUE);
this.appendValueInput("CONTENT", String)
.appendField(Blockly.Msg.MIXLY_SERIALBT_INIT)
.setCheck(String);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_SERIAL_BEGIN);
}
};
export const serialBT_available = {
init: function () {
this.setColour(COMMUNICATE_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_SERIALBT_AVAILABLE);
this.setOutput(true, Boolean);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_SERIAL_AVAILABLE);
}
};
export const serialBT_read = {
init: function () {
this.setColour(COMMUNICATE_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_SERIALBT_READ);
this.setOutput(true, Boolean);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_SERIAL_AVAILABLE);
}
};
export const serialBT_write = {
init: function () {
this.setColour(COMMUNICATE_HUE);
this.appendValueInput("CONTENT", String)
.appendField(Blockly.Msg.MIXLY_SERIALBT_WRITE);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip(Blockly.Msg.TEXT_WRITE_TOOLTIP);
}
};

View File

@@ -0,0 +1,101 @@
import * as Blockly from 'blockly/core';
const LOOPS_HUE = 120;
export const controls_hw_timer = {
init: function () {
this.setColour(LOOPS_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_ESP32_HW_TIMER)
.appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"]]), "TIMER_NUM");
this.appendValueInput('TIME')
.setCheck(Number)
.appendField(Blockly.Msg.MIXLY_MSTIMER2_EVERY);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_MILLIS)
.appendField(Blockly.Msg.MIXLY_MODE)
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_PYTHON_ONE_SHOT, "false"], [Blockly.Msg.MIXLY_PYTHON_PERIODIC, "true"]]), "mode");
this.appendStatementInput('DO')
.appendField(Blockly.Msg.MIXLY_MSTIMER2_DO);
this.setPreviousStatement(false);
this.setNextStatement(false);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_CONTROL_MSTIMER2);
}
};
export const controls_runnig_core = {
init: function () {
this.appendDummyInput()
.appendField("ESP32")
.appendField("Task")
.appendField(new Blockly.FieldDropdown([["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"]]), "task")
.appendField("Core")
.appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"]]), "core");
this.appendValueInput("length")
.setCheck(null)
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(Blockly.Msg.SPACE_ALLOCATION);
this.appendStatementInput("setup")
.setCheck(null)
.appendField(Blockly.Msg.MIXLY_SETUP);
this.appendStatementInput("loop")
.setCheck(null)
.appendField(Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_INPUT_OFLOOP);
this.setColour(LOOPS_HUE);
this.setTooltip("");
this.setHelpUrl("");
}
};
export const control_core_delay = {
init: function () {
this.setColour(LOOPS_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_CONTROL_CORE_DELAY);
this.appendValueInput("sleeplength", Number)
.setCheck(Number);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_MILLIS);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_SCOOP_SLEEP);
}
};
export const controls_hw_timer_start = {
init: function () {
this.setColour(LOOPS_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_ESP32_HW_TIMER)
.appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"]]), "TIMER_NUM")
.appendField(Blockly.Msg.MIXLY_MSTIMER2_START);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_CONTROL_MSTIMER2_START);
}
};
export const controls_hw_timer_stop = {
init: function () {
this.setColour(LOOPS_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_ESP32_HW_TIMER)
.appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"]]), "TIMER_NUM")
.appendField(Blockly.Msg.MIXLY_STOP);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_CONTROL_MSTIMER2_STOP);
}
};
export const esp32_deep_sleep = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.DFPLAYER_MINI_SLEEP)
.appendField(new Blockly.FieldTextInput("5"), "time")
.appendField(Blockly.Msg.MIXLY_SECOND);
this.setPreviousStatement(true, null);
this.setColour(LOOPS_HUE);
this.setTooltip("");
this.setHelpUrl("");
}
};

View File

@@ -0,0 +1,54 @@
import * as Blockly from 'blockly/core';
const ETHERNET_HUE = 0;
//esp_now
export const esp_now_send = {
init: function () {
this.appendDummyInput()
.appendField("ESP NOW" + Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_SEND);
this.appendValueInput("mac")
.setCheck(null)
.appendField(Blockly.Msg.MIXLY_ETHERNET_MAC_ADDRESS);
this.appendValueInput("data")
.setCheck(null)
.appendField(Blockly.Msg.MIXLY_SD_DATA);
this.appendStatementInput("success")
.setCheck(null)
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_SEND + Blockly.Msg.MIXLY_SUCCESS);
this.appendStatementInput("failure")
.setCheck(null)
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_SEND + Blockly.Msg.MIXLY_FAILED);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(ETHERNET_HUE);
this.setTooltip("");
this.setHelpUrl("https://randomnerdtutorials.com/esp-now-esp32-arduino-ide/");
}
};
//esp_now
export const esp_now_receive = {
init: function () {
this.appendDummyInput()
.appendField("ESP NOW" + Blockly.Msg.MQTT_subscribe2 + Blockly.Msg.MIXLY_SD_DATA);
this.appendStatementInput("receive_data")
.setCheck(null);
this.setColour(ETHERNET_HUE);
this.setTooltip("");
this.setHelpUrl("https://randomnerdtutorials.com/esp-now-esp32-arduino-ide/");
}
};
export const esp32_wifi_connection_event = {
init: function () {
this.appendDummyInput()
.appendField("WiFi连接事件")
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_ESP32_WIFI_CONNECTION_EVENT1, "1"], [Blockly.Msg.MIXLY_ESP32_WIFI_CONNECTION_EVENT2, "2"], [Blockly.Msg.MIXLY_ESP32_WIFI_CONNECTION_EVENT3, "3"]]), "type");
this.appendStatementInput("event")
.setCheck(null);
this.setColour(ETHERNET_HUE);
this.setTooltip("");
this.setHelpUrl("");
}
};

View File

@@ -0,0 +1,125 @@
import * as Blockly from 'blockly/core';
import { Profile } from 'mixly';
import { inout_analog_write } from '@mixly/arduino-avr/blocks/inout';
const BASE_HUE = 20//'#ae3838';//40;
export const ledcSetup = {
init: function () {
this.setColour(BASE_HUE);
this.appendValueInput('CHANNEL')
.setCheck(Number)
.appendField("ledc" + Blockly.Msg.MIXLY_SETUP + Blockly.Msg.MIXLY_CHANNEL);
this.appendValueInput("FREQ", Number)
.appendField(Blockly.Msg.MIXLY_FREQUENCY)
.setCheck(Number);
this.appendValueInput('PWM_RESOLUTION')
.setCheck(Number)
.appendField(Blockly.Msg.MIXLY_RESOLUTION);
this.appendDummyInput("")
.appendField("bit");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip();
}
};
export const ledcAttachPin = {
init: function () {
this.setColour(BASE_HUE);
this.appendValueInput("PIN", Number)
.appendField("ledc" + Blockly.Msg.MIXLY_ATTATCH + Blockly.Msg.MIXLY_PIN)
.setCheck(Number);
this.appendValueInput('CHANNEL')
.setCheck(Number)
.appendField(Blockly.Msg.MIXLY_CHANNEL);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip();
}
};
export const ledcDetachPin = {
init: function () {
this.setColour(BASE_HUE);
this.appendValueInput("PIN", Number)
.appendField("ledc" + Blockly.Msg.MIXLY_DETACH + Blockly.Msg.MIXLY_PIN)
.setCheck(Number);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip();
}
};
export const ledcWrite = inout_analog_write;
export const inout_touchRead = {
init: function () {
this.setColour(BASE_HUE);
this.appendValueInput("PIN", Number)
.appendField(Blockly.Msg.MIXLY_ESP32_TOUCH)
.appendField(Blockly.Msg.MIXLY_PIN);
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 touchAttachInterrupt = {
init: function () {
this.setColour(BASE_HUE);
this.appendValueInput("PIN", Number)
.appendField(Blockly.Msg.MIXLY_TOUCHATTACHINTERRUPT_PIN)
.setCheck(Number);
this.appendValueInput("threshold", Number)
.appendField(Blockly.Msg.MIXLY_ESP32_THRESHOLD)
.setCheck(Number);
this.appendDummyInput("");
this.appendStatementInput('DO')
.appendField(Blockly.Msg.MIXLY_DO);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_INOUT_ATTACHINTERRUPT);
}
};
export const inout_esp32_dac = {
init: function () {
this.appendValueInput("value")
.setCheck(null)
.appendField(Blockly.Msg.inout_esp32_dac)
.appendField(new Blockly.FieldDropdown(Profile.default.dac), "PIN")
.appendField(Blockly.Msg.MIXLY_VALUE2);
this.appendDummyInput();
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(20);
this.setTooltip(Blockly.Msg.inout_esp32_dac_HELP);
this.setHelpUrl("");
}
};
export const esp32_led_pwm = {
init: function () {
this.appendValueInput("PIN")
.setCheck(null)
.appendField(Blockly.Msg.MICROBIT_ACTUATOR_ticks)
.appendField(new Blockly.FieldTextInput("8"), "resolution")
.appendField(Blockly.Msg.MIXLY_FREQUENCY)
.appendField(new Blockly.FieldTextInput("5000"), "freq")
.appendField(Blockly.Msg.MIXLY_CHANNEL)
.appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"]]), "ledChannel")
.appendField(Blockly.Msg.MIXLY_ANALOGWRITE_PIN);
this.appendValueInput("val")
.setCheck(null)
.appendField(Blockly.Msg.MIXLY_VALUE2);
this.appendDummyInput();
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(20);
this.setTooltip("");
this.setHelpUrl("");
}
};

View File

@@ -0,0 +1,219 @@
import * as Blockly from 'blockly/core';
import { Profile } from 'mixly';
const PINS_HUE = 230;
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_button = {
init: function () {
this.setColour(PINS_HUE);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.button), 'PIN');
this.setOutput(true, Number);
}
};
export const pins_sda = {
init: function () {
this.setColour(PINS_HUE);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.SDA), 'PIN');
this.setOutput(true, Number);
}
};
export const pins_tx = {
init: function () {
this.setColour(PINS_HUE);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.tx), 'PIN');
this.setOutput(true, Number);
}
};
export const pins_scl = {
init: function () {
this.setColour(PINS_HUE);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.SCL), '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_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 serial_select = {
init: function () {
this.setColour(PINS_HUE);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.serial_select), 'PIN');
this.setOutput(true);
}
};
export const serial_HardwareSelect = {
init: function () {
this.setColour(PINS_HUE);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.serial_HardwareSelect), 'PIN');
this.setOutput(true);
}
};
export const brightness = {
init: function () {
this.setColour(PINS_HUE);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.brightness), 'PIN');
this.setOutput(true);
}
};
export const CHANNEL = {
init: function () {
this.setColour(PINS_HUE);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.CHANNEL), 'PIN');
this.setOutput(true);
}
};
export const PWM_RESOLUTION = {
init: function () {
this.setColour(PINS_HUE);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.PWM_RESOLUTION), 'PIN');
this.setOutput(true);
}
};
export const OCTAVE = {
init: function () {
this.setColour(PINS_HUE);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.OCTAVE), 'PIN');
this.setOutput(true);
}
};
export const TONE_NOTE = {
init: function () {
this.setColour(PINS_HUE);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.TONE_NOTE), 'PIN');
this.setOutput(true);
}
};
export const pins_digitalWrite = {
init: function () {
this.setColour(PINS_HUE);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.digitalWrite), 'PIN');
this.setOutput(true, Number);
}
};

View File

@@ -0,0 +1,62 @@
import * as Blockly from 'blockly/core';
import { Profile } from 'mixly';
const SENSOR_HUE = 40;
//ESP32片内霍尔传感器值
export const ESP32_hallRead = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.ESP32_HALL);
this.setOutput(true, null);
this.setColour(SENSOR_HUE);
this.setTooltip();
this.setHelpUrl("");
}
};
//ESP32片内温度传感器值
export const ESP32_temprature = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.ESP32_TEMP);
this.setOutput(true, null);
this.setColour(SENSOR_HUE);
this.setTooltip();
this.setHelpUrl("");
}
};
export const OneButton = {
init: function () {
this.setColour(SENSOR_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_CURRENT);
this.appendDummyInput("")
.appendField(new Blockly.FieldDropdown(Profile.default.button), 'PIN');
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_BUTTON)
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_CLICK, "attachClick"], [Blockly.Msg.MIXLY_DOUBLE_CLICK, "attachDoubleClick"], [Blockly.Msg.MIXLY_LONG_PRESS_START, "attachLongPressStart"], [Blockly.Msg.MIXLY_DURING_LONG_PRESS, "attachDuringLongPress"], [Blockly.Msg.MIXLY_LONG_PRESS_END, "attachLongPressStop"]]), "mode");
this.appendStatementInput('DO')
.appendField(Blockly.Msg.MIXLY_DO);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_INOUT_ATTACHINTERRUPT);
this.setInputsInline(true);
this.setHelpUrl();
}
};
export const ESP_TCS34725_Get_RGB = {
init: function () {
const TCS34725_COLOR = [
[Blockly.Msg.COLOUR_RGB_RED, "r"],
[Blockly.Msg.COLOUR_RGB_GREEN, "g"],
[Blockly.Msg.COLOUR_RGB_BLUE, "b"],
];
this.setColour(SENSOR_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.TCS34725_Get_RGB)
.appendField(new Blockly.FieldDropdown(TCS34725_COLOR), "TCS34725_COLOR");
this.setInputsInline(true);
this.setOutput(true);
}
};

View File

@@ -0,0 +1,204 @@
import * as Blockly from 'blockly/core';
import { Profile } from 'mixly';
const SERIAL_HUE = 65;
export const serial_HardwareSerial = {
init: function () {
this.setColour(SERIAL_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_SETUP + Blockly.Msg.Hardware_Serial)
.appendField(new Blockly.FieldDropdown(Profile.default.serial_HardwareSelect), "serial_select");
this.appendValueInput("RX", Number)
.setCheck(Number)
.appendField("RX#")
.setAlign(Blockly.inputs.Align.RIGHT);
this.appendValueInput("TX", Number)
.appendField("TX#")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT);
this.appendValueInput("CONTENT", Number)
.appendField(Blockly.Msg.MIXLY_SERIAL_BEGIN)
.setCheck(Number);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_SOFTSERIAL.replace('%1', Blockly.Arduino.valueToCode(this, 'RX', Blockly.Arduino.ORDER_ATOMIC))
.replace('%2', Blockly.Arduino.valueToCode(this, 'TX', Blockly.Arduino.ORDER_ATOMIC)));
}
};
export const serial_begin = {
init: function () {
this.setColour(SERIAL_HUE);
this.appendValueInput("CONTENT", Number)
.appendField(new Blockly.FieldDropdown(Profile.default.serial_HardwareSelect), "serial_select")
.appendField(Blockly.Msg.MIXLY_SERIAL_BEGIN)
.setCheck(Number);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_SERIAL_BEGIN);
}
};
export const serial_write = {
init: function () {
this.setColour(SERIAL_HUE);
this.appendValueInput("CONTENT", String)
.appendField(new Blockly.FieldDropdown(Profile.default.serial_HardwareSelect), "serial_select")
.appendField(Blockly.Msg.MIXLY_SERIAL_WRITE);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip(Blockly.Msg.TEXT_WRITE_TOOLTIP);
}
};
export const serial_print = {
init: function () {
this.setColour(SERIAL_HUE);
this.appendValueInput("CONTENT", String)
.appendField(new Blockly.FieldDropdown(Profile.default.serial_HardwareSelect), "serial_select")
.appendField(Blockly.Msg.MIXLY_SERIAL_PRINT)
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_PRINT_INLINE, "print"], [Blockly.Msg.TEXT_PRINT_Huanhang_TOOLTIP, "println"]]), "new_line");
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(new Blockly.FieldDropdown(Profile.default.serial_HardwareSelect), "serial_select")
.appendField(Blockly.Msg.MIXLY_SERIAL_PRINT)
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.TEXT_PRINT_Huanhang_TOOLTIP, "println"], [Blockly.Msg.MIXLY_PRINT_INLINE, "print"]]), "new_line");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip(Blockly.Msg.TEXT_PRINT_TOOLTIP);
}
};
export const serial_print_num = {
init: function () {
this.setColour(SERIAL_HUE);
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown(Profile.default.serial_HardwareSelect), "serial_select")
.appendField(Blockly.Msg.MIXLY_SERIAL_PRINT)
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MIXLY_PRINT_INLINE, "print"], [Blockly.Msg.TEXT_PRINT_Huanhang_TOOLTIP, "println"]]), "new_line")
.appendField(Blockly.Msg.MIXLY_NUMBER);
this.appendValueInput("CONTENT", Number)
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.MATH_HEX, "HEX"], [Blockly.Msg.MATH_BIN, "BIN"], [Blockly.Msg.MATH_OCT, "OCT"], [Blockly.Msg.MATH_DEC, "DEC"]]), "STAT")
.setCheck(Number);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.TEXT_PRINT_HEX_TOOLTIP);
}
};
export const serial_print_hex = serial_print_num;
export const serial_available = {
init: function () {
this.setColour(SERIAL_HUE);
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown(Profile.default.serial_HardwareSelect), "serial_select")
.appendField(Blockly.Msg.MIXLY_SERIAL_AVAILABLE);
this.setOutput(true, Boolean);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_SERIAL_AVAILABLE);
}
};
export const serial_readstr = {
init: function () {
this.setColour(SERIAL_HUE);
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown(Profile.default.serial_HardwareSelect), "serial_select")
.appendField(Blockly.Msg.MIXLY_SERIAL_READSTR);
this.setOutput(true, String);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_SERIAL_READ_STR);
}
};
export const serial_readstr_until = {
init: function () {
this.setColour(SERIAL_HUE);
this.appendValueInput("CONTENT", Number)
.appendField(new Blockly.FieldDropdown(Profile.default.serial_HardwareSelect), "serial_select")
.appendField(Blockly.Msg.MIXLY_SERIAL_READSTR_UNTIL)
.setCheck(Number);
this.setInputsInline(true);
this.setOutput(true, String);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_SERIAL_READSTRUNITL.replace('%1', Blockly.Arduino.valueToCode(this, 'CONTENT', Blockly.Arduino.ORDER_ATOMIC)));
}
};
export const serial_parseInt_Float = {
init: function () {
this.setColour(SERIAL_HUE);
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown(Profile.default.serial_HardwareSelect), "serial_select")
//.appendField(Blockly.Msg.MIXLY_SERIAL_READ)
.appendField(new Blockly.FieldDropdown([["read", "read"], ["peek", "peek"], ["parseInt", "parseInt"], ["parseFloat", "parseFloat"]]), "STAT");
this.setOutput(true, Number);
var thisBlock = this;
this.setTooltip(function () {
var op = thisBlock.getFieldValue('STAT');
var TOOLTIPS = {
'parseInt': Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_SERIAL_READ_INT,
'parseFloat': Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_SERIAL_READ_FLOAT
};
return TOOLTIPS[op];
});
}
};
export const serial_flush = {
init: function () {
this.setColour(SERIAL_HUE);
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown(Profile.default.serial_HardwareSelect), "serial_select")
.appendField(Blockly.Msg.MIXLY_SERIAL_FLUSH);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_SERIAL_FLUSH);
}
};
export const serial_softserial = {
init: function () {
this.setColour(SERIAL_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_SETUP)
.appendField(new Blockly.FieldDropdown(Profile.default.serial_HardwareSelect), "serial_select");
this.appendValueInput("RX", Number)
.setCheck(Number)
.appendField("RX#")
.setAlign(Blockly.inputs.Align.RIGHT);
this.appendValueInput("TX", Number)
.appendField("TX#")
.setCheck(Number)
.setAlign(Blockly.inputs.Align.RIGHT);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_SOFTSERIAL.replace('%1', Blockly.Arduino.valueToCode(this, 'RX', Blockly.Arduino.ORDER_ATOMIC))
.replace('%2', Blockly.Arduino.valueToCode(this, 'TX', Blockly.Arduino.ORDER_ATOMIC)));
}
};
export const serial_event = {
init: function () {
this.setColour(SERIAL_HUE);
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown(Profile.default.serial_HardwareSelect), "serial_select")
.appendField(Blockly.Msg.MIXLY_SERIAL_EVENT);
this.appendStatementInput('DO')
.appendField(Blockly.Msg.MIXLY_DO);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_SERIALEVENT);
}
};

View File

@@ -0,0 +1,97 @@
import * as Blockly from 'blockly/core';
const ACTUATOR_HUE = 100;
Blockly.Msg.TURN_OFF_BLUETOOTH_TO_CONNECT = "关闭蓝牙可连接";
Blockly.Msg.TURN_ON_BLUETOOTH_TO_CONNECT = "打开蓝牙可连接";
Blockly.Msg.RANGE_0 = "范围0-30";
Blockly.Msg.HSC025A_CONTROL_INSTRUCTION = "HSC025A控制指令";
Blockly.Msg.HSC025A_DESIGNATED_PLAYBACK = "HSC025A指定播放";
Blockly.Msg.HSC025A_DESIGNATED_PLAYBACK1 = "HSC025A指定播放歌曲名0000-0255";
Blockly.Msg.HSC025A_VOLUME_IS_SET_TO = "HSC025A音量设置为";
Blockly.Msg.BLUETOOTH_ON = "蓝牙开启";
Blockly.Msg.BLUETOOTH_OFF = "蓝牙关闭";
Blockly.Msg.MUTE = "静音";
Blockly.Msg.RESTORE_SOUND = "恢复声音";
Blockly.Msg.STANDBY = "待机";
Blockly.Msg.BOOT = "开机";
Blockly.Msg.PLAY_PAUSE = "播放/暂停";
Blockly.Msg.SHUTDOWN = "关机";
Blockly.Msg.SD_CARD_MODE = "SD卡模式";
Blockly.Msg.BLUETOOTH_MODE = "蓝牙模式";
Blockly.Msg.RESET = "恢复出厂设置";
Blockly.Msg.STOP_PLAYING = "放完停止";
Blockly.Msg.BLUETOOTH_CONNECT = "蓝牙回连";
Blockly.Msg.MATH_DEC_MODE = "方式";
Blockly.Msg.REQUEST_SUCCEEDED = "请求成功";
Blockly.Msg.MIXLY_FAILED = "请求失败";
Blockly.Msg.MODE_SWITCH = "模式切换";
//HSC025A 蓝牙MP3指令
var hsc025a_mode = [
[Blockly.Msg.MODE_SWITCH, "1"],
[Blockly.Msg.MIXLY_MP3_PLAY, "2"],
[Blockly.Msg.MIXLY_MP3_PAUSE, "3"],
[Blockly.Msg.MIXLY_MP3_NEXT, "4"],
[Blockly.Msg.MIXLY_MP3_PREV, "5"],
[Blockly.Msg.MIXLY_MP3_VOL_UP, "6"],
[Blockly.Msg.MIXLY_MP3_VOL_DOWN, "7"],
[Blockly.Msg.STANDBY, "8"],
[Blockly.Msg.BOOT, "9"],
[Blockly.Msg.PLAY_PAUSE, "10"],
[Blockly.Msg.MIXLY_MICROBIT_Stop_music, "11"],
[Blockly.Msg.SHUTDOWN, "12"],
[Blockly.Msg.SD_CARD_MODE, "13"],
[Blockly.Msg.BLUETOOTH_MODE, "14"],
[Blockly.Msg.RESET, "15"],
[Blockly.Msg.STOP_PLAYING, "16"],
[Blockly.Msg.BLUETOOTH_CONNECT, "17"],
[Blockly.Msg.TURN_OFF_BLUETOOTH_TO_CONNECT, "18"],
[Blockly.Msg.TURN_ON_BLUETOOTH_TO_CONNECT, "19"],
[Blockly.Msg.BLUETOOTH_ON, "20"],
[Blockly.Msg.BLUETOOTH_OFF, "21"],
[Blockly.Msg.MUTE, "22"],
[Blockly.Msg.RESTORE_SOUND, "23"]
];
export const hsc025a_instruction = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.HSC025A_CONTROL_INSTRUCTION)
.appendField(new Blockly.FieldDropdown(hsc025a_mode), "instruction");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(ACTUATOR_HUE);
this.setTooltip("");
this.setHelpUrl("");
}
};
//指定播放歌曲
export const hsc025a_play = {
init: function () {
this.appendValueInput("num")
.setCheck(null)
.appendField(Blockly.Msg.HSC025A_DESIGNATED_PLAYBACK);
this.appendDummyInput();
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(ACTUATOR_HUE);
this.setTooltip(Blockly.Msg.HSC025A_DESIGNATED_PLAYBACK1);
this.setHelpUrl("");
}
};
//音量设置
export const hsc025a_volume = {
init: function () {
this.appendValueInput("num")
.setCheck(null)
.appendField(Blockly.Msg.HSC025A_VOLUME_IS_SET_TO);
this.appendDummyInput();
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(ACTUATOR_HUE);
this.setTooltip(Blockly.Msg.RANGE_0);
this.setHelpUrl("");
}
};

View File

@@ -0,0 +1,146 @@
import * as Blockly from 'blockly/core';
const STORAGE_HUE = 0;
//初始化SPIFFS
export const initialize_spiffs = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_SETUP + "SPIFFS");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(STORAGE_HUE);
this.setTooltip("");
this.setHelpUrl("");
}
};
var OPEN_MODE = [
[Blockly.Msg.MIXLY_READONLY, 'FILE_READ'],
[Blockly.Msg.TEXT_WRITE_TEXT, 'FILE_WRITE'],
[Blockly.Msg.TEXT_APPEND_APPENDTEXT, 'FILE_APPEND']]
//打开文件并向其中写入数据
export const spiffs_open_file = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_OPEN_FILE);
this.appendDummyInput()
.appendField(new Blockly.FieldTextInput("myFile"), "file_var");
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_FILE_PATH);
this.appendDummyInput()
.appendField(new Blockly.FieldTextInput("/fileName.txt"), "file_path");
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_MODE);
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown(OPEN_MODE), 'MODE');
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(STORAGE_HUE);
this.setTooltip("");
this.setHelpUrl("");
}
};
//打开文件并向其中写入数据
export const spiffs_close_file = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_CLOSE_FILE);
this.appendDummyInput()
.appendField(new Blockly.FieldTextInput("myFile"), "file_var");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(STORAGE_HUE);
this.setInputsInline(true);
this.setTooltip("");
this.setHelpUrl("");
}
};
//将数据追加到文件
export const spiffs_write_data = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_OPEN_FILE);
this.appendDummyInput()
.appendField(new Blockly.FieldTextInput("myFile"), "file_var");
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_WRITE);
this.appendValueInput("data")
.setCheck(null);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
this.setColour(STORAGE_HUE);
this.setTooltip("");
this.setHelpUrl("");
}
};
//文件可读
export const spiffs_read_available = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.HTML_FILE);
this.appendDummyInput()
.appendField(new Blockly.FieldTextInput("myFile"), "file_var");
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_AVAILABLE);
this.setColour(STORAGE_HUE);
this.setOutput(true, null);
this.setInputsInline(true);
this.setTooltip("");
this.setHelpUrl("");
}
};
//读取文件内容
export const spiffs_read_data = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET_FILE_SIZE);
this.appendDummyInput()
.appendField(new Blockly.FieldTextInput("myFile"), "file_var");
this.appendDummyInput()
.appendField(Blockly.Msg.OLED_STRING);
this.setOutput(true, null);
this.setInputsInline(true);
this.setColour(STORAGE_HUE);
this.setTooltip("");
this.setHelpUrl("");
}
};
//检查文件大小
export const spiffs_file_size = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.HTML_FILE);
this.appendDummyInput()
.appendField(new Blockly.FieldTextInput("myFile"), "file_var");
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_SIZE);
this.setOutput(true, null);
this.setInputsInline(true);
this.setColour(STORAGE_HUE);
this.setTooltip("");
this.setHelpUrl("");
}
};
//删除文件
export const spiffs_delete_file = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_DELETE_FILE);
this.appendDummyInput()
.appendField(new Blockly.FieldTextInput("/fileName.txt"), "file_path");
this.appendDummyInput();
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
this.setColour(STORAGE_HUE);
this.setTooltip("");
this.setHelpUrl("");
}
};

View File

@@ -0,0 +1,85 @@
import * as Blockly from 'blockly/core';
const TOOLS_HUE = "#555555";
let toolsBlocks = {};
let toolsGenerators = {};
const BOARDS_PIN_DEF = {
esp32_pin: {
path: require("../../../../common/media/board_pin/ESP32.png"),
height: 270
},
handbit_A: {
path: require("../../../../common/media/board_pin/handbit_A.jpg"),
height: 260
},
handbit_B: {
path: require("../../../../common/media/board_pin/handbit_B.jpg"),
height: 260,
width: 460
},
handbit_pin_A: {
path: require("../../../../common/media/board_pin/handbit_pin_A.jpg"),
width: 270
},
handbit_pin_B: {
path: require("../../../../common/media/board_pin/handbit_pin_B.jpg"),
width: 290
},
mixgo_pin_A: {
path: require("../../../../common/media/board_pin/MixGo_pin_A.png")
},
mixgo_pin_B: {
path: require("../../../../common/media/board_pin/MixGo_pin_B.png")
},
PocketCard_A: {
path: require("../../../../common/media/board_pin/PocketCard_A.jpg")
},
PocketCard_B: {
path: require("../../../../common/media/board_pin/PocketCard_B.jpg")
},
PocketCard_pin: {
path: require("../../../../common/media/board_pin/PocketCard_pin.png")
},
esp32_cam_pin: {
path: require("../../../../common/media/board_pin/ESP32_CAM_pin.png"),
height: 270
},
esp32_pico_kit_1_pin: {
path: require("../../../../common/media/board_pin/ESP32_pico_kit_1.png"),
height: 230
},
nodemcu_32s_pin: {
path: require("../../../../common/media/board_pin/nodemcu_32s_pin.png"),
width: 380
}
}
for (let i in BOARDS_PIN_DEF) {
const defaultDef = {
path: require('../../../../common/media/board_pin/ESP32.png'),
height: 376,
width: 525,
tooltip: '',
helpUrl: ''
};
let pinDef = {};
Object.assign(pinDef, defaultDef, BOARDS_PIN_DEF[i]);
toolsBlocks[i] = {
init: function () {
this.appendDummyInput()
.appendField(new Blockly.FieldImage(pinDef.path, pinDef.width, pinDef.height, "*"));
this.setColour(TOOLS_HUE);
this.setTooltip(pinDef.tooltip);
this.setHelpUrl(pinDef.helpUrl);
}
};
toolsGenerators[i] = function () {
return "";
};
}
export const blocks = toolsBlocks;
export const generators = toolsGenerators;