Skip to content
Snippets Groups Projects

Display Backlight: automatically adjust to ambient sensor reading

Open cs requested to merge klausdieter1/firmware:autobacklight into master
Files
2
+ 46
0
#include "epicardium.h"
#include "modules.h"
#include "log.h"
bool _autobrightness_enabled = true;
void vAutoBrightnessTask(void *pvParameters)
{
vTaskDelay(pdMS_TO_TICKS(500));
while (1) {
vTaskDelay(pdMS_TO_TICKS(60000));
if (_autobrightness_enabled) {
unsigned short int light;
while (epic_light_sensor_run() < 0)
LOG_CRIT(
"autobrightness",
"Could not start ambient sensor"
);
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();
}
}
}
Loading