Commit dab03c28 authored by Hermann Mayer's avatar Hermann Mayer

[Binary][Docs] Implemented the disabling of the ambient light sensor check, when…

[Binary][Docs] Implemented the disabling of the ambient light sensor check, when setting the light sensor threshold to zero.
parent 3e42d93d
......@@ -30,8 +30,8 @@ turn_device_off_after = 600;
# Sensor thresholds
#
# With a 10-bit ADC (eg. MCP3008) the range is 0-1023
# The daemon takes care of a PIR motion trigger if the value of the light is
# below the specified threshold
# The daemon takes care of a detected PIR motion if the level of the ambient
# light is below the specified threshold
# 0 will disable the light sensor check
# light_sensor_thold = 500;
......
......@@ -91,8 +91,8 @@ This value is a
.B "light_sensor_thold"
The daemon takes care of a PIR motion trigger if the value of the light is
below the specified threshold. 0 will disable the light sensor check.
The daemon takes care of a detected PIR motion if the level of the ambient
light is below the specified threshold. 0 will disable the light sensor check.
With a 10-bit ADC (eg. MCP3008) the range is 0-1023.
This parameter is
.I ignored by
......
......@@ -106,14 +106,24 @@ void detect_motions(struct config *conf)
utlog(LOG_INFO, "A motion was detected\n");
allvl = amblght_level();
// Check if the light_sensor is zero,
// then we skip the light sensor check
if (0 != conf->tholds.light_sensor) {
if (allvl < conf->tholds.light_sensor) {
// It is to bright in here, so its unlikely to change in 30 secs
utlog(LOG_INFO, " The ambient light level (%d) did not passed the threshold (%d)\n",
allvl, conf->tholds.light_sensor);
sleep(30);
continue;
allvl = amblght_level();
if (allvl >= conf->tholds.light_sensor) {
// It is to bright in here, so its unlikely to change in 30 secs
utlog(LOG_INFO, " %s (%d) %s (%d), %s\n", "The ambient light level",
allvl, "passed the threshold", conf->tholds.light_sensor,
"it is to bright in here");
sleep(30);
continue;
}
utlog(LOG_INFO, " %s (%d) %s (%d), %s\n", "The ambient light level",
allvl, "did not passed the threshold", conf->tholds.light_sensor,
"let's trigger the actor");
}
if (0 < switch_action(conf)) {
......@@ -153,10 +163,14 @@ void init_sensors(struct config *conf)
exit(EXIT_FAILURE);
}
if (0 != amblght_init(conf->sensor.light_dev,
(uint8_t) conf->sensor.light_channel)) {
utlog(LOG_ERR, "Failed to initialize the Ambient Light sensor.\n");
exit(EXIT_FAILURE);
if (0 != conf->tholds.light_sensor) {
if (0 != amblght_init(conf->sensor.light_dev,
(uint8_t) conf->sensor.light_channel)) {
utlog(LOG_ERR, "Failed to initialize the Ambient Light sensor.\n");
exit(EXIT_FAILURE);
}
} else {
utlog(LOG_NOTICE, "Disabled the ambient light sensor..");
}
}
......
......@@ -30,8 +30,8 @@ turn_device_off_after = 600;
# Sensor thresholds
#
# With a 10-bit ADC (eg. MCP3008) the range is 0-1023
# The daemon takes care of a PIR motion trigger if the value of the light is
# below the specified threshold
# The daemon takes care of a detected PIR motion if the level of the ambient
# light is below the specified threshold
# 0 will disable the light sensor check
# light_sensor_thold = 500;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment