aboutsummaryrefslogtreecommitdiff
path: root/guile/starlet/fixture-library/arduino.scm
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-04-18 11:42:21 +0200
committerThomas White <taw@physics.org>2021-04-18 12:58:53 +0200
commit17177f965f281583d68c19e891e611d9ff7c1d4c (patch)
tree9184d03fb469a7bf517bb6a9f203fd786e8de6c6 /guile/starlet/fixture-library/arduino.scm
parent4cfef7e2f9f5fc5451cd2e949d7b6229bbaf972b (diff)
Add <arduino-dmx-thing>
Diffstat (limited to 'guile/starlet/fixture-library/arduino.scm')
-rw-r--r--guile/starlet/fixture-library/arduino.scm27
1 files changed, 27 insertions, 0 deletions
diff --git a/guile/starlet/fixture-library/arduino.scm b/guile/starlet/fixture-library/arduino.scm
new file mode 100644
index 0000000..a46cb73
--- /dev/null
+++ b/guile/starlet/fixture-library/arduino.scm
@@ -0,0 +1,27 @@
+(define-module (starlet fixture-library arduino)
+ #:use-module (oop goops)
+ #:use-module (starlet base)
+ #:use-module (starlet colours)
+ #:export (<arduino-dmx-thing>))
+
+
+;; This fixture class drives the RGB LED on the Arduino DMX shield
+;; as described by Matthias Hertel at http://www.mathertel.de/Arduino/DMXShield.aspx
+
+
+(define-class <arduino-dmx-thing> (<fixture>)
+ (attributes
+ #:init-form (list
+ (attr-continuous 'intensity '(0 100) 0)
+ (attr-colour 'colour white))))
+
+
+(define-method (scanout-fixture (fixture <arduino-dmx-thing>)
+ get-attr set-chan8 set-chan16)
+
+ (let ((intensity (get-attr 'intensity))
+ (rgb (colour-as-rgb (get-attr 'colour))))
+ (set-chan8 1 (percent->dmxval8 (* intensity 0.01 (car rgb))))
+ (set-chan8 2 (percent->dmxval8 (* intensity 0.01 (cadr rgb))))
+ (set-chan8 3 (percent->dmxval8 (* intensity 0.01 (caddr rgb))))))
+