First, a few words about how the idea for this device came about. This will also answer questions like "why not STM32?" and "why not Raspberry Pi with a color display?"
I've always been interested in the history of computing, retro computers, old laptops. I even have a few of them, the oldest being an i386. Looking at their specs, I couldn't help comparing them to the AVR, which runs at 16 MHz — more than many machines of that era. And the thought crossed my mind: what if I built a computer on an AVR/Arduino — what would it be like, what tasks could it handle? Obviously, it's not meant for that, but still? That idea is what started my project, and at first I didn't even imagine what would come of it.
The first thing I tackled was the display. I chose a 128×64 monochrome display based on the ST7920 and started figuring out how to connect it, what it could do, its instruction set. In parallel, I was thinking about the enclosure. At first I wasn't sure about the controller: use a bare AVR, which would give me control over power and the ability to go into sleep mode (at the cost of designing and manufacturing my own board), or take a ready-made Arduino board (which would mean giving up on power-down). In the end I went with the second option and chose the Mega 2560 Pro Mini for its compact size. And most importantly — it makes the project easier to replicate: a person just buys the same board instead of soldering a controller with its supporting circuitry themselves.
The ST7920 supports parallel (4-bit and 8-bit) and serial (SPI) modes. I chose parallel because it provides the maximum transfer speed. For the same reason, I abandoned general-purpose libraries and started writing my own display driver. I allocated a 1 KB video buffer in SRAM (exactly the size of a 128×64 monochrome frame), wrote methods to send its contents to the display, and added several graphics functions: from setting individual pixels to drawing primitives, rendering text, and outputting XBM images.
The hardest part turned out to be print: supporting fonts of different sizes (up to 16×16) and rendering text from an arbitrary horizontal position — you can't just take a byte from the font and write it to the video buffer. You have to account for the font size and how many free bits are left in the current byte of the video buffer, shift the font data if it doesn't fit, and write the remaining bits into the next byte. Each character is a series of shifts, masks, and carries between bytes.


Once the graphics functions were in place, I moved on to programming the shell: a menu with a list of available tasks, a base Task class describing the required methods — setup and loop — and other things that came up as I went along.
Vladimir Tsibrov
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.