Skip to content
Snippets Groups Projects
Commit f9996e22 authored by Christof Schulze's avatar Christof Schulze
Browse files

Display Backlight: automatically adjust to ambient sensor reading

This registers a Task, reading the ambient light sensor once aminute and
adjusting the display backlight accordingly
parent 83a19117
No related branches found
No related tags found
No related merge requests found
Pipeline #3508 passed
......@@ -69,6 +69,23 @@ int main(void)
abort();
}
/* Automatically adjust the brightness of the display according to the
** light sensor */
if (xTaskCreate(
vAutoBrightnessTask,
(const char *)"DisplayBrightness",
configMINIMAL_STACK_SIZE,
NULL,
tskIDLE_PRIORITY + 4,
NULL) != pdPASS) {
LOG_CRIT(
"startup",
"Failed to create %s task!",
"vAutoBrightnessTask"
);
abort();
}
/* MAX30001 */
if (xTaskCreate(
vMAX30001Task,
......@@ -80,6 +97,7 @@ int main(void)
LOG_CRIT("startup", "Failed to create %s task!", "MAX30001");
abort();
}
/* API */
if (xTaskCreate(
vApiDispatcher,
......
#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();
}
}
}
module_sources = files(
'bhi.c',
'bme680.c',
'brightness.c',
'buttons.c',
'dispatcher.c',
'display.c',
......
......@@ -44,6 +44,9 @@ int personal_state_enabled();
/* ---------- PMIC --------------------------------------------------------- */
void vPmicTask(void *pvParameters);
/* ---------- Automatically adjust Brightness ------------------------------ */
void vAutoBrightnessTask(void *pvParameters);
/* ---------- Watchdog ----------------------------------------------------- */
void watchdog_init();
void watchdog_clearer_init();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment