From eb2f425621eb3746abdb96a3dd7da87351153f25 Mon Sep 17 00:00:00 2001 From: Folkert van Heusden Date: Wed, 12 Jun 2024 22:35:28 +0200 Subject: [PATCH] timestamps in output / reduced panel screenrate --- ESP32/console_esp32.cpp | 2 +- console.cpp | 15 +++++++++++++++ console.h | 6 ++++++ debugger.cpp | 6 ++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ESP32/console_esp32.cpp b/ESP32/console_esp32.cpp index 548569e..6d603bf 100644 --- a/ESP32/console_esp32.cpp +++ b/ESP32/console_esp32.cpp @@ -108,7 +108,7 @@ void console_esp32::panel_update_thread() pixels.show(); while(!stop_panel) { - vTaskDelay(20 / portTICK_PERIOD_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); try { // note that these are approximately as there's no mutex on the emulation diff --git a/console.cpp b/console.cpp index 82f92d3..ea1de78 100644 --- a/console.cpp +++ b/console.cpp @@ -290,6 +290,21 @@ void console::put_char(const char c) debug_buffer.clear(); } + if (timestamps) { + char buffer[32] { }; + uint64_t timestamp = get_us() - start_ts; + uint64_t seconds = timestamp / 1000000; + + int len = snprintf(buffer, sizeof buffer, "%02d:%02d:%02d.%06d ", + int(seconds / 3600), + int((seconds / 60) % 60), + int(seconds % 60), + int(timestamp % 1000000)); + + for(int i=0; i #include +#include "utils.h" + #if defined(_WIN32) #include "win32.h" #endif @@ -48,6 +50,8 @@ protected: char *screen_buffer { nullptr }; uint8_t tx { 0 }; uint8_t ty { 0 }; + std::atomic_bool timestamps { false }; + const uint64_t start_ts { get_us() }; const size_t n_edit_lines_hist { 8 }; // maximum number of previous edit-lines std::vector edit_lines_hist; @@ -75,6 +79,8 @@ public: std::string read_line(const std::string & prompt); void flush_input(); + void enable_timestamp(const bool state) { timestamps = state; } + void emit_backspace(); void put_char(const char c); void put_string(const std::string & what); diff --git a/debugger.cpp b/debugger.cpp index 044e889..8b61e81 100644 --- a/debugger.cpp +++ b/debugger.cpp @@ -1082,6 +1082,11 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto continue; } + else if (parts[0] == "pts" && parts.size() == 2) { + cnsl->enable_timestamp(std::stoi(parts[1])); + + continue; + } else if (cmd == "qi") { show_queued_interrupts(cnsl, c); @@ -1183,6 +1188,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto "trace/t - toggle tracing", "setll x,y - set loglevel: terminal,file", "setsl x,y - set syslog target: requires a hostname and a loglevel", + "pts x - enable (1) / disable (0) timestamps", "turbo - toggle turbo mode (cannot be interrupted)", "debug - enable CPU debug mode", "bt - show backtrace - need to enable debug first",