Skip to content

Commit

Permalink
032524
Browse files Browse the repository at this point in the history
  • Loading branch information
puttley committed Mar 25, 2024
1 parent 965b2ee commit 0395ce0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ <h1><!--a href="https://www.pitsco.com"> PITSCO LUMA Robot</a-->
</block>
<block type="get_color_rgbc_byte"></block>
<block type="get_temperature_humidity"></block>
<block type="get_rotary_sensor"></block>
<block type="get_sensor_port_value"></block>
<block type="get_encoder"></block>
<block type="reset_encoders"></block>
Expand Down
14 changes: 14 additions & 0 deletions msl_blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,20 @@ Blockly.Blocks['get_temperature_humidity'] = {
}
};

Blockly.Blocks['get_rotary_sensor'] = {
init: function() {
this.appendDummyInput()
.appendField("port")
.appendField(new Blockly.FieldDropdown([["1","1"], ["2","2"], ["3","3"], ["4","4"], ["5","5"]]), "port")
.appendField("rotary sensor | get value");
this.setInputsInline(true);
this.setOutput(true, null);
this.setColour("#ec5b13");
this.setTooltip("Returns the value of the rotary angle sensor knob position. Min / Max = 0 - 100.");
this.setHelpUrl("");
}
};


Blockly.Blocks['get_sensor_port_value'] = {
init: function() {
Expand Down
6 changes: 6 additions & 0 deletions msl_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,12 @@ Blockly.Python['get_temperature_humidity'] = function(block) {
return [code, Blockly.Python.ORDER_NONE];
};

Blockly.Python['get_rotary_sensor'] = function(block) {
var dropdown_port = block.getFieldValue('port');
var code = 'skr.getRotarySensor(' + dropdown_port + ')';
return [code, Blockly.Python.ORDER_NONE];
};

Blockly.Python['get_sensor_port_value'] = function(block) {
var dropdown_port = block.getFieldValue('port');
var dropdown_type = block.getFieldValue('type');
Expand Down

0 comments on commit 0395ce0

Please sign in to comment.