Skip to content

Sensors

Federico edited this page Jan 21, 2020 · 25 revisions

Sensors support

Clightd supports both Camera and ALS devices.
Moreover, since Clightd 4.1, a Custom sensor has been added.

Clightd offers an unified API to use these sensors under /org/clightd/clightd/Sensor: Capture and IsAvailable. When using these methods, if no device is specified, first supported sensor found will be used.
Obviously, ALS devices have higher priority as they are less power hungry and offer better results.
This is the priority list:

  • ALS
  • Camera
  • Custom

API also offers specific paths for each sensor: /org/clightd/clightd/Sensor/Als, /org/clightd/clightd/Sensor/Camera and /org/clightd/clightd/Sensor/Custom implement org.clightd.clightd.Sensor interface, but only for chosen sensor type.

Camera

Clightd should support any capture device, both internal or USB, through udev.
Supported capture format are Greyscale and YUV.

ALS

Clightd should support any ALS device through udev. If you have an acpi-als device and it does not work properly, it was reported that you may need an additional acpi call to enable the sensor:
echo \\_SB.PCI0.LPCB.EC0.ALSC 0x1 > /proc/acpi/call.
This call is needed at each reboot; thanks to u/bradbrad2x for its kind testing!

Custom

Custom sensor were made available to support your own sensor source; it just requires a text file with an integer and it can be filled by any source.
This means you theoretically should be able to eg: read ambient light values from your smartphone to a text file and let Clightd gracefully handle the value.
Custom sensor behaviour depends upon "sysname" parameter:

  • if empty, it will use first file it finds into /etc/clightd/sensors.d/ folder, in alphabetical order
  • if absolute path, it will just use "sysname" as a path to be read from
  • if relative path, it will try to find "sysname" file into /etc/clightd/sensors.d/ folder

Note also that /etc/clightd/sensors.d/ is monitored for changes through inotify, thus you can runtime-add a new custom sensor to the folder and a dbus signal will be emitted, and clightd will start using it from subsequent calls.

Settings String

Sensor settings string can be used to further customize your sensor capture parameters; it should be built as "A=b,C=d" string.

Camera

A and C are v4l2 operation ids, and b and d are their desired values. Operation ids are taken from . Example: "10094849=1,10094850=166" means "V4L2_CID_EXPOSURE_AUTO=V4L2_EXPOSURE_MANUAL,V4L2_CID_EXPOSURE_ABSOLUTE=166".

ALS

Three options are made available: "i", "m", "M".

  • "i" -> interval used by Clightd for polling sensor. It defaults to 20ms and it is the time Clightd waits before each sequential sensor reading (eg: when capturing 5 frames, it will sleep 20ms between each captured frame).
  • "m" -> minimum value threshold for sensor readings: if sensor reading is below this threshold, it will be set to this value.
  • "M" -> maximum value threshold for sensor readings: if sensor reading is above this threshold, it will be set to this value.

Note that "m" and "M" affects returned percentages (valued as read_value / maximum, and read_value is bounded to minimum and maximum values).

Custom

Three options are made available: "i", "m", "M".

  • "i" -> interval used by Clightd for polling text file. It defaults to 20ms and it is the time Clightd waits before each sequential file reading (eg: when capturing 5 frames, it will sleep 20ms between each read).
  • "m" -> minimum value threshold for sensor readings: if sensor reading is below this threshold, it will be set to this value.
  • "M" -> maximum value threshold for sensor readings: if sensor reading is above this threshold, it will be set to this value.

Note that "m" and "M" affects returned percentages (valued as read_value / maximum, and read_value is bounded to minimum and maximum values).

Clone this wiki locally