; ; Scrolling display server ; (defvar *codes* '(#x0 #x6 #x220 #x12CE #x12ED #xC24 #x235D #x400 #x2400 #x900 #x3FC0 #x12C0 #x800 #xC0 #x0 #xC00 #xC3F #x6 #xDB #x8F #xE6 #x2069 #xFD #x7 #xFF #xEF #x1200 #xA00 #x2400 #xC8 #x900 #x1083 #x2BB #xF7 #x128F #x39 #x120F #xF9 #x71 #xBD #xF6 #x1200 #x1E #x2470 #x38 #x536 #x2136 #x3F #xF3 #x203F #x20F3 #xED #x1201 #x3E #xC30 #x2836 #x2D00 #x1500 #xC09 #x39 #x2100 #xF #xC03 #x8)) (defun on (bri) (with-i2c (str #x70) (write-byte #x21 str) (restart-i2c str) (write-byte (+ bri #xe0) str) (restart-i2c str) (write-byte #x81 str))) (defun display (x str) (if (>= x #x60) (setq x (- x #x20))) (if (= x #x2b) (setq x 32)) (write-byte (nth (- x 32) *codes*) str) (write-byte (ash (nth (- x 32) *codes*) -8) str)) (defun scroll (string) (let ((len (length string))) (dotimes (x (+ len 5)) (with-i2c (str #x70) (write-byte #x00 str) (dotimes (j 4) (let ((i (+ x j -4))) (display (if (<= 0 i (1- len)) (char-code (char string i)) 32) str)))) (delay 250)))) (defun println (x s) (princ x s) (princ #\return s) (princ #\newline s)) (defun display-server () (wifi-server) (on 8) (loop (with-client (s) (let* ((line (read-line s)) (text (subseq line 6 (- (length line) 10)))) (loop (unless (= 0 (available s))) (return)) (println "HTTP/1.1 200 OK" s) (println "Content-Type: text/html" s) (println "Connection: close" s) (println "" s) (print text) (princ "Received OK" s) (println "" s) (scroll text))) (delay 1000)))