From 165540c1205e4330d4b241968aca07fb536fe5ce Mon Sep 17 00:00:00 2001 From: Bernd Stellwag Date: Wed, 2 Oct 2024 17:55:52 +0200 Subject: [PATCH] reformat comments --- src/main.cpp | 4 +++- src/util.h | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 70f2593..fbed474 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,6 +19,7 @@ static SocketServer socketServer; #define AIO_SERVERPORT credentials::mqtt_port #define AIO_USERNAME credentials::mqtt_username.c_str() #define AIO_KEY credentials::mqtt_password.c_str() + WiFiClient client; Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY); Adafruit_MQTT_Subscribe mqtt_subscribe_topic = Adafruit_MQTT_Subscribe(&mqtt, "homeassistant/marquee_sign/text"); @@ -90,7 +91,8 @@ void MQTT_connect() { } uint8_t retries = 6; - while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected + // connect will return 0 for connected + while ((ret = mqtt.connect()) != 0) { mqtt.disconnect(); // wait 10s till next try diff --git a/src/util.h b/src/util.h index 32ab2a1..2fefc99 100644 --- a/src/util.h +++ b/src/util.h @@ -287,7 +287,8 @@ String convertToCP437(const String& input) { if ((ch & 0xF0) == 0xE0) { if (i + 2 < len) { uint32_t utf8_char = ((uint8_t)input[i] << 16) | ((uint8_t)input[i + 1] << 8) | (uint8_t)input[i + 2]; - i += 2; // skip 2 additional bytes + // skip 2 additional bytes + i += 2; if (cp437_map.find(utf8_char) != cp437_map.end()) { output += static_cast(cp437_map[utf8_char]); continue; @@ -298,7 +299,8 @@ String convertToCP437(const String& input) { else if ((ch & 0xE0) == 0xC0) { if (i + 1 < len) { uint16_t utf8_char = ((uint8_t)input[i] << 8) | (uint8_t)input[i + 1]; - i++; // skip second byte + // skip second byte + i++; if (cp437_map.find(utf8_char) != cp437_map.end()) { output += static_cast(cp437_map[utf8_char]); continue; @@ -306,11 +308,13 @@ String convertToCP437(const String& input) { } } // single UTF-16 character (or plain ANSI character) - else if ((uint8_t)ch < 0x80) { // keep ASCII as is + else if ((uint8_t)ch < 0x80) { + // keep ASCII as is output += ch; } else { - uint16_t utf16_char = (uint8_t)ch; // UTF-16 range + uint16_t utf16_char = (uint8_t)ch; + // check if character is in UTF-16 range, fallback to ? if (cp437_map.find(utf16_char) != cp437_map.end()) { output += static_cast(cp437_map[utf16_char]); } else {