Lunchbox computer
The latest iteration of my 'lunchbox' computer is powered by a BBC micro:bit. It has a monochrome 128 x 64 LCD display, and a keyboard recycled from an XBox 360 chatpad. The software consists of the micro:bian operating system and a threaded interpreter for a language I'm calling Morf.
The hardware
Power supply
The board is powered from two AA batteries. A 5V rail is provided by a small boost converter board, and the 3.3V supply for the micro:bit is derived from it by an LDO linear regulator.
Display
The display consists of a MIKROE–4 monochrome graphic LCD of 128 x 64 pixels, with a controller based on a pair of NT7108 chips. An ATMega328P AVR microcontroller is used as an interface between the display and the micro:bit.
Both the display electronics and its backlight are powered from the 5V rail. Communication between the micro:bit and the AVR chip is over an I2C bus, with the micro:bit end operating at 3.3V and the AVR end operating at 5V. A level shifter connects the two, consisting of two BS270 MOSFETS configured as described in a famous Philips application note.
The display protocol contains the following commands:
CLEAR
- Clear the LCD and reset the cursor to (0, 0).
WRITE str
- Write the string
str
to the display at the cursor position. The display scrolls as necessary, and newline (\n
) and backspace (\b
) characters in the string are interpreted appropriately. GOTOXY col row
- Move the cursor to (col, row).
GETXY
- Return the cursor position as two bytes
row col
(sic). CLRLINE
- Clear from the cursor to the end of the current line.
CLREND
- Clear from the cursor to the end of the display.
BACKLIGHT f
- Set the backlight intensity to f/255.
MOVELEFT n
- Move the cursor
n
positions to the left. MOVERIGHT n
- Move the cursor
n
positions to the right. RVIDEO flag
- Set the reverse video flag.
In addition to the above commands, the protocol provides access to the 1KB EEPROM of the ATMega328P via commands GETBYTE
, GETWORD
, PUTBYTE
and PUTWORD
.
Keyboard
The keyboard is recycled from a chatpad accessory for the XBox 360. This communicates over 19200-baud serial using a somewhat obscure proprietary protocol that is documented (to the extent I understand it) on the linked page. The chatpad is managed by a micro:bian device driver that is layer on top of a driver for the raw serial device.
The software
micro:bian
Morf
Morf (Mike's Own Reimplementation of Forth) runs as a process under micro:bian. As the name suggests, it is a dialect of Charles H. Moore's Forth language, but it does not aim for compatibility with ANSI Forth or any other standard dialect.