Skip to content

Commit ac1c818

Browse files
committed
Many things...
1 parent 2d7d206 commit ac1c818

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3074
-1040
lines changed

app.js

+286-398
Large diffs are not rendered by default.

blockly

blocks/break.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@ Blockly.Blocks['uprog_break'] = {
44
this.setColour(Blockly.Blocks.loops.HUE);
55
this.setPreviousStatement(true);
66
this.setNextStatement(true);
7-
var x = this.appendDummyInput();
8-
this.i18n();
9-
},
10-
i18n: function() {
7+
// var x = this.appendDummyInput();
118
if ( App.language === 'fr' ) {
129
//this.setHelpUrl(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_HELPURL);
13-
x.appendField("SORTIR");
10+
this.appendDummyInput().appendField("SORTIR");
1411
this.setTooltip("Sort de la boucle.");
1512
}
1613
else {
17-
x.appendField("BREAK");
14+
this.appendDummyInput().appendField("BREAK");
1815
this.setTooltip("Break out of loop.");
1916
}
20-
}
17+
},
18+
i18n: function() {}
2119
};
2220

2321

blocks/io.js

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
2+
/* Copyright (c) 2016 Christophe Duparquet.
3+
* http://github.com/duparq/uprog
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
6+
* use this file except in compliance with the License.
7+
*
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*/
11+
12+
'use strict';
13+
14+
15+
Blockly.Blocks['uprog_io_get'] = {
16+
/**
17+
* Block for variable getter.
18+
* @this Blockly.Block
19+
*/
20+
init: function() {
21+
this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL);
22+
this.setColour(60);
23+
this.appendDummyInput()
24+
.appendField(new Blockly.FieldIo(null,'w'), 'VAR');
25+
this.setOutput(true);
26+
this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP);
27+
this.contextMenuMsg_ = Blockly.Msg.VARIABLES_GET_CREATE_SET;
28+
},
29+
contextMenuType_: 'variables_set',
30+
/**
31+
* Add menu option to create getter/setter block for this setter/getter.
32+
* @param {!Array} options List of menu options to add to.
33+
* @this Blockly.Block
34+
*/
35+
// customContextMenu: function(options) {
36+
// var option = {enabled: true};
37+
// var name = this.getFieldValue('VAR');
38+
// option.text = this.contextMenuMsg_.replace('%1', name);
39+
// var xmlField = goog.dom.createDom('field', null, name);
40+
// xmlField.setAttribute('name', 'VAR');
41+
// var xmlBlock = goog.dom.createDom('block', null, xmlField);
42+
// xmlBlock.setAttribute('type', this.contextMenuType_);
43+
// option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);
44+
// options.push(option);
45+
// }
46+
// customContextMenu: Blockly.Blocks['variables_set'].customContextMenu,
47+
};
48+
49+
50+
Blockly.JavaScript['uprog_io_get'] = function ( block )
51+
{
52+
var key1 = block.getFieldValue('VAR');
53+
var code = "__hw_read_io__('"+key1+"')";
54+
return [code, Blockly.JavaScript.ORDER_ATOMIC];
55+
};
56+
57+
Blockly.Blocks['uprog_io_set'] = {
58+
init: function() {
59+
this.appendValueInput("VALUE").setCheck(null)
60+
.appendField(new Blockly.FieldIo(null,'w'), "VAR")
61+
.appendField(new Blockly.FieldImage( "blocks/variable_set.svg", 20, 16, "<-" ));
62+
this.setPreviousStatement(true, null);
63+
this.setNextStatement(true, null);
64+
this.setColour(60);
65+
this.contextMenuMsg_ = Blockly.Msg.VARIABLES_SET_CREATE_GET;
66+
if ( App.language === 'fr' ) {
67+
//this.setHelpUrl(Blockly.Msg.CONTROLS_WHILEUNTIL_HELPURL);
68+
this.setTooltip("Fixe l'état logique de la broche.");
69+
// this.message0 = "Fix %1 to %2";
70+
}
71+
else {
72+
this.setTooltip("Set the pin state.");
73+
}
74+
},
75+
contextMenuType_: 'variables_get',
76+
// customContextMenu: Blockly.Blocks['variables_get'].customContextMenu,
77+
};
78+
79+
80+
Blockly.JavaScript['uprog_io_set'] = function ( block )
81+
{
82+
var key1 = block.getFieldValue('VAR');
83+
var value = Blockly.JavaScript.valueToCode(
84+
block, 'VALUE', Blockly.JavaScript.ORDER_ASSIGNMENT) || '0';
85+
var code = "__hw_write_io__('"+key1+"',"+value+");\n";
86+
87+
return code;
88+
};

0 commit comments

Comments
 (0)