Skip to content

Commit 357c351

Browse files
committed
smoothing
1 parent 9d94b96 commit 357c351

1 file changed

Lines changed: 29 additions & 23 deletions

File tree

docs/doc-plan.md

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@ to MicroCode programs,
1212
## Syntax
1313

1414
MicroCode has a concrete syntax, as detailed below, for the
15-
purpose of creating programs without the need for visual
15+
purpose of creating programs without the need for the
1616
MicroCode editor.
1717

1818
In the following, a word in ALLCAPS refers to a non-terminal in
1919
MicroCode's grammar. All other words are terminal symbols, with
20-
the following exceptions: <float> is a floating point number;
21-
<pos> is an integer greater than zero; // designates a comment
22-
(just for use in this markdown - MicroCode does not support comments);
23-
the symbols \s, \*, (, ), [, ], and | are part of the grammar
24-
specification. Words are always separated by whitespace.
25-
26-
Note that non-terminals correspond to the tooltips used in MicroCode's
27-
visual editor (where the underscores are replaced by spaces), which
20+
the following exceptions:
21+
22+
- <float> is a floating point number;
23+
- <pos> is an integer greater than zero;
24+
- // designates a comment
25+
(just for use in this markdown - MicroCode does not support comments);
26+
- the symbols \s, \*, (, ), [, ], and | are part of the grammar
27+
specification
28+
29+
Words are always separated by whitespace. Note that non-terminals
30+
correspond to the tooltips used in MicroCode's visual editor
31+
(where the underscores are replaced by spaces), which
2832
accounts for their long form.
2933

3034
A program (PROG) consists of 5 pages, numbered P_1 to P_5, each with a (possibly
@@ -42,8 +46,7 @@ Each rule has an optional section WHEN and an optional section DO.
4246

4347
RULE := when [WHEN] do [DO]
4448

45-
The WHEN section specifies a signal of interest and, optionally, a filter on that signal.
46-
The DO section specifies an action and, optionally, parameters to that action.
49+
The WHEN section specifies a signal of interest and, optionally, a filter on that signal. The DO section specifies an action and, optionally, parameters to that action.
4750

4851
WHEN :=
4952
| start_page [TS] // fires (once) when control transitions to this page, with optional delay
@@ -55,10 +58,10 @@ The DO section specifies an action and, optionally, parameters to that action.
5558
| temperature [UD | C] // fire on UD event or comparison C of current temperature (in Celsius)
5659
| light [UD | C] // fire on UD event or comparison C of current light level (0-255)
5760
| magnet [UD | C] // fire on UD event or comparison C of current magnetic level
58-
| radio_receive [C] // fire when number arrives via radio, subject to optional comparison C
59-
| variable_X_set [C] // fire after variable X has been assigned, subject to optional comparison C
60-
| variable_Y_set [C] // fire after variable Y has been assigned, subject to optional comparison C
61-
| variable_Z_set [C] // fire after variable Z has been assigned, subject to optional comparison C
61+
| radio_receive [C] // fire when number arrives via radio, subject to comparison C
62+
| variable_X_set [C] // fire after variable X has been assigned, subject to comparison C
63+
| variable_Y_set [C] // fire after variable Y has been assigned, subject to comparison C
64+
| variable_Z_set [C] // fire after variable Z has been assigned, subject to comparison C
6265

6366
UD := up | down
6467
TS := (1/4_second | 1_second | 1_random_second | 5_seconds)\* // sum the sequence of times
@@ -89,6 +92,8 @@ An expression E is either atomic A, a binary expression, or a randomly chosen va
8992
| A * E
9093
| random_number PE
9194

95+
Note that the expression language does not admit parentheses and is right-recursive.
96+
9297
An atomic value A is either a floating point number, one of the three variables,
9398
or the current value of one of the four sensors, or the last value received over radio:
9499

@@ -98,20 +103,20 @@ or the current value of one of the four sensors, or the last value received over
98103
| light_value | sound_value | temp_value | magnet_value
99104
| radio_value
100105

101-
A positive (integer) expression PE is
106+
A positive (integer) expression PE is:
102107

103108
PE :=
104109
| <pos>
105110
| <pos> + PE
106111
| <pos> * PE
107112

108-
A DO action
113+
A DO action takes on of the following forms:
109114

110115
DO :=
111116
| show_number [V]
112117
| show_image (IMAGE)\* [repeat [PE]]
113118
| play_sound (SND)\* [repeat [PE]]
114-
| music (NOTES)* [repeat [PE]]
119+
| music (NOTES)\* [repeat [PE]]
115120
| radio_send [V]
116121
| radio_set_group [PE]
117122
| set_variable_X [V]
@@ -120,9 +125,9 @@ A DO action
120125
| switch_page [PAGE]
121126

122127
PAGE := | page_1 | page_2 | page_3 | page_4 | page_5
123-
SND := | giggle | happy | hello | mysterious | sad | slide | soaring
128+
SND := | giggle | happy | hello | mysterious | sad | slide | soaring | spring | twinkle | yawn
124129

125-
An led image occurs inside backquotes ` and consists of 25 characters, either . or 1, separated by
130+
An LED image occurs inside backquotes ` and consists of 25 characters, either . or 1, separated by
126131
whitespace:
127132

128133
IMAGE := image ` (.\s+ | 1\s+)25 `
@@ -138,11 +143,12 @@ Before execution starts, all variables (X, Y, and Z) are initialized to 0
138143
and the current value of all micro:bit/jacdac sensors is cached.
139144
The initial value of radio_value is undefined.
140145
The radio group is initialized to 1.
141-
Execution begins by transitioning to page 1.
146+
Execution begins by transitioning (switching) to page 1.
142147

143148
### Defaults
144149

145-
The absence of an optional element/value results in the use of a default element/value, as follows:
150+
The absence of an optional element/value in the when or do section of a rule
151+
results in the use of a default element/value, as follows:
146152

147153
- A rule with an empty do section never executes (no matching performed
148154
on it).
@@ -183,7 +189,7 @@ used for timers, as detailed later.
183189

184190
### Resources and conflicts
185191

186-
Actions have effects through writing to resources, which are as follows:
192+
Actions have effects by writing to (updating) a resource, which are as follows:
187193

188194
- screen
189195
- speaker

0 commit comments

Comments
 (0)