Knob

Knob

A circular component that rotates to set numerical values. In Default mode the value goes from -100 on the left to 100 on the right. When set to Infinite mode the rotation is unclamped and the value is the absolute angle in degrees.

Similar to the Slider in functionality.

Properties

Mode KnobMode

The mode of the Knob:
In Default mode the value goes from -100 on the left to 100 on the right.
When set to Infinite mode the rotation is unclamped and the value is the absolute angle in degrees.

Value number

The value returned by the position of the knob.
In Default mode the value goes from -100 on the left to 100 on the right.
When set to Infinite mode the rotation is unclamped and the value is the absolute angle in degrees.

DeltaValue number

The rotation delta from the previous update.

IsMoving boolean read only

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
* DeltaValue is the the rotation delta from the previous update
* 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