Backlight bei Inaktivität aus.
authorWintermute <wintermute@hannover.ccc.de>
Mon, 28 Oct 2013 22:12:26 +0000 (23:12 +0100)
committerWintermute <wintermute@hannover.ccc.de>
Mon, 28 Oct 2013 22:12:26 +0000 (23:12 +0100)
Makefile
badge/backlight.h [new file with mode: 0644]
badge/init.c
badge/ui/event.c

index 21b726e..97eda7a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -34,6 +34,7 @@ OPTDEFINES = -D__NEWLIB__
 \r
 SRCS = \\r
   badge/fahrplan.c \\r
+  badge/backlight.c \\r
   badge/init.c \\r
   badge/main.c \\r
   badge/jumpnrun/collision.c \\r
diff --git a/badge/backlight.h b/badge/backlight.h
new file mode 100644 (file)
index 0000000..9169c00
--- /dev/null
@@ -0,0 +1,8 @@
+#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
index 33d048d..7f9cec1 100644 (file)
@@ -1,4 +1,5 @@
 #include "init.h"
+#include "backlight.h"
 #include "pinconfig.h"
 #include "util/util.h"
 #include "ui/display.h"
@@ -6,16 +7,6 @@
 #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);                                       \
@@ -47,6 +38,6 @@ void badge_init(void) {
 
 #undef OUTPUT_PIN_CONFIG
 
-  badge_init_backlight();
+  badge_backlight_init();
   badge_display_init();
 }
index 55cbdbd..e77dcb5 100644 (file)
@@ -1,4 +1,5 @@
 #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,
@@ -51,12 +57,23 @@ void badge_event_irq(void) {
   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;
 }
 
This page took 0.02695 seconds and 4 git commands to generate.