aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2014-09-30 16:48:39 +0200
committerLars-Dominik Braun <lars@6xq.net>2014-09-30 16:48:39 +0200
commit7d78e567cae3b8d3eaa11bf00ec45d18244e4645 (patch)
treec4ba78f08518cb41f621ee6b6bd5754d2b556aaa
parent40a747a13a71c3c95c141173281ca1d82794b679 (diff)
downloadhourglass-7d78e567cae3b8d3eaa11bf00ec45d18244e4645.tar.gz
hourglass-7d78e567cae3b8d3eaa11bf00ec45d18244e4645.tar.bz2
hourglass-7d78e567cae3b8d3eaa11bf00ec45d18244e4645.zip
Limit fine value range
-rw-r--r--ui.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ui.c b/ui.c
index b9528a4..ce98b32 100644
--- a/ui.c
+++ b/ui.c
@@ -94,6 +94,8 @@ static void doSelectCoarse () {
if (abs (zticks) > 0) {
gyroResetZTicks ();
coarseValue = limits(coarseValue + zticks, 0, 6);
+ /* at least 1 min */
+ fineValue = coarseValue == 0 ? 1 : 0;
puts ("\ncoarseValue\n");
fwrite (&coarseValue, sizeof (coarseValue), 1, stdout);
@@ -122,7 +124,10 @@ static void doSelectFine () {
const int16_t zticks = gyroGetZTicks ();
if (abs (zticks) > 0) {
gyroResetZTicks ();
- fineValue = limits(fineValue + zticks, -5, 5);
+ /* min timer value is 1 minute, disable subtract if coarse is below ten
+ * minutes */
+ const int8_t bottomlimit = coarseValue == 0 ? 1 : -5;
+ fineValue = limits(fineValue + zticks, bottomlimit, 5);
puts ("\nfineValue\n");
fwrite (&fineValue, sizeof (fineValue), 1, stdout);
@@ -182,6 +187,7 @@ static void doIdle () {
mode = UIMODE_SELECT_COARSE;
puts ("idle->select");
speakerStart (SPEAKER_BEEP);
+ coarseValue = 0;
return;
}
}