Permalink
Browse files

s/LED/light and add Button, Light and RangedInput protocols

  • Loading branch information...
1 parent aaef0ea commit 02820db9007bf14a7ecd764dce14d7be3e046e39 @samaaron samaaron committed Apr 6, 2012
Showing with 34 additions and 8 deletions.
  1. +34 −8 src/overtone/device/protocols.clj
@@ -21,23 +21,49 @@
"A generic representation of a grid of lights."
(width [this]
"Returns the number of elements of the grid width-wise. This value
- is not expected to change." )
+ is not expected to change.")
(height [this]
"Returns the number of elements of the grid height-wise. This
value is not expected to change.")
- (led-set [this x y colour]
- "Set the LED at position [x y] to the given colour. Color 0 is
+ (light-set [this x y colour]
+ "Set the light at position [x y] to the given colour. Color 0 is
off, > 0 represents a specific palette colour. Subject to
change.")
- (led-set-all [this colour]
- "Sets all LEDs to a single colour or off if 0.")
- (led-frame [this leds]
- "Update the entire field of LEDs. The rows arg is a map of coords
+ (light-set-all [this colour]
+ "Sets all light to a single colour or off if 0.")
+ (light-frame [this leds]
+ "Update the entire field of lights. The rows arg is a map of coords
to colour values, the same as in led-set. Any unspecified coords
should default to 0.
For example, if you have a 2x2 grid, you could update all of the
- LEDs like this:
+ lights like this:
(led-frame grid {[0 0] 1 [1 0] 0
[0 1] 0 [1 1] 1})"))
+
+(defprotocol Button
+ (on-action [this f]
+ "Registers a callback fn, to be called when the button is pressed
+ or released. If a handler has already been registered, replace the
+ old handler with this new one.
+
+ The handler fn should take one arg [action], where action is a
+ keyword from the set #{:pressed :released}"))
+
+(defprotocol Light
+ (light-set [this colour]
+ "Set the light to the given colour. Color 0 is off, > 0 represents a
+ specific palette colour. Subject to change."))
+
+(defprotocol RangedInput
+ (min-val [this]
+ "Returns the minimum value the slider will output. This value is
+ not expected to change.")
+ (max-val [this]
+ "Returns the maximum value the slider will output. This value is
+ not expected to change.")
+ (on-action [this f]
+ "Registers a callback fn, to be called when the slider is
+ moved. If a handler has already been registered, replace the old
+ handler with this new one."))

0 comments on commit 02820db

Please sign in to comment.