Skip to content

Add basic display primitives for zephyr#337

Open
MaartenS11 wants to merge 8 commits intomainfrom
feat/basic-zephyr-display-support
Open

Add basic display primitives for zephyr#337
MaartenS11 wants to merge 8 commits intomainfrom
feat/basic-zephyr-display-support

Conversation

@MaartenS11
Copy link
Member

@MaartenS11 MaartenS11 commented Dec 7, 2025

Adds the following primitives to Zephyr:

  • display_setup
  • display_set_orientation
  • display_width
  • display_height
  • display_fill_rect
  • display_draw_string

Additionally, this PR also brings millis to Zephyr + the new random int primitive random_int.

Note

The display drivers can be disabled at compile time by setting CONFIG_DISPLAY to n in prj.conf.

Currently designed for 16bit color displays (buffer size needs to be changed for others).

Important to note, on little endian hardware this is what a color looks like:

  7......0 15.....8
| gggBbbbb RrrrrGgg | ...
image
function drawText(x: i32, y: i32, str: string, foreground: i32, background: i32): void {
  draw_text(x, y, String.UTF8.encode(str, true), String.UTF8.byteLength(str, true), foreground, background);
}

export function main(): void {
    setup();

    initDisplay();

    drawText(0, 32, "TOPLLAB/WARDuino", 0xffff, 0x0000);
    drawText(0, 32 + 16, "PR#337 demo", 0xff, 0x0000);
    drawText(0, 32 + 32, "Hello there from WARDuino!", 0xffff, 0x0000)
    drawText(0, 32 + 16 * 3, "width = " + displayWidth().toString() + ", height = " + displayHeight().toString(), 0xffff, 0x0000);

    const time = 5000;
    while (true) {
        digitalWrite(Pin.led1, PinVoltage.HIGH);
        drawRect(0, 0, 32, 32, 0b1110000000000111); // Green square
        delay(500);
        digitalWrite(Pin.led1, PinVoltage.LOW);
        drawRect(0, 0, 32, 32, 0xFFFF);
        delay(500);
    }
}

Currently designed for 16bit color displays (buffer size needs to be changed for others).

Can be disabled by setting CONFIG_DISPLAY to 'n'.
This makes use of the IBM 8x16 VGA font.
@MaartenS11 MaartenS11 force-pushed the feat/basic-zephyr-display-support branch from 82bf7ec to 01fe5f2 Compare December 8, 2025 16:20
@MaartenS11 MaartenS11 force-pushed the feat/basic-zephyr-display-support branch from de8e515 to ac8770d Compare December 9, 2025 08:41
@MaartenS11 MaartenS11 self-assigned this Dec 9, 2025
@MaartenS11 MaartenS11 requested a review from tolauwae December 9, 2025 08:45
Allows scaling text 2x for example. Very useful for when you need
bigger text like when using a board as a nametag.
@MaartenS11 MaartenS11 force-pushed the feat/basic-zephyr-display-support branch from 1304057 to f43d407 Compare February 1, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant