use DEBUG option
This commit is contained in:
parent
e2859b1080
commit
bea4e707ac
|
@ -32,7 +32,9 @@
|
||||||
/* variables */
|
/* variables */
|
||||||
volatile uint8_t state_portD; // the state of port D
|
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 scale_on = false; // is the scale on (based on the SCALE_ON PIN)
|
||||||
|
#ifdef DEBUG
|
||||||
volatile bool scale_old = false; // the previous state (to detect changes)
|
volatile bool scale_old = false; // the previous state (to detect changes)
|
||||||
|
#endif
|
||||||
volatile bool pwm_high = false; // is the PWM for the weight measurement high
|
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 bool measurement_flag = false; // is a PWM measurement value ready
|
||||||
volatile uint16_t measurement_value = 0; // the PWM measurement value from the timer
|
volatile uint16_t measurement_value = 0; // the PWM measurement value from the timer
|
||||||
|
@ -146,25 +148,33 @@ int main(void)
|
||||||
|
|
||||||
printf(PSTR("welcome to the body scale weight reader\n")); // print welcome message
|
printf(PSTR("welcome to the body scale weight reader\n")); // print welcome message
|
||||||
while (true) { // endless loop for micro-controller
|
while (true) { // endless loop for micro-controller
|
||||||
|
#ifdef DEBUG
|
||||||
/* display if scale switches on */
|
/* display if scale switches on */
|
||||||
if (scale_old!=scale_on && scale_on) {
|
if (scale_old!=scale_on && scale_on) {
|
||||||
printf(PSTR("scale start\n"));
|
printf(PSTR("scale start\n"));
|
||||||
scale_old=scale_on;
|
scale_old=scale_on;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* display value if available */
|
/* display value if available */
|
||||||
if (measurement_flag) {
|
if (measurement_flag) {
|
||||||
if (pwm_high) {
|
if (pwm_high) {
|
||||||
|
#ifdef DEBUG
|
||||||
printf("high: %u\n",measurement_value);
|
printf("high: %u\n",measurement_value);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef DEBUG
|
||||||
printf("low: %u\n",measurement_value);
|
printf("low: %u\n",measurement_value);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
measurement_flag = false;
|
measurement_flag = false;
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
/* display if scale switches off */
|
/* display if scale switches off */
|
||||||
if (scale_old!=scale_on && !scale_on) {
|
if (scale_old!=scale_on && !scale_on) {
|
||||||
printf(PSTR("scale stop\n"));
|
printf(PSTR("scale stop\n"));
|
||||||
scale_old=scale_on;
|
scale_old=scale_on;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* go to sleep and wait for next interrupt */
|
/* go to sleep and wait for next interrupt */
|
||||||
set_sleep_mode(SLEEP_MODE_IDLE);
|
set_sleep_mode(SLEEP_MODE_IDLE);
|
||||||
sleep_mode();
|
sleep_mode();
|
||||||
|
|
Loading…
Reference in New Issue