Asv.Hal 1.2.4 Help

Display output gallery

These examples run the actual Asv.Hal controls and ConsoleScreen without opening GPIO pins, serial ports, or network connections. Each example renders one final frame and exits, so its output is repeatable.

The screenshots are browser previews of the captured console text. They preserve the output characters and spacing; the surrounding card is a documentation presentation, not a device UI. They are not photographs of a physical LCD. The terminal card intentionally uses the same colors in both documentation themes.

Run the examples

From the repository root, build the supplied example project once:

dotnet build src/Writerside/examples/DisplayExamples/DisplayExamples.csproj -c Release

Then select an example with frame, menu, status, or controls:

dotnet run --project src/Writerside/examples/DisplayExamples/DisplayExamples.csproj -c Release --no-build --no-restore -- frame

Rendered: 0 is a diagnostic line emitted by ConsoleScreen below its border. It identifies the first rendered frame, not a menu selection or a button count. These static examples render a control tree directly. For an interactive window with keyboard input and periodic rendering, use Getting started.

Direct frame

The frame example uses the exact drawing operations from Screens and rendering: text on the first row, a separator on the second, and a cropped region starting at column 2 on the third.

╔════════════════════╗ ║Device ready ║ ║--------------------║ ║ Voltage: 12 V ║ ║ ║ ╚════════════════════╝ Rendered: 0
A 20 by 4 ConsoleScreen frame with Device ready and Voltage: 12 V

Select menu instead of frame in the run command. The program activates the counter button three times through its focus callback, then renders the menu once. The first item remains selected and its label reads Count: 3. In the interactive example, press Enter three times to obtain the same menu content; its render diagnostics can differ.

╔════════════════════════════════╗ ║ HAL demo ║ ║->1. Count: 3 ║ ║ 2. Exit ║ ║ ║ ╚════════════════════════════════╝ Rendered: 0
A 32 by 4 menu with Count: 3 selected and an Exit item

Numeric readout

Select status to render PropertyReaderPage with a value of 22.5 and format F1. The sample explicitly calls ExternalUpdateValue(true) to put its header switch in the ON state; this boolean is separate from the numeric value.

╔════════════════════════════════╗ ║Sensor ON║ ║Temperature, C ║ ║ 22.5 ║ ║ ║ ╚════════════════════════════════╝ Rendered: 0
A numeric readout showing Sensor ON and a centered temperature of 22.5

See Property pages for numeric and enum editor examples.

Text, toggle, and progress

Select controls for an InfoPage containing a TextBlock, ToggleSwitch, and Progress. The progress value is 0.65, rather than 65. With a 32-column screen the bar has 30 inner cells, of which 19 are filled after truncation.

╔════════════════════════════════╗ ║ Device status ║ ║Temperature: 22.5 C ║ ║Output ON║ ║Progress: 65% ║ ║[===================-----------]║ ║ ║ ╚════════════════════════════════╝ Rendered: 0
A six-row status page showing temperature, Output ON, and a 65 percent progress bar

See Controls and events for event handling and updates from background work.

Reproduce the screenshots

The screenshot inputs are the text files in src/Writerside/examples/DisplayExamples/output. To refresh one, redirect the corresponding example output, for example:

dotnet run --project src/Writerside/examples/DisplayExamples/DisplayExamples.csproj -c Release --no-build --no-restore -- menu > src/Writerside/examples/DisplayExamples/output/menu.txt

Serve the example directory locally:

python3 -m http.server 8772 --bind 127.0.0.1 --directory src/Writerside/examples/DisplayExamples

Open http://127.0.0.1:8772/preview.html?example=menu in a browser. Other supported values are frame, status, and controls. Capture the entire dark output card, including its title and footer, then save the image in src/Writerside/images. Save an identical copy with the _dark.jpg suffix for Writerside's dark theme (for example, display-menu_dark.jpg). Repeat for every changed example, and verify that the text blocks and images still agree. Stop the local server after capturing.

Writerside includes the text below directly from the same source file used to build the example project, so the displayed C# is not a separate copy.

Example source

using System.Text; using Asv.Hal; using Asv.Hal.Impl; Console.OutputEncoding = Encoding.UTF8; switch (args.FirstOrDefault() ?? "frame") { case "frame": DrawFrame(); break; case "menu": DrawMenu(); break; case "status": DrawStatus(); break; case "controls": DrawControls(); break; default: Console.Error.WriteLine("Choose frame, menu, status, or controls."); Environment.ExitCode = 1; break; } static void DrawFrame() { IScreen screen = new ConsoleScreen(new Size(20, 4)); using (screen.BeginRenderLoop()) { screen.WriteString(0, 0, "Device ready"); screen.FillChar(0, 1, 20, '-'); IRenderContext details = screen.Crop(2, 2, 16, 1); details.WriteString(0, 0, "Voltage: 12 V"); } } static void DrawMenu() { using var counter = new TextBlock("Count: 0"); var count = 0; using var increment = new Button(onClick: _ => counter.Text = $"Count: {++count}") { Content = counter }; using var exit = new Button("Exit"); using var menu = new MenuPanel("HAL demo", HorizontalPosition.Center) { Items = { increment, exit } }; // A Button activates on focus and immediately releases it. for (var i = 0; i < 3; i++) { increment.IsFocused = true; } Render(menu, new Size(32, 4)); } static void DrawStatus() { using var page = new PropertyReaderPage( "Sensor ", "ON", "OFF", "Temperature, C", "F1") { PropertyValue = 22.5 }; page.ExternalUpdateValue(true); Render(page, new Size(32, 4)); } static void DrawControls() { using var temperature = new TextBlock("Temperature: 22.5 C"); using var enabled = new ToggleSwitch("Output ") { Value = true }; using var label = new TextBlock("Progress: 65%"); using var progress = new Progress { Value = 0.65 }; using var page = new InfoPage("Device status", HorizontalPosition.Center) { Items = { temperature, enabled, label, progress } }; Render(page, new Size(32, 6)); } static void Render(Control control, Size size) { IScreen screen = new ConsoleScreen(size); using (screen.BeginRenderLoop()) { control.Render(screen); } }
28 October 2026