Expand description
VGA Frame Buffer for Embedded Microcontrollers
Generates an 800 x 600 @ 60 Hz SVGA signal from a 48 column x 36 row monochrome text buffer. The image has a border.
TODO: Implement smooth scrolling in the vertical direction with an extra text row.
Width = 400 double width pixels => 400 = 8 + (48 x 8) + 8
Height = 600 pixels => 600 = 12 + (36 x 16) + 12
<-------------- 400 px, pixel doubled to 800 px ------------->
+------------------------------------------------------------+
|<--> 8 pixel border ^ 8 pixel border <-->|
| | 12 px border |
| v |
| +--------------------------------------------------+ |
| | <--^------ 48 chars x 8 px = 384 px ----------->| |
| | | | |
| | | | |
| | | 36 rows x 16 px = 576 px | |
| | | | |
| | | | |
| | v | |
| +--------------------------------------------------+ |
| ^ |
| | 12 px border |
| v |
+------------------------------------------------------------+
Requires pixels to be emitted with a 20 MHz pixel clock (against a nominal 40 MHz pixel clock, in order to acheive the horizontal doubling).
In order to maintain performance, only one font size is supported: 8x16 pixels. But you can substitute your own font if required (e.g. for Teletext support).
There is optional cursor support. Rather than try and check each text cell at render time to see if it is in the cursor position, we swap chars in and out of the text buffer as the cursor moves. It’s a little more expensive, but the cost is at text write time, not at render time (and so it won’t break sync).
See https://github.com/thejpster/monotron for an example.
Modules§
Structs§
- Attr
- This structure describes the attributes for a Char. They’re all packed into 8 bits to save RAM.
- Col
- Describes a vertical column on the screen. Zero is on the left.
- Frame
Buffer - This structure represents the framebuffer - a 2D array of monochome pixels.
- Mode0
Text Row - Mode2
- Represents Mode2 1-bpp graphics
- Mode
Info - Describes a video mode.
- Point
- A point on the screen. The arguments are X (column), Y (row)
- Position
- Describes a place on the screen. (0, 0) is the top left.
- Row
- Identifies a horizontal row on the screen. Zero is at the top.
- XRGB
Colour - Represents 8 pixels, each of which can be any 3-bit RGB colour
Enums§
- Char
- This MS-DOS CodePage 850. It offers a compromise between the box characters of CodePage 437 and the accents of ISO 8859-1 / Latin-1.
- Colour
- Control
Char Mode - How to handle Control Characters
- Double
Height Mode - You can set this on a row to make the text double-height. This was common on the BBC Micro in Mode 7/Teletext mode.
- Escape
Char Mode - Special
Char - Special types of character we need to interpret
Constants§
- MODE0_
HORIZONTAL_ OCTETS - How many words in a line (including the border)
- MODE0_
TEXT_ MAX_ COL - Highest X co-ord for text
- MODE0_
TEXT_ MAX_ ROW - Highest Y co-ord for text
- MODE0_
TEXT_ NUM_ COLS - How many characters in a row
- MODE0_
TEXT_ NUM_ ROWS - How many rows of characters on the screen
- MODE0_
USABLE_ COLS - Number of columns in frame buffer
- MODE0_
USABLE_ HORIZONTAL_ OCTETS - How many words in a line (excluding the border)
- MODE0_
USABLE_ LINES - Number of lines in frame buffer
- MODE2_
USABLE_ LINES - Number of scan-lines in an image in Mode 2. Note, we print each one twice.
- MODE2_
WIDTH_ PIXELS - Number of pixels in a scan-line in Mode 2
Traits§
- Ascii
Console - Refinement of
BaseConsole
which supports 8-bit characters. Use this is you are implementing an old-fashioned ASCII console (including extended ASCII, like Code Page 850, or ISO 8859-1). - Base
Console - Abstraction for our console. We can move the cursor around and write text
to it. You should use either
UnicodeConsole
orAsciiConsole
depending on whether you want full Unicode support (&str
,char
, etc), or just 8-bit characters (&[u8]
andu8
). - Hardware
- Implement this on your microcontroller’s timer object.
- Unicode
Console - Refinement of
BaseConsole
which supports Unicode characters. Use this is you are implementing a modern console with Unicode support.