Lisp Badge LE
27th September 2023
This is a self-contained low-power computer with its own display and keyboard that you can program in uLisp, a version of the high-level language Lisp for microcontrollers:
The Lisp Badge LE, a low-power computer programmed in Lisp
with a self-contained keyboard and display.
It’s based on an AVR128DB48 which provides 128K bytes of flash memory, and 16K bytes of RAM. There’s an integrated 45-key keyboard optimised for Lisp, using reverse-mounted buttons giving room for large key legends on the PCB.
It has a low-power monochrome display, readable in daylight without a backlight, so it’s ideal for programming in the garden or on the beach! This gives 10 lines of 41 characters, or graphics with a resolution of 250×122 pixels, supported by several graphics commands.
You can use it to run programs that interface to components such as LEDs and push-buttons via the I/O pins, read the analogue inputs, and operate external devices via the I2C and SPI interfaces.
Introduction
A few years ago I designed the Lisp Badge, a self-contained computer with its own display and keyboard, based on an ATmega1284, that you could program in Lisp. Since then I’ve been thinking about how I could improve it, and made a list of features I’d like to add.
On the one hand I wanted it to have a better keyboard, and be low power, powered from a button cell, with an eInk display that you could see in daylight. On the other hand I wanted it to have a colour TFT graphics display, and use a fast 32-bit ARM processor, with support for floating-point arithmetic.
I soon realised that these requirements are incompatible in a single design, and so set about designing two different Lisp Badges to meet the two sets of requirements. This Lisp Badge LE (low energy) is the first of those designs, and has the following new features:
Processor and memory
It’s based on an AVR128DB48 (or AVR128DA48) running at 24MHz, and provides 2800 Lisp objects, about the same as the original Lisp Badge. You can save the entire workspace to flash.
Current consumption
The Lisp Badge LE draws only 6mA from its CR2032 button cell, and so should have a life of about 40 hours. There’s a physical on/off switch too for long periods of inactivity.
Lisp language
The Lisp Badge LE runs the AVR version of uLisp which provides 16-bit integer arithmetic, arbitrary length symbols and strings, lists, multi-dimensional arrays, Arduino interface functions, debugging features, and built-in documentation.
Display
The display is a low-power monochrome graphics display [1] which I explored in an earlier article; see Monochrome Low-Power Display Library. It has a resolution of 250×122 pixels, and a text resolution of 10 lines of 41 characters per line. It supports reading back from the display, which makes it possible to support a full range of graphics functions, including plotting points, drawing lines, drawing outline and filled rectangles circles or triangles, and plotting characters and text at normal size or enlarged by any integer scale factor.
Keyboard
The keyboard takes advantage of push buttons that mount on the reverse of the board, with the button caps protruding through holes in the PCB. This makes it much easier to use than on the original Lisp Badge because it’s easier to press the keys, and there’s space for larger key legends. The push buttons are available from Adafruit [2]. or The Pi Hut in the UK [3].
It uses the same 45-key layout as the original Lisp badge, with upper and lower-case characters, digits, and the symbols required by uLisp. However, it now provides an addition META modifier key in addition to SHIFT, allowing you to enter characters that don’t have a dedicated key on the keyboard.
Peripherals
There’s a large piezo speaker that supports playing notes, and a reverse-mounting LED that shines through a hole on the front of the board.
Here’s the full specification:
Lisp Badge – Specification
Size: 107mm x 61mm (4.2″ x 2.4″).
Display: 41 characters x 10 lines, or 250 x 122 pixels.
Keyboard: Integrated 45-key keyboard providing upper and lower-case characters, digits, and the symbols required by uLisp.
The META key pressed in conjunction with another key gives access to the following characters not available from the main keyboard:
META + | A | C | D | E | P | Q | T | U | V | < | > |
Character | & | : | $ | ! | % | ? | @ | ^ | | | { | } |
Memory available: 2800 Lisp cells (11200 bytes).
Flash: 16384 bytes of flash are reserved for use to save the Lisp workspace using save-image.
Processor: AVR128DB48
Clock speed: 24 MHz.
Current consumption: Approx. 6 mA. A CR2032 cell has a typical capacity of 225 mAh, so this should give a life of about 40 hours.
Types supported: list, symbol, integer, character, string, stream, and array.
An integer is a sequence of digits, optionally prefixed with “+” or “-“. Integers can be between -32768 and 32767. You can enter numbers in hexadecimal, octal, or binary with the notations #x2A, #o52, or #b101010, all of which represent 42.
User-defined symbol names can have arbitrary names. Any sequence that isn’t an integer can be used as a symbol; so, for example, 12a is a valid symbol.
There is one namespace for functions and variables; in other words, you cannot use the same name for a function and a variable.
Includes a mark and sweep garbage collector. Garbage collection takes 5 msec.
Language
uLisp, a subset of Common Lisp, with the following 196 Lisp functions and special forms:
* + – / /= 1+ 1- < <= = > >= ? abs analogread analogreadresolution analogreference analogwrite and append apply apropos apropos-list aref array-dimensions arrayp ash assoc atom bit boundp break caaar caadr caar cadar caddr cadr car case cdaar cdadr cdar cddar cdddr cddr cdr char char-code characterp check-key closure cls code-char concatenate cond cons consp dacreference decf defcode defun defvar delay digitalread digitalwrite documentation dolist dotimes draw-char draw-circle draw-line draw-pixel draw-rect draw-triangle edit eq equal error eval evenp fill-circle fill-rect fill-screen fill-triangle first for-millis format funcall gc get-pixel globals glyph-pixel if ignore-errors incf integerp keyboard keywordp lambda length let let* list list-library listp load-image locals logand logbitp logior lognot logxor loop make-array makunbound mapc mapcan mapcar max member millis min minusp mod not note nothing nth null numberp oddp or pinmode plot plot3d plusp pop pprint pprintall prin1 prin1-to-string princ princ-to-string print progn push quote random read read-byte read-from-string read-line register require rest restart-i2c return reverse room save-image search second set set-cursor setf setq sleep sort streamp string string< string= string> stringp subseq symbolp t terpri third >