reformat comments

This commit is contained in:
Bernd Stellwag 2024-10-02 17:55:52 +02:00
parent ad4ee16f19
commit 165540c120
2 changed files with 11 additions and 5 deletions

View File

@ -19,6 +19,7 @@ static SocketServer socketServer;
#define AIO_SERVERPORT credentials::mqtt_port #define AIO_SERVERPORT credentials::mqtt_port
#define AIO_USERNAME credentials::mqtt_username.c_str() #define AIO_USERNAME credentials::mqtt_username.c_str()
#define AIO_KEY credentials::mqtt_password.c_str() #define AIO_KEY credentials::mqtt_password.c_str()
WiFiClient client; WiFiClient client;
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY); 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"); 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; 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(); mqtt.disconnect();
// wait 10s till next try // wait 10s till next try

View File

@ -287,7 +287,8 @@ String convertToCP437(const String& input) {
if ((ch & 0xF0) == 0xE0) { if ((ch & 0xF0) == 0xE0) {
if (i + 2 < len) { if (i + 2 < len) {
uint32_t utf8_char = ((uint8_t)input[i] << 16) | ((uint8_t)input[i + 1] << 8) | (uint8_t)input[i + 2]; 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()) { if (cp437_map.find(utf8_char) != cp437_map.end()) {
output += static_cast<char>(cp437_map[utf8_char]); output += static_cast<char>(cp437_map[utf8_char]);
continue; continue;
@ -298,7 +299,8 @@ String convertToCP437(const String& input) {
else if ((ch & 0xE0) == 0xC0) { else if ((ch & 0xE0) == 0xC0) {
if (i + 1 < len) { if (i + 1 < len) {
uint16_t utf8_char = ((uint8_t)input[i] << 8) | (uint8_t)input[i + 1]; 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()) { if (cp437_map.find(utf8_char) != cp437_map.end()) {
output += static_cast<char>(cp437_map[utf8_char]); output += static_cast<char>(cp437_map[utf8_char]);
continue; continue;
@ -306,11 +308,13 @@ String convertToCP437(const String& input) {
} }
} }
// single UTF-16 character (or plain ANSI character) // 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; output += ch;
} }
else { 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()) { if (cp437_map.find(utf16_char) != cp437_map.end()) {
output += static_cast<char>(cp437_map[utf16_char]); output += static_cast<char>(cp437_map[utf16_char]);
} else { } else {