SHIP:Port:gpio:ambLight

From Serious Documentation
Jump to: navigation, search
Portvar Data Type Permissions Description
ambLight Byte Read Only Reflects the current ambient light intensity, from 0 to 100%. Can be combined with backlight to make the LCD backlight brightness track the ambient light conditions.

For example, you can create a listener to wake up when the ambient light conditions change:

listener listeningto="platform.GPIO.ambLight"

then, in the script, assign the backlight intensity with a formula that maps the 0-100% range of the ambient light to, for example, 30 to 100% of the backlight brightness:

platform.GLASS0.backlight = 30 + platform.GPIO.ambLight * 0.7f;

You can, of course, create any formula you wish. One simpler formula is

platform.GLASS0.backlight = 50 + platform.GPIO.ambLight;

This says the minimum brightness is 50%, and since assigning to platform.GLASS0.backlight clips at 100% any time the ambLight is >50% the LCD backlight brightness will be 100%.