Format times better for timer widget and statistics times (#896)

* Fix widget timer.
Modifie getStrString() for  using hms

* Timer over blink with COLOR_THEME_WARNING
Timer unit in uppercase

* Use lowercase unit with small timer display, use uppercase unit in large
display

* Auto formatting

Co-authored-by: Runsys16 <rene.negre@orange.com>
Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
runsys
2021-10-15 21:32:24 +11:00
committed by GitHub
co-authored by Runsys16 Peter Feerick
parent ecf386e71f
commit 520eac3e4f
3 changed files with 447 additions and 328 deletions
+101 -69
View File
@@ -28,90 +28,122 @@
#define TIMEHOUR 0x2000 #define TIMEHOUR 0x2000
#endif #endif
class TimerWidget: public Widget class TimerWidget : public Widget
{ {
public: public:
TimerWidget(const WidgetFactory * factory, FormGroup * parent, const rect_t & rect, Widget::PersistentData * persistentData): TimerWidget(const WidgetFactory* factory, FormGroup* parent,
const rect_t& rect, Widget::PersistentData* persistentData) :
Widget(factory, parent, rect, persistentData) Widget(factory, parent, rect, persistentData)
{ {
}
void refresh(BitmapBuffer* dc) override
{
uint32_t index = persistentData->options[0].value.unsignedValue;
TimerData& timerData = g_model.timers[index];
TimerState& timerState = timersStates[index];
char sDigitGroup0[LEN_TIMER_STRING];
char sDigitGroup1[LEN_TIMER_STRING];
char sUnit0[] = "M";
char sUnit1[] = "S";
LcdFlags colorBack; // background color
LcdFlags colorFore; // foreground color
// Middle size widget
if (width() >= 180 && height() >= 70) {
colorBack = (timerState.val >= 0 || !(timerState.val % 2))
? COLOR_THEME_PRIMARY2
: COLOR_THEME_WARNING;
colorFore = (timerState.val >= 0 || !(timerState.val % 2))
? COLOR_THEME_SECONDARY1
: COLOR_THEME_SECONDARY2;
// background
dc->drawBitmapPattern(0, 0, LBM_TIMER_BACKGROUND, colorBack);
if (timerData.start && timerState.val >= 0) {
dc->drawBitmapPatternPie(
2, 3, LBM_RSCALE, colorFore, 0,
timerState.val <= 0
? 360
: 360 * (timerData.start - timerState.val) / timerData.start);
} else {
dc->drawBitmapPattern(3, 4, LBM_TIMER, colorFore);
}
// value
splitTimer(sDigitGroup0, sDigitGroup1, sUnit0, sUnit1,
abs(timerState.val), false);
dc->drawSizedText(76, 31, sDigitGroup0, ZLEN(sDigitGroup0),
FONT(XL) | colorFore);
dc->drawSizedText(76 + 35, 33, sUnit0, ZLEN(sUnit0),
FONT(STD) | colorFore);
dc->drawSizedText(76 + 50, 31, sDigitGroup1, ZLEN(sDigitGroup1),
FONT(XL) | colorFore);
dc->drawSizedText(76 + 85, 33, sUnit1, ZLEN(sUnit1),
FONT(STD) | colorFore);
// name
if (ZLEN(timerData.name) > 0) { // user name exist
dc->drawSizedText(78, 20, timerData.name, LEN_TIMER_NAME,
FONT(XS) | colorFore);
} else { // user name not exist "TMRn"
drawStringWithIndex(dc, 137, 17, "TMR", index + 1,
FONT(XS) | colorFore);
}
} }
// Small size widget
void refresh(BitmapBuffer * dc) override else {
{ // background
uint32_t index = persistentData->options[0].value.unsignedValue; if (timerState.val < 0 && timerState.val % 2) {
TimerData & timerData = g_model.timers[index]; dc->drawSolidFilledRect(0, 0, width(), height(), COLOR_THEME_WARNING);
TimerState & timerState = timersStates[index]; }
// name
if (width() >= 180 && height() >= 70) { if (ZLEN(timerData.name) > 0) { // user name exist
if (timerState.val >= 0 || !(timerState.val % 2)) { dc->drawText(2, 0, timerData.name, FONT(XS) | COLOR_THEME_PRIMARY2);
dc->drawBitmapPattern(0, 0, LBM_TIMER_BACKGROUND, COLOR_THEME_PRIMARY2); } else { // user name not exist "TMRn"
} drawStringWithIndex(dc, 2, 0, "TMR", index + 1,
else { FONT(XS) | COLOR_THEME_PRIMARY2);
dc->drawBitmapPattern(0, 0, LBM_TIMER_BACKGROUND, COLOR_THEME_PRIMARY2); }
} // value
if (timerData.start && timerState.val >= 0) { if (width() > 100 && height() > 40) {
dc->drawBitmapPatternPie(
2, 3, LBM_RSCALE, COLOR_THEME_SECONDARY1, 0,
timerState.val <= 0 ? 360 : 360 * (timerData.start - timerState.val) / timerData.start);
}
else {
dc->drawBitmapPattern(3, 4, LBM_TIMER, COLOR_THEME_SECONDARY1);
}
if (abs(timerState.val) >= 3600) { if (abs(timerState.val) >= 3600) {
drawTimer(dc, 70, 31, abs(timerState.val), COLOR_THEME_SECONDARY1 | FONT(STD) | LEFT | TIMEHOUR); drawTimer(dc, 3, 20, abs(timerState.val),
} COLOR_THEME_PRIMARY2 | LEFT | TIMEHOUR);
else { } else {
drawTimer(dc,76, 31, abs(timerState.val), COLOR_THEME_SECONDARY1 | FONT(XL) | LEFT); drawTimer(dc, 3, 18, abs(timerState.val),
} COLOR_THEME_PRIMARY2 | LEFT | FONT(STD));
if (ZLEN(timerData.name) > 0) {
dc->drawSizedText(78, 20, timerData.name, LEN_TIMER_NAME, FONT(XS) | COLOR_THEME_SECONDARY1);
}
else {
drawStringWithIndex(dc, 137, 17, "TMR", index + 1, FONT(XS) | COLOR_THEME_SECONDARY1);
} }
} }
// very small size
else { else {
if (timerState.val < 0 && timerState.val % 2) { if (abs(timerState.val) >= 3600) {
dc->drawSolidFilledRect(0, 0, width(), height(), COLOR_THEME_SECONDARY1); drawTimer(dc, 3, 20, abs(timerState.val),
} COLOR_THEME_PRIMARY2 | LEFT | FONT(XS) | TIMEHOUR);
drawStringWithIndex(dc, 2, 0, "TMR", index + 1, FONT(XS) | COLOR_THEME_PRIMARY2); } else {
if (width() > 100 && height() > 40) { drawTimer(dc, 3, 18, abs(timerState.val),
if (abs(timerState.val) >= 3600) { COLOR_THEME_PRIMARY2 | LEFT);
drawTimer(dc,3, 16, abs(timerState.val), COLOR_THEME_PRIMARY2 | LEFT | TIMEHOUR);
}
else {
drawTimer(dc, 3, 16, abs(timerState.val), COLOR_THEME_PRIMARY2 | LEFT | FONT(STD));
}
}
else {
if (abs(timerState.val) >= 3600) {
drawTimer(dc,3, 14, abs(timerState.val), COLOR_THEME_PRIMARY2 | LEFT | FONT(XS) | TIMEHOUR);
}
else {
drawTimer(dc, 3, 14, abs(timerState.val), COLOR_THEME_PRIMARY2 | LEFT);
}
} }
} }
} }
}
void checkEvents() override void checkEvents() override
{ {
Widget::checkEvents(); Widget::checkEvents();
auto newValue = timersStates[persistentData->options[0].value.unsignedValue].val; auto newValue =
if (lastValue != newValue) { timersStates[persistentData->options[0].value.unsignedValue].val;
lastValue = newValue; if (lastValue != newValue) {
invalidate(); lastValue = newValue;
} invalidate();
} }
}
static const ZoneOption options[]; static const ZoneOption options[];
tmrval_t lastValue = 0; tmrval_t lastValue = 0;
}; };
const ZoneOption TimerWidget::options[] = { const ZoneOption TimerWidget::options[] = {
{ STR_TIMER_SOURCE, ZoneOption::Timer, OPTION_VALUE_UNSIGNED(0) }, {STR_TIMER_SOURCE, ZoneOption::Timer, OPTION_VALUE_UNSIGNED(0)},
{ nullptr, ZoneOption::Bool } {nullptr, ZoneOption::Bool}};
};
BaseWidgetFactory<TimerWidget> timerWidget("Timer", TimerWidget::options); BaseWidgetFactory<TimerWidget> timerWidget("Timer", TimerWidget::options);
+315 -235
View File
@@ -19,21 +19,16 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "opentx.h"
#include "strhelpers.h" #include "strhelpers.h"
#include "opentx.h"
#if !defined(BOOT) #if !defined(BOOT)
const char s_charTab[] = "_-.,"; const char s_charTab[] = "_-.,";
char hex2zchar(uint8_t hex) char hex2zchar(uint8_t hex) { return (hex >= 10 ? hex - 9 : 27 + hex); }
{
return (hex >= 10 ? hex-9 : 27+hex);
}
char hex2char(uint8_t hex) char hex2char(uint8_t hex) { return (hex >= 10 ? hex - 9 + 'A' : hex + '0'); }
{
return (hex >= 10 ? hex-9+'A' : hex+'0');
}
char zchar2char(int8_t idx) char zchar2char(int8_t idx)
{ {
@@ -44,23 +39,20 @@ char zchar2char(int8_t idx)
} }
if (idx < 27) return 'A' + idx - 1; if (idx < 27) return 'A' + idx - 1;
if (idx < 37) return '0' + idx - 27; if (idx < 37) return '0' + idx - 27;
if (idx <= 40) return *(s_charTab+idx-37); if (idx <= 40) return *(s_charTab + idx - 37);
#if LEN_SPECIAL_CHARS > 0 #if LEN_SPECIAL_CHARS > 0
if (idx <= (LEN_STD_CHARS + LEN_SPECIAL_CHARS)) return 'z' + 5 + idx - 40; if (idx <= (LEN_STD_CHARS + LEN_SPECIAL_CHARS)) return 'z' + 5 + idx - 40;
#endif #endif
return ' '; return ' ';
} }
char char2lower(char c) char char2lower(char c) { return (c >= 'A' && c <= 'Z') ? c + 32 : c; }
{
return (c >= 'A' && c <= 'Z') ? c + 32 : c;
}
int8_t char2zchar(char c) int8_t char2zchar(char c)
{ {
if (c == '_') return 37; if (c == '_') return 37;
#if LEN_SPECIAL_CHARS > 0 #if LEN_SPECIAL_CHARS > 0
if ((int8_t)c < 0 && c+128 <= LEN_SPECIAL_CHARS) return 41 + (c+128); if ((int8_t)c < 0 && c + 128 <= LEN_SPECIAL_CHARS) return 41 + (c + 128);
#endif #endif
if (c >= 'a') return 'a' - c - 1; if (c >= 'a') return 'a' - c - 1;
if (c >= 'A') return c - 'A' + 1; if (c >= 'A') return c - 'A' + 1;
@@ -71,65 +63,63 @@ int8_t char2zchar(char c)
return 0; return 0;
} }
void str2zchar(char * dest, const char * src, int size) void str2zchar(char *dest, const char *src, int size)
{ {
memset(dest, 0, size); memset(dest, 0, size);
for (int c=0; c<size && src[c]; c++) { for (int c = 0; c < size && src[c]; c++) {
dest[c] = char2zchar(src[c]); dest[c] = char2zchar(src[c]);
} }
} }
int zchar2str(char * dest, const char * src, int size) int zchar2str(char *dest, const char *src, int size)
{ {
for (int c=0; c<size; c++) { for (int c = 0; c < size; c++) {
dest[c] = zchar2char(src[c]); dest[c] = zchar2char(src[c]);
} }
do { do {
dest[size--] = '\0'; dest[size--] = '\0';
} while (size >= 0 && dest[size] == ' '); } while (size >= 0 && dest[size] == ' ');
return size+1; return size + 1;
} }
int strnlen(const char *src, int max_size) int strnlen(const char *src, int max_size)
{ {
for (int i=0; i<max_size; i++) { for (int i = 0; i < max_size; i++) {
if (src[i] == '\0') if (src[i] == '\0') return i;
return i;
} }
return max_size; return max_size;
} }
unsigned int effectiveLen(const char * str, unsigned int size) unsigned int effectiveLen(const char *str, unsigned int size)
{ {
while (size > 0) { while (size > 0) {
if (str[size-1] != ' ' && str[size-1] != '\0') if (str[size - 1] != ' ' && str[size - 1] != '\0') return size;
return size;
size--; size--;
} }
return 0; return 0;
} }
bool zexist(const char * str, uint8_t size) bool zexist(const char *str, uint8_t size)
{ {
for (int i=0; i<size; i++) { for (int i = 0; i < size; i++) {
if (str[i] != 0) if (str[i] != 0) return true;
return true;
} }
return false; return false;
} }
uint8_t zlen(const char * str, uint8_t size) uint8_t zlen(const char *str, uint8_t size)
{ {
while (size > 0) { while (size > 0) {
if (str[size-1] != 0) if (str[size - 1] != 0) return size;
return size;
size--; size--;
} }
return 0; return 0;
} }
char * strcat_zchar(char * dest, const char * name, uint8_t size, const char spaceSym, const char * defaultName, uint8_t defaultNameSize, uint8_t defaultIdx) char *strcat_zchar(char *dest, const char *name, uint8_t size,
const char spaceSym, const char *defaultName,
uint8_t defaultNameSize, uint8_t defaultIdx)
{ {
int8_t len = 0; int8_t len = 0;
@@ -137,14 +127,12 @@ char * strcat_zchar(char * dest, const char * name, uint8_t size, const char spa
memcpy(dest, name, size); memcpy(dest, name, size);
dest[size] = '\0'; dest[size] = '\0';
int8_t i = size-1; int8_t i = size - 1;
while (i>=0) { while (i >= 0) {
if (!len && dest[i]) if (!len && dest[i]) len = i + 1;
len = i+1;
if (len) { if (len) {
if (dest[i] == spaceSym) if (dest[i] == spaceSym) dest[i] = '_';
dest[i] = '_';
} }
i--; i--;
} }
@@ -162,100 +150,192 @@ char * strcat_zchar(char * dest, const char * name, uint8_t size, const char spa
#endif #endif
#if !defined(BOOT) #if !defined(BOOT)
char * getStringAtIndex(char * dest, const char * s, int idx) char *getStringAtIndex(char *dest, const char *s, int idx)
{ {
uint8_t len = s[0]; uint8_t len = s[0];
strncpy(dest, s+1+len*idx, len); strncpy(dest, s + 1 + len * idx, len);
dest[len] = '\0'; dest[len] = '\0';
return dest; return dest;
} }
char * strAppendStringWithIndex(char * dest, const char * s, int idx) char *strAppendStringWithIndex(char *dest, const char *s, int idx)
{ {
return strAppendUnsigned(strAppend(dest, s), abs(idx)); return strAppendUnsigned(strAppend(dest, s), abs(idx));
} }
constexpr int secondsPerDay = 24 * 3600; #define SECONDSPERMIN 60
constexpr int secondsPer99Hours = 99*3600 + 59*60 + 59; #define SECONDSPERHOUR (60 * SECONDSPERMIN)
constexpr int secondsPerYear = 365 * secondsPerDay; #define SECONDSPERDAY (24 * SECONDSPERHOUR)
#define SECONDSPERYEAR (365 * SECONDSPERDAY)
char * getTimerString(char * dest, int tme, uint8_t hours) char *getTimerStringCase(char *dest, int32_t tme, uint8_t hours,
bool bLowerCase)
{ {
char * s = dest; char *s = dest;
div_t qr; div_t qr;
int val = abs(tme);
uint8_t digit_group = 0;
if (tme < 0) { if (tme < 0) {
tme = -tme; tme = -tme;
*s++ = '-'; *s++ = '-';
} }
if (tme < secondsPerDay) { // years
qr = div((int) tme, 60); qr = div((int)val, SECONDSPERYEAR);
if (qr.quot != 0) {
qr = div((int)val, SECONDSPERYEAR);
*s++ = '0' + (qr.quot / 10);
*s++ = '0' + (qr.quot % 10);
*s++ = bLowerCase ? 'y' : 'Y';
val = qr.rem;
digit_group++;
}
// days
qr = div((int)val, SECONDSPERDAY);
if (qr.quot != 0 || digit_group != 0) {
qr = div((int)val, SECONDSPERDAY);
*s++ = '0' + (qr.quot / 10);
*s++ = '0' + (qr.quot % 10);
*s++ = bLowerCase ? 'd' : 'D';
val = qr.rem;
digit_group++;
}
// hours
qr = div((int)val, SECONDSPERHOUR);
if (qr.quot != 0 || digit_group != 0) {
qr = div((int)val, SECONDSPERHOUR);
*s++ = '0' + (qr.quot / 10);
*s++ = '0' + (qr.quot % 10);
*s++ = bLowerCase ? 'h' : 'H';
val = qr.rem;
digit_group++;
}
if (digit_group == 3) {
*s = 0;
return dest;
}
// minutes
qr = div((int)val, SECONDSPERMIN);
*s++ = '0' + (qr.quot / 10);
*s++ = '0' + (qr.quot % 10);
*s++ = bLowerCase ? 'm' : 'M';
digit_group++;
if (digit_group == 3) {
*s = 0;
return dest;
}
// seconds
*s++ = '0' + (qr.rem / 10);
*s++ = '0' + (qr.rem % 10);
// if ( digit_group != 1 ) {
*s++ = bLowerCase ? 's' : 'S';
//}
*s = 0;
if (hours) {
div_t qr2 = div(qr.quot, 60);
*s++ = '0' + (qr2.quot / 10);
*s++ = '0' + (qr2.quot % 10);
*s++ = ':';
qr.quot = qr2.rem;
}
if (!hours && qr.quot > 99) {
*s++ = '0' + (qr.quot / 100);
qr.quot = qr.quot % 100;
}
*s++ = '0' + (qr.quot / 10);
*s++ = '0' + (qr.quot % 10);
*s++ = ':';
*s++ = '0' + (qr.rem / 10);
*s++ = '0' + (qr.rem % 10);
*s = '\0';
}
else if (tme < secondsPer99Hours) {
qr = div(tme, 3600);
div_t qr2 = div(qr.rem, 60);
*s++ = '0' + (qr.quot / 10);
*s++ = '0' + (qr.quot % 10);
*s++ = 'H';
*s++ = '0' + (qr2.quot / 10);
*s++ = '0' + (qr2.quot % 10);
*s = '\0';
}
else if (tme < secondsPerYear) {
qr = div(tme, secondsPerDay);
div_t qr2 = div(qr.rem, 60);
*s++ = '0' + (qr.quot / 100);
*s++ = '0' + (qr.quot / 10);
*s++ = '0' + (qr.quot % 10);
*s++ = 'D';
*s++ = '0' + (qr2.quot / 10);
*s++ = '0' + (qr2.quot % 10);
*s++ = 'H';
*s = '\0';
}
else {
qr = div(tme, secondsPerYear);
div_t qr2 = div(qr.rem, secondsPerDay);
*s++ = '0' + (qr.quot / 10);
*s++ = '0' + (qr.quot % 10);
*s++ = 'Y';
*s++ = 'Y';
*s++ = '0' + (qr2.quot / 10);
*s++ = '0' + (qr2.quot % 10);
*s++ = 'D';
*s = '\0';
}
return dest; return dest;
} }
char * getCurveString(char * dest, int idx) void splitTimer(char *sDb0, char *sDb1, char *sUnit0, char *sUnit1, int tme,
bool bLowerCase)
{
char *s0 = sDb0;
char *s1 = sDb1;
char *s2 = sUnit0;
char *s3 = sUnit1;
s0[0] = s1[0] = s0[1] = s1[1] = '0';
div_t qr;
int val = tme;
uint8_t digit_group = 0;
/*
if (tme < 0) {
tme = -tme;
*s++ = '-';
}
*/
// years
qr = div((int)val, SECONDSPERYEAR);
if (qr.quot != 0) {
qr = div((int)val, SECONDSPERYEAR);
*s0++ += (qr.quot / 10);
*s0++ += (qr.quot % 10);
*s0 = 0;
;
*s2++ = bLowerCase ? 'y' : 'Y';
*s2 = 0;
digit_group++;
val = qr.rem;
}
// days
qr = div((int)val, SECONDSPERDAY);
if (digit_group == 1) {
*s1++ += (qr.quot / 10);
*s1++ += (qr.quot % 10);
*s1 = 0;
*s3++ = bLowerCase ? 'd' : 'D';
*s3 = 0;
return;
}
if (qr.quot != 0) {
*s0++ += (qr.quot / 10);
*s0++ += (qr.quot % 10);
*s0 = 0;
;
*s2++ = bLowerCase ? 'd' : 'D';
*s2 = 0;
digit_group++;
val = qr.rem;
}
// hours
qr = div((int)val, SECONDSPERHOUR);
if (digit_group == 1) {
*s1++ += (qr.quot / 10);
*s1++ += (qr.quot % 10);
*s1 = 0;
*s3++ = bLowerCase ? 'h' : 'H';
*s3 = 0;
return;
}
if (qr.quot != 0) {
*s0++ += (qr.quot / 10);
*s0++ += (qr.quot % 10);
*s0 = 0;
*s2++ = bLowerCase ? 'h' : 'H';
*s2 = 0;
digit_group++;
val = qr.rem;
}
// minutes
qr = div((int)val, SECONDSPERMIN);
if (digit_group == 1) {
*s1++ += (qr.quot / 10);
*s1++ += (qr.quot % 10);
*s1 = 0;
*s3++ = bLowerCase ? 'm' : 'M';
*s3 = 0;
return;
}
*s0++ += (qr.quot / 10);
*s0++ += (qr.quot % 10);
*s0 = 0;
*s2++ = bLowerCase ? 'm' : 'M';
*s2 = 0;
// seconds
*s1++ += (qr.rem / 10);
*s1++ += (qr.rem % 10);
*s1 = 0;
*s3++ = bLowerCase ? 's' : 'S';
*s3 = 0;
}
char *getCurveString(char *dest, int idx)
{ {
if (idx == 0) { if (idx == 0) {
return getStringAtIndex(dest, STR_MMMINV, 0); return getStringAtIndex(dest, STR_MMMINV, 0);
} }
char * s = dest; char *s = dest;
if (idx < 0) { if (idx < 0) {
*s++ = '!'; *s++ = '!';
idx = -idx; idx = -idx;
@@ -269,27 +349,27 @@ char * getCurveString(char * dest, int idx)
return dest; return dest;
} }
char * getGVarString(char * dest, int idx) char *getGVarString(char *dest, int idx)
{ {
char * s = dest; char *s = dest;
if (idx < 0) { if (idx < 0) {
*s++ = '-'; *s++ = '-';
idx = -idx-1; idx = -idx - 1;
} }
if (g_model.gvars[idx].name[0]) if (g_model.gvars[idx].name[0])
strAppend(s, g_model.gvars[idx].name, LEN_GVAR_NAME); strAppend(s, g_model.gvars[idx].name, LEN_GVAR_NAME);
else else
strAppendStringWithIndex(s, STR_GV, idx+1); strAppendStringWithIndex(s, STR_GV, idx + 1);
return dest; return dest;
} }
char * getFlightModeString(char * dest, int8_t idx) char *getFlightModeString(char *dest, int8_t idx)
{ {
char * s = dest; char *s = dest;
if (idx==0) { if (idx == 0) {
strcpy(s, "---"); strcpy(s, "---");
return dest; return dest;
} }
@@ -304,10 +384,10 @@ char * getFlightModeString(char * dest, int8_t idx)
return dest; return dest;
} }
char * getSwitchWarningString(char * dest, swsrc_t idx) char *getSwitchWarningString(char *dest, swsrc_t idx)
{ {
char * s = dest; char *s = dest;
uint8_t state = g_model.switchWarningState >> (3*idx) & 0x07; uint8_t state = g_model.switchWarningState >> (3 * idx) & 0x07;
*s++ = 'A' + idx; *s++ = 'A' + idx;
if (state == 0) if (state == 0)
@@ -320,25 +400,25 @@ char * getSwitchWarningString(char * dest, swsrc_t idx)
} }
#if !defined(PCBSKY9X) #if !defined(PCBSKY9X)
char * getSwitchName(char * dest, swsrc_t idx) char *getSwitchName(char *dest, swsrc_t idx)
{ {
div_t swinfo = switchInfo(idx); div_t swinfo = switchInfo(idx);
if (g_eeGeneral.switchNames[swinfo.quot][0] != '\0') { if (g_eeGeneral.switchNames[swinfo.quot][0] != '\0') {
dest = strAppend(dest, g_eeGeneral.switchNames[swinfo.quot], LEN_SWITCH_NAME); dest =
} strAppend(dest, g_eeGeneral.switchNames[swinfo.quot], LEN_SWITCH_NAME);
else { } else {
*dest++ = 'S'; *dest++ = 'S';
#if defined(PCBX7) && !defined(RADIO_TX12) #if defined(PCBX7) && !defined(RADIO_TX12)
if (swinfo.quot >= 5) if (swinfo.quot >= 5)
*dest++ = 'H' + swinfo.quot - 5; *dest++ = 'H' + swinfo.quot - 5;
else if (swinfo.quot == 4) else if (swinfo.quot == 4)
#if defined(RADIO_T12) #if defined(RADIO_T12)
*dest++ = 'G'; *dest++ = 'G';
#else #else
*dest++ = 'F'; *dest++ = 'F';
#endif #endif
else else
*dest++ = 'A'+swinfo.quot; *dest++ = 'A' + swinfo.quot;
#else #else
*dest++ = 'A' + swinfo.quot; *dest++ = 'A' + swinfo.quot;
#endif #endif
@@ -347,65 +427,64 @@ char * getSwitchName(char * dest, swsrc_t idx)
} }
#endif #endif
char * getSwitchPositionName(char * dest, swsrc_t idx) char *getSwitchPositionName(char *dest, swsrc_t idx)
{ {
if (idx == SWSRC_NONE) { if (idx == SWSRC_NONE) {
return getStringAtIndex(dest, STR_VSWITCHES, 0); return getStringAtIndex(dest, STR_VSWITCHES, 0);
} } else if (idx == SWSRC_OFF) {
else if (idx == SWSRC_OFF) {
return getStringAtIndex(dest, STR_OFFON, 0); return getStringAtIndex(dest, STR_OFFON, 0);
} }
char * s = dest; char *s = dest;
if (idx < 0) { if (idx < 0) {
*s++ = '!'; *s++ = '!';
idx = -idx; idx = -idx;
} }
#if defined(PCBSKY9X) #if defined(PCBSKY9X)
#define IDX_TRIMS_IN_STR_VSWITCHES (1+SWSRC_LAST_SWITCH) #define IDX_TRIMS_IN_STR_VSWITCHES (1 + SWSRC_LAST_SWITCH)
#define IDX_ON_IN_STR_VSWITCHES (IDX_TRIMS_IN_STR_VSWITCHES+SWSRC_LAST_TRIM-SWSRC_FIRST_TRIM+2) #define IDX_ON_IN_STR_VSWITCHES \
(IDX_TRIMS_IN_STR_VSWITCHES + SWSRC_LAST_TRIM - SWSRC_FIRST_TRIM + 2)
if (idx <= SWSRC_LAST_SWITCH) { if (idx <= SWSRC_LAST_SWITCH) {
getStringAtIndex(s, STR_VSWITCHES, idx); getStringAtIndex(s, STR_VSWITCHES, idx);
} }
#else #else
#define IDX_TRIMS_IN_STR_VSWITCHES (1) #define IDX_TRIMS_IN_STR_VSWITCHES (1)
#define IDX_ON_IN_STR_VSWITCHES (IDX_TRIMS_IN_STR_VSWITCHES + SWSRC_LAST_TRIM - SWSRC_FIRST_TRIM + 1) #define IDX_ON_IN_STR_VSWITCHES \
(IDX_TRIMS_IN_STR_VSWITCHES + SWSRC_LAST_TRIM - SWSRC_FIRST_TRIM + 1)
if (idx <= SWSRC_LAST_SWITCH) { if (idx <= SWSRC_LAST_SWITCH) {
div_t swinfo = switchInfo(idx); div_t swinfo = switchInfo(idx);
s = getSwitchName(s, idx); s = getSwitchName(s, idx);
*s++ = (STR_CHAR_UP "-" STR_CHAR_DOWN)[swinfo.rem]; *s++ = (STR_CHAR_UP "-" STR_CHAR_DOWN)[swinfo.rem];
*s = '\0'; *s = '\0';
} }
#endif // PCBSKY9X #endif // PCBSKY9X
#if NUM_XPOTS > 0 #if NUM_XPOTS > 0
else if (idx <= SWSRC_LAST_MULTIPOS_SWITCH) { else if (idx <= SWSRC_LAST_MULTIPOS_SWITCH) {
div_t swinfo = div(int(idx - SWSRC_FIRST_MULTIPOS_SWITCH), XPOTS_MULTIPOS_COUNT); div_t swinfo =
char temp[LEN_ANA_NAME+1]; div(int(idx - SWSRC_FIRST_MULTIPOS_SWITCH), XPOTS_MULTIPOS_COUNT);
getSourceString(temp, MIXSRC_FIRST_POT+swinfo.quot); char temp[LEN_ANA_NAME + 1];
temp[LEN_ANA_NAME]= '\0'; getSourceString(temp, MIXSRC_FIRST_POT + swinfo.quot);
strAppendStringWithIndex(s, temp, swinfo.rem+1); temp[LEN_ANA_NAME] = '\0';
strAppendStringWithIndex(s, temp, swinfo.rem + 1);
} }
#endif #endif
else if (idx <= SWSRC_LAST_TRIM) { else if (idx <= SWSRC_LAST_TRIM) {
getStringAtIndex(s, STR_VSWITCHES, IDX_TRIMS_IN_STR_VSWITCHES+idx-SWSRC_FIRST_TRIM); getStringAtIndex(s, STR_VSWITCHES,
} IDX_TRIMS_IN_STR_VSWITCHES + idx - SWSRC_FIRST_TRIM);
else if (idx <= SWSRC_LAST_LOGICAL_SWITCH) { } else if (idx <= SWSRC_LAST_LOGICAL_SWITCH) {
*s++ = 'L'; *s++ = 'L';
strAppendUnsigned(s, idx-SWSRC_FIRST_LOGICAL_SWITCH+1, 2); strAppendUnsigned(s, idx - SWSRC_FIRST_LOGICAL_SWITCH + 1, 2);
} } else if (idx <= SWSRC_ONE) {
else if (idx <= SWSRC_ONE) { getStringAtIndex(s, STR_VSWITCHES,
getStringAtIndex(s, STR_VSWITCHES, IDX_ON_IN_STR_VSWITCHES + idx - SWSRC_ON); IDX_ON_IN_STR_VSWITCHES + idx - SWSRC_ON);
} } else if (idx <= SWSRC_LAST_FLIGHT_MODE) {
else if (idx <= SWSRC_LAST_FLIGHT_MODE) { strAppendStringWithIndex(s, STR_FM, idx - SWSRC_FIRST_FLIGHT_MODE);
strAppendStringWithIndex(s, STR_FM, idx-SWSRC_FIRST_FLIGHT_MODE); } else if (idx == SWSRC_TELEMETRY_STREAMING) {
}
else if (idx == SWSRC_TELEMETRY_STREAMING) {
strcpy(s, "Tele"); strcpy(s, "Tele");
} } else if (idx == SWSRC_RADIO_ACTIVITY) {
else if (idx == SWSRC_RADIO_ACTIVITY) {
strcpy(s, "Act"); strcpy(s, "Act");
} }
#if defined(DEBUG_LATENCY) #if defined(DEBUG_LATENCY)
@@ -414,52 +493,52 @@ char * getSwitchPositionName(char * dest, swsrc_t idx)
} }
#endif #endif
else { else {
strncpy(s, g_model.telemetrySensors[idx-SWSRC_FIRST_SENSOR].label, TELEM_LABEL_LEN); strncpy(s, g_model.telemetrySensors[idx - SWSRC_FIRST_SENSOR].label,
TELEM_LABEL_LEN);
s[TELEM_LABEL_LEN] = '\0'; s[TELEM_LABEL_LEN] = '\0';
} }
return dest; return dest;
} }
char * getSourceString(char * dest, mixsrc_t idx) char *getSourceString(char *dest, mixsrc_t idx)
{ {
if (idx == MIXSRC_NONE) { if (idx == MIXSRC_NONE) {
return getStringAtIndex(dest, STR_VSRCRAW, 0); return getStringAtIndex(dest, STR_VSRCRAW, 0);
} } else if (idx <= MIXSRC_LAST_INPUT) {
else if (idx <= MIXSRC_LAST_INPUT) {
idx -= MIXSRC_FIRST_INPUT; idx -= MIXSRC_FIRST_INPUT;
*dest = CHAR_INPUT; *dest = CHAR_INPUT;
if (strlen(g_model.inputNames[idx])) { if (strlen(g_model.inputNames[idx])) {
memset(dest + 1, 0, LEN_INPUT_NAME+1); memset(dest + 1, 0, LEN_INPUT_NAME + 1);
strncpy(dest + 1, g_model.inputNames[idx], LEN_INPUT_NAME); strncpy(dest + 1, g_model.inputNames[idx], LEN_INPUT_NAME);
} } else {
else {
strAppendUnsigned(dest + 1, idx + 1, 2); strAppendUnsigned(dest + 1, idx + 1, 2);
} }
} }
#if defined(LUA_INPUTS) #if defined(LUA_INPUTS)
else if (idx <= MIXSRC_LAST_LUA) { else if (idx <= MIXSRC_LAST_LUA) {
#if defined(LUA_MODEL_SCRIPTS) #if defined(LUA_MODEL_SCRIPTS)
div_t qr = div(idx-MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS); div_t qr = div(idx - MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS);
if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot].outputsCount) { if (qr.quot < MAX_SCRIPTS &&
qr.rem < scriptInputsOutputs[qr.quot].outputsCount) {
*dest++ = CHAR_LUA; *dest++ = CHAR_LUA;
// temporary string // temporary string
#define MAX_CHAR 16 #define MAX_CHAR 16
char temp[MAX_CHAR]; char temp[MAX_CHAR];
strncpy( temp, g_model.scriptsData[qr.quot].name, MAX_CHAR ); strncpy(temp, g_model.scriptsData[qr.quot].name, MAX_CHAR);
// instance Name is empty : dest = n-ScriptFileName/OutputName // instance Name is empty : dest = n-ScriptFileName/OutputName
if ( temp[0]== 0) { if (temp[0] == 0) {
snprintf( temp, MAX_CHAR, "%d-%s/%s", qr.quot+1, snprintf(temp, MAX_CHAR, "%d-%s/%s", qr.quot + 1,
g_model.scriptsData[qr.quot].file, g_model.scriptsData[qr.quot].file,
scriptInputsOutputs[qr.quot].outputs[qr.rem].name ); scriptInputsOutputs[qr.quot].outputs[qr.rem].name);
// instance Name is not empty : dest = InstanceName/OutputName // instance Name is not empty : dest = InstanceName/OutputName
} else { } else {
snprintf( temp, MAX_CHAR, "%s/%s", g_model.scriptsData[qr.quot].name, snprintf(temp, MAX_CHAR, "%s/%s", g_model.scriptsData[qr.quot].name,
scriptInputsOutputs[qr.quot].outputs[qr.rem].name ); scriptInputsOutputs[qr.quot].outputs[qr.rem].name);
} }
strcpy( dest, temp); strcpy(dest, temp);
} }
#else #else
strcpy(dest, "N/A"); strcpy(dest, "N/A");
@@ -469,9 +548,8 @@ char * getSourceString(char * dest, mixsrc_t idx)
else if (idx <= MIXSRC_LAST_POT) { else if (idx <= MIXSRC_LAST_POT) {
if (g_eeGeneral.anaNames[idx - MIXSRC_Rud][0]) { if (g_eeGeneral.anaNames[idx - MIXSRC_Rud][0]) {
// TODO: add correct symbol
//TODO: add correct symbol if (idx <= MIXSRC_LAST_STICK) {
if(idx <= MIXSRC_LAST_STICK) {
dest[0] = CHAR_STICK; dest[0] = CHAR_STICK;
#if NUM_SLIDERS > 0 #if NUM_SLIDERS > 0
} else if (idx < MIXSRC_FIRST_SLIDER) { } else if (idx < MIXSRC_FIRST_SLIDER) {
@@ -485,66 +563,65 @@ char * getSourceString(char * dest, mixsrc_t idx)
} }
idx -= MIXSRC_Rud; idx -= MIXSRC_Rud;
memcpy(dest+1, g_eeGeneral.anaNames[idx], LEN_ANA_NAME); memcpy(dest + 1, g_eeGeneral.anaNames[idx], LEN_ANA_NAME);
dest[LEN_ANA_NAME+1] = '\0'; dest[LEN_ANA_NAME + 1] = '\0';
} } else {
else {
idx -= MIXSRC_Rud; idx -= MIXSRC_Rud;
getStringAtIndex(dest, STR_VSRCRAW, idx + 1); getStringAtIndex(dest, STR_VSRCRAW, idx + 1);
} }
} } else if (idx <= MIXSRC_LAST_TRIM) {
else if (idx <= MIXSRC_LAST_TRIM) {
idx -= MIXSRC_Rud; idx -= MIXSRC_Rud;
getStringAtIndex(dest, STR_VSRCRAW, idx + 1); getStringAtIndex(dest, STR_VSRCRAW, idx + 1);
} } else if (idx <= MIXSRC_LAST_SWITCH) {
else if (idx <= MIXSRC_LAST_SWITCH) {
idx -= MIXSRC_FIRST_SWITCH; idx -= MIXSRC_FIRST_SWITCH;
if (g_eeGeneral.switchNames[idx][0] != '\0') { if (g_eeGeneral.switchNames[idx][0] != '\0') {
strncpy(dest, g_eeGeneral.switchNames[idx], LEN_SWITCH_NAME); strncpy(dest, g_eeGeneral.switchNames[idx], LEN_SWITCH_NAME);
dest[LEN_SWITCH_NAME] = '\0'; dest[LEN_SWITCH_NAME] = '\0';
} else {
getStringAtIndex(dest, STR_VSRCRAW,
idx + MIXSRC_FIRST_SWITCH - MIXSRC_Rud + 1);
} }
else { } else if (idx <= MIXSRC_LAST_LOGICAL_SWITCH) {
getStringAtIndex(dest, STR_VSRCRAW, idx + MIXSRC_FIRST_SWITCH - MIXSRC_Rud + 1);
}
}
else if (idx <= MIXSRC_LAST_LOGICAL_SWITCH) {
getSwitchPositionName(dest, SWSRC_SW1 + idx - MIXSRC_SW1); getSwitchPositionName(dest, SWSRC_SW1 + idx - MIXSRC_SW1);
} } else if (idx <= MIXSRC_LAST_TRAINER) {
else if (idx <= MIXSRC_LAST_TRAINER) { strAppendStringWithIndex(dest, STR_PPM_TRAINER,
strAppendStringWithIndex(dest, STR_PPM_TRAINER, idx - MIXSRC_FIRST_TRAINER + 1); idx - MIXSRC_FIRST_TRAINER + 1);
} } else if (idx <= MIXSRC_LAST_CH) {
else if (idx <= MIXSRC_LAST_CH) {
strAppendStringWithIndex(dest, STR_CH, idx - MIXSRC_CH1 + 1); strAppendStringWithIndex(dest, STR_CH, idx - MIXSRC_CH1 + 1);
} } else if (idx <= MIXSRC_LAST_GVAR) {
else if (idx <= MIXSRC_LAST_GVAR) {
strAppendStringWithIndex(dest, STR_GV, idx - MIXSRC_GVAR1 + 1); strAppendStringWithIndex(dest, STR_GV, idx - MIXSRC_GVAR1 + 1);
} } else if (idx < MIXSRC_FIRST_TIMER) {
else if (idx < MIXSRC_FIRST_TIMER) { getStringAtIndex(dest, STR_VSRCRAW,
getStringAtIndex(dest, STR_VSRCRAW, idx-MIXSRC_Rud+1-MAX_LOGICAL_SWITCHES-MAX_TRAINER_CHANNELS-MAX_OUTPUT_CHANNELS-MAX_GVARS); idx - MIXSRC_Rud + 1 - MAX_LOGICAL_SWITCHES -
} MAX_TRAINER_CHANNELS - MAX_OUTPUT_CHANNELS -
else if (idx <= MIXSRC_LAST_TIMER) { MAX_GVARS);
if(g_model.timers[idx-MIXSRC_FIRST_TIMER].name[0] != '\0') { } else if (idx <= MIXSRC_LAST_TIMER) {
strncpy(dest,g_model.timers[idx-MIXSRC_FIRST_TIMER].name, LEN_TIMER_NAME); if (g_model.timers[idx - MIXSRC_FIRST_TIMER].name[0] != '\0') {
strncpy(dest, g_model.timers[idx - MIXSRC_FIRST_TIMER].name,
LEN_TIMER_NAME);
dest[LEN_TIMER_NAME] = '\0'; dest[LEN_TIMER_NAME] = '\0';
} else {
getStringAtIndex(dest, STR_VSRCRAW,
idx - MIXSRC_Rud + 1 - MAX_LOGICAL_SWITCHES -
MAX_TRAINER_CHANNELS - MAX_OUTPUT_CHANNELS -
MAX_GVARS);
} }
else { } else {
getStringAtIndex(dest, STR_VSRCRAW, idx-MIXSRC_Rud+1-MAX_LOGICAL_SWITCHES-MAX_TRAINER_CHANNELS-MAX_OUTPUT_CHANNELS-MAX_GVARS);
}
}
else {
idx -= MIXSRC_FIRST_TELEM; idx -= MIXSRC_FIRST_TELEM;
div_t qr = div(idx, 3); div_t qr = div(idx, 3);
dest[0] = CHAR_TELEMETRY; dest[0] = CHAR_TELEMETRY;
char * pos = strAppend(&dest[1], g_model.telemetrySensors[qr.quot].label, sizeof(g_model.telemetrySensors[qr.quot].label)); char *pos = strAppend(&dest[1], g_model.telemetrySensors[qr.quot].label,
if (qr.rem) * pos = (qr.rem==2 ? '+' : '-'); sizeof(g_model.telemetrySensors[qr.quot].label));
* ++pos = '\0'; if (qr.rem) *pos = (qr.rem == 2 ? '+' : '-');
*++pos = '\0';
} }
return dest; return dest;
} }
#endif #endif
char * strAppendUnsigned(char * dest, uint32_t value, uint8_t digits, uint8_t radix) char *strAppendUnsigned(char *dest, uint32_t value, uint8_t digits,
uint8_t radix)
{ {
if (digits == 0) { if (digits == 0) {
unsigned int tmp = value; unsigned int tmp = value;
@@ -564,7 +641,7 @@ char * strAppendUnsigned(char * dest, uint32_t value, uint8_t digits, uint8_t ra
return &dest[digits]; return &dest[digits];
} }
char * strAppendSigned(char * dest, int32_t value, uint8_t digits, uint8_t radix) char *strAppendSigned(char *dest, int32_t value, uint8_t digits, uint8_t radix)
{ {
if (value < 0) { if (value < 0) {
*dest++ = '-'; *dest++ = '-';
@@ -573,7 +650,7 @@ char * strAppendSigned(char * dest, int32_t value, uint8_t digits, uint8_t radix
return strAppendUnsigned(dest, (uint32_t)value, digits, radix); return strAppendUnsigned(dest, (uint32_t)value, digits, radix);
} }
char * strAppend(char * dest, const char * source, int len) char *strAppend(char *dest, const char *source, int len)
{ {
while ((*dest++ = *source++)) { while ((*dest++ = *source++)) {
if (--len == 0) { if (--len == 0) {
@@ -584,7 +661,7 @@ char * strAppend(char * dest, const char * source, int len)
return dest - 1; return dest - 1;
} }
char * strSetCursor(char * dest, int position) char *strSetCursor(char *dest, int position)
{ {
*dest++ = 0x1F; *dest++ = 0x1F;
*dest++ = position; *dest++ = position;
@@ -592,10 +669,10 @@ char * strSetCursor(char * dest, int position)
return dest; return dest;
} }
char * strAppendFilename(char * dest, const char * filename, const int size) char *strAppendFilename(char *dest, const char *filename, const int size)
{ {
memset(dest, 0, size); memset(dest, 0, size);
for (int i=0; i<size; i++) { for (int i = 0; i < size; i++) {
char c = *filename++; char c = *filename++;
if (c == '\0' || c == '.') { if (c == '\0' || c == '.') {
*dest = 0; *dest = 0;
@@ -609,12 +686,12 @@ char * strAppendFilename(char * dest, const char * filename, const int size)
#if defined(RTCLOCK) #if defined(RTCLOCK)
#include "rtc.h" #include "rtc.h"
char * strAppendDate(char * str, bool time) char *strAppendDate(char *str, bool time)
{ {
str[0] = '-'; str[0] = '-';
struct gtm utm; struct gtm utm;
gettime(&utm); gettime(&utm);
div_t qr = div(utm.tm_year+TM_YEAR_BASE, 10); div_t qr = div(utm.tm_year + TM_YEAR_BASE, 10);
str[4] = '0' + qr.rem; str[4] = '0' + qr.rem;
qr = div(qr.quot, 10); qr = div(qr.quot, 10);
str[3] = '0' + qr.rem; str[3] = '0' + qr.rem;
@@ -622,7 +699,7 @@ char * strAppendDate(char * str, bool time)
str[2] = '0' + qr.rem; str[2] = '0' + qr.rem;
str[1] = '0' + qr.quot; str[1] = '0' + qr.quot;
str[5] = '-'; str[5] = '-';
qr = div(utm.tm_mon+1, 10); qr = div(utm.tm_mon + 1, 10);
str[7] = '0' + qr.rem; str[7] = '0' + qr.rem;
str[6] = '0' + qr.quot; str[6] = '0' + qr.quot;
str[8] = '-'; str[8] = '-';
@@ -643,8 +720,7 @@ char * strAppendDate(char * str, bool time)
str[16] = '0' + qr.quot; str[16] = '0' + qr.quot;
str[18] = '\0'; str[18] = '\0';
return &str[18]; return &str[18];
} } else {
else {
str[11] = '\0'; str[11] = '\0';
return &str[11]; return &str[11];
} }
@@ -654,33 +730,37 @@ char * strAppendDate(char * str, bool time)
#if !defined(BOOT) #if !defined(BOOT)
static char tmpHelpersString[32]; static char tmpHelpersString[32];
char * getSwitchWarningString(swsrc_t idx) char *getSwitchWarningString(swsrc_t idx)
{ {
return getSwitchWarningString(tmpHelpersString, idx); return getSwitchWarningString(tmpHelpersString, idx);
} }
char * getSourceString(mixsrc_t idx) char *getSourceString(mixsrc_t idx)
{ {
return getSourceString(tmpHelpersString, idx); return getSourceString(tmpHelpersString, idx);
} }
char * getCurveString(int idx) char *getCurveString(int idx) { return getCurveString(tmpHelpersString, idx); }
char *getTimerString(int32_t tme, uint8_t hours)
{ {
return getCurveString(tmpHelpersString, idx); return getTimerStringCase(tmpHelpersString, tme, hours, true);
} }
char * getTimerString(int32_t tme, uint8_t hours) char *getTimerString(int32_t tme, uint8_t hours, bool bLowerCase)
{ {
return getTimerString(tmpHelpersString, tme, hours); return getTimerStringCase(tmpHelpersString, tme, hours, bLowerCase);
} }
char * getSwitchPositionName(swsrc_t idx) char *getTimerString(char *dest, int32_t tme, uint8_t hours)
{
return getTimerStringCase(dest, tme, hours, true);
}
char *getSwitchPositionName(swsrc_t idx)
{ {
return getSwitchPositionName(tmpHelpersString, idx); return getSwitchPositionName(tmpHelpersString, idx);
} }
char * getGVarString(int idx) char *getGVarString(int idx) { return getGVarString(tmpHelpersString, idx); }
{
return getGVarString(tmpHelpersString, idx);
}
#endif #endif
+31 -24
View File
@@ -33,34 +33,41 @@ void str2zchar(char *dest, const char *src, int size);
int zchar2str(char *dest, const char *src, int size); int zchar2str(char *dest, const char *src, int size);
int strnlen(const char *src, int max_size); int strnlen(const char *src, int max_size);
char * strAppend(char * dest, const char * source, int len = 0); char *strAppend(char *dest, const char *source, int len = 0);
char * strAppendUnsigned(char * dest, uint32_t value, uint8_t digits = 0, uint8_t radix = 10); char *strAppendUnsigned(char *dest, uint32_t value, uint8_t digits = 0,
char * strAppendSigned(char * dest, int32_t value, uint8_t digits = 0, uint8_t radix = 10); uint8_t radix = 10);
char * strSetCursor(char * dest, int position); char *strAppendSigned(char *dest, int32_t value, uint8_t digits = 0,
char * strAppendDate(char * str, bool time=false); uint8_t radix = 10);
char * strAppendFilename(char * dest, const char * filename, const int size); char *strSetCursor(char *dest, int position);
char *strAppendDate(char *str, bool time = false);
char *strAppendFilename(char *dest, const char *filename, const int size);
#if !defined(BOOT) #if !defined(BOOT)
char * getStringAtIndex(char * dest, const char * s, int idx); char *getStringAtIndex(char *dest, const char *s, int idx);
char * strAppendStringWithIndex(char * dest, const char * s, int idx); char *strAppendStringWithIndex(char *dest, const char *s, int idx);
#define LEN_TIMER_STRING 10 // "-00:00:00" #define LEN_TIMER_STRING 10 // "-00:00:00"
char * getTimerString(char * dest, int tme, uint8_t hours=0); char *getTimerString(char *dest, int32_t tme, uint8_t hours = 0u);
char * getCurveString(char * dest, int idx); char *getTimerStringCase(char *dest, int32_t tme, uint8_t hours = 0u,
char * getGVarString(char * dest, int idx); bool bLowerCase = true);
char * getGVarString(int idx); char *getCurveString(char *dest, int idx);
char * getSwitchPositionName(char * dest, swsrc_t idx); char *getGVarString(char *dest, int idx);
char * getSwitchName(char * dest, swsrc_t idx); char *getGVarString(int idx);
char * getSourceString(char * dest, mixsrc_t idx); char *getSwitchPositionName(char *dest, swsrc_t idx);
char *getSwitchName(char *dest, swsrc_t idx);
char *getSourceString(char *dest, mixsrc_t idx);
#endif #endif
char * getFlightModeString(char * dest, int8_t idx); char *getFlightModeString(char *dest, int8_t idx);
#define SWITCH_WARNING_STR_SIZE 3 #define SWITCH_WARNING_STR_SIZE 3
char * getSwitchWarningString(char * dest, swsrc_t idx); char *getSwitchWarningString(char *dest, swsrc_t idx);
char * getSourceString(mixsrc_t idx); char *getSourceString(mixsrc_t idx);
char * getSwitchPositionName(swsrc_t idx); char *getSwitchPositionName(swsrc_t idx);
char * getSwitchWarningString(swsrc_t idx); char *getSwitchWarningString(swsrc_t idx);
char * getCurveString(int idx); char *getCurveString(int idx);
char * getTimerString(int32_t tme, uint8_t hours); char *getTimerString(int32_t tme, uint8_t hours);
char *getTimerString(int32_t tme, uint8_t hours, bool bLowercase);
void splitTimer(char *s0, char *s1, char *s2, char *s3, int tme,
bool bLowercase = true);
#endif // _STRHELPERS_H_ #endif // _STRHELPERS_H_