Skip to content

Commit 14f0365

Browse files
committed
Update pulseIn() block to clarify time-out
1 parent 48d7350 commit 14f0365

File tree

8 files changed

+98
-60
lines changed

8 files changed

+98
-60
lines changed

ardublockly/ardublockly_toolbox.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ Ardublockly.TOOLBOX_XML =
147147
' <shadow type="io_highlow"></shadow>' +
148148
' </value>' +
149149
' <value name="TIMEOUT">' +
150-
' <block type="math_number"></block>' +
150+
' <shadow type="math_number">' +
151+
' <field name="NUM">100</field>' +
152+
' </shadow>' +
151153
' </value>'+
152154
' </block>' +
153155
' </category>' +

blockly/blocks/arduino/io.js

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -193,50 +193,69 @@ Blockly.Blocks['io_highlow'] = {
193193
};
194194

195195
Blockly.Blocks['io_pulsein'] = {
196+
/**
197+
* Block for measuring the duration of a pulse in an input pin.
198+
* @this Blockly.Block
199+
*/
196200
init: function() {
197-
this.appendDummyInput()
198-
.appendField(Blockly.Msg.ARD_PULSEREAD);
199-
this.appendValueInput("PULSETYPE")
200-
.setCheck(Blockly.Types.BOOLEAN.check);
201-
this.appendDummyInput()
202-
.appendField(Blockly.Msg.ARD_PULSEON)
203-
.appendField(new Blockly.FieldDropdown(
204-
Blockly.Arduino.Boards.selected.digitalPins), "PULSEPIN");
205-
this.setOutput(true);
206-
this.setInputsInline(true);
207-
this.setColour(Blockly.Blocks.io.HUE);
208-
this.setTooltip(Blockly.Msg.ARD_PULSE_TIP);
209-
this.setHelpUrl('https://www.arduino.cc/en/Reference/PulseIn');
201+
this.jsonInit({
202+
"type": "math_foo",
203+
"message0": Blockly.Msg.ARD_PULSE_READ,
204+
"args0": [{
205+
"type": "input_value",
206+
"name": "PULSETYPE",
207+
"check": Blockly.Types.BOOLEAN.check
208+
}, {
209+
"type": "field_dropdown",
210+
"name": "PULSEPIN",
211+
"options": Blockly.Arduino.Boards.selected.digitalPins
212+
}
213+
],
214+
"output": Blockly.Types.NUMBER.output,
215+
"inputsInline": true,
216+
"colour": Blockly.Blocks.io.HUE,
217+
"tooltip": Blockly.Msg.ARD_PULSE_TIP,
218+
"helpUrl": 'https://www.arduino.cc/en/Reference/PulseIn'
219+
});
210220
},
211-
/** @return {!string} The type of input value for the block, an integer. */
221+
/** @return {!string} The type of input value for the block, an integer. */
212222
getBlockType: function() {
213223
return Blockly.Types.NUMBER;
214224
}
215225
};
216226

217227
Blockly.Blocks['io_pulsetimeout'] = {
228+
/**
229+
* Block for measuring (with a time-out) the duration of a pulse in an input
230+
* pin.
231+
* @this Blockly.Block
232+
*/
218233
init: function () {
219-
this.appendDummyInput()
220-
.appendField(Blockly.Msg.ARD_PULSEREAD);
221-
this.appendValueInput("PULSETYPE")
222-
.setCheck(Blockly.Types.BOOLEAN.check);
223-
this.appendDummyInput()
224-
.appendField(Blockly.Msg.ARD_PULSEON)
225-
.appendField(new Blockly.FieldDropdown(
226-
Blockly.Arduino.Boards.selected.digitalPins), "PULSEPIN");
227-
this.appendDummyInput()
228-
.appendField(Blockly.Msg.ARD_PULSETIMEOUT);
229-
this.appendValueInput('TIMEOUT')
230-
.setCheck(Blockly.Types.NUMBER.output);
231-
this.appendDummyInput()
232-
.appendField(Blockly.Msg.ARD_PULSETIMEOUT_MS);
233-
this.setOutput(true);
234-
this.setInputsInline(true);
235-
this.setColour(Blockly.Blocks.io.HUE);
236-
this.setTooltip(Blockly.Msg.ARD_PULSETIMEOUT_TIP);
237-
this.setHelpUrl('https://www.arduino.cc/en/Reference/PulseIn');
234+
this.jsonInit({
235+
"type": "math_foo",
236+
"message0": Blockly.Msg.ARD_PULSE_READ_TIMEOUT,
237+
"args0": [{
238+
"type": "input_value",
239+
"name": "PULSETYPE",
240+
"check": Blockly.Types.BOOLEAN.check
241+
}, {
242+
"type": "field_dropdown",
243+
"name": "PULSEPIN",
244+
"options": Blockly.Arduino.Boards.selected.digitalPins
245+
}, {
246+
"type": "input_value",
247+
"name": "TIMEOUT",
248+
"check": Blockly.Types.NUMBER.check
249+
}
250+
],
251+
"output": Blockly.Types.NUMBER.output,
252+
"inputsInline": true,
253+
"colour": Blockly.Blocks.io.HUE,
254+
"tooltip": Blockly.Msg.ARD_PULSETIMEOUT_TIP,
255+
"helpUrl": 'https://www.arduino.cc/en/Reference/PulseIn'
256+
});
238257
},
239-
/** @return {!string} The type of input value for the block, an integer. */
258+
/** @return {!string} The type of input value for the block, an integer. */
240259
getBlockType: function() {
241260
return Blockly.Types.NUMBER;
242261
}

blockly/msg/json/es_ardublockly.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"carlosperate"
55
]
66
},
7+
"ARD_PULSE_READ": "mide pulso %1 en pin #%2",
8+
"ARD_PULSE_READ_TIMEOUT": "mide pulso %1 en pin #%2 (agotar tiempo en %3 μs)",
9+
"ARD_PULSE_TIP": "Mide la duración de un pulso en el pin especificado.",
10+
"ARD_PULSETIMEOUT_TIP": "Mide la duración de un pulso en el pin especificado y configura el tiempo de espera en micro-segundos.",
711
"NEW_INSTANCE": "Nueva instancia...",
812
"RENAME_INSTANCE": "Renombrar la instancia...",
913
"NEW_INSTANCE_TITLE": "Nueva nombre de la instance:",

blockly/msg/json/fr_ardublockly.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,8 @@
103103
"ARD_TIME_INF_TIP": "Attente indéfinie, arrêt du programme.",
104104
"ARD_VAR_AS": "comme",
105105
"ARD_VAR_AS_TIP": "Configure une valeur à un type précis",
106-
"ARD_PULSEREAD": "Lecture",
107-
"ARD_PULSEON": "Impulsion sur le signal #",
108-
"ARD_PULSETIMEOUT": "délai de retard",
109-
"ARD_PULSETIMEOUT_MS": "",
106+
"ARD_PULSE_READ": "mesure %1 impulsion sur le signal #%2",
107+
"ARD_PULSE_READ_TIMEOUT": "mesure %1 impulsion sur le signal #%2 (délai de retard %3 μs)",
110108
"ARD_PULSE_TIP": "Mesure la durée d'une pulsation sur le signal selectioné.",
111109
"ARD_PULSETIMEOUT_TIP": "Mesure la durée d'une pulsation sur le signal selectioné, dans le delai imparti",
112110
"ARD_SETTONE": "Définir une tonalité sur le signal #",

blockly/msg/json/it_ardublockly.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,8 @@
104104
"ARD_TIME_INF_TIP": "Attende per un tempo infinito, cioè il programma termina.",
105105
"ARD_VAR_AS": "come",
106106
"ARD_VAR_AS_TIP": "Imposta un tipo di valore",
107-
"ARD_PULSEREAD": "Leggi",
108-
"ARD_PULSEON": "impulso sul pin #",
109-
"ARD_PULSETIMEOUT": "timeout dopo",
110-
"ARD_PULSETIMEOUT_MS": "",
107+
"ARD_PULSE_READ": "misura %1 impulso sul pin #%2",
108+
"ARD_PULSE_READ_TIMEOUT": "misura %1 impulso sul pin #%2 (timeout dopo %3 μs)",
111109
"ARD_PULSE_TIP": "Misura la durata di un impulso sul pin selezionato.",
112110
"ARD_PULSETIMEOUT_TIP": "Misura la durata di un impulso sul pin selezionato, se è compreso all'interno del timeout.",
113111
"ARD_SETTONE": "Imposta un tono sul pin #",

blockly/msg/json/nl_ardublockly.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,8 @@
105105
"ARD_TIME_INF_TIP": "Wacht voor altijd, stopt het programma waar deze lijn staat.",
106106
"ARD_VAR_AS": "als",
107107
"ARD_VAR_AS_TIP": "Wijzigt de waarde in het gegeven type",
108-
"ARD_PULSEREAD": "Lees een",
109-
"ARD_PULSEON": "puls op pin #",
110-
"ARD_PULSETIMEOUT": "wacht maximaal",
111-
"ARD_PULSETIMEOUT_MS": "milliseconden",
108+
"ARD_PULSE_READ": "lees een %1 puls op pin #%2",
109+
"ARD_PULSE_READ_TIMEOUT": "lees een %1 puls op pin #%2 (wacht maximaal %3 μs)",
112110
"ARD_PULSE_TIP": "Meet de duur van een puls op een geselecteerde pin.",
113111
"ARD_PULSETIMEOUT_TIP": "Meet de duur van een puls op een geselecteerde pin, zolang het gebeurt binnen de opgegeven maximale duur (in milliseconden).",
114112
"ARD_SETTONE": "Speel noot op pin#",

blockly/msg/json/ru_ardublockly.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,8 @@
103103
"ARD_TIME_INF_TIP": "Ждет неопределенное время, останавливая при этом программу.",
104104
"ARD_VAR_AS": "как",
105105
"ARD_VAR_AS_TIP": "Приводит значение к определенному типу",
106-
"ARD_PULSEREAD": "Считать",
107-
"ARD_PULSEON": "импульс на пине №",
108-
"ARD_PULSETIMEOUT": "с таймаутом ",
109-
"ARD_PULSETIMEOUT_MS": "",
106+
"ARD_PULSE_READ": "Считать %1 импульс на пине №%2",
107+
"ARD_PULSE_READ_TIMEOUT": "Считать %1 импульс на пине №%2 (с таймаутом %3)",
110108
"ARD_PULSE_TIP": "Измеряет длительность импульса на выбранном пине.",
111109
"ARD_PULSETIMEOUT_TIP": "Измеряет длительность импульса на выбранном пине, в течение таймаута.",
112110
"ARD_SETTONE": "Установить на пине №",

blockly/msg/messages_ardublockly.js

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @fileoverview Ardublockly specific English strings.
66
*
7-
* After modifying this file, either run "build.py" from the parent directory,
7+
* After modifying this file, either run "build.py" from the blockly directory,
88
* or run (from this directory):
99
* ../i18n/js_to_json.py
1010
* to regenerate json/{en,qqq,synonyms}.json.
@@ -25,24 +25,37 @@ goog.require('Blockly.Msg');
2525
*/
2626

2727
/**
28-
* Each message is preceded with a tripple-slash comment that becomes the
28+
* Each message is preceded with a triple-slash comment that becomes the
2929
* message descriptor. The build process extracts these descriptors, adds
3030
* them to msg/json/qqq_ardublockly.json, and they show up in the translation
3131
* console.
3232
* Note the strings have to be surrounded by single quotation marks: ''
3333
*/
3434

35-
/// Ardublockly Types
35+
/**
36+
* Ardublockly Types
37+
*/
38+
/// Arduino Types - Character C type char
3639
Blockly.Msg.ARD_TYPE_CHAR = 'Character';
40+
/// Arduino Types - Text C type String
3741
Blockly.Msg.ARD_TYPE_TEXT = 'Text';
42+
/// Arduino Types - Boolean type
3843
Blockly.Msg.ARD_TYPE_BOOL = 'Boolean';
44+
/// Arduino Types - Short number C type char
3945
Blockly.Msg.ARD_TYPE_SHORT = 'Short Number';
46+
/// Arduino Types - Number C type integer
4047
Blockly.Msg.ARD_TYPE_NUMBER = 'Number';
48+
/// Arduino Types - Large number C type long integer
4149
Blockly.Msg.ARD_TYPE_LONG = 'Large Number';
50+
/// Arduino Types - Decimal number C type floating point
4251
Blockly.Msg.ARD_TYPE_DECIMAL = 'Decimal';
52+
/// Arduino Types - Array
4353
Blockly.Msg.ARD_TYPE_ARRAY = 'Array';
54+
/// Arduino Types - Null C type void
4455
Blockly.Msg.ARD_TYPE_NULL = 'Null';
56+
/// Arduino Types - Undefined type
4557
Blockly.Msg.ARD_TYPE_UNDEF = 'Undefined';
58+
/// Arduino Types - Place holder value, indicates block with type not connected
4659
Blockly.Msg.ARD_TYPE_CHILDBLOCKMISSING = 'ChildBlockMissing';
4760

4861
/// Arduino Blocks
@@ -137,21 +150,29 @@ Blockly.Msg.ARD_TIME_INF = 'wait forever (end program)';
137150
Blockly.Msg.ARD_TIME_INF_TIP = 'Wait indefinitely, stopping the program.';
138151
Blockly.Msg.ARD_VAR_AS = 'as';
139152
Blockly.Msg.ARD_VAR_AS_TIP = 'Sets a value to a specific type';
140-
Blockly.Msg.ARD_PULSEREAD = 'Read';
141-
Blockly.Msg.ARD_PULSEON = 'pulse on pin #';
142-
Blockly.Msg.ARD_PULSETIMEOUT = 'timeout after';
143-
Blockly.Msg.ARD_PULSETIMEOUT_MS = '';
153+
/// IO blocks - pulseIn - Block for function pulseIn(), it measure a pulse duration in a given pin.
154+
Blockly.Msg.ARD_PULSE_READ = 'measure %1 pulse on pin #%2';
155+
/// IO blocks - pulseIn - Block similar to ARD_PULSE_READ, but it adds a time-out in microseconds.
156+
Blockly.Msg.ARD_PULSE_READ_TIMEOUT = 'measure %1 pulse on pin #%2 (timeout after %3 μs)';
157+
/// IO blocks - pulseIn - Tooltip for pulseIn() block.
144158
Blockly.Msg.ARD_PULSE_TIP = 'Measures the duration of a pulse on the selected pin.';
145-
Blockly.Msg.ARD_PULSETIMEOUT_TIP = 'Measures the duration of a pulse on the selected pin, if it is within the timeout.';
159+
/// IO blocks - pulseIn - Tooltip for pulseIn() block when it uses the optional argument for time-out.
160+
Blockly.Msg.ARD_PULSETIMEOUT_TIP = 'Measures the duration of a pulse on the selected pin, if it is within the time-out in microseconds.';
146161
Blockly.Msg.ARD_SETTONE = 'Set tone on pin #';
147162
Blockly.Msg.ARD_TONEFREQ = 'at frequency';
148163
Blockly.Msg.ARD_TONE_TIP = 'Sets tone on pin to specified frequency within range 31 - 65535';
149164
Blockly.Msg.ARD_TONE_WARNING = 'Frequency must be in range 31 - 65535';
150165
Blockly.Msg.ARD_NOTONE = 'Turn off tone on pin #';
151166
Blockly.Msg.ARD_NOTONE_TIP = 'Turns the tone off on the selected pin';
152167

153-
/// Ardublockly instances
168+
/**
169+
* Ardublockly instances
170+
*/
171+
/// Instances - Menu item to indicate that it will create a new instance
154172
Blockly.Msg.NEW_INSTANCE = 'New instance...';
173+
/// Instances - Menu item to rename an instance name
155174
Blockly.Msg.RENAME_INSTANCE = 'Rename instance...';
175+
/// Instances - Menu item to create a new instance name and apply it to that block
156176
Blockly.Msg.NEW_INSTANCE_TITLE = 'New instance name:';
177+
/// Instances - Confirmation message that a number of instances will be renamed to a new name
157178
Blockly.Msg.RENAME_INSTANCE_TITLE = 'Rename all "%1" instances to:';

0 commit comments

Comments
 (0)