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
4
+ 37
0
#include "epicardium.h"
#include "modules.h"
#include "log.h"
bool _autobrightness_enabled = true;
void vAutoBrightnessTask(void *pvParameters)
{
vTaskDelay(pdMS_TO_TICKS(500));
while (epic_light_sensor_run() < 0)
LOG_CRIT("autobrightness", "Could not start ambient sensor");
while (1) {
vTaskDelay(pdMS_TO_TICKS(1000));
if (_autobrightness_enabled) {
unsigned short int light;
if (epic_light_sensor_get(&light) < 0) {
LOG_CRIT("autobrightness", "Could not read light sensor");
continue;
}
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