Improvements to time and timer display #911 (#912)

* Fix time display #911

* move TIMEHOUR definition

* change time format

* Refactoring

* rename

* remove unncessary code

* Change hour/minute format

* pack TimerDisplayOptions structure
This commit is contained in:
eshifri
2021-10-25 12:36:16 +11:00
committed by GitHub
parent 2b8dfeef59
commit 4e571c1325
13 changed files with 95 additions and 56 deletions
+22 -5
View File
@@ -22,8 +22,27 @@
#ifndef _STRHELPERS_H_
#define _STRHELPERS_H_
#include "definitions.h"
#include "opentx_types.h"
#define SHOW_TIME 0x1
#define SHOW_TIMER 0x0
#define SHOW_TIMER_UPPER_CASE 0x2
#define SHOW_TIMER_HM_FORMAT 0x5
PACK(typedef struct {
uint8_t showTime:1;
uint8_t upperCase:1;
uint8_t numDigitGroups:3;
uint8_t hmFormat:1;
uint8_t reserved:2;
}) TimerDisplayOptions;
typedef union {
uint8_t options;
TimerDisplayOptions displayOptions;
} TimerOptions;
char hex2zchar(uint8_t hex);
char hex2char(uint8_t hex);
char zchar2char(int8_t idx);
@@ -46,9 +65,8 @@ char *strAppendFilename(char *dest, const char *filename, const int size);
char *getStringAtIndex(char *dest, const char *s, int idx);
char *strAppendStringWithIndex(char *dest, const char *s, int idx);
#define LEN_TIMER_STRING 10 // "-00:00:00"
char *getTimerString(char *dest, int32_t tme, uint8_t hours = 0u);
char *getTimerStringCase(char *dest, int32_t tme, uint8_t hours = 0u,
bool bLowerCase = true);
char *getTimerString(char *dest, int32_t tme, TimerOptions timerOptions = {.options = 0});
char *getFormattedTimerString(char *dest, int32_t tme, TimerOptions timerOptions);
char *getCurveString(char *dest, int idx);
char *getGVarString(char *dest, int idx);
char *getGVarString(int idx);
@@ -65,8 +83,7 @@ char *getSourceString(mixsrc_t idx);
char *getSwitchPositionName(swsrc_t idx);
char *getSwitchWarningString(swsrc_t idx);
char *getCurveString(int idx);
char *getTimerString(int32_t tme, uint8_t hours);
char *getTimerString(int32_t tme, uint8_t hours, bool bLowercase);
char *getTimerString(int32_t tme, TimerOptions timerOptions = {.options = 0});
void splitTimer(char *s0, char *s1, char *s2, char *s3, int tme,
bool bLowercase = true);