From 83c1f0e3059295ad4ed02e7798361e916db3a351 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Thu, 10 Apr 2025 20:09:06 -0700 Subject: [PATCH] fix list processing issue --- .gitignore | 5 ++++- Makefile | 9 +++++++++ beepy.lisp | 28 ++++++++++++++++------------ 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index e80952f..ff51367 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ *.fasl beepy -fw \ No newline at end of file +fw +bin +man1 + diff --git a/Makefile b/Makefile index 8a5c2f2..fb72b99 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,10 @@ names := $(files:.lisp=) all: $(names) +$(binaries): $: bin/% + +$(manuals): %: man/man1/%.1 + $(names): %: bin/% man/man1/%.1 bin/%: %.lisp build-binary.sh Makefile @@ -17,5 +21,10 @@ man/man1/%.1: %.lisp build-manual.sh Makefile ./build-manual.sh $< 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: rm -rf bin man *.fasl diff --git a/beepy.lisp b/beepy.lisp index 1cebaa5..3d8b574 100644 --- a/beepy.lisp +++ b/beepy.lisp @@ -193,10 +193,14 @@ (every #'uint8p rgb)))) (defun get-color (color) - (when (validate-rgb color) - (if (keywordp color) - (cadr (assoc color *rgb-pure*)) - color))) + (let ((color (if (and (listp color) + (listp (car color))) + (car color) + color))) + (when (validate-rgb color) + (if (keywordp color) + (cadr (assoc color *rgb-pure*)) + color)))) (defun set-led (state) (unless (typep state 'boolean) @@ -204,17 +208,17 @@ (let ((state-number (if state 1 0))) (write-value-to-interface "led" state-number))) -(defun set-led-color (rgb) - (println rgb) - (let ((rgb (get-color rgb))) - (println rgb) +(defun set-led-color (color &optional no-write) + (let ((rgb (get-color color))) (unless rgb (error 'invalid-color :color rgb)) (destructuring-bind (r g b) rgb - (list - (write-value-to-interface "led_red" r) - (write-value-to-interface "led_green" g) - (write-value-to-interface "led_blue" b))))) + (if no-write + (format t "r: ~a, g: ~a, b: ~a~%" r g b) + (list + (write-value-to-interface "led_red" r) + (write-value-to-interface "led_green" g) + (write-value-to-interface "led_blue" b)))))) (defun set-keyboard-backlight (level) (unless (uint8p level)