The flow diagram above shows a simplified view of the main program. There are multiple
Sources representing the different sensors and the pads and one Plotter object. One omitted action is the invocation of the
stop() methods on the source when the source is first used or changed.
The flow diagram is unusual in not having a Stop symbol. In this case the program has an intentional infinite loop and runs perpetually. Turning the power off is the only way to terminate the program. This is fairly common for embedded systems. Regulatory changes have affected some designs in the last decade initiating and improving power saving when idle.
The diagram doesn't show the detail of exactly how the button inputs are processed. This is described in detail in the next section.
The CLUE follows the design of the BBC micro:bit and only has two buttons for user input. The three large pads on the edge connector can be used as touch pads but in this program they are used as analogue inputs which prevents touch pad use, at least when the analogue inputs are being plotted.
Any button can be used for more than just simple clicks. The action can be varied based on waiting for a double-click or measuring the duration of the press. The latter approach is used with the following actions:
- Left (A) button:
- 0-2 seconds: change to the next plotting source.
- 2-4s: toggle between palette from the
PlotSourceand a default palette.
- 4-6s: toggle data output on/off to serial console in a format suitable for plotting in Mu.
- >6s: toggle range lock on the y axis scale to inhibit auto-scaling.
- Right (B) button: change to a different plot style/mode.
Another option, not used here, would be for the two buttons to have a different action when both are pressed at the same time.
The first design timed the button press duration and then displayed the action on screen to the user. This meant the user had to mentally time the presses and could select the wrong option. A simple redesign changed this to cycle through the actions on screen as time passes. This allows the user to release the button reliably on the desired option.