#text #vga

no-std vga-framebuffer

A text console output over a VGA compatible signal

13 unstable releases

new 0.8.1 Jul 13, 2019
0.7.5 Apr 18, 2019
0.7.4 Oct 22, 2018
0.4.0 Jul 27, 2018

#38 in Embedded development

Download history 1/week @ 2019-03-30 19/week @ 2019-04-06 14/week @ 2019-04-13 11/week @ 2019-04-20 7/week @ 2019-04-27 19/week @ 2019-05-04 21/week @ 2019-05-11 33/week @ 2019-05-18 4/week @ 2019-05-25 22/week @ 2019-06-01 23/week @ 2019-06-08 13/week @ 2019-06-15 32/week @ 2019-06-22 42/week @ 2019-06-29 145/week @ 2019-07-06

129 downloads per month
Used in 2 crates



VGA Framebuffer

This crate implements basic VGA text output on an embedded microcontroller, using nothing more than some timer peripherals and a few GPIO pins.

This crate is written to be hardware-agnostic.

  • You supply an object implementing the Hardware trait.
  • The function isr_sol() must be called at the start of every scan-line, e.g. with a Timer interrupt.
  • This will then call write_pixels() on the given Hardware object with the RGB values for every byte in that scan-line.
  • These pixel values should be buffered (e.g. in an SPI FIFO) and then sent to the screen at the appropriate moment (e.g. when the line_start timer fires).
  • The configure() callback gives you the appropriate timings for all of this.

The Specs:

  • 800 x 600 @ 60 Hz output signal with a 40 MHz pixel clock
  • 400 x 600 effective resolution (runs pixel clock at half-speed)
  • 8-colour RGB output (Red, Green, Blue, Cyan, Magenta, Yellow, Black and White)
  • 8x16 bitmap glyphs, from FreeBSD console font
  • MS-DOS CodePage 850 character set
  • 48 column x 36 row text output
  • One foreground/background pair stored per character cell
  • Single-buffered
    • Uses unsafe mutation of a static, but the worst case scenario is a minor screen glitch which is fixed on the next frame
  • Optional Mono 384x288 framebuffer, coloured with text-mode attributes.
    • Doubles each horizontal line to keep memory usage down
    • Uses an extra 13,824 bytes over text mode
    • Will suffer terrible attribute-clash, just like a ZX Spectrum :)
    • Can set a start and end scan-line for the graphics mode, to allow a mixed text/graphics split-screen with reduced memory consumption

The pixels are double-width as I was unable to get 40 MHz SPI output functioning correctly on my particular micro. 20 MHz works just fine.

Tested on Monotron using a Texas Instruments Tiva-C TM4C123 clocked at 80 MHz.

Coming soon...

  • Optional 3-bits-per-pixel RGB 192x288 framebuffer mode.
    • Uses an extra 20,736 bytes over text mode.
    • No attribute clash, but half the resolution.
  • 8x8 pixel font, more suited to the graphics modes


I'll happy accept a patches to enable other resolutions and/or other text resolutions.