aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2015-06-09 14:02:21 +0200
committerLars-Dominik Braun <lars@6xq.net>2015-06-09 14:02:21 +0200
commit3f861e826d621d43bd05a54dd034c517a999beed (patch)
tree2e581b43b58382dd75ff8be951de81bcf42711f1
parent7ef723e1c217652d6b329faa6aa3120fbd91d24c (diff)
downloadhourglass-3f861e826d621d43bd05a54dd034c517a999beed.tar.gz
hourglass-3f861e826d621d43bd05a54dd034c517a999beed.tar.bz2
hourglass-3f861e826d621d43bd05a54dd034c517a999beed.zip
Disable PWM in idle state
Reduces power consumption
-rw-r--r--ui.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/ui.c b/ui.c
index 21fcd38..3d8a8d2 100644
--- a/ui.c
+++ b/ui.c
@@ -34,8 +34,6 @@ THE SOFTWARE.
#include "timer.h"
#include "pwm.h"
-#define sign(x) ((x < 0) ? -1 : 1)
-
/* keep the lights on for 10 ms */
#define FLASH_ALARM_ON ((uint32_t) 10*1000)
/* and wait 500 ms */
@@ -131,13 +129,12 @@ static int16_t limits (const int16_t in, const int16_t min, const int16_t max) {
}
}
-/* Enter idle mode
+/* Enter low-power idle mode
*/
static void enterIdle () {
mode = UIMODE_IDLE;
- pwmSetOff ();
- pwmSet (horizonLed (0), 1);
+ pwmStop ();
}
static void enterFlash (const flashmode next) {
@@ -268,10 +265,12 @@ static void doIdle () {
const uint32_t brightnessStep = timerValue/(uint32_t) ((PWM_LED_COUNT-1)*PWM_MAX_BRIGHTNESS);
mode = UIMODE_RUN;
+ pwmStart ();
timerStart (brightnessStep, false);
speakerStart (SPEAKER_BEEP);
} else if (accelGetShakeCount () >= 1) {
/* set timer */
+ pwmStart ();
accelResetShakeCount ();
enterFlash (FLASH_ENTER_COARSE);
return;