From eee8ebadfab08d8e98447f5ce3f9bde672b80dca Mon Sep 17 00:00:00 2001 From: Manfred Steiner Date: Sat, 30 Sep 2023 22:17:28 +0200 Subject: [PATCH] minor bug fixes --- examples/simuc/src/main.cpp | 4 +++- examples/simuc/src/simavr/simavr.cpp | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/simuc/src/main.cpp b/examples/simuc/src/main.cpp index 88167a4..345a872 100644 --- a/examples/simuc/src/main.cpp +++ b/examples/simuc/src/main.cpp @@ -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) { diff --git a/examples/simuc/src/simavr/simavr.cpp b/examples/simuc/src/simavr/simavr.cpp index 0774e0c..b12befe 100644 --- a/examples/simuc/src/simavr/simavr.cpp +++ b/examples/simuc/src/simavr/simavr.cpp @@ -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; -- 2.39.5