From e23938af182f18d27dee4107b2b3dfb94b6d9d50 Mon Sep 17 00:00:00 2001 From: Thomas Ball Date: Thu, 20 Nov 2025 11:49:46 -0800 Subject: [PATCH 1/4] start plan --- docs/doc-plan.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/doc-plan.md diff --git a/docs/doc-plan.md b/docs/doc-plan.md new file mode 100644 index 00000000..e69de29b From 0ed3d447db3dd350523e6b38e939a447fb17bf75 Mon Sep 17 00:00:00 2001 From: Thomas Ball Date: Fri, 28 Nov 2025 23:31:03 -0800 Subject: [PATCH 2/4] work on syntax --- docs/doc-plan.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/docs/doc-plan.md b/docs/doc-plan.md index e69de29b..8b887fdf 100644 --- a/docs/doc-plan.md +++ b/docs/doc-plan.md @@ -0,0 +1,37 @@ +MicroCode programs consist of 5 pages, numbered 1 - 5. +Execution always starts on page 1. Before execution +starts, all variables are initialized to 0 and the current value of all sensors is cached. + +A page consists of a sequence of rules, ordered from top to bottom. +Each rule has a When section and a Do section. +The When section specifies an event of interest +and, optionally, a filter on that event. + +When + +page-start [timespan] +timer [timespan] +press [pressable-kind] +release [pressable-kind] +move [move-kind] +sound [loud-quiet,compare] +temperature [up-down,compare] +light [up-down,compare] +magnet [up-down,compare] +radio-receive [compare] +variable-X-set [compare] +variable-Y-set [compare] +variable-Z-set [compare] + +Do + +show-number [value] +show-image [image*] [repeat [pos-value]] +play-sound [sound*] [repeat [pos-value]] +play-music [notes*] [repeat [pos-value]] +radio-send [value] +radio-set-group [pos-value] +set-variable-X [value] +set-variable-Y [value] +set-variable-Z [value] +switch-page [page] From 8b0e727fb92d4daaea9c3138a24841eca25c40ad Mon Sep 17 00:00:00 2001 From: Thomas Ball Date: Sat, 29 Nov 2025 09:45:32 -0800 Subject: [PATCH 3/4] grammar --- docs/doc-plan.md | 75 +++++++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 29 deletions(-) diff --git a/docs/doc-plan.md b/docs/doc-plan.md index 8b887fdf..c5e9708d 100644 --- a/docs/doc-plan.md +++ b/docs/doc-plan.md @@ -1,37 +1,54 @@ MicroCode programs consist of 5 pages, numbered 1 - 5. Execution always starts on page 1. Before execution -starts, all variables are initialized to 0 and the current value of all sensors is cached. +starts, all variables are initialized to 0 and +the current value of all sensors is cached. -A page consists of a sequence of rules, ordered from top to bottom. -Each rule has a When section and a Do section. -The When section specifies an event of interest +A page consists of a sequence of rules (R), ordered from top to bottom. +Each rule has an option when section W and an optional do section D. +The when section specifies an event of interest and, optionally, a filter on that event. +The do section specifies an action and, optionally, +parameters to that action. +Some actions can be repeated. -When +R := [W] [D] -page-start [timespan] -timer [timespan] -press [pressable-kind] -release [pressable-kind] -move [move-kind] -sound [loud-quiet,compare] -temperature [up-down,compare] -light [up-down,compare] -magnet [up-down,compare] -radio-receive [compare] -variable-X-set [compare] -variable-Y-set [compare] -variable-Z-set [compare] +W := +| page-start [TS] +| timer [TS] +| press [PK] +| release [PK] +| move [MK] +| sound [loud | quiet | C] +| temperature [up | down | C] +| light [up | down | C] +| magnet [up | down | C] +| radio-receive [C] +| variable-X-set [C] +| variable-Y-set [C] +| variable-Z-set [C] -Do +TS := (1/4-second | 1-second | 1-random-second | 5-seconds)\* +PK := button-A | button-B | logo | pin-0 | pin-1 | pin-2 +MK := shake | tilt-left | tilt-right | ... +C := CO V -show-number [value] -show-image [image*] [repeat [pos-value]] -play-sound [sound*] [repeat [pos-value]] -play-music [notes*] [repeat [pos-value]] -radio-send [value] -radio-set-group [pos-value] -set-variable-X [value] -set-variable-Y [value] -set-variable-Z [value] -switch-page [page] +D := +| show-number [V] +| show-image (image)_ [repeat [PV]] +| play-sound (sound)_ [repeat [PV]] +| play-music (notes)\* [repeat [PV]] +| radio-send [V] +| radio-set-group [PV] +| set-variable-X [V] +| set-variable-Y [V] +| set-variable-Z [V] +| switch-page [PG] + +CO := +| equals +| not-equals +| less-then +| less-then-or-equal +| greater-than +| greater-than-or-equal From d473b50dbcbcd9047437e65af4dfb5deaa944643 Mon Sep 17 00:00:00 2001 From: Thomas Ball Date: Sat, 29 Nov 2025 10:54:56 -0800 Subject: [PATCH 4/4] more grammar --- docs/doc-plan.md | 53 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/docs/doc-plan.md b/docs/doc-plan.md index c5e9708d..11b8159e 100644 --- a/docs/doc-plan.md +++ b/docs/doc-plan.md @@ -3,16 +3,20 @@ Execution always starts on page 1. Before execution starts, all variables are initialized to 0 and the current value of all sensors is cached. -A page consists of a sequence of rules (R), ordered from top to bottom. +A page consists of a sequence of rules (R): + +P := page-D R\* + Each rule has an option when section W and an optional do section D. + +R := when [W] do [D] + The when section specifies an event of interest and, optionally, a filter on that event. The do section specifies an action and, optionally, parameters to that action. Some actions can be repeated. -R := [W] [D] - W := | page-start [TS] | timer [TS] @@ -20,19 +24,48 @@ W := | release [PK] | move [MK] | sound [loud | quiet | C] -| temperature [up | down | C] -| light [up | down | C] -| magnet [up | down | C] +| temperature [UD | C] +| light [UD | C] +| magnet [UD | C] | radio-receive [C] | variable-X-set [C] | variable-Y-set [C] | variable-Z-set [C] +UD := up | down TS := (1/4-second | 1-second | 1-random-second | 5-seconds)\* PK := button-A | button-B | logo | pin-0 | pin-1 | pin-2 MK := shake | tilt-left | tilt-right | ... + C := CO V +CO := +| equals +| not-equals +| less-then +| less-then-or-equal +| greater-than +| greater-than-or-equal + +V := +| A +| A + V +| A / V +| A - V +| A \* V +| random PV + +A := +| +| var-X | var-Y | var-Z +| light-value | sound-value | temp-value | magnet-value +| radio-value + +PV := +| int>0 +| int>0 + PV +| int>0 \* PV + D := | show-number [V] | show-image (image)_ [repeat [PV]] @@ -45,10 +78,4 @@ D := | set-variable-Z [V] | switch-page [PG] -CO := -| equals -| not-equals -| less-then -| less-then-or-equal -| greater-than -| greater-than-or-equal +PG := | page-1 | page-2 | page-3 | page-4 | page-5 \ No newline at end of file