Updated Check
This commit is contained in:
parent
f912df9d06
commit
679cfab9e8
|
|
@ -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";
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
#include <CharGraphTimeLogic.h>
|
||||
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -8,25 +8,28 @@
|
|||
#include "Constants.h"
|
||||
#include <cstring>
|
||||
|
||||
#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: ");
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -36,17 +36,33 @@ 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') {
|
||||
// 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};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -467,7 +467,7 @@ uint8_t testWords()
|
|||
|
||||
void checkPattern()
|
||||
{
|
||||
testWords();
|
||||
//testWords();
|
||||
|
||||
FastLED.clear();
|
||||
uint8_t lengthPattern = strlen(testPattern);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ build_flags =
|
|||
-DTEST_RGB_ONLY=false
|
||||
-DTEST_RGB=false
|
||||
-DPOWERLOSSDETECT=false
|
||||
-DCHARGRAPH_DEBUG
|
||||
|
||||
; Monitor-Einstellungen
|
||||
monitor_filters =
|
||||
|
|
|
|||
30
src/main.cpp
30
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);
|
||||
}
|
||||
|
||||
// ════════════════════════════════════════════════════════════════
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user