Merge pull request #237 from sensebox/dev/button_asSwitch
add Button as Switch
This commit is contained in:
commit
abce42f764
@ -336,6 +336,7 @@ Blockly.Blocks["sensebox_button"] = {
|
|||||||
[Blockly.Msg.senseBox_button_isPressed, "isPressed"],
|
[Blockly.Msg.senseBox_button_isPressed, "isPressed"],
|
||||||
[Blockly.Msg.senseBox_button_wasPressed, "wasPressed"],
|
[Blockly.Msg.senseBox_button_wasPressed, "wasPressed"],
|
||||||
[Blockly.Msg.senseBox_button_longPress, "longPress"],
|
[Blockly.Msg.senseBox_button_longPress, "longPress"],
|
||||||
|
[Blockly.Msg.senseBox_button_switch,"toggleButton"]
|
||||||
]),
|
]),
|
||||||
"FUNCTION"
|
"FUNCTION"
|
||||||
)
|
)
|
||||||
|
@ -399,6 +399,7 @@ Blockly.Arduino.sensebox_button = function () {
|
|||||||
Blockly.Arduino.libraries_[
|
Blockly.Arduino.libraries_[
|
||||||
"library_jcButtons"
|
"library_jcButtons"
|
||||||
] = `#include <JC_Button.h> // http://librarymanager/All#JC_Button`;
|
] = `#include <JC_Button.h> // http://librarymanager/All#JC_Button`;
|
||||||
|
|
||||||
Blockly.Arduino.definitions_["define_button" + dropdown_pin + ""] =
|
Blockly.Arduino.definitions_["define_button" + dropdown_pin + ""] =
|
||||||
"Button button_" + dropdown_pin + "(" + dropdown_pin + ");";
|
"Button button_" + dropdown_pin + "(" + dropdown_pin + ");";
|
||||||
Blockly.Arduino.setupCode_["setup_button" + dropdown_pin + ""] =
|
Blockly.Arduino.setupCode_["setup_button" + dropdown_pin + ""] =
|
||||||
@ -413,6 +414,10 @@ Blockly.Arduino.sensebox_button = function () {
|
|||||||
} else if (dropown_function === "longPress") {
|
} else if (dropown_function === "longPress") {
|
||||||
var time = this.getFieldValue("time");
|
var time = this.getFieldValue("time");
|
||||||
code = "button_" + dropdown_pin + ".pressedFor(" + time + ")";
|
code = "button_" + dropdown_pin + ".pressedFor(" + time + ")";
|
||||||
|
} else if (dropown_function === "toggleButton") {
|
||||||
|
code = "button_" + dropdown_pin + ".toggleState()";
|
||||||
|
Blockly.Arduino.definitions_["define_button" + dropdown_pin + ""] =
|
||||||
|
"ToggleButton button_" + dropdown_pin + "(" + dropdown_pin + ");";
|
||||||
}
|
}
|
||||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user