From 8f543a5c1fe5a82b5103297b533a794b09c1f012 Mon Sep 17 00:00:00 2001 From: Edgar W Date: Sun, 30 Mar 2025 18:45:41 +0200 Subject: [PATCH] add swiss german language version --- README.md | 2 +- wordclockfunctions.ino_swiss | 225 +++++++++++++++++++++++++++++++++++ 2 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 wordclockfunctions.ino_swiss diff --git a/README.md b/README.md index f98983e..67e5e7b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ More details on my website: https://techniccontroller.com/word-clock-with-wifi-a **Languages** -The Wordclock is available in **German**, **English**, **Italian**, **French** and **Javanese** language. By default the language is German. +The Wordclock is available in **German**, **English**, **Italian**, **French**, **Swiss German**, and **Javanese** language. By default the language is German. To use other languages like English or Italian please replace the file *wordclockfunctions.ino* with *wordclockfunctions.ino_english* or *wordclockfunctions.ino_italian*. The code compiles only with one file named *wordclockfunctions.ino*. So please rename the file you want to use to *wordclockfunctions.ino* and replace the existing file. diff --git a/wordclockfunctions.ino_swiss b/wordclockfunctions.ino_swiss new file mode 100644 index 0000000..7ec5f2c --- /dev/null +++ b/wordclockfunctions.ino_swiss @@ -0,0 +1,225 @@ +// Thanks to Sandro for providing this swiss german version +const String clockStringSwiss = "ESPESCHAFUFVIERTUBFZAAZWANZGSIVORABOHWORTUHRHAUBIANESSIEISZWOISDRUVIERIYFUFIOSACHSISEBNIACHTINUNIELZANIERBEUFIZWOUFINAGSI"; + +/** + * @brief control the four minute indicator LEDs + * + * @param minutes minutes to be displayed [0 ... 59] + * @param color 24bit color value + */ +void drawMinuteIndicator(uint8_t minutes, uint32_t color){ + //separate LEDs for minutes in an additional row + { + switch (minutes%5) + { + case 0: + break; + + case 1: + ledmatrix.setMinIndicator(0b1000, color); + break; + + case 2: + ledmatrix.setMinIndicator(0b1100, color); + break; + + case 3: + ledmatrix.setMinIndicator(0b1110, color); + break; + + case 4: + ledmatrix.setMinIndicator(0b1111, color); + break; + } + } +} + +/** + * @brief Draw the given sentence to the word clock + * + * @param message sentence to be displayed + * @param color 24bit color value + * @return int: 0 if successful, -1 if sentence not possible to display + */ +int showStringOnClock(String message, uint32_t color){ + String word = ""; + int lastLetterClock = 0; + int positionOfWord = 0; + int index = 0; + + // add space on the end of message for splitting + message = message + " "; + + // empty the targetgrid + ledmatrix.gridFlush(); + + while(true){ + // extract next word from message + word = split(message, ' ', index); + index++; + + if(word.length() > 0){ + // find word in clock string + positionOfWord = clockStringSwiss.indexOf(word, lastLetterClock); + + if(positionOfWord >= 0){ + // word found on clock -> enable leds in targetgrid + for(unsigned int i = 0; i < word.length(); i++){ + int x = (positionOfWord + i)%WIDTH; + int y = (positionOfWord + i)/WIDTH; + ledmatrix.gridAddPixel(x, y, color); + } + // remember end of the word on clock + lastLetterClock = positionOfWord + word.length(); + } + else{ + // word is not possible to show on clock + logger.logString("word is not possible to show on clock: " + String(word)); + return -1; + } + }else{ + // end - no more word in message + break; + } + } + // return success + return 0; +} + +/** + * @brief Converts the given time as sentence (String) + * + * @param hours hours of the time value + * @param minutes minutes of the time value + * @return String time as sentence + */ +String timeToString(uint8_t hours, uint8_t minutes, bool puristModeActive){ + + //ES IST + String message = ""; + + if(puristModeActive){ + message = ""; + if(minutes < 5 || (minutes >=30 && minutes < 35)){ + message = "ES ESCH "; + } + } + else{ + message = "ES ESCH "; + } + + //show minutes + if(minutes >= 5 && minutes < 10) + { + message += "FUF AB "; + } + else if(minutes >= 10 && minutes < 15) + { + message += "ZAA AB "; + } + else if(minutes >= 15 && minutes < 20) + { + message += "VIERTU AB "; + } + else if(minutes >= 20 && minutes < 25) + { + message += "ZWANZG AB "; //Sandro + } + else if(minutes >= 25 && minutes < 30) + { + message += "FUF VOR HAUBI "; + } + else if(minutes >= 30 && minutes < 35) + { + message += "HAUBI "; + } + else if(minutes >= 35 && minutes < 40) + { + message += "FUF AB HAUBI "; + } + else if(minutes >= 40 && minutes < 45) + { + message += "ZWANZG VOR "; //Sandro + } + else if(minutes >= 45 && minutes < 50) + { + message += "VIERTU VOR "; + } + else if(minutes >= 50 && minutes < 55) + { + message += "ZAA VOR "; + } + else if(minutes >= 55 && minutes < 60) + { + message += "FUF VOR "; + } + + //convert hours to 12h format + if(hours >= 12) + { + hours -= 12; + } + if(minutes >= 25) //Sandro 20 + { + hours++; + } + if(hours == 12) + { + hours = 0; + } + + // show hours + switch(hours) + { + case 0: + message += "ZWOUFI "; + break; + case 1: + message += "EIS "; + // //EIN(S) + // if(minutes > 4){ // Sandro + // message += "S"; + // } + // message += " "; + break; + case 2: + message += "ZWOI "; + break; + case 3: + message += "DRU "; + break; + case 4: + message += "VIERI "; + break; + case 5: + message += "FUFI "; + break; + case 6: + message += "SACHSI "; + break; + case 7: + message += "SEBNI "; + break; + case 8: + message += "ACHTI "; + break; + case 9: + message += "NUNI "; + break; + case 10: + message += "ZANI "; + break; + case 11: + message += "EUFI "; + break; + } + if(minutes < 5) + { + message += "GSI "; + } + + logger.logString("time as String: " + String(message)); + + return message; +} +