Skip to content

Commit

Permalink
duty_cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
ioanaculic committed Nov 5, 2024
1 parent e17147c commit eb99dcf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@ module.exports = function (blockly) {
Blockly.Python.import_machine();
var duty_cycle = Blockly.Python.valueToCode(block, 'duty_cycle', Blockly.Python.ORDER_ATOMIC);
var pin_name = block.getFieldValue('pin_name').toString();

console.log (duty_cycle);
console.log ( Math.max (duty_cycle, 0));
console.log (Math.min(100, Math.max (duty_cycle, 0)));
console.log (Math.min(100, Math.max (duty_cycle, 0)) * 65535 / 100);
console.log (Math.floor(Math.min(100, Math.max (duty_cycle, 0)) * 65535 / 100));
console.log (parseInt(Math.floor(Math.min(100, Math.max (duty_cycle, 0)) * 65535 / 100)));

duty_cycle = parseInt(Math.floor(Math.min(100, Math.max (duty_cycle, 0)) * 65535 / 100));

var code = pin_name + '.duty_u16(' + duty_cycle + ')\n';
return code;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ module.exports = function (blockly) {
this.appendValueInput('duty_cycle')
.appendField('Set duty cycle');
this.appendDummyInput()
.appendField('% for pin')
.appendField('for pin')
.appendField(new Blockly.FieldTextInput('pinName1'), 'pin_name');
this.setPreviousStatement(true);
this.setNextStatement(true);
Expand Down

0 comments on commit eb99dcf

Please sign in to comment.