refactor(boards): 规范化arduino板卡代码
This commit is contained in:
@@ -97,7 +97,6 @@ export const motor_id = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const HR8833_Motor_Setup = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
|
||||
@@ -14,6 +14,7 @@ export const serialBT_Init = {
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_SERIAL_BEGIN);
|
||||
}
|
||||
};
|
||||
|
||||
export const serialBT_available = {
|
||||
init: function () {
|
||||
this.setColour(COMMUNICATE_HUE);
|
||||
@@ -34,6 +35,7 @@ export const serialBT_read = {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
export const serialBT_write = {
|
||||
init: function () {
|
||||
this.setColour(COMMUNICATE_HUE);
|
||||
@@ -43,5 +45,4 @@ export const serialBT_write = {
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.TEXT_WRITE_TOOLTIP);
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
@@ -7,14 +7,22 @@ export const controls_hw_timer = {
|
||||
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(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");
|
||||
.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);
|
||||
@@ -28,9 +36,21 @@ export const controls_runnig_core = {
|
||||
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(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");
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["0", "0"],
|
||||
["1", "1"]
|
||||
]), "core");
|
||||
this.appendValueInput("length")
|
||||
.setCheck(null)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
@@ -61,12 +81,18 @@ export const control_core_delay = {
|
||||
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(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);
|
||||
@@ -79,7 +105,12 @@ export const controls_hw_timer_stop = {
|
||||
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(new Blockly.FieldDropdown([
|
||||
["0", "0"],
|
||||
["1", "1"],
|
||||
["2", "2"],
|
||||
["3", "3"]
|
||||
]), "TIMER_NUM")
|
||||
.appendField(Blockly.Msg.MIXLY_STOP);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
|
||||
@@ -44,7 +44,11 @@ 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");
|
||||
.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);
|
||||
|
||||
@@ -73,22 +73,6 @@ export const touchAttachInterrupt = {
|
||||
}
|
||||
};
|
||||
|
||||
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 () {
|
||||
@@ -97,12 +81,17 @@ export const handbit_MSA300 = {
|
||||
.appendField(Blockly.Msg.MixGo_MPU9250);
|
||||
this.appendDummyInput("")
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(new Blockly.FieldDropdown(HANDBIT_MSA300_GETAB), "HANDBIT_MSA300_GETAB");
|
||||
.appendField(new Blockly.FieldDropdown(this.HANDBIT_MSA300_GETAB), "HANDBIT_MSA300_GETAB");
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
this.setTooltip("");
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
},
|
||||
HANDBIT_MSA300_GETAB: [
|
||||
[Blockly.Msg.MixGo_MPU9250_AX, "msa.getX()"],
|
||||
[Blockly.Msg.MixGo_MPU9250_AY, "msa.getY()"],
|
||||
[Blockly.Msg.MixGo_MPU9250_AZ, "msa.getZ()"],
|
||||
]
|
||||
};
|
||||
|
||||
export const handbit_MSA300_action = {
|
||||
@@ -112,12 +101,20 @@ export const handbit_MSA300_action = {
|
||||
.appendField(Blockly.Msg.Handbit);
|
||||
this.appendDummyInput("")
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(new Blockly.FieldDropdown(HANDBIT_MSA300_ACTION), "HANDBIT_MSA300_ACTION");
|
||||
.appendField(new Blockly.FieldDropdown(this.HANDBIT_MSA300_ACTION), "HANDBIT_MSA300_ACTION");
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
this.setTooltip("");
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
},
|
||||
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_rgb_rainbow1 = {
|
||||
@@ -135,18 +132,13 @@ export const handbit_rgb_rainbow1 = {
|
||||
}
|
||||
};
|
||||
|
||||
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");
|
||||
.appendField(new Blockly.FieldDropdown(this.DISPLAY_RAINBOW_TYPE), "TYPE");
|
||||
this.appendValueInput("rainbow_color")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
@@ -154,7 +146,11 @@ export const handbit_rgb_rainbow3 = {
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
}
|
||||
},
|
||||
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 = {
|
||||
|
||||
@@ -2,7 +2,7 @@ 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;
|
||||
const BASE_HUE = 20;
|
||||
|
||||
export const ledcSetup = {
|
||||
init: function () {
|
||||
@@ -40,6 +40,7 @@ export const ledcAttachPin = {
|
||||
this.setTooltip();
|
||||
}
|
||||
};
|
||||
|
||||
export const ledcDetachPin = {
|
||||
init: function () {
|
||||
this.setColour(BASE_HUE);
|
||||
@@ -52,6 +53,7 @@ export const ledcDetachPin = {
|
||||
this.setTooltip();
|
||||
}
|
||||
};
|
||||
|
||||
export const ledcWrite = inout_analog_write;
|
||||
|
||||
export const inout_touchRead = {
|
||||
@@ -85,6 +87,7 @@ export const touchAttachInterrupt = {
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_INOUT_ATTACHINTERRUPT);
|
||||
}
|
||||
};
|
||||
|
||||
export const inout_esp32_dac = {
|
||||
init: function () {
|
||||
this.appendValueInput("value")
|
||||
@@ -110,7 +113,24 @@ export const esp32_led_pwm = {
|
||||
.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(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)
|
||||
|
||||
@@ -5,26 +5,24 @@ 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');
|
||||
.appendField(new Blockly.FieldDropdown(this.BRIGHTNESS_SELECT), 'STAT');
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
},
|
||||
BRIGHTNESS_SELECT: [
|
||||
["0", "0"],
|
||||
["1", "1"],
|
||||
["2", "2"],
|
||||
["3", "3"],
|
||||
["4", "4"],
|
||||
["5", "5"],
|
||||
["6", "6"],
|
||||
["7", "7"],
|
||||
["8", "8"]
|
||||
]
|
||||
};
|
||||
|
||||
export const mixePi_button_is_pressed = {
|
||||
@@ -79,7 +77,6 @@ export const mixepi_inout_touchRead = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const mixepi_ADXL345_action = {
|
||||
init: function () {
|
||||
this.setColour(SENSOR_HUE);
|
||||
@@ -87,12 +84,20 @@ export const mixepi_ADXL345_action = {
|
||||
.appendField("MIXEPI");
|
||||
this.appendDummyInput("")
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(new Blockly.FieldDropdown(MIXEPI_ADXL345_ACTION), "MIXEPI_ADXL345_ACTION");
|
||||
.appendField(new Blockly.FieldDropdown(this.MIXEPI_ADXL345_ACTION), "MIXEPI_ADXL345_ACTION");
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
this.setTooltip("");
|
||||
this.setHelpUrl('');
|
||||
}
|
||||
},
|
||||
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"]
|
||||
]
|
||||
};
|
||||
|
||||
export const mixepi_rgb_rainbow1 = {
|
||||
@@ -110,18 +115,13 @@ export const mixepi_rgb_rainbow1 = {
|
||||
}
|
||||
};
|
||||
|
||||
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");
|
||||
.appendField(new Blockly.FieldDropdown(this.DISPLAY_RAINBOW_TYPE), "TYPE");
|
||||
this.appendValueInput("rainbow_color")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
@@ -129,7 +129,11 @@ export const mixepi_rgb_rainbow3 = {
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
}
|
||||
},
|
||||
DISPLAY_RAINBOW_TYPE: [
|
||||
[Blockly.Msg.MIXLY_RGB_DISPLAY_RAINBOW_TYPE_1, "normal"],
|
||||
[Blockly.Msg.MIXLY_RGB_DISPLAY_RAINBOW_TYPE_2, "change"]
|
||||
]
|
||||
};
|
||||
|
||||
export const RGB_color_seclet = {
|
||||
@@ -225,5 +229,4 @@ export const mixepi_rgb_Brightness = {
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
@@ -23,11 +23,6 @@ export const HT16K33_TEXT = {
|
||||
//执行器_点阵屏显示_画点显示
|
||||
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);
|
||||
@@ -42,12 +37,16 @@ export const HT16K33_POS = {
|
||||
this.appendDummyInput("")
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
.appendField(Blockly.Msg.MIXLY_DISPLAY_MATRIX_SHOWPOINT)
|
||||
.appendField(new Blockly.FieldDropdown(MixGo_DrawPixel_NUM), "DrawPixel_TYPE");
|
||||
.appendField(new Blockly.FieldDropdown(this.DRAW_TYPE), "DrawPixel_TYPE");
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip("");
|
||||
}
|
||||
},
|
||||
DRAW_TYPE: [
|
||||
[Blockly.Msg.MIXLY_4DIGITDISPLAY_ON, "LED_ON"],
|
||||
[Blockly.Msg.MIXLY_4DIGITDISPLAY_OFF, "LED_OFF"]
|
||||
]
|
||||
};
|
||||
|
||||
//执行器_点阵屏显示_显示图案
|
||||
@@ -211,7 +210,6 @@ export const HT16K33_LedArray = {
|
||||
.appendField(new Blockly.FieldCheckbox("FALSE"), "a116");
|
||||
this.setOutput(true, Number);
|
||||
this.setTooltip();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -328,7 +326,6 @@ export const mixgo_button_is_pressed = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const sensor_mixgo_light = {
|
||||
init: function () {
|
||||
this.setColour(Blockly.Msg['SENSOR_HUE']);
|
||||
@@ -370,7 +367,10 @@ 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(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);
|
||||
@@ -387,13 +387,17 @@ export const sensor_mixgo_pin_near = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
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');
|
||||
.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);
|
||||
@@ -409,7 +413,10 @@ export const mixGo_led_brightness = {
|
||||
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');
|
||||
.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);
|
||||
@@ -434,18 +441,13 @@ export const MixGo_rgb_rainbow1 = {
|
||||
}
|
||||
};
|
||||
|
||||
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");
|
||||
.appendField(new Blockly.FieldDropdown(this.DISPLAY_RAINBOW_TYPE), "TYPE");
|
||||
this.appendValueInput("rainbow_color")
|
||||
.setCheck(Number)
|
||||
.setAlign(Blockly.inputs.Align.RIGHT)
|
||||
@@ -453,7 +455,11 @@ export const MixGo_rgb_rainbow3 = {
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
}
|
||||
},
|
||||
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 = {
|
||||
@@ -512,6 +518,7 @@ export const MixGo_rgb_Brightness = {
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
export const MixGo_rgb_show = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
|
||||
@@ -2,7 +2,6 @@ import * as Blockly from 'blockly/core';
|
||||
|
||||
const PINOUT_HUE = '#555555';
|
||||
|
||||
|
||||
export const esp32_pin = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
|
||||
@@ -20,6 +20,7 @@ export const pins_button = {
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_sda = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
@@ -100,6 +101,7 @@ export const pins_axis = {
|
||||
this.setOutput(true, Number);
|
||||
}
|
||||
};
|
||||
|
||||
export const pins_brightness = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
@@ -172,7 +174,6 @@ export const brightness = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const CHANNEL = {
|
||||
init: function () {
|
||||
this.setColour(PINS_HUE);
|
||||
|
||||
@@ -81,6 +81,7 @@ export const MPU9250_update = {
|
||||
this.setInputsInline(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const Pocket_rgb = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
@@ -128,6 +129,7 @@ export const Pocket_rgb_Brightness = {
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
export const Pocket_rgb_show = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
@@ -137,6 +139,7 @@ export const Pocket_rgb_show = {
|
||||
this.setNextStatement(true, null);
|
||||
}
|
||||
};
|
||||
|
||||
export const pocket_RGB_color_HSV = {
|
||||
init: function () {
|
||||
this.setColour(ACTUATOR_HUE);
|
||||
|
||||
@@ -36,7 +36,13 @@ export const OneButton = {
|
||||
.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");
|
||||
.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);
|
||||
@@ -47,16 +53,16 @@ export const OneButton = {
|
||||
|
||||
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");
|
||||
.appendField(new Blockly.FieldDropdown(this.TCS34725_COLOR), "TCS34725_COLOR");
|
||||
this.setInputsInline(true);
|
||||
this.setOutput(true);
|
||||
}
|
||||
},
|
||||
TCS34725_COLOR: [
|
||||
[Blockly.Msg.COLOUR_RGB_RED, "r"],
|
||||
[Blockly.Msg.COLOUR_RGB_GREEN, "g"],
|
||||
[Blockly.Msg.COLOUR_RGB_BLUE, "b"],
|
||||
]
|
||||
};
|
||||
@@ -60,7 +60,10 @@ export const serial_print = {
|
||||
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");
|
||||
.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);
|
||||
@@ -73,24 +76,34 @@ export const serial_println = {
|
||||
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");
|
||||
.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(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")
|
||||
.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);
|
||||
@@ -142,7 +155,12 @@ export const serial_parseInt_Float = {
|
||||
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");
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["read", "read"],
|
||||
["peek", "peek"],
|
||||
["parseInt", "parseInt"],
|
||||
["parseFloat", "parseFloat"]
|
||||
]), "STAT");
|
||||
this.setOutput(true, Number);
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function () {
|
||||
@@ -167,6 +185,7 @@ export const serial_flush = {
|
||||
this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_SERIAL_FLUSH);
|
||||
}
|
||||
};
|
||||
|
||||
export const serial_softserial = {
|
||||
init: function () {
|
||||
this.setColour(SERIAL_HUE);
|
||||
|
||||
@@ -14,10 +14,6 @@ export const initialize_spiffs = {
|
||||
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 = {
|
||||
@@ -33,14 +29,19 @@ export const spiffs_open_file = {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_MODE);
|
||||
this.appendDummyInput()
|
||||
.appendField(new Blockly.FieldDropdown(OPEN_MODE), 'MODE');
|
||||
.appendField(new Blockly.FieldDropdown(this.OPEN_MODE), 'MODE');
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(STORAGE_HUE);
|
||||
this.setTooltip("");
|
||||
this.setHelpUrl("");
|
||||
}
|
||||
},
|
||||
OPEN_MODE: [
|
||||
[Blockly.Msg.MIXLY_READONLY, 'FILE_READ'],
|
||||
[Blockly.Msg.TEXT_WRITE_TEXT, 'FILE_WRITE'],
|
||||
[Blockly.Msg.TEXT_APPEND_APPENDTEXT, 'FILE_APPEND']
|
||||
]
|
||||
};
|
||||
|
||||
//打开文件并向其中写入数据
|
||||
@@ -58,6 +59,7 @@ export const spiffs_close_file = {
|
||||
this.setHelpUrl("");
|
||||
}
|
||||
};
|
||||
|
||||
//将数据追加到文件
|
||||
export const spiffs_write_data = {
|
||||
init: function () {
|
||||
@@ -77,6 +79,7 @@ export const spiffs_write_data = {
|
||||
this.setHelpUrl("");
|
||||
}
|
||||
};
|
||||
|
||||
//文件可读
|
||||
export const spiffs_read_available = {
|
||||
init: function () {
|
||||
|
||||
Reference in New Issue
Block a user