Skip to content

Commit 87730e7

Browse files
authored
Merge pull request #1041 from MatzElectronics/demo
2 parents 5a68a8c + 067ff0e commit 87730e7

File tree

9 files changed

+253
-91
lines changed

9 files changed

+253
-91
lines changed

src/main/resources/com/parallax/server/blocklyprop/internationalization/translations.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ category.communicate = Communicate
262262
category.communicate.serial-lcd = Serial LCD
263263
category.communicate.serial-terminal = Terminal
264264
category.communicate.oled = OLED
265-
category.communicate.graphing = Graphing Output
265+
category.communicate.graphing = Graph
266266
category.communicate.protocols = Protocols
267267
category.communicate.xbee = XBee
268268
category.communicate.WS2812B = RGB LEDs

src/main/webapp/WEB-INF/includes/pageparts/editor-menu.jsp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<%@page contentType="text/html" pageEncoding="UTF-8"%>
88
<%@ include file="/WEB-INF/includes/include.jsp"%>
99

10+
<c:set var="experimental" scope="page" value="${properties:experimentalmenu(false)}" />
11+
1012
<nav class="navbar navbar-default clearfix" role="navigation">
1113
<div style="width:100%;">
1214
<div style="display:inline;"><span><a id="nav-logo" href="<url:getUrl url="/"/>">BlocklyProp<br><strong>BETA</strong></a></span>
@@ -47,11 +49,14 @@
4749
</c:if>
4850
<a onclick="loadIntoEeprom()" data-toggle="tooltip" title="Load and run (save code to EEPROM)" data-placement="bottom" class="btn btn-success btn-circle"><i class="glyphicon glyphicon-save"></i></a>
4951
<a onclick="serial_console()" data-toggle="tooltip" title="Open Serial Terminal" data-placement="bottom" class="btn btn-primary btn-circle"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="15"><rect x="1" y="1" width="12" height="13" rx="1" ry="1" style="stroke:#fff;stroke-width:2;fill:none;"/><path d="M3,4.5 L10,4.5 M3,6.5 L6,6.5 M3,8.5 L8,8.5" style="stroke:#fff;stroke-width:1;fill:none;"/></svg></a>
50-
<% if ("1".equals(request.getParameter("graphing"))) {%>
51-
<a onclick="graphing_console()" data-toggle="tooltip" title="Open Graphing Output" data-placement="bottom" class="btn btn-primary btn-circle"><svg xmlns="http://www.w3.org/2000/svg" width="13" height="14">
52-
<path d="M.5,0 L.5,13.5 L12.5,13.5 M3.5,0 L3.5,13.5 M6.5,0 L6.5,13.5 M9.5,0 L9.5,13.5 M12.5,0 L12.5,13.5 M.5,3.5 L12.5,3.5 M.5,7 L12.5,7 M.5,10.5 L12.5,10.5 M.5,.5 L12.5,.5" style="stroke:rgba(255,255,255,.6);stroke-width:1;fill:none;"/>
53-
<path d="M0,13 L6,5 L9,8 L14,2" style="stroke:#fff;stroke-width:2;fill:none;"/>
54-
</svg></a><% } %>
52+
<c:choose>
53+
<c:when test="${experimental == true}">
54+
<a onclick="graphing_console()" data-toggle="tooltip" title="Open Graphing Output" data-placement="bottom" class="btn btn-primary btn-circle"><svg xmlns="http://www.w3.org/2000/svg" width="13" height="14">
55+
<path d="M.5,0 L.5,13.5 L12.5,13.5 M3.5,0 L3.5,13.5 M6.5,0 L6.5,13.5 M9.5,0 L9.5,13.5 M12.5,0 L12.5,13.5 M.5,3.5 L12.5,3.5 M.5,7 L12.5,7 M.5,10.5 L12.5,10.5 M.5,.5 L12.5,.5" style="stroke:rgba(255,255,255,.6);stroke-width:1;fill:none;"/>
56+
<path d="M0,13 L6,5 L9,8 L14,2" style="stroke:#fff;stroke-width:2;fill:none;"/>
57+
</svg></a>
58+
</c:when>
59+
</c:choose>
5560
</div>
5661
<div style="display:inline; clear:right; float:right; padding-right: 10px;" align="right">
5762

@@ -88,7 +93,6 @@
8893
<li><a id="upload-project" href="#"><fmt:message key="editor.upload" /></a></li>
8994
<hr style="line-height:5px; margin:5px;">
9095
<li><a href="#" onclick="configure_client()"><fmt:message key="editor.run.configure" /></a></li>
91-
9296
</ul></span>
9397
</div>
9498
</div>

src/main/webapp/cdn/blockly/generators/propc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,7 @@ Blockly.propc.finish = function (code) {
403403
var setup = '';
404404
if (Blockly.propc.serial_terminal_) {
405405
setup += "/* SERIAL_TERMINAL USED */\n";
406-
}
407-
if (Blockly.propc.serial_graphing_) {
406+
} else if (Blockly.propc.serial_graphing_) {
408407
setup += "/* SERIAL_GRAPHING USED */\n";
409408
}
410409
if (Blockly.mainWorkspace.getAllBlocks().length === 0) {

src/main/webapp/cdn/blockly/generators/propc/communicate.js

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3168,19 +3168,17 @@ Blockly.Blocks.graph_output = {
31683168
// this.setTooltip(Blockly.MSG_GRAPH_OUTPUT_TOOLTIP);
31693169
this.setColour(colorPalette.getColor('protocols'));
31703170
this.appendDummyInput()
3171-
.appendField('Graphing output');
3171+
.appendField('Graph');
31723172
this.appendValueInput('PRINTa')
31733173
.setAlign(Blockly.ALIGN_RIGHT)
31743174
.setCheck('Number')
3175-
.appendField('value');
3176-
this.appendValueInput('PRINTb')
3177-
.setAlign(Blockly.ALIGN_RIGHT)
3178-
.setCheck('Number')
3175+
.appendField(new Blockly.FieldTextInput(''), 'GRAPH_LABELa')
31793176
.appendField('value');
31803177
this.setPreviousStatement(true);
31813178
this.setNextStatement(true);
31823179
this.setMutator(new Blockly.Mutator(['graph_dec']));
3183-
this.optionList_ = ['dec', 'dec'];
3180+
this.optionList_ = ['dec'];
3181+
this.graph_labels_ = [];
31843182
},
31853183
mutationToDom: function (workspace) {
31863184
// Create XML to represent menu options.
@@ -3195,6 +3193,7 @@ Blockly.Blocks.graph_output = {
31953193
for (var i = 0; i < this.optionList_.length; i++) {
31963194
this.appendValueInput('PRINT' + i)
31973195
.setAlign(Blockly.ALIGN_RIGHT)
3196+
.appendField(new Blockly.FieldTextInput(''), 'GRAPH_LABEL' + i)
31983197
.appendField('value');
31993198
}
32003199
},
@@ -3208,6 +3207,13 @@ Blockly.Blocks.graph_output = {
32083207
connection.connect(optionBlock.previousConnection);
32093208
connection = optionBlock.nextConnection;
32103209
}
3210+
var i = 0;
3211+
this.graph_labels_ = null;
3212+
this.graph_labels_ = [];
3213+
while (this.getFieldValue('GRAPH_LABEL' + i)) {
3214+
this.graph_labels_.push(this.getFieldValue('GRAPH_LABEL' + i));
3215+
i++;
3216+
}
32113217
return containerBlock;
32123218

32133219
},
@@ -3218,7 +3224,6 @@ Blockly.Blocks.graph_output = {
32183224
this.removeInput('PRINT' + i);
32193225
i++;
32203226
}
3221-
32223227
i = 0;
32233228
this.optionList_.length = 0;
32243229
// Rebuild the block's optional inputs.
@@ -3229,6 +3234,7 @@ Blockly.Blocks.graph_output = {
32293234
var printInput = this.appendValueInput('PRINT' + i)
32303235
.setAlign(Blockly.ALIGN_RIGHT)
32313236
.setCheck('Number')
3237+
.appendField(new Blockly.FieldTextInput('label'), 'GRAPH_LABEL' + i)
32323238
.appendField('value');
32333239

32343240
if (clauseBlock.valueConnection_) {
@@ -3239,6 +3245,11 @@ Blockly.Blocks.graph_output = {
32393245
clauseBlock = clauseBlock.nextConnection &&
32403246
clauseBlock.nextConnection.targetBlock();
32413247
}
3248+
i = this.graph_labels_.length;
3249+
for (i = 0; i < this.graph_labels_.length; i++) {
3250+
if (this.getFieldValue('GRAPH_LABEL' + i))
3251+
this.setFieldValue(this.graph_labels_[i], 'GRAPH_LABEL' + i);
3252+
}
32423253
},
32433254
saveConnections: function (containerBlock) {
32443255
// Store a pointer to any connected child blocks.
@@ -3254,6 +3265,14 @@ Blockly.Blocks.graph_output = {
32543265
clauseBlock = clauseBlock.nextConnection &&
32553266
clauseBlock.nextConnection.targetBlock();
32563267
}
3268+
var i = 0;
3269+
this.graph_labels_ = null;
3270+
this.graph_labels_ = [];
3271+
while (this.getFieldValue('GRAPH_LABEL' + i)) {
3272+
this.graph_labels_.push(this.getFieldValue('GRAPH_LABEL' + i));
3273+
i++;
3274+
}
3275+
32573276
},
32583277
onchange: function () {
32593278
if (this.workspace && this.optionList_.length < 1) {
@@ -3266,7 +3285,7 @@ Blockly.Blocks.graph_output = {
32663285
}
32673286
if (this.getInput('PRINT0') && this.getInput('PRINTa')) {
32683287
this.removeInput('PRINTa');
3269-
this.removeInput('PRINTb');
3288+
//this.removeInput('PRINTb');
32703289
}
32713290
}
32723291
};
@@ -3298,18 +3317,23 @@ Blockly.propc.graph_output = function () {
32983317

32993318
var code = 'print("%u';
33003319
var varList = '';
3320+
var labelList = '';
33013321
var i = 0;
33023322
var orIt = '';
33033323
while (Blockly.propc.valueToCode(this, 'PRINT' + i, Blockly.propc.ORDER_NONE)) {
33043324
code += ',%d';
33053325
varList += ', ' + Blockly.propc.valueToCode(this, 'PRINT' + i, Blockly.propc.NONE || '0');
3326+
labelList += this.getFieldValue("GRAPH_LABEL" + i);
3327+
if (Blockly.propc.valueToCode(this, 'PRINT' + (i + 1), Blockly.propc.ORDER_NONE) && i < 9)
3328+
labelList += ',';
33063329
i++;
33073330
if (i > 10)
33083331
break;
33093332
}
33103333
code += '\\r", (CNT >> 16)' + varList + ');\n';
33113334

33123335
Blockly.propc.serial_graphing_ = true;
3336+
Blockly.propc.definitions_['graphing_labels'] = '// GRAPH_LABELS_START:' + labelList + ':GRAPH_LABELS_END //';
33133337

33143338
return code;
33153339
};
@@ -3320,25 +3344,23 @@ Blockly.Blocks.graph_settings = {
33203344
// this.setTooltip(Blockly.MSG_GRAPH_SETTINGS_TOOLTIP);
33213345
this.setColour(colorPalette.getColor('protocols'));
33223346
this.appendDummyInput()
3323-
.appendField("Graph settings");
3324-
this.appendDummyInput()
3325-
.appendField("x-axis")
3347+
.appendField("Graph initialize x-axis")
33263348
.appendField(new Blockly.FieldDropdown([
3327-
["keep 10 seconds of data", "10,S"],
3328-
["keep 20 seconds of data", "20,S"],
3329-
["keep 30 seconds of data", "30,S"],
3330-
["keep 40 seconds of data", "40,S"],
3331-
["keep 50 seconds of data", "50,S"],
3332-
["keep 60 seconds of data", "60,S"],
3333-
["keep 90 seconds of data", "90,S"] // Add comma back when resetting
3349+
["10 seconds", "10,S"],
3350+
["20 seconds", "20,S"],
3351+
["30 seconds", "30,S"],
3352+
["40 seconds", "40,S"],
3353+
["50 seconds", "50,S"],
3354+
["60 seconds", "60,S"],
3355+
["90 seconds", "90,S"] // Add comma back when resetting
33343356
// ["trigger on value 1 rising edge", "1,TU"],
33353357
// ["trigger on value 1 falling edge", "1,TD"],
33363358
// ["trigger on value 1 zero crossing", "1,TZ"]
3337-
]), "XAXIS");
3338-
this.appendDummyInput()
3359+
]), "XAXIS")
3360+
.appendField('y-axis ')
33393361
.appendField(new Blockly.FieldDropdown([
3340-
["y-axis autoscale", "AUTO"],
3341-
["y-axis range", "FIXED"]]), "YSETTING")
3362+
["autoscale", "AUTO"],
3363+
["range", "FIXED"]]), "YSETTING")
33423364
.appendField("minimum", 'LABELMIN')
33433365
.appendField(new Blockly.FieldTextInput('0',
33443366
Blockly.FieldTextInput.numberValidator), "YMIN")
@@ -3361,6 +3383,7 @@ Blockly.Blocks.graph_settings = {
33613383
this.setInputsInline(false);
33623384
this.setPreviousStatement(true, null);
33633385
this.setNextStatement(true, null);
3386+
this.render();
33643387
},
33653388
onchange: function () {
33663389
if (this.getFieldValue('YSETTING') === 'AUTO') {

0 commit comments

Comments
 (0)