1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 19:40:31 +03:00

Add GPS Lap Timer (#11856)

* Add gps lap timer

* change timing to GPS time instead of local time

* rebase and minor changes

* implement KarateBrot's suggestions

* follow ledvinap's suggestions, some OSD symbol changes

* move platform.h include to the top

Co-authored-by: Jan Post <Rm2k-Freak@web.de>

* fix osd elements not showing, remove useless block

* cleanup, move pg stuff to pg folder

* cleanup from review

* minor mods to gps lap timer update, add number of laps tracked

* rename time variable

* add const to timeMs

Co-authored-by: Jan Post <Rm2k-Freak@web.de>

* Update licenses, add is_sys_element macro

* update licenses

* round to nearest centisecond

Co-authored-by: Jan Post <Rm2k-Freak@web.de>

---------

Co-authored-by: Jan Post <Rm2k-Freak@web.de>
This commit is contained in:
SpencerGraffunder 2023-05-24 20:31:22 -04:00 committed by GitHub
parent 23a416b431
commit aad197f791
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 660 additions and 10 deletions

View file

@ -514,6 +514,11 @@ static void printValuePointer(const char *cmdName, const clivalue_t *var, const
// uin32_t array
cliPrintf("%u", ((uint32_t *)valuePointer)[i]);
break;
case VAR_INT32:
// in32_t array
cliPrintf("%d", ((int32_t *)valuePointer)[i]);
break;
}
if (i < var->config.array.length - 1) {
@ -543,6 +548,10 @@ static void printValuePointer(const char *cmdName, const clivalue_t *var, const
case VAR_UINT32:
value = *(uint32_t *)valuePointer;
break;
case VAR_INT32:
value = *(int32_t *)valuePointer;
break;
}
@ -556,6 +565,13 @@ static void printValuePointer(const char *cmdName, const clivalue_t *var, const
} else if (full) {
cliPrintf(" 0 %u", var->config.u32Max);
}
} else if ((var->type & VALUE_TYPE_MASK) == VAR_INT32) {
cliPrintf("%d", (int32_t)value);
if ((int32_t)value > var->config.d32Max || (int32_t)value < -var->config.d32Max) {
valueIsCorrupted = true;
} else if (full) {
cliPrintf(" 0 %u", var->config.u32Max);
}
} else {
int min;
int max;
@ -627,6 +643,9 @@ static bool valuePtrEqualsDefault(const clivalue_t *var, const void *ptr, const
case VAR_UINT32:
result = result && (((uint32_t *)ptr)[i] & mask) == (((uint32_t *)ptrDefault)[i] & mask);
break;
case VAR_INT32:
result = result && (((int32_t *)ptr)[i] & mask) == (((int32_t *)ptrDefault)[i] & mask);
break;
}
}
@ -792,6 +811,10 @@ static void cliPrintVarRange(const clivalue_t *var)
case VAR_UINT32:
cliPrintLinef("Allowed range: 0 - %u", var->config.u32Max);
break;
case VAR_INT32:
cliPrintLinef("Allowed range: %d - %d", -var->config.d32Max, var->config.d32Max);
break;
case VAR_UINT8:
case VAR_UINT16:
@ -873,6 +896,16 @@ static void cliSetVar(const clivalue_t *var, const uint32_t value)
}
*(uint32_t *)ptr = workValue;
break;
case VAR_INT32:
mask = 1 << var->config.bitpos;
if (value) {
workValue = *(int32_t *)ptr | mask;
} else {
workValue = *(int32_t *)ptr & ~mask;
}
*(int32_t *)ptr = workValue;
break;
}
} else {
switch (var->type & VALUE_TYPE_MASK) {
@ -895,6 +928,10 @@ static void cliSetVar(const clivalue_t *var, const uint32_t value)
case VAR_UINT32:
*(uint32_t *)ptr = value;
break;
case VAR_INT32:
*(int32_t *)ptr = value;
break;
}
}
}
@ -4400,6 +4437,14 @@ STATIC_UNIT_TESTED void cliSet(const char *cmdName, char *cmdline)
cliSetVar(val, value);
valueChanged = true;
}
} else if ((val->type & VALUE_TYPE_MASK) == VAR_INT32) {
int32_t value = strtol(eqptr, NULL, 10);
// INT32s are limited to being symmetric, so we test both bounds with the same magnitude
if (value <= val->config.d32Max && value >= -val->config.d32Max) {
cliSetVar(val, value);
valueChanged = true;
}
} else {
int value = atoi(eqptr);
@ -4495,7 +4540,16 @@ STATIC_UNIT_TESTED void cliSet(const char *cmdName, char *cmdline)
uint32_t *data = (uint32_t *)cliGetValuePointer(val) + i;
// store value
*data = (uint32_t)strtoul((const char*) valPtr, NULL, 10);
}
}
break;
case VAR_INT32:
{
// fetch data pointer
int32_t *data = (int32_t *)cliGetValuePointer(val) + i;
// store value
*data = (int32_t)strtol((const char*) valPtr, NULL, 10);
}
break;
}