fix list processing issue

This commit is contained in:
Kyle Isom 2025-04-10 20:09:06 -07:00
parent aeed5bb515
commit 83c1f0e305
3 changed files with 29 additions and 13 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
*.fasl *.fasl
beepy beepy
fw fw
bin
man1

View File

@ -5,6 +5,10 @@ names := $(files:.lisp=)
all: $(names) all: $(names)
$(binaries): $: bin/%
$(manuals): %: man/man1/%.1
$(names): %: bin/% man/man1/%.1 $(names): %: bin/% man/man1/%.1
bin/%: %.lisp build-binary.sh Makefile bin/%: %.lisp build-binary.sh Makefile
@ -17,5 +21,10 @@ man/man1/%.1: %.lisp build-manual.sh Makefile
./build-manual.sh $< ./build-manual.sh $<
mv $(@F) man/man1/ mv $(@F) man/man1/
install: $(names)
cp -p bin/* /usr/local/bin
mkdir -p /usr/local/man/man1
cp -p man1/* /usr/local/man/man1/
clean: clean:
rm -rf bin man *.fasl rm -rf bin man *.fasl

View File

@ -193,10 +193,14 @@
(every #'uint8p rgb)))) (every #'uint8p rgb))))
(defun get-color (color) (defun get-color (color)
(let ((color (if (and (listp color)
(listp (car color)))
(car color)
color)))
(when (validate-rgb color) (when (validate-rgb color)
(if (keywordp color) (if (keywordp color)
(cadr (assoc color *rgb-pure*)) (cadr (assoc color *rgb-pure*))
color))) color))))
(defun set-led (state) (defun set-led (state)
(unless (typep state 'boolean) (unless (typep state 'boolean)
@ -204,17 +208,17 @@
(let ((state-number (if state 1 0))) (let ((state-number (if state 1 0)))
(write-value-to-interface "led" state-number))) (write-value-to-interface "led" state-number)))
(defun set-led-color (rgb) (defun set-led-color (color &optional no-write)
(println rgb) (let ((rgb (get-color color)))
(let ((rgb (get-color rgb)))
(println rgb)
(unless rgb (unless rgb
(error 'invalid-color :color rgb)) (error 'invalid-color :color rgb))
(destructuring-bind (r g b) rgb (destructuring-bind (r g b) rgb
(if no-write
(format t "r: ~a, g: ~a, b: ~a~%" r g b)
(list (list
(write-value-to-interface "led_red" r) (write-value-to-interface "led_red" r)
(write-value-to-interface "led_green" g) (write-value-to-interface "led_green" g)
(write-value-to-interface "led_blue" b))))) (write-value-to-interface "led_blue" b))))))
(defun set-keyboard-backlight (level) (defun set-keyboard-backlight (level)
(unless (uint8p level) (unless (uint8p level)