Skip to content
Snippets Groups Projects

Display Backlight: automatically adjust to ambient sensor reading

Open cs requested to merge klausdieter1/firmware:autobacklight into master
4 unresolved threads
Files
2
+ 46
0
#include "epicardium.h"
#include "modules.h"
#include "log.h"
bool _autobrightness_enabled = true;
void vAutoBrightnessTask(void *pvParameters)
Please register or sign in to reply
{
vTaskDelay(pdMS_TO_TICKS(500));
while (1) {
vTaskDelay(pdMS_TO_TICKS(60000));
    • I think once a minute is a little slow. Lightlevels can change quite quickly, e.g. when moving from a hackerspace to the "outside world".

Please register or sign in to reply
if (_autobrightness_enabled) {
unsigned short int light;
while (epic_light_sensor_run() < 0)
LOG_CRIT(
"autobrightness",
"Could not start ambient sensor"
);
    • The light-sensor is always running in the current firmware. You should not enable/disable it here.

Please register or sign in to reply
while (epic_light_sensor_get(&light) < 0) {
LOG_CRIT(
"autobrightness",
"Could not read light sensor"
);
vTaskDelay(pdMS_TO_TICKS(500));
}
epic_light_sensor_stop();
unsigned short int brightness;
if (light > 199)
brightness = 100;
else
brightness = light / 2 + 1;
if (epic_disp_open() < 0)
continue;
epic_disp_backlight(brightness);
epic_disp_close();
Please register or sign in to reply
}
}
}
Loading