aboutsummaryrefslogtreecommitdiff
path: root/guile
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-08-22 12:40:58 +0200
committerThomas White <taw@physics.org>2020-08-22 12:40:58 +0200
commit4f010d04fe38324769e6cf77e6720a84e08e99a8 (patch)
tree9353db6be86c84a21ab728a50fe9650f981bbf95 /guile
parente5c10f8ad742ca8bb157e96e477931758a4866f1 (diff)
Pass higher-level DMX setters to scanout functions
Diffstat (limited to 'guile')
-rw-r--r--guile/starlet/base.scm15
-rw-r--r--guile/starlet/fixture-library/generic.scm7
-rw-r--r--guile/starlet/fixture-library/robe.scm14
3 files changed, 17 insertions, 19 deletions
diff --git a/guile/starlet/base.scm b/guile/starlet/base.scm
index 839c064..2d218cd 100644
--- a/guile/starlet/base.scm
+++ b/guile/starlet/base.scm
@@ -326,7 +326,20 @@
combined-state)
(hirestime)))
- (scanout-fixture fix get-attr set-dmx))
+ ;; Helper function to set 8-bit DMX value
+ (define (set-chan relative-channel-number value)
+ (set-dmx (get-fixture-universe fix)
+ (+ (get-fixture-addr fix)
+ (- relative-channel-number 1))
+ value))
+
+ ;; Helper function to set 16-bit DMX value
+ (define (set-chan-16bit relative-channel-number value max-value)
+ (let ((val16 (* value (/ 65535 max-value))))
+ (set-chan relative-channel-number (msb val16))
+ (set-chan (+ relative-channel-number 1) (lsb val16))))
+
+ (scanout-fixture fix get-attr set-chan set-chan-16bit))
(atomic-box-ref patched-fixture-list)))
diff --git a/guile/starlet/fixture-library/generic.scm b/guile/starlet/fixture-library/generic.scm
index f90bf3a..2ab7ce2 100644
--- a/guile/starlet/fixture-library/generic.scm
+++ b/guile/starlet/fixture-library/generic.scm
@@ -10,10 +10,7 @@
(define-method (scanout-fixture (fixture <generic-dimmer>)
- get-attr
- set-dmx)
+ get-attr set-chan set-chan-16bit)
;; Set DMX value for intensity
- (set-dmx (get-fixture-universe fixture)
- (get-fixture-addr fixture)
- (percent->dmxval (get-attr 'intensity))))
+ (set-chan 1 (percent->dmxval (get-attr 'intensity))))
diff --git a/guile/starlet/fixture-library/robe.scm b/guile/starlet/fixture-library/robe.scm
index a2b46c8..7ad12a6 100644
--- a/guile/starlet/fixture-library/robe.scm
+++ b/guile/starlet/fixture-library/robe.scm
@@ -21,19 +21,7 @@
(define-method (scanout-fixture (fixture <robe-dl7s-mode1>)
- get-attr
- set-dmx)
-
- (define (set-chan relative-channel-number value)
- (set-dmx (get-fixture-universe fixture)
- (+ (get-fixture-addr fixture)
- (- relative-channel-number 1))
- value))
-
- (define (set-chan-16bit relative-channel-number value max-value)
- (let ((val16 (* value (/ 65535 max-value))))
- (set-chan relative-channel-number (msb val16))
- (set-chan (+ relative-channel-number 1) (lsb val16))))
+ get-attr set-chan set-chan-16bit)
(set-chan-16bit 50 (get-attr 'intensity) 100)