aboutsummaryrefslogtreecommitdiff
path: root/ui.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2015-02-26 14:39:30 +0100
committerLars-Dominik Braun <lars@6xq.net>2015-02-26 14:46:23 +0100
commite2e3038c627ea7460915cdd535cb91301af614a7 (patch)
tree392efd367176e57696eac7d21674b262f0cc7997 /ui.c
parent1a73da01d68d743d795830a6f7f36a083c7b6ed2 (diff)
downloadhourglass-e2e3038c627ea7460915cdd535cb91301af614a7.tar.gz
hourglass-e2e3038c627ea7460915cdd535cb91301af614a7.tar.bz2
hourglass-e2e3038c627ea7460915cdd535cb91301af614a7.zip
accel: Stop polling
Use freefall interrupts instead. This drop the fancy horizon/shake detection algorithms, but it works surprisingly well and is way more energy-efficient. Shake detection is a little too sensitive imo and horizon detection needs some tweaking too.
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/ui.c b/ui.c
index 0d95751..f9e478d 100644
--- a/ui.c
+++ b/ui.c
@@ -461,21 +461,10 @@ void uiLoop () {
accelStart ();
pwmSet (1, PWM_OFF);
- /* make sure data is read even when missing the first interrupt (i.e.
- * reboot) */
- enableWakeup (WAKE_ACCEL);
- enableWakeup (WAKE_GYRO);
-
while (1) {
processSensors ();
- horizon newh = accelGetHorizon ();
- if (newh != h) {
- horizonChanged = true;
- } else {
- horizonChanged = false;
- }
- h = newh;
+ h = accelGetHorizon (&horizonChanged);
switch (mode) {
case UIMODE_INIT:
@@ -514,12 +503,11 @@ void uiLoop () {
sleepwhile (wakeup == 0);
#if 0
- printf ("t=%i, h=%i, s=%i\n", gyroGetZTicks (), accelGetHorizon (),
+ printf ("t=%i, h=%i, s=%i\n", gyroGetZTicks (), h,
accelGetShakeCount ());
const int32_t gyroval = gyroGetZAccum ();
const int16_t gyroraw = gyroGetZRaw ();
- const int8_t accelval = accelGetZ ();
- printf ("%li - %i - %i\n", gyroval, gyroraw, accelval);
+ printf ("%li - %i\n", gyroval, gyroraw);
#endif
}