^41 - The Preset Port

This is a read only port for the current preset on a device.
For a load controller this will be the current preset of each output. For sensors and UIs it will be things like motion control, light control, native current preset, and temperature current preset.

The value is reported as base zero. EX Preset 1 returns 0x00.

Syntax

LDA ^41,x //load the current preset value
Where x is the proxy channel index of the thing you want the current preset of.

^41 Logical current preset subport mapping

SubPort

Load Controller

Sensor

UI

^41,0

Output 1

Motion

Native Area

^41,1

Output 2

Primary Closed Loop

Proximity Sensor

^41,2

Output 3

Tertiary Closed Loop

Device Area

^41,3

Output 4

Open Loop

^41,4

Output 5

IR Lighting

Temperature

^41,5

Output 6

^41,6

Output 7

^41,7

Output 8

^41,8

Output 9

^41,9

Output 10

IR Temperature

^41,n

Output n-1

Example

Example 1

Task checks the current preset of an output on the controller.

Task1()
{
LDA ^41,2	    //Load the preset of output3
BRZ HIGH		//Are the lights on full?
CMP #2
BRZ LOW			//Are the lights on low?
CMP #3
BRZ OFF			//Are the lights off?
HIGH:
	Preset(A=10,P=4,F=3)	//Turn off bedroom
	Delay(.2)
	Preset(A=5,P=1,F=3)		//Turn on nightlights
	Null
LOW:
	Preset(A=10,P=4,F=3)	//Turn off bedroom
	Null
OFF:
	Preset(A=10,P=1,F=3)	//Turn on bedroom
	Delay(.2)
	Preset(A=5,P=4,F=3)		//Turn off nightlights
	Null
}

Example 2

Reports what preset the motion sensor thinks it is in.

Task1()
{
    Name="Sensor Preset Report"
    LDA #0x6c
	STA ~0
	LDA ^41,0	//Load the motion sensor current preset into the first byte
	STA ~1
	tx ~0,2,7	//Send it out as a debug message
}

Example 3

This task uses the current preset for a jump table.

{
    Name="Preset Jumper"
    LDA ^41,0       //Load the current preset of channel 1 (RED)
    SWAP   			//Swap the preset number to the x register
    MUL 4           //Multiply the value by 4. This creates an offset of 4
	TAX             //Transfer the value in the accumulator to the x register
	BRA PJumper,x   //Jump to the label plus the value in the x register
	Null
	PJumper:        //This is the jump table. The task will jump to the specified row.
		BRA P1
		BRA P2
		BRA P3
		BRA P4
		BRA P5
	Null
		P1:
		//Do something for Preset 1
		Null
		...
}