Move split function.
This commit is contained in:
@@ -30,7 +30,6 @@ typedef enum
|
|||||||
|
|
||||||
int EEPROM_read_address(int address);
|
int EEPROM_read_address(int address);
|
||||||
String leading_zero2digit(int value);
|
String leading_zero2digit(int value);
|
||||||
String split(String s, char parser, int index);
|
|
||||||
void check_night_mode(void);
|
void check_night_mode(void);
|
||||||
void EEPROM_write_to_address(int address, int value);
|
void EEPROM_write_to_address(int address, int value);
|
||||||
void handle_button(void);
|
void handle_button(void);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
int show_string_on_clock(String message, uint32_t color);
|
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);
|
String time_to_string(uint8_t hours, uint8_t minutes);
|
||||||
void draw_minute_indicator(uint8_t minutes, uint32_t color);
|
void draw_minute_indicator(uint8_t minutes, uint32_t color);
|
||||||
|
|
||||||
|
|||||||
@@ -939,37 +939,6 @@ void handle_command()
|
|||||||
webserver.send(204, "text/plain", "No Content"); // this page doesn't send back content --> 204
|
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
|
* @brief Handler for GET requests
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -3,11 +3,9 @@
|
|||||||
#include "ledmatrix.h"
|
#include "ledmatrix.h"
|
||||||
#include "udp_logger.h"
|
#include "udp_logger.h"
|
||||||
|
|
||||||
|
|
||||||
extern LEDMatrix led_matrix;
|
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
|
* @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)
|
if (word.length() > 0)
|
||||||
{
|
{
|
||||||
// find word in clock string
|
// 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)
|
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
|
else // end - no more word in message
|
||||||
{
|
{
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,3 +233,34 @@ String time_to_string(uint8_t hours, uint8_t minutes)
|
|||||||
|
|
||||||
return message;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user