--- /dev/null
+#ifndef INCLUDED_BADGE_BACKLIGHT_H
+#define INCLUDED_BADGE_BACKLIGHT_H
+
+void badge_backlight_init(void);
+void badge_backlight_enable(void);
+void badge_backlight_disable(void);
+
+#endif
#include "init.h"
+#include "backlight.h"
#include "pinconfig.h"
#include "util/util.h"
#include "ui/display.h"
#include <core/wdt/wdt.h>
#include <core/gpio/gpio.h>
-static void badge_init_backlight(void) {
- HOB_SET_PIN_FUNC(HOB_LCD_BACKLIGHT, CLKOUT);
-
- wdtInit(false);
- SCB_CLKOUTCLKSEL = SCB_MAINCLKSEL_SOURCE_WDTOSC;
- SCB_CLKOUTCLKUEN = SCB_CLKOUTCLKUEN_DISABLE;
- SCB_CLKOUTCLKUEN = SCB_CLKOUTCLKUEN_UPDATE;
- SCB_CLKOUTCLKDIV = 75;
-}
-
void badge_init(void) {
#define INPUT_PIN_CONFIG(spec, mode) do { \
HOB_SET_PIN_FUNC(spec, GPIO); \
#undef OUTPUT_PIN_CONFIG
- badge_init_backlight();
+ badge_backlight_init();
badge_display_init();
}
#include "event.h"
+#include "../backlight.h"
#include <core/gpio/gpio.h>
#include <core/pmu/pmu.h>
#include <badge/pinconfig.h>
#endif
+enum {
+ BACKLIGHT_ACTIVITY_TIMEOUT = 2307
+};
+
// We depend on input being popped often, so no queue.
static badge_event_t volatile event_buffer;
static uint8_t volatile event_flag;
+static uint16_t volatile activity_counter = BACKLIGHT_ACTIVITY_TIMEOUT;
enum {
BADGE_EVENT_FLAG_INPUT = 1,
uint8_t new_state = badge_input_raw();
if(new_state != old_state) {
+ if(activity_counter == 0) {
+ badge_backlight_enable();
+ }
+ activity_counter = BACKLIGHT_ACTIVITY_TIMEOUT;
+
event_buffer = badge_event_new(BADGE_EVENT_USER_INPUT,
old_state,
new_state);
event_flag |= BADGE_EVENT_FLAG_INPUT;
}
+ if(activity_counter == 0) {
+ badge_backlight_disable();
+ } else {
+ --activity_counter;
+ }
+
event_flag |= BADGE_EVENT_FLAG_TIMER;
}