(defun pprintf (sym str)
  "(pprintf sym str)
Pretty-print the function pointed to by sym to
the stream, which follows the 'format directives."
  (let ((form (eval sym)))
    (format str "(defun ~a ~a~%~{  ~a~^~%~})"
       (string sym)
       (cadr form)
       (cddr form))))

(defun copy-file (source dest)
  (with-sd-card (writer dest 2)
    (with-sd-card (reader source)
      (loop
	(let ((data (read-byte reader)))
	  (when (null data)
	    (return))
	  (write-byte data writer))))))

(defun i2c-scan (port)
  (dotimes (addr 127)
    (with-i2c (str port addr)
      (when str (print addr)))))

(defun i2c-scan2 (port)
  (dotimes (addr 127)
    (with-i2c (str port addr)
      (format t "~,20'x: " addr)
      (if str (print t)
	(print nil)))))
