support for brightness
This commit is contained in:
Родитель
a2ca46648e
Коммит
4b1fcb5520
|
@ -145,6 +145,8 @@ Blockly.Blocks['device_set_digital_pin'] = {
|
|||
.setCheck("pin_type")
|
||||
.appendField("to pin");
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
@ -175,6 +177,34 @@ Blockly.Blocks['device_set_analog_pin'] = {
|
|||
.setCheck("pin_type")
|
||||
.appendField("to pin");
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['device_get_brightness'] = {
|
||||
init: function () {
|
||||
this.setHelpUrl('http://www.example.com/');
|
||||
this.setColour(160);
|
||||
this.appendDummyInput()
|
||||
.appendField("brightness");
|
||||
this.setOutput(true, "Number");
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['device_set_brightness'] = {
|
||||
init: function () {
|
||||
this.setHelpUrl('http://www.example.com/');
|
||||
this.setColour(160);
|
||||
this.appendDummyInput()
|
||||
.appendField("set brightness (%)");
|
||||
this.appendValueInput("value")
|
||||
.setCheck("Number");
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip('');
|
||||
}
|
||||
};
|
||||
|
|
|
@ -639,6 +639,7 @@ function compileBuildImage(e: Environment, b: B.Block, big: boolean): J.JCall {
|
|||
}
|
||||
|
||||
var stdCallTable: { [blockName: string]: { f: string; args: string[] }} = {
|
||||
device_clear_display: { f: "clear display", args: [] },
|
||||
device_show_letter: { f: "show letter", args: ["letter"] },
|
||||
device_pause: { f: "pause", args: ["pause"] },
|
||||
device_print_message: { f: "print string", args: ["message", "pausetime"] },
|
||||
|
@ -655,6 +656,8 @@ var stdCallTable: { [blockName: string]: { f: string; args: string[] }} = {
|
|||
device_set_digital_pin: { f: "digital write pin", args: ["name", "value"] },
|
||||
device_get_analog_pin: { f: "analog read pin", args: ["name"] },
|
||||
device_set_analog_pin: { f: "analog write pin", args: ["name", "value"] },
|
||||
device_get_brightness: { f: "brightness", args: [] },
|
||||
device_set_brightness: { f: "set brightness", args: ["value"] },
|
||||
}
|
||||
|
||||
function compileStatements(e: Environment, b: B.Block): J.JStmt[] {
|
||||
|
|
|
@ -119,6 +119,16 @@
|
|||
</block>
|
||||
</value>
|
||||
</block>
|
||||
|
||||
<block type="device_get_brightness"></block>
|
||||
<block type="device_set_brightness">
|
||||
<value name="value">
|
||||
<block type="math_number">
|
||||
<field name="NUM">100</field>
|
||||
</block>
|
||||
</value>
|
||||
</block>
|
||||
|
||||
</category>
|
||||
<category name="Images">
|
||||
<block type="device_make_StringImage">
|
||||
|
|
Загрузка…
Ссылка в новой задаче