From 679cfab9e84fe06089b54a0f50b30b274cf09722 Mon Sep 17 00:00:00 2001 From: "XPS\\Micro" Date: Thu, 29 Jan 2026 07:26:48 +0100 Subject: [PATCH] Updated Check --- include/charPattern.inc | 4 ++- include/defines.inc | 2 +- include/vars.inc | 4 +-- .../examples/FullExample.ino | 2 +- .../src/CharGraphTimeLogic.cpp | 17 +++++---- .../src/CharGraphTimeLogic.h | 11 +++--- lib/CharGraphTimeLogic/src/Validator.cpp | 36 +++++++++++++------ lib/CharGraphTimeLogic/src/Validator.h | 3 +- lib/rgbPanel/rgbPanel.cpp | 2 +- platformio.ini | 1 + src/main.cpp | 30 +++++++++------- 11 files changed, 71 insertions(+), 41 deletions(-) diff --git a/include/charPattern.inc b/include/charPattern.inc index d6e8201..3b40563 100644 --- a/include/charPattern.inc +++ b/include/charPattern.inc @@ -3,7 +3,9 @@ //Hier Umlaute wie Ö und Ü bereits durch o und u wegen UTF8 ersetzen!!!! -const char DEFAULT_CHARSOAP[] = "ESxISTxFASTBALDKURZEHNFuNFZEITVORDREIVIERTELNACHRWDHALBxSECHSVIERxELFZWoLFuNFZEHNEUNACHTDREINSIEBENxZWEIxxUHRx"; +const char DEFAULT_CHARSOAP[] = "ESHISTRFASTKURZVIERTELFuNFZWANZIGAZEHNJNACHRVORWHALBKLBZWEINSECHSEELFVIERACHTFuNFSIEBENITDREIZWoLFZZEHNEUNLUHR"; //119 +//"ESXISTEFuNFVIERTELZEHNKURZWXPNACHSVORTHALBTVEINSXJZWEIUDREIVIERYPHFuNFSECHSWYSIEBENACHTUNEUNZEHNELFZWoLFXUHRJT"; +//115"ESHISTCKURZSIVORXZEHNMFuNFVIERTELVORNACHBALDHALBXEINSMEZEHNEUNZWEIELFuNFZWoLFSECHSIEBENXMDREIVIERVILRACHTSYUHR"; char testPattern[]="ES-IST-WIR-HABEN-BALD-FAST-KURZ-FuNF-ZEHN-DREIVIERTEL-VIERTEL-ZWANZIG-VOR-NACH-EIN-EINS-ZWEI-DREI-VIER-FuNF-SECHS-SIEBEN-ACHT-NEUN-ZEHN-ELF-ZWoLF-UHR-NACHT-PAUSE-ALARM-ZEIT-RWD-KKS-KARLKUEBEL-MINT\0"; /* diff --git a/include/defines.inc b/include/defines.inc index a694812..0d78c4b 100644 --- a/include/defines.inc +++ b/include/defines.inc @@ -104,6 +104,6 @@ #define MINUTE_LEDS_MAGIC 0xEE #define RUNNING_FLAG_MAGIC 0x42 // Magic Byte -#define MAGIC_BYTE_INIT 0xA5 +#define MAGIC_BYTE_INIT 0xAA #endif \ No newline at end of file diff --git a/include/vars.inc b/include/vars.inc index d6383c4..afde676 100644 --- a/include/vars.inc +++ b/include/vars.inc @@ -17,8 +17,8 @@ int8_t isConfigured = 0xFF; const unsigned long AP_TIMEOUT = 300000; bool powerLossDetected = false; //Flag für Stromausfall -char AP_SSID[AP_SSID_LENGHT] = "CharGrap-01\0"; -char AP_PASSWORD[AP_PASSWORD_LENGTH] = "MeinPasswort123\0"; +char AP_SSID[AP_SSID_LENGHT] = "CharGrap101\0"; +char AP_PASSWORD[AP_PASSWORD_LENGTH] = "MeinPasswort101\0"; uint16_t bootCounter = 0; diff --git a/lib/CharGraphTimeLogic/examples/FullExample.ino b/lib/CharGraphTimeLogic/examples/FullExample.ino index b58d974..5e67b9f 100644 --- a/lib/CharGraphTimeLogic/examples/FullExample.ino +++ b/lib/CharGraphTimeLogic/examples/FullExample.ino @@ -23,7 +23,7 @@ #include // Define this to enable debug output -// #define CHARGRAPH_DEBUG +#define CHARGRAPH_DEBUG // 110-character pattern - MUST be exactly 110 characters // Format: 10 rows of 11 characters each diff --git a/lib/CharGraphTimeLogic/src/CharGraphTimeLogic.cpp b/lib/CharGraphTimeLogic/src/CharGraphTimeLogic.cpp index 7f6ab8c..a81bc1b 100644 --- a/lib/CharGraphTimeLogic/src/CharGraphTimeLogic.cpp +++ b/lib/CharGraphTimeLogic/src/CharGraphTimeLogic.cpp @@ -8,25 +8,28 @@ #include "Constants.h" #include +#define CHARGRAPH_DEBUG true + // ============================================================================ // PUBLIC API: GET CHARGRAPH WORDS // ============================================================================ int8_t getCharGraphWords( const char* pattern, + const char* wordsList, uint8_t hour, uint8_t minute, CharGraphTimeWords& outResult ) { - if (!pattern) { + if (!pattern || !wordsList) { outResult.wordCount = 0; return -1; } // Validate pattern length - if (strlen(pattern) != GRID_SIZE) { + if ((int8_t)strlen(pattern) != GRID_SIZE) { outResult.wordCount = 0; - return -2; + return (int8_t)strlen(pattern) * -1; } // Validate input ranges @@ -36,7 +39,7 @@ int8_t getCharGraphWords( } // Validate pattern structure (ES/IST, HALB, UHR placement) - ValidationResult structValidation = validateStructure(pattern); + ValidationResult structValidation = validateStructure(pattern, wordsList); if (!structValidation.valid) { outResult.wordCount = 0; if (structValidation.reason) { @@ -135,10 +138,10 @@ uint16_t buildCharGraphText( #ifdef CHARGRAPH_DEBUG -void debugPrintValidationError(const char* gridStr) { - if (!gridStr) return; +void debugPrintValidationError(const char* gridStr, const char* wordsList) { + if (!gridStr || !wordsList) return; - ValidationResult result = validateStructure(gridStr); + ValidationResult result = validateStructure(gridStr, wordsList); if (!result.valid) { Serial.print("Validation Error: "); diff --git a/lib/CharGraphTimeLogic/src/CharGraphTimeLogic.h b/lib/CharGraphTimeLogic/src/CharGraphTimeLogic.h index 2585443..8c4cc97 100644 --- a/lib/CharGraphTimeLogic/src/CharGraphTimeLogic.h +++ b/lib/CharGraphTimeLogic/src/CharGraphTimeLogic.h @@ -49,6 +49,7 @@ struct CharGraphTimeWords { * Convert time to CharGraph words and LED positions * * @param pattern 110-character grid (uppercase, uppercase A-Z and 0-9) + * @param wordsList Words separated by '-' (e.g. "ES-IST-HALB-UHR-...") * @param hour Hour (0-23) * @param minute Minute (0-59) * @param outResult Result structure (filled on success) @@ -56,8 +57,9 @@ struct CharGraphTimeWords { * * Example: * const char pattern[] PROGMEM = "ESIST-FÜNFZEHN..."; + * const char wordsList[] = "ES-IST-HALB-UHR-..."; * CharGraphTimeWords result; - * if (getCharGraphWords(pattern, 14, 25, result)) { + * if (getCharGraphWords(pattern, wordsList, 14, 25, result)) { * Serial.print("Words: "); * for (int i = 0; i < result.wordCount; i++) { * Serial.print((const __FlashStringHelper*) pgm_read_ptr(&result.words[i])); @@ -67,6 +69,7 @@ struct CharGraphTimeWords { */ int8_t getCharGraphWords( const char* pattern, + const char* wordsList, uint8_t hour, uint8_t minute, CharGraphTimeWords& outResult @@ -95,13 +98,13 @@ uint16_t buildCharGraphText( // DEBUG FUNCTIONS (Optional, can be disabled) // ============================================================================ -#ifdef CHARGRAPH_DEBUG +//#ifdef CHARGRAPH_DEBUG /** * Print validation error message to Serial * Only available if CHARGRAPH_DEBUG is defined */ -void debugPrintValidationError(const char* gridStr); +void debugPrintValidationError(const char* gridStr, const char* wordsList); /** * Print LED calculation details to Serial @@ -109,6 +112,6 @@ void debugPrintValidationError(const char* gridStr); */ void debugPrintLEDInfo(const CharGraphTimeWords& result); -#endif +//#endif #endif // CHARGRAPH_TIME_LOGIC_H diff --git a/lib/CharGraphTimeLogic/src/Validator.cpp b/lib/CharGraphTimeLogic/src/Validator.cpp index c5ba6f2..60aafde 100644 --- a/lib/CharGraphTimeLogic/src/Validator.cpp +++ b/lib/CharGraphTimeLogic/src/Validator.cpp @@ -36,15 +36,31 @@ static int16_t findWord(const char* pattern, const char* word_progmem, uint16_t } // ============================================================================ -// HELPER: Check if PROGMEM string contains uppercase letters +// HELPER: Check if any word from wordsList appears after startPos in pattern // ============================================================================ -static bool containsUppercase(const char* pattern, uint16_t startPos) { - if (!pattern) return false; +static bool containsWordAfter(const char* pattern, const char* wordsList, uint16_t startPos) { + if (!pattern || !wordsList) return false; - for (uint16_t i = startPos; pattern[i] != '\0'; i++) { - if (pattern[i] >= 'A' && pattern[i] <= 'Z') { - return true; + // Parse wordsList and check each word + uint16_t wordStart = 0; + for (uint16_t i = 0; wordsList[i] != '\0'; i++) { + if (wordsList[i] == '-' || wordsList[i + 1] == '\0') { + // Extract word + uint16_t wordLen = (wordsList[i] == '-') ? (i - wordStart) : (i - wordStart + 1); + char word[12]; // Max 11 chars + null terminator + + if (wordLen > 0 && wordLen < 12) { + strncpy(word, &wordsList[wordStart], wordLen); + word[wordLen] = '\0'; + + // Check if this word appears after startPos + if (findWord(pattern, (const char*)word, startPos) != -1) { + return true; + } + } + + wordStart = i + 1; } } return false; @@ -65,8 +81,8 @@ bool wordFitsInLine(uint16_t startPos, uint8_t wordLen) { // STRUCTURE VALIDATION (with Word Integrity Check) // ============================================================================ -ValidationResult validateStructure(const char* gridStr) { - if (!gridStr) { +ValidationResult validateStructure(const char* gridStr, const char* wordsList) { + if (!gridStr || !wordsList) { return {false, ERR_NO_ES}; } @@ -144,8 +160,8 @@ ValidationResult validateStructure(const char* gridStr) { // ========== UHR VALIDATION ========== if (uhrPos != -1) { // UHR is present - check if at end - // After UHR, only placeholders allowed (no uppercase letters) - if (containsUppercase(gridStr, uhrPos + 3)) { + // After UHR, no words from wordsList should appear + if (containsWordAfter(gridStr, wordsList, uhrPos + 3)) { return {false, ERR_UHR_NOT_LAST}; } } diff --git a/lib/CharGraphTimeLogic/src/Validator.h b/lib/CharGraphTimeLogic/src/Validator.h index b97b245..3c47c5c 100644 --- a/lib/CharGraphTimeLogic/src/Validator.h +++ b/lib/CharGraphTimeLogic/src/Validator.h @@ -29,9 +29,10 @@ bool wordFitsInLine(uint16_t startPos, uint8_t wordLen); * - UHR is optional, but if present must be at pattern end * * @param gridStr 110-character pattern (uppercase) + * @param wordsList Words separated by '-' (e.g. "ES-IST-HALB-UHR-...") * @return ValidationResult with valid flag and error message */ -ValidationResult validateStructure(const char* gridStr); +ValidationResult validateStructure(const char* gridStr, const char* wordsList); /** * Validate mandatory words presence and gaps diff --git a/lib/rgbPanel/rgbPanel.cpp b/lib/rgbPanel/rgbPanel.cpp index 6baf010..84e133b 100644 --- a/lib/rgbPanel/rgbPanel.cpp +++ b/lib/rgbPanel/rgbPanel.cpp @@ -467,7 +467,7 @@ uint8_t testWords() void checkPattern() { - testWords(); + //testWords(); FastLED.clear(); uint8_t lengthPattern = strlen(testPattern); diff --git a/platformio.ini b/platformio.ini index 4f668b9..6fb0d3d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -44,6 +44,7 @@ build_flags = -DTEST_RGB_ONLY=false -DTEST_RGB=false -DPOWERLOSSDETECT=false + -DCHARGRAPH_DEBUG ; Monitor-Einstellungen monitor_filters = diff --git a/src/main.cpp b/src/main.cpp index 9e08b8b..cb925f0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -812,7 +812,7 @@ String getHourName(int hour) void displayTime(int hours, int minutes) { - DEBUG_PRINT("Zeit: '"); + DEBUG_PRINT("displayTime Zeit: '"); if (hours < 10) DEBUG_PRINT("0"); DEBUG_PRINT(hours); DEBUG_PRINT(":"); @@ -820,14 +820,14 @@ void displayTime(int hours, int minutes) DEBUG_PRINT(minutes); DEBUG_PRINT("' -> "); - fadeOutAll(200, 15); - //FastLED.setBrightness(80); - //FastLED.clear(); - //showLEDs(); - //yield(); + //fadeOutAll(200, 15); + FastLED.setBrightness(80); + FastLED.clear(); + showLEDs(); + yield(); CharGraphTimeWords result; - int8_t resultval = getCharGraphWords(DEFAULT_CHARSOAP, hours, minutes, result); + int8_t resultval = getCharGraphWords(DEFAULT_CHARSOAP, testPattern, hours, minutes, result); if (resultval == 0) { @@ -882,12 +882,16 @@ void displayTime(int hours, int minutes) } DEBUG_PRINT("\n"); } - //yield(); - //noInterrupts(); - //showLEDs(); // finaler Frame - //interrupts(); - //yield(); - fadeInCurrentFrame(80,200,15); + else + { + DEBUG_PRINTF("ERROR %d",resultval); + } + yield(); + noInterrupts(); + showLEDs(); // finaler Frame + interrupts(); + yield(); + //fadeInCurrentFrame(80,200,15); } // ════════════════════════════════════════════════════════════════