Skip to content

11. A 1980s dashboard ​

the dashboard: a segmented bar in blue-green, an amber ramp, a red scanner, seven-segment numbers

The digital dashboards of the 1980s drew their gauges with a few tricks that still work on a terminal. Unlit segments stay faintly visible. A gauge turns amber, then red, near the end of its scale. The bars of a tachometer rise in height. A red light sweeps back and forth, and numbers are drawn in seven segments. This chapter dresses the bar of march in each of them, then shows how one keyword does it all.

24-bit colours ​

Every colour keyword also takes #rrggbb: an exact colour, the same whatever the palette of the terminal. The dark blue-green of an unlit segment is not among the 17 named colours. With #0E342C the empty part becomes the unlit segments of a display, drawn with the same glyph as the lit ones: ▌, a block whose right half is the gap between two segments.

Zones ​

bar_zones colours each filled cell by its position along the bar, as a tachometer turns amber and then red towards its redline. Each limit:colour item covers the cells up to that fraction of the bar:

f90
call bar%initialize(prefix_string='RPM ', prefix_color_fg='#2EF5C0', prefix_style='bold_on',               &
                    filled_char_string='▌', empty_char_string='▌', empty_char_color_fg='#0E342C',          &
                    bar_zones='0.7:#2EF5C0 0.88:#FFB000 1:#FF3B30',                                        &
                    add_progress_percent=.true., progress_percent_color_fg='#FFB000',                      &
                    width=40, max_value=real(steps, R8P))

At 80%, past the first zone:

$ tach
RPM ▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌  80%

A ramp ​

bar_profile='ramp' draws the cells as blocks rising from one eighth to the full height. The cells still to do keep their blocks, unlit, so the whole ramp is always visible:

f90
call bar%initialize(prefix_string='RPM ', prefix_color_fg='#2EF5C0', prefix_style='bold_on',               &
                    bar_profile='ramp', empty_char_color_fg='#0E342C',                                     &
                    bar_zones='0.7:#2EF5C0 0.88:#FFB000 1:#FF3B30',                                        &
                    add_progress_percent=.true., progress_percent_color_fg='#FFB000',                      &
                    width=40, max_value=real(steps, R8P))
$ tach
RPM ▁▁▁▁▁▁▂▂▂▂▂▂▃▃▃▃▃▄▄▄▄▄▄▅▅▅▅▅▆▆▆▆▆▆▇▇▇▇▇█  80%

A scanner ​

An indeterminate bar shows a block going back and forth. pulse_trail turns it into a scanner: a head of one cell, followed by the cells it lit on the last drawings, in darker and darker shades:

f90
call bar%initialize(prefix_string='solve ', prefix_color_fg='#FF3B30',                                       &
                    indeterminate=.true., width=24, add_progress_count=.true., progress_count_color_fg='#FFB000', &
                    filled_char_string='▬', filled_char_color_fg='#FF3B30',                                   &
                    empty_char_string='▬', empty_char_color_fg='#3C0C0A',                                     &
                    pulse_trail='#C0281E #7A1912 #4A0F0B')

On its way back, with the trail behind the head:

$ solve
solve ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ 31

Segment digits ​

digits='segment' writes the numbers in seven segments, and digits_unlit_color turns their padding into unlit 8s:

f90
call bar%initialize(prefix_string='march ', prefix_color_fg='#2EF5C0', width=30,                              &
                    filled_char_string='▌', filled_char_color_fg='#2EF5C0',                                     &
                    empty_char_string='▌', empty_char_color_fg='#0E342C',                                       &
                    add_progress_percent=.true., progress_percent_color_fg='#FFB000',                           &
                    add_progress_count=.true., progress_count_color_fg='#FFB000',                               &
                    digits='segment', digits_unlit_color='#3A2800', max_value=real(steps, R8P))
$ march
march ▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌ 🯸🯸🯵% 🯸🯸🯷/🯱🯲🯰

Check the font first

The seven-segment digits are characters that most terminal fonts do not have: Cascadia Code, Iosevka, JuliaMono and GNU Unifont have them; DejaVu Sans Mono, Menlo and Consolas do not. Try digits='segment' in your terminal before you rely on it. A log always gets plain digits.

Themes ​

theme sets all of the above, except the zones, the ramp and the digits, in one keyword: vfd (a vacuum fluorescent display, blue-green), amber (a liquid crystal display) and kitt (a red scanner). Any keyword you pass wins over the theme:

f90
call vfd%initialize(theme='vfd', prefix_string='vfd   ', add_progress_percent=.true., width=30, &
                    max_value=real(steps, R8P))
call amber%initialize(theme='amber', prefix_string='amber ', bar_profile='ramp', add_progress_percent=.true., &
                      width=30, max_value=real(steps, R8P), position=1)
call kitt%initialize(theme='kitt', prefix_string='kitt  ', indeterminate=.true., add_progress_count=.true., &
                     width=30, position=2)
$ march
vfd   ▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌  58%
amber ▁▁▁▁▁▂▂▂▂▃▃▃▃▄▄▄▄▅▅▅▅▆▆▆▆▇▇▇▇█  58%
kitt  ▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌ 29
  • A theme sets segments, colours, a bold prefix and, on an indeterminate bar, a pulse trail.
  • Add zones, a ramp or segment digits on top of a theme, as the amber bar adds a ramp.
  • In a log there are no colours. Zones and trails change nothing there, and a ramp shows its lit blocks only.

What you learned

#rrggbb colours, bar_zones, bar_profile='ramp', pulse_trail, digits='segment', theme. Reference: Themes, Zones, Profiles, Pulse trail, Segment digits.

That is the end of the tutorial: the cookbook has short recipes for everyday tasks.

Released under the GPL v3, BSD 2-Clause, BSD 3-Clause or MIT License.