^35 - The Light Level Sensor Port
This port is a read only value of the current lux level in two bytes.
This can be useful to make sure a task only executes above or below certain lux levels.
This only reports the calibrated value not a raw value recorded by the sensor. |
Syntax
LDA ^35,x
Where x is the detector index you want a value for
LDA ^35,0 //The lux level low byte
LDA ^35,1 //The lux level high byte
SubPort |
Response Type |
^35,0 |
Filtered Lux Low |
^35,1 |
Filtered Lux High |
^35,2 |
Unfiltered Lux Low |
^35,3 |
Unfiltered Lux High |
^35,4 |
Filtered Raw Lux Low |
^35,5 |
Filtered Raw Lux High |
^35,6 |
Unfiltered Raw Lux Low |
^35,7 |
Unfiltered Raw Lux High |
^35,8* |
Target Lux Level for Current Preset Low |
^35,9* |
Target Lux Level for Current Preset High |
*Target lux level for current preset is a read/write value and can be edited unlike the other subports. |
Example
Excerpt from the D3 Sensor Closed loop daylight holdoff switch task template included in System Builder.
#const ClosedLoopArea 8
#const DaylightSwitchLuxHI 0
#const DaylightSwitchLuxLO 200
Task1()
{
Name="Daylight Switch"
//Task is configured to start on motion and stop on no motion. Task stops itself when lights are switched on.
//Task reads lux port and calculates if lights should be set to preset 1 (on)
GetLux:
LDA ^35,1 //Lux level Hi byte
CMP #DaylightSwitchLuxHI
BRZ HiByteEqual
BCC TooBright //Measured lux level higher than switch level
BRA P1
HiByteEqual:
LDA ^35,0 //Lux level Lo byte
CMP #DaylightSwitchLuxLO
BCC TooBright //Measured lux level higher than switch level
BRA P1
TooBright:
delay(2)
BRA GetLux
P1:
Preset(a=ClosedLoopArea,p=1,f=2)
null
}