Commit eee8ebadfab08d8e98447f5ce3f9bde672b80dca
receivedSat, 30. Sep 2023, 22:17:34 (by user sx)
Sat, 30 Sep 2023 20:17:34 +0000 (22:17 +0200)
authorManfred Steiner <sx@htl-kaindorf.at>
Sat, 30 Sep 2023 20:17:28 +0000 (22:17 +0200)
committerManfred Steiner <sx@htl-kaindorf.at>
Sat, 30 Sep 2023 20:17:28 +0000 (22:17 +0200)
2 files changed:
examples/simuc/src/main.cpp
examples/simuc/src/simavr/simavr.cpp

index 88167a4e924369daafeda3d2b2ae229dc7db110d..345a87214d7ec595fa2bd51b002681b29e679313 100644 (file)
@@ -210,7 +210,9 @@ int main (int argc, char **argv) {
     printf("----------------------------------------------------------------------\n");
     printf("init done - press key to start\n");
     char c = getchar();
-    getchar(); // remove line feed from stdin
+    if (c != '\n') {
+        getchar(); // remove line feed from stdin
+    }
     printf("----------------------------------------------------------------------\n");
     
     switch (c) {
index 0774e0c0a625a92fbfb289ee8213f64d6592416c..b12befe4c97e069260ce2372e55523e28f26a506 100644 (file)
@@ -495,7 +495,7 @@ bool SimAvr::sprintfLedStatus (char *s, size_t size, bool onlyOnChange) {
                                }
                                if (!onlyOnChange || nextLedL != ledL) {
                                        ledL = nextLedL;
-                                       snprintf(s, size, "LED L = %c", ledL ? 'X' : '.');
+                                       snprintf(s, size, "LED L = %c", ledL == 1 ? 'X' : '.');
                                        rv = true;
                                }
                                break;
@@ -520,7 +520,7 @@ bool SimAvr::sprintfLedStatus (char *s, size_t size, bool onlyOnChange) {
                                if (!onlyOnChange || change) {
                                        int n = snprintf(s, size, "LED PA[3210] =");
                                        for (int i = 3; i >= 0; i--) {
-                                               n += snprintf(s + n, size - n, " %c", led[i] ? 'X' : '.');
+                                               n += snprintf(s + n, size - n, " %c", led[i] == 1 ? 'X' : '.');
                                        }
                                        rv = true;
                                }
@@ -536,7 +536,7 @@ bool SimAvr::sprintfLedStatus (char *s, size_t size, bool onlyOnChange) {
                                }
                                if (!onlyOnChange || nextLed != led) {
                                        led = nextLed;
-                                       snprintf(s, size, "LED1 (PB0) = %c", led ? 'X' : '.');
+                                       snprintf(s, size, "LED1 (PB0) = %c", led == 1 ? 'X' : '.');
                                        rv = true;
                                }
                                break;