Knob
A circular component that rotates from left to right to set numerical values.
Similar to the Slider in functionality.
Properties
The value returned by the position of the knob, ranging from -100 to 100.
Returns
true
if the user is moving the knob.
Events
KnobValueChangeEvent : { Value number, Type string }
Triggered when the knob is moved.
*Value
is the respective value given by the knob's position
*Type
is"KnobValueChangeEvent"
Examples
A simple code using some math to map knob's value into the hue of a LED's color:
-- a function that maps "value"
-- from a scale of "src_from" to "src_to"
-- into a scale of "tgt_from" to "tgt_to"
function map(value, src_from, src_to, tgt_from, tgt_to)
return ((value - src_from) / (src_to - src_from) * (tgt_to - tgt_from)) + tgt_from
end
-- turn LED on at startup
gdt.Led0.State = true
function update()
-- map slider -100,100 to hue 0,360
local hue = map(gdt.Knob0.Value, -100, 100, 0, 360)
-- set LED color to hue
gdt.Led0.Color = ColorHSV(hue, 100, 100)
end