diff --git a/src/app/definition.cpp b/src/app/definition.cpp index e474f44..5125421 100644 --- a/src/app/definition.cpp +++ b/src/app/definition.cpp @@ -72,16 +72,17 @@ char *lastIndexOf(char *str, const char character) * The monthNumTo3LetterAbbreviation function takes the month number from 1 to 12 and returns the abbreviation in a 3 letter * format. */ -char *monthNumTo3LetterAbbreviation(char *buffer, const uint8_t monthNumber) +uint32_t monthNumTo3LetterAbbreviation(const uint8_t monthNumber) { - static const char monthArray[][4] = {{"Jan"},{"Feb"},{"Mar"},{"Apr"},{"May"},{"Jun"},{"Jul"},{"Aug"},{"Sep"},{"Oct"},{"Nov"},{"Dec"}}; - - if(buffer == NULL) return NULL; + /** + * This array contains months as 3 letter abbreviations + * Jan is written \0naJ and in hex : 0x006E614A an so on. They are thus 4Bytes aligned and easy to put and read back from prog mem :) + */ + static const uint32_t PROGMEM monthArray[] = {0x6E614A, 0x626546, 0x72614D, 0x727041, 0x79614D, 0x6E754A, 0x6C754A, 0x677541, 0x706553, 0x74634F, 0x766f4E, 0x636544}; + uint32_t toReturn(0x6E614A); //Default to Jan. if(monthNumber >= 1 && monthNumber <= 12) - strcpy_P(buffer, monthArray[monthNumber-1]); - else //If the month number is garbage, we return the first month of the year - strcpy_P(buffer, monthArray[0]); + toReturn = monthArray[monthNumber - 1]; - return buffer; + return toReturn; } diff --git a/src/app/definition.h b/src/app/definition.h index e2fc1f7..c192ec4 100644 --- a/src/app/definition.h +++ b/src/app/definition.h @@ -57,6 +57,6 @@ char *lastIndexOf(char *str, const char character); char *dateTimeFormater(char *pointer, const uint8_t value, const char character); -char *monthNumTo3LetterAbbreviation(char *month, const uint8_t monthNumber); +uint32_t monthNumTo3LetterAbbreviation(const uint8_t monthNumber); #endif //DEFINITION_H