From e2859b10807c4ea1e9171b090805ba988c733a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Wed, 7 Jan 2015 16:50:45 +0100 Subject: [PATCH] add start stop message --- firmware/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/firmware/main.c b/firmware/main.c index 1af7e2e..5e1e087 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -32,7 +32,8 @@ /* variables */ volatile uint8_t state_portD; // the state of port D volatile bool scale_on = false; // is the scale on (based on the SCALE_ON PIN) -volatile bool pwm_high = false; // is the PWM for the last weight measurement high +volatile bool scale_old = false; // the previous state (to detect changes) +volatile bool pwm_high = false; // is the PWM for the weight measurement high volatile bool measurement_flag = false; // is a PWM measurement value ready volatile uint16_t measurement_value = 0; // the PWM measurement value from the timer @@ -145,6 +146,11 @@ int main(void) printf(PSTR("welcome to the body scale weight reader\n")); // print welcome message while (true) { // endless loop for micro-controller + /* display if scale switches on */ + if (scale_old!=scale_on && scale_on) { + printf(PSTR("scale start\n")); + scale_old=scale_on; + } /* display value if available */ if (measurement_flag) { if (pwm_high) { @@ -154,6 +160,11 @@ int main(void) } measurement_flag = false; } + /* display if scale switches off */ + if (scale_old!=scale_on && !scale_on) { + printf(PSTR("scale stop\n")); + scale_old=scale_on; + } /* go to sleep and wait for next interrupt */ set_sleep_mode(SLEEP_MODE_IDLE); sleep_mode();