]> www.fi.muni.cz Git - openparking.git/blobdiff - firmware/firmware.c
fix incorrect error state handling for LED2
[openparking.git] / firmware / firmware.c
index c2dd944e54f12566a8bee73473076fe99f7b03e4..3554dcc768e38e6deda7bdd7fe5fb8459e52a2c2 100644 (file)
@@ -110,7 +110,7 @@ static void do_measurement(unsigned char trig)
 
                if (to_start & (1 << i)) { // echo not received
                        uint16_t err_count = err_counts[off] & 0xFF;
-                       if (err_count < 255) {
+                       if (distances[off] != -1 && err_count < 255) {
                                err_count++;
                                err_counts[off] = (err_counts[off] & 0xFF00)
                                        | err_count;
@@ -187,9 +187,9 @@ static void leds_update()
        }
 
        if (led_bitmap & 8) {
-               DDRB |= _BV(PB5);
-       } else {
                DDRB &= ~_BV(PB5);
+       } else {
+               DDRB |= _BV(PB5);
        }
 }