Commit 02016bc6 authored by carlosperate's avatar carlosperate

Update serial block.

parent 24c42b23
...@@ -14,27 +14,22 @@ ...@@ -14,27 +14,22 @@
## Python 3 specific ## Python 3 specific
- [x] ~~When a sketch is send to the IDE using python 3 the following error is shown (tested on linux):~~
```
Can't convert 'bytes' object to str implicitly
There was an error manipulating the sketch data!!
```
## Server ## Server
- [ ] Complete `compilerserttings` module unite test - [ ] Complete `compilerserttings` module unite test
- [ ] Complete `actions` module unit test module - [ ] Complete `actions` module unit test module
- [x] ~~Complete `SketchCreator` module unit test~~
- [x] ~~Combine Arduino boards from code generator with Arduino boards offered for compilation~~
## Blockly general ## Blockly general
- [ ] Expand `setWarning` to be able to buffer and manage several warnings per block (add an ID to a block of text) - [x] ~~Expand `setWarning` to be able to buffer and manage several warnings per block (add an ID to a block of text)~~
- [ ] Implement the zoom feature from @carloslfu once matured - [ ] Implement the zoom feature from @carloslfu once properly tested and matured
- [x] ~~Add setup and loop functions to the custom toolbox flyout and ensure only one instance can be included in workspace~~
- [ ] Arduino setup and loop block can be copy/pasted using keyboard shorcuts, stop this from happening
## Static typing ## Static typing
- [ ] logic_ternary block getType to defines type as that of its inputs - [ ] logic_ternary block getType to defines type as that of its inputs
- [ ] logic_null block right now does not return a type, this might change - [ ] logic_null block right now does not return a type, this might change
- [x] math_number block 'errornumber' type used for debugging, remove - [ ] math_number block 'errornumber' type used for debugging, remove
- [ ] math_arithmetic getType to check types of given inputs to decide between int or float . Right now first block within sets the type. - [ ] math_arithmetic getType to check types of given inputs to decide between int or float . Right now first block within sets the type.
- [ ] math_constrain getType to check types of given inputs to decide between int or float . Right now first block within sets the type. - [ ] math_constrain getType to check types of given inputs to decide between int or float . Right now first block within sets the type.
- [ ] math_number getType to use regular expressions more efficiently - [ ] math_number getType to use regular expressions more efficiently
...@@ -48,6 +43,7 @@ There was an error manipulating the sketch data!! ...@@ -48,6 +43,7 @@ There was an error manipulating the sketch data!!
## Arduino generator related code ## Arduino generator related code
- [x] ~~Add information for other Arduino boards~~ - [x] ~~Add information for other Arduino boards~~
- [x] ~~Add a way to switch Arduino boards dynamically~~
- [ ] Text trim does not currently generate Arduino valid code - [ ] Text trim does not currently generate Arduino valid code
## Arduino blocks ## Arduino blocks
...@@ -62,11 +58,13 @@ There was an error manipulating the sketch data!! ...@@ -62,11 +58,13 @@ There was an error manipulating the sketch data!!
## Arduino front end ## Arduino front end
- [ ] ~~Edit toolbox fade out + visibility button fade in with a CSS animated change in height with overflow hidden~~ - [x] ~~Edit toolbox fade out + visibility button fade in with a CSS animated change in height with overflow hidden~~
- [ ] Remove old IDE output text while waiting for a new verify/open/upload - [ ] Remove old IDE output text while waiting for a new verify/open/upload
# Future features # Future features
- [ ] Block creator app that also used blockly to create the generator code
- [ ] Server component of the block creator to add files into folder and client side update to read them and include them into the toolbox
- [ ] Serial console for comms with Arduino - [ ] Serial console for comms with Arduino
- [ ] Serial data graphing - [ ] Serial data graphing
- [ ] Auto updating for the desktop app - [ ] Auto updating for the desktop app
...@@ -16,8 +16,47 @@ goog.provide('Blockly.Blocks.Arduino.serial'); ...@@ -16,8 +16,47 @@ goog.provide('Blockly.Blocks.Arduino.serial');
goog.require('Blockly.Arduino'); goog.require('Blockly.Arduino');
/** Common HSV hue for all blocks in this category. */
Blockly.Blocks.Arduino.serial.HUE = 160; Blockly.Blocks.Arduino.serial.HUE = 160;
Blockly.Blocks['serial_setup'] = {
/**
* Block for setting the speed of the serial connection.
* @this Blockly.Block
*/
init: function() {
this.setHelpUrl('http://arduino.cc/en/Serial/Begin');
this.setColour(Blockly.Blocks.Arduino.serial.HUE);
this.appendDummyInput()
.appendField('Setup')
.appendField(
new Blockly.FieldDropdown(
Blockly.Arduino.Boards.selected.serial), 'SERIAL_ID')
.appendField(': speed to')
.appendField(
new Blockly.FieldDropdown(
Blockly.Arduino.Boards.selected.serialSpeed), 'SPEED')
.appendField('bps');
this.setInputsInline(true);
this.setTooltip('Selects the speed for a specific Serial peripheral');
},
/**
* Returns the serial instance name.
* @return {!string} Serial instance name.
* @this Blockly.Block
*/
getSerialSetupInstance: function() {
return this.getFieldValue('SERIAL_ID');;
},
/** Updates the content of the the serial related fields. */
updateFields: function() {
Blockly.Arduino.Boards.refreshBlockFieldDropdown(
this, 'SERIAL_ID', 'serial');
Blockly.Arduino.Boards.refreshBlockFieldDropdown(
this, 'SPEED', 'serialSpeed');
}
};
Blockly.Blocks['serial_print'] = { Blockly.Blocks['serial_print'] = {
/** /**
* Block for creating a write to serial com function. * Block for creating a write to serial com function.
...@@ -51,7 +90,7 @@ Blockly.Blocks['serial_print'] = { ...@@ -51,7 +90,7 @@ Blockly.Blocks['serial_print'] = {
if (!this.workspace) { return; } // Block has been deleted. if (!this.workspace) { return; } // Block has been deleted.
// Get the Serial instance from this block // Get the Serial instance from this block
var InstanceName = this.getFieldValue('SERIAL_ID'); var thisInstanceName = this.getFieldValue('SERIAL_ID');
// Iterate through blocks to find a setup instance for the same serial id. // Iterate through blocks to find a setup instance for the same serial id.
var blocks = Blockly.mainWorkspace.getAllBlocks(); var blocks = Blockly.mainWorkspace.getAllBlocks();
...@@ -60,16 +99,16 @@ Blockly.Blocks['serial_print'] = { ...@@ -60,16 +99,16 @@ Blockly.Blocks['serial_print'] = {
var func = blocks[x].getSerialSetupInstance; var func = blocks[x].getSerialSetupInstance;
if (func) { if (func) {
var setupBlockInstanceName = func.call(blocks[x]); var setupBlockInstanceName = func.call(blocks[x]);
if (InstanceName == setupBlockInstanceName) { if (thisInstanceName == setupBlockInstanceName) {
setupInstancePresent = true; setupInstancePresent = true;
} }
} }
} }
if (!setupInstancePresent) { if (!setupInstancePresent) {
this.setWarningText('A setup block for '+ InstanceName + ' must be ' + this.setWarningText(
'added to the workspace to use this block!', 'A setup block for '+ thisInstanceName + ' must be added to the ' +
'serial_setup'); 'workspace to use this block!', 'serial_setup');
} else { } else {
this.setWarningText(null, 'serial_setup'); this.setWarningText(null, 'serial_setup');
} }
...@@ -79,43 +118,4 @@ Blockly.Blocks['serial_print'] = { ...@@ -79,43 +118,4 @@ Blockly.Blocks['serial_print'] = {
Blockly.Arduino.Boards.refreshBlockFieldDropdown( Blockly.Arduino.Boards.refreshBlockFieldDropdown(
this, 'SERIAL_ID', 'serial'); this, 'SERIAL_ID', 'serial');
} }
}; };
\ No newline at end of file
Blockly.Blocks['serial_setup'] = {
/**
* Block for setting the speed of the serial connection.
* @this Blockly.Block
*/
init: function() {
this.setHelpUrl('http://arduino.cc/en/Serial/Begin');
this.setColour(Blockly.Blocks.Arduino.serial.HUE);
this.appendDummyInput()
.appendField('setup: ')
.appendField(
new Blockly.FieldDropdown(
Blockly.Arduino.Boards.selected.serial), 'SERIAL_ID')
.appendField('speed')
.appendField(
new Blockly.FieldDropdown(
Blockly.Arduino.Boards.selected.serialSpeed), 'SPEED')
.appendField('bps');
this.setInputsInline(true);
this.setTooltip('Selects the speed for a specific Serial peripheral');
},
/**
* Returns the serial_setup instance name, defined in the 'SERIAL_ID' drop
* down of this block.
* @return {!Array.<string>} List with the instance name.
* @this Blockly.Block
*/
getSerialSetupInstance: function() {
return this.getFieldValue('SERIAL_ID');;
},
/** Updates the content of the the serial related fields. */
updateFields: function() {
Blockly.Arduino.Boards.refreshBlockFieldDropdown(
this, 'SERIAL_ID', 'serial');
Blockly.Arduino.Boards.refreshBlockFieldDropdown(
this, 'SPEED', 'serialSpeed');
}
};
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* The Arduino built in functions syntax can be found at: * The Arduino built in functions syntax can be found at:
* http://arduino.cc/en/Reference/HomePage * http://arduino.cc/en/Reference/HomePage
* *
* TODO: There are more function that can be added: * TODO: There are more functions that can be added:
* http://arduino.cc/en/Reference/Serial * http://arduino.cc/en/Reference/Serial
*/ */
'use strict'; 'use strict';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment