diff --git a/include/wordclock_esp8266.h b/include/wordclock_esp8266.h index cde48a3..64f8efd 100644 --- a/include/wordclock_esp8266.h +++ b/include/wordclock_esp8266.h @@ -30,7 +30,6 @@ typedef enum int EEPROM_read_address(int address); String leading_zero2digit(int value); -String split(String s, char parser, int index); void check_night_mode(void); void EEPROM_write_to_address(int address, int value); void handle_button(void); diff --git a/include/wordclock_functions.h b/include/wordclock_functions.h index cabd1dc..64d59a7 100644 --- a/include/wordclock_functions.h +++ b/include/wordclock_functions.h @@ -4,6 +4,7 @@ #include int show_string_on_clock(String message, uint32_t color); +String split(String s, char parser, int index); String time_to_string(uint8_t hours, uint8_t minutes); void draw_minute_indicator(uint8_t minutes, uint32_t color); diff --git a/src/wordclock_esp8266.cpp b/src/wordclock_esp8266.cpp index 4a98e44..bbbf220 100644 --- a/src/wordclock_esp8266.cpp +++ b/src/wordclock_esp8266.cpp @@ -939,37 +939,6 @@ void handle_command() webserver.send(204, "text/plain", "No Content"); // this page doesn't send back content --> 204 } -/** - * @brief Splits a string at given character and return specified element - * - * @param s string to split - * @param parser separating character - * @param index index of the element to return - * @return String - */ -String split(String s, char parser, int index) -{ - String rs = ""; - int parser_cnt = 0; - int r_from_index = 0, r_to_index = -1; - while (index >= parser_cnt) - { - r_from_index = r_to_index + 1; - r_to_index = s.indexOf(parser, r_from_index); - if (index == parser_cnt) - { - if (r_to_index == 0 || r_to_index == -1) - { - return ""; - } - return s.substring(r_from_index, r_to_index); - } - else - parser_cnt++; - } - return rs; -} - /** * @brief Handler for GET requests * diff --git a/src/wordclock_functions.cpp b/src/wordclock_functions.cpp index b550c53..e9c94a1 100644 --- a/src/wordclock_functions.cpp +++ b/src/wordclock_functions.cpp @@ -3,11 +3,9 @@ #include "ledmatrix.h" #include "udp_logger.h" - extern LEDMatrix led_matrix; -extern String split(String s, char parser, int index); // TODO cleanup -const String clockStringGerman = "ESPISTAFUNFVIERTELZEHNZWANZIGUVORTECHNICNACHHALBMELFUNFXCONTROLLEREINSEAWZWEIDREITUMVIERSECHSQYACHTSIEBENZWOLFZEHNEUNJUHR"; +const String clock_chars_as_string = "ESRISTNFUNFVIERTELZEHNZWANZIGHVORPIKACHUNACHHALBMELFUNFMITTERNACHTEINSUWUZWEIDREIFUNVIERSECHSOBACHTSIEBENZWOLFZEHNEUNEUHR"; /** * @brief control the four minute indicator LEDs @@ -82,7 +80,7 @@ int show_string_on_clock(String message, uint32_t color) if (word.length() > 0) { // find word in clock string - word_position = clockStringGerman.indexOf(word, last_letter_clock); + word_position = clock_chars_as_string.indexOf(word, last_letter_clock); if (word_position >= 0) { @@ -104,7 +102,6 @@ int show_string_on_clock(String message, uint32_t color) } else // end - no more word in message { - break; } } @@ -236,3 +233,34 @@ String time_to_string(uint8_t hours, uint8_t minutes) return message; } + +/** + * @brief Splits a string at given character and return specified element + * + * @param s string to split + * @param parser separating character + * @param index index of the element to return + * @return String + */ +String split(String s, char parser, int index) +{ + String rs = ""; + int parser_cnt = 0; + int r_from_index = 0, r_to_index = -1; + while (index >= parser_cnt) + { + r_from_index = r_to_index + 1; + r_to_index = s.indexOf(parser, r_from_index); + if (index == parser_cnt) + { + if (r_to_index == 0 || r_to_index == -1) + { + return ""; + } + return s.substring(r_from_index, r_to_index); + } + else + parser_cnt++; + } + return rs; +}