add start stop message

This commit is contained in:
King Kévin 2015-01-07 16:50:45 +01:00
parent 7b1287afaf
commit e2859b1080
1 changed files with 12 additions and 1 deletions

View File

@ -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();