timestamps in output / reduced panel screenrate

This commit is contained in:
Folkert van Heusden 2024-06-12 22:35:28 +02:00
parent a4cc44c222
commit eb2f425621
Signed by untrusted user who does not match committer: folkert
GPG key ID: 30190E8C1F28D8AE
4 changed files with 28 additions and 1 deletions

View file

@ -108,7 +108,7 @@ void console_esp32::panel_update_thread()
pixels.show(); pixels.show();
while(!stop_panel) { while(!stop_panel) {
vTaskDelay(20 / portTICK_PERIOD_MS); vTaskDelay(100 / portTICK_PERIOD_MS);
try { try {
// note that these are approximately as there's no mutex on the emulation // note that these are approximately as there's no mutex on the emulation

View file

@ -290,6 +290,21 @@ void console::put_char(const char c)
debug_buffer.clear(); 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<len; i++)
put_char_ll(buffer[i]);
}
ty++; ty++;
} }
else if (c == 8) { // backspace else if (c == 8) { // backspace

View file

@ -10,6 +10,8 @@
#include <thread> #include <thread>
#include <vector> #include <vector>
#include "utils.h"
#if defined(_WIN32) #if defined(_WIN32)
#include "win32.h" #include "win32.h"
#endif #endif
@ -48,6 +50,8 @@ protected:
char *screen_buffer { nullptr }; char *screen_buffer { nullptr };
uint8_t tx { 0 }; uint8_t tx { 0 };
uint8_t ty { 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 const size_t n_edit_lines_hist { 8 }; // maximum number of previous edit-lines
std::vector<std::string> edit_lines_hist; std::vector<std::string> edit_lines_hist;
@ -75,6 +79,8 @@ public:
std::string read_line(const std::string & prompt); std::string read_line(const std::string & prompt);
void flush_input(); void flush_input();
void enable_timestamp(const bool state) { timestamps = state; }
void emit_backspace(); void emit_backspace();
void put_char(const char c); void put_char(const char c);
void put_string(const std::string & what); void put_string(const std::string & what);

View file

@ -1082,6 +1082,11 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
continue; continue;
} }
else if (parts[0] == "pts" && parts.size() == 2) {
cnsl->enable_timestamp(std::stoi(parts[1]));
continue;
}
else if (cmd == "qi") { else if (cmd == "qi") {
show_queued_interrupts(cnsl, c); 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", "trace/t - toggle tracing",
"setll x,y - set loglevel: terminal,file", "setll x,y - set loglevel: terminal,file",
"setsl x,y - set syslog target: requires a hostname and a loglevel", "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)", "turbo - toggle turbo mode (cannot be interrupted)",
"debug - enable CPU debug mode", "debug - enable CPU debug mode",
"bt - show backtrace - need to enable debug first", "bt - show backtrace - need to enable debug first",