Module Duplex.StateController
The StateController handles states within a display/controlmap
A state can toggle any part of a control-map on/off while a device configuration is running.
They represent a separate mapping layer, independantly of the device configuration, and are especially useful when you are running out of space on the controller - or when an application does not provide you with enough flexibility.
Adding a state is done via the special
Once a state has been defined, you can begin prefixing target nodes, using the state's name as the identifier - for example,
Most nodes can be prefixed: Group, Row, Column and Param (but not SubParam). For a detailed description of all supported attributes for
Changes
0.99.3
- First release
Functions
__init (display) | Initialize the StateController class |
handle_message (msg) | interpret an incoming message, update display accordingly (this method is invoked when the MessageStream receive a message) |
add_state (xarg, t) | add a state |
match (msg) | match states with message - discover if message is a trigger |
initialize () | called once the display has created the virtual control surface |
add_view (state_id, view) | associate a parameter with a named state |
toggle (state_id) | toggle a named state |
enable (state_id) | activate a named state |
disable (state_id) | deactivate a named state |
update_trigger (ui_obj, color, text, val) | update the display of a trigger-button |
Tables
self.states |
associative array
|
self.registered_ids | (table) list of control-map elements (used when initializing) |
Fields
self.display | (Duplex.Display) |
self.app | (Duplex.Application) handles our trigger-buttons |
Functions
- __init (display)
-
Initialize the StateController class
Parameters:
- display
- handle_message (msg)
-
interpret an incoming message, update display accordingly
(this method is invoked when the MessageStream receive a message)
Parameters:
- msg
- add_state (xarg, t)
-
add a state
Parameters:
- xarg
- t
- match (msg)
-
match states with message - discover if message is a trigger
Parameters:
- msg TRACE("StateController - match",msg)
Returns:
-
table
- initialize ()
- called once the display has created the virtual control surface
- add_view (state_id, view)
-
associate a parameter with a named state
Parameters:
- state_id (string) unique name/id for the state
- view (table) control-map parameter
- toggle (state_id)
-
toggle a named state
Parameters:
- state_id (string) unique name/id for the state
- enable (state_id)
-
activate a named state
Parameters:
- state_id (string) unique name/id for the state
- disable (state_id)
-
deactivate a named state
Parameters:
- state_id (string) unique name/id for the state
- update_trigger (ui_obj, color, text, val)
-
update the display of a trigger-button
Parameters:
- ui_obj (Duplex.UIButton)
- color (table) 8-bit r/g/b values
- text (string) button or label text
- val (number or table) as defined by the UIComponent
Tables
- self.states
-
associative array
[string] = { -- state name/id xarg = (table) -- control-map attributes active = (bool) -- current state triggers = [ param = (table) -- control-map <Param> ui_obj = (table) -- instance of UIButton ],... params = (table) -- table of control-map params [1] = { xarg = (table) } },...
- self.registered_ids
- (table) list of control-map elements (used when initializing)
Fields
- self.display
- (Duplex.Display)
- self.app
- (Duplex.Application) handles our trigger-buttons