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

This registers a Task, reading the ambient light sensor and adjusting the display backlight accordingly

fixes #95

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 #include "epicardium.h"
2 #include "modules.h"
3 #include "log.h"
4
5 bool _autobrightness_enabled = true;
6
7 void vAutoBrightnessTask(void *pvParameters)
  • rahix
    rahix @rahix started a thread on the diff
  • 5 bool _autobrightness_enabled = true;
    6
    7 void vAutoBrightnessTask(void *pvParameters)
    8 {
    9 vTaskDelay(pdMS_TO_TICKS(500));
    10
    11 while (1) {
    12 vTaskDelay(pdMS_TO_TICKS(60000));
    13 if (_autobrightness_enabled) {
    14 unsigned short int light;
    15
    16 while (epic_light_sensor_run() < 0)
    17 LOG_CRIT(
    18 "autobrightness",
    19 "Could not start ambient sensor"
    20 );
  • rahix
    rahix @rahix started a thread on the diff
  • 1 #include "epicardium.h"
    2 #include "modules.h"
    3 #include "log.h"
    4
    5 bool _autobrightness_enabled = true;
    6
    7 void vAutoBrightnessTask(void *pvParameters)
    8 {
    9 vTaskDelay(pdMS_TO_TICKS(500));
    10
    11 while (1) {
    12 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
  • rahix
    rahix @rahix started a thread on the diff
  • 28 }
    29
    30 epic_light_sensor_stop();
    31
    32 unsigned short int brightness;
    33
    34 if (light > 199)
    35 brightness = 100;
    36 else
    37 brightness = light / 2 + 1;
    38
    39 if (epic_disp_open() < 0)
    40 continue;
    41
    42 epic_disp_backlight(brightness);
    43 epic_disp_close();
  • added 6 - Changes Requested label and removed 6 - Needs Review label

  • Another thing to consider is what happens when an app sets the backlight. With the current implementation, the backlight setting will get overwritten periodically. This is not what we want. I'd suggest that an App writing the backlight will completely disable auto-backlight until a new app is loaded.

  • rahix removed milestone

    removed milestone

  • Please register or sign in to reply
    Loading