; Simple data plotter for SSD1306 72x40 OLED display (defun init () (with-i2c (s 1 60) (writebytes s 0 #x8d #x14 #x20 #x01 #xd9 #xf1 #xad #x30 #xa1 #xaf))) (defun writebytes (s &rest b) (dolist (i b) (write-byte i s))) (defvar xa 0) (defvar ya 20) (defun set (yy byt) (if (<= 0 yy 7) (logior byt (ash 1 yy)) byt)) (defun plot (x y) (with-i2c (s 1 60) (writebytes s 0 #x21 (+ x 28) (+ x 28) #x22 0 4) (restart-i2c s) (write-byte #x40 s) (dotimes (p 5) (write-byte (if (= x xa) #xff (set (- ya (* p 8)) (set (- y (* p 8)) 0))) s)))) (defvar pi 3.14159) (defun test () (dotimes (x 72) (plot x (round (+ 20 (/ (* 22 (sin (/ x pi))) (exp (/ x 36)))))))) (defun clear () (dotimes (x 72) (plot x -1)))