Lisp Badge LE extensions

This page describes the additional functions provided in the Lisp Badge LE.

Note that for consistency with the uLisp graphics extensions the origin (0,0) is in the top left corner of the display.

get-pixel function

Syntax: (get-pixel x y)

Returns the colour of the pixel at (x, y) as 0 (black) or 1 (white).

plot function

Syntax: (plot [x-intercept y-intercept] [function]...)

Plots up to four functions on the same graph, optionally with axes. Each function should be a function of one parameter, the x coordinate, and it will be called with each value of x from 0 to 249. The function should return the y value, from 0 to 121.

If x-intercept and y-intercept are specified, plot draws axes through those intercepts. For example, defining:

(defun sine ()
  (let ((x 0) (y 2045))
    (lambda (n) 
      n
      (incf x (/ (* y 16) 163))
      (decf y (/ (* x 16) 163))
    (+ 32 (ash x -6)))))

the following command plots a sine wave with axes:

(plot 0 32 (sine))

plot3d function

Syntax: (plot3d [x-intercept y-intercept] [function])

The function should be a function of two parameters, the x and y coordinates, and it will be called with each value of x from 0 to 249 and y from 0 to 121. The function should return 0 (black) or 1 (white).

If x-intercept and y-intercept are specified, plot3d draws axes through those intercepts.

For example, define:

(defun p (x y) 
  (let ((a (/ (- x 125) 2))
        (b (- y 61))) 
    (logand (/ (+ (* a a) (* b b) (* a b)) 64) 1)))

and then run the following command:

(plot3d 125 61 p)

keyboard function

Syntax: (keyboard enable)

Disables or enables the keyboard buffer. Before using check-key call:

(keyboard nil)

check-key function

Syntax: (check-key character)

Allows you to read the state of a key on the keyboard, and returns t if the key corresponding to character is being pressed, or nil otherwise. This allows you to write interactive games using the keyboard.

The character should be the unshifted character corresponding to each key on the matrix, namely one of:

#\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9 #\0 #\backspace
#\q #\w #\e #\r #\t #\y #\u #\i #\o #\p \#newline
#\a #\s #\d #\f #\g #\h #\j #\k #\l #\escape
#\z #\x #\c #\v #\b #\n #\m #\( #\) #\.

You can also read the state of the SHIFT and META keys with:

(digitalread :shift-key)

and:

(digitalread :meta-key)

They will return nil if the key is pressed and t otherwise.