; Digital Photo Frame for M5Stack Tab5 ; ; see http://forum.ulisp.com/t/a-digital-photo-frame-written-in-lisp/1870 (defun collect-pics-list nil (with-client (s "www.wackyimage.com" 80) (format s "GET /show?K5A HTTP/1.0~a~%" #\Return) (format s "Host: www.wackyimage.com~a~%" #\Return) (format s "Cookie: LOGIN=KCJQaG90b0ZyYW1lIiAuICJmYWI1NDlkNmE4YzBmZmE4MTQyYzNjODk2YzRkZDEwMiIp~a~%" #\Return) (format s "Connection: close~a~%" #\Return) (format s "~a~%" #\Return) (skip-headers s) (collect-pics s))) (defun skip-headers (s) (loop (when (= (length (read-line s)) 1) (return)))) (defun collect-pics (s) (let (line pics) (loop (setq line (read-line s)) (when (search "" line) (return pics)) (let ((pic (search "/k58/" line)) (end (search "\" alt=\"" line))) (when (and pic end) (push (subseq line (+ pic 5) end) pics)))))) (defun display-pic (pic) (with-client (s "www.wackyimage.com" 80) (format s "GET /pictures/k58/~a HTTP/1.0~a~%" pic #\return) (format s "Host: www.wackyimage.com~a~%" #\return) (format s "Connection: close~a~%" #\return) (format s "~a~%" #\return) (skip-headers s) (decode-gif s))) (defvar *minutes* 10) (defun photo-frame () (wifi-connect "Mynetwork" "mypassword") (delay 5000) (let ((nextpic 0) (lastpics 0)) (loop (let* ((pics (collect-pics-list)) (npics (length pics))) (when (> npics lastpics) (setq nextpic lastpics) (setq lastpics npics)) (display-pic (nth (mod nextpic npics) pics))) (incf nextpic) (delay (* 1000 60 *minutes*)))))