aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2015-01-13 13:18:48 +0100
committerLars-Dominik Braun <lars@6xq.net>2015-01-13 13:18:48 +0100
commite748efd36ae4fb41f24baa4cc79d674dba2a8c3f (patch)
treef2425e5dc1aff9f8874da55941de0dbfe436c1c6
parentebc6f6a6cf20a25c0dd2cefaa9c86285509a3407 (diff)
downloadhourglass-e748efd36ae4fb41f24baa4cc79d674dba2a8c3f.tar.gz
hourglass-e748efd36ae4fb41f24baa4cc79d674dba2a8c3f.tar.bz2
hourglass-e748efd36ae4fb41f24baa4cc79d674dba2a8c3f.zip
Remove debugging puts/fwrite
We’re tight on SRAM and the stack seems overflow from time to time. Removing the strings should give us some breathing room.
-rw-r--r--accel.c8
-rw-r--r--i2c.c1
-rw-r--r--ui.c22
3 files changed, 3 insertions, 28 deletions
diff --git a/accel.c b/accel.c
index 350bf9f..152346a 100644
--- a/accel.c
+++ b/accel.c
@@ -85,11 +85,10 @@ void accelStart () {
if (!twRequest (TWM_WRITE, LIS302DL, LIS302DL_CTRLREG1, data,
sizeof (data)/sizeof (*data))) {
- puts ("cannot start write");
+ assert (0);
}
sleepwhile (twr.status == TWST_WAIT);
assert (twr.status == TWST_OK);
- puts ("accelStart done");
disableWakeup (WAKE_I2C);
}
@@ -166,15 +165,14 @@ bool accelProcess () {
/* new data transfered */
return true;
} else if (twr.status == TWST_ERR) {
- puts ("accel i2c error: ");
- fwrite ((void *) &twr.error, sizeof (twr.error), 1, stdout);
+ assert (0);
}
} else {
if (shouldWakeup (WAKE_ACCEL) && twr.status == TWST_OK) {
/* new data available in device buffer and bus is free */
if (!twRequest (TWM_READ, LIS302DL, LIS302DL_OUTZ,
(uint8_t *) &zval, sizeof (zval))) {
- puts ("cannot start read");
+ assert (0);
} else {
/* wakeup source is disabled by isr to prevent race condition */
reading = true;
diff --git a/i2c.c b/i2c.c
index 26da2d8..bbee35b 100644
--- a/i2c.c
+++ b/i2c.c
@@ -39,7 +39,6 @@ static void twWaitRaw () {
static bool twWriteRaw (const uint8_t data) {
TWDR = data;
if (TWCR & (1 << TWWC)) {
- puts ("write collision");
return false;
} else {
return true;
diff --git a/ui.c b/ui.c
index 3327318..219edd0 100644
--- a/ui.c
+++ b/ui.c
@@ -123,8 +123,6 @@ static void setFine (const int8_t value) {
* minutes */
const int8_t bottomlimit = coarseValue == 0 ? 1 : -5;
fineValue = limits(value, bottomlimit, 5);
- puts ("\nfineValue\n");
- fwrite (&fineValue, sizeof (fineValue), 1, stdout);
/* from bottom to top for positive values, top to bottom for negative
* values */
@@ -148,7 +146,6 @@ static void doSelectCoarse () {
/* selection */
accelResetShakeCount ();
mode = UIMODE_SELECT_FINE;
- puts ("selectcoarse->selectfine");
setFine (0);
speakerStart (SPEAKER_BEEP);
return;
@@ -161,8 +158,6 @@ static void doSelectCoarse () {
coarseValue = limits(coarseValue + zticks, 0, 6);
/* at least 1 min */
fineValue = coarseValue == 0 ? 1 : 0;
- puts ("\ncoarseValue\n");
- fwrite (&coarseValue, sizeof (coarseValue), 1, stdout);
pwmSetOff ();
for (uint8_t i = 0; i < coarseValue; i++) {
@@ -180,7 +175,6 @@ static void doSelectFine () {
speakerStart (SPEAKER_BEEP);
gyroStop ();
- puts ("selectfine->idle");
enterIdle ();
return;
}
@@ -208,25 +202,19 @@ static void doIdle () {
timerValue = coarseValue * (uint32_t) 10*60*1000*1000 +
fineValue * (uint32_t) 60*1000*1000;
- puts ("\ntimerValue\n");
- fwrite (&timerValue, sizeof (timerValue), 1, stdout);
timerElapsed = 0;
/* (PWM_LED_COUNT-1)*PWM_MAX_BRIGHTNESS states; -1, since two leds’s
* states are interleaved */
const uint32_t brightnessStep = timerValue/(uint32_t) ((PWM_LED_COUNT-1)*PWM_MAX_BRIGHTNESS);
- puts ("\nbrightnessStep\n");
- fwrite (&brightnessStep, sizeof (brightnessStep), 1, stdout);
mode = UIMODE_RUN;
timerStart (brightnessStep, false);
- puts ("idle->run");
speakerStart (SPEAKER_BEEP);
} else if (accelGetShakeCount () >= 1) {
/* set timer */
accelResetShakeCount ();
gyroStart ();
mode = UIMODE_SELECT_COARSE;
- puts ("idle->select");
speakerStart (SPEAKER_BEEP);
/* start with a value of zero */
pwmSetOff ();
@@ -241,15 +229,12 @@ static void doRun () {
const uint32_t t = timerHit ();
if (t > 0) {
timerElapsed += t;
- puts ("\ntimerElapsed");
- fwrite (&timerElapsed, sizeof (timerElapsed), 1, stdout);
if (timerElapsed >= timerValue) {
/* ring the alarm! */
for (uint8_t i = 0; i < PWM_LED_COUNT; i++) {
pwmSet (i, PWM_MAX_BRIGHTNESS);
}
timerStop ();
- puts ("run->alarm");
/* beep only once */
speakerStart (SPEAKER_BEEP);
enterFlash (FLASH_ALARM);
@@ -262,16 +247,11 @@ static void doRun () {
if (brightness[currLed] == 0 && currLed > 0) {
--currLed;
}
- puts ("\ncurrLed");
- fwrite (&currLed, sizeof (currLed), 1, stdout);
- puts ("\nbrightness");
- fwrite (&brightness, sizeof (brightness), 1, stdout);
}
} else if (horizonChanged) {
/* stop timer */
speakerStart (SPEAKER_BEEP);
- puts ("run->idle (stopped)");
enterIdle ();
}
}
@@ -350,7 +330,6 @@ static void doFlashOff () {
static void doInit () {
/* get initial orientation */
if (horizonChanged && h != HORIZON_NONE) {
- puts ("init->idle");
enterIdle ();
#if 0
@@ -361,7 +340,6 @@ static void doInit () {
/* (PWM_LED_COUNT-1)*PWM_MAX_BRIGHTNESS states; -1, since two leds’s
* states are interleaved */
brightnessStep = timerValue/(uint32_t) ((PWM_LED_COUNT-1)*PWM_MAX_BRIGHTNESS);
- puts ("\nbrightnessStep\n");
fwrite (&brightnessStep, sizeof (brightnessStep), 1, stdout);
currLed = PWM_LED_COUNT-1;