From 49a773bcb41e33f1dd040fca7b646556fede84ed Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sat, 19 Mar 2022 22:39:43 +0100 Subject: [PATCH] less memory hungry terminal refresh --- ESP32/main.ino | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ESP32/main.ino b/ESP32/main.ino index cbadef4..93d1ef3 100644 --- a/ESP32/main.ino +++ b/ESP32/main.ino @@ -170,16 +170,19 @@ void wifi(void *p) { clients.push_back(client); // send initial terminal stat - std::string out = "\033[2J"; + write(client, "\033[2J", 4); xSemaphoreTake(terminal_mutex, portMAX_DELAY); - for(int y=0; y<25; y++) - out += format("\033[%dH", y + 1) + std::string(&terminal[y * 80], 80); + for(int y=0; y<25; y++) { + std::string out = format("\033[%dH", y + 1); + write(client, out.c_str(), out.size()); + + if (write(client, &terminal[y * 80], 80) != 80) + break; + } xSemaphoreGive(terminal_mutex); - - write(client, out.c_str(), out.size()); } }