Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Support Betaflight's gyro_scale field
Browse files Browse the repository at this point in the history
  • Loading branch information
thenickdude committed Jan 24, 2017
1 parent aa48d98 commit 3c0b9ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ static void parseHeaderLine(flightLog_t *log, mmapStream_t *stream)

log->sysConfig.currentMeterOffset = currentMeterParams[0];
log->sysConfig.currentMeterScale = currentMeterParams[1];
} else if (strcmp(fieldName, "gyro.scale") == 0) {
} else if (strcmp(fieldName, "gyro.scale") == 0 || strcmp(fieldName, "gyro_scale") == 0) {
floatConvert.u = strtoul(fieldValue, 0, 16);

log->sysConfig.gyroScale = floatConvert.f;
Expand All @@ -463,7 +463,7 @@ static void parseHeaderLine(flightLog_t *log, mmapStream_t *stream)
* per second and leaves the conversion to radians per us to the IMU. Let's just convert Cleanflight's scale to
* match Baseflight so we can use Baseflight's IMU for both: */

if (log->sysConfig.firmwareType == FIRMWARE_TYPE_CLEANFLIGHT) {
if (log->sysConfig.firmwareType != FIRMWARE_TYPE_BASEFLIGHT) {
log->sysConfig.gyroScale = (float) (log->sysConfig.gyroScale * (M_PI / 180.0) * 0.000001);
}
} else if (strcmp(fieldName, "acc_1G") == 0) {
Expand Down
3 changes: 2 additions & 1 deletion src/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
typedef enum FirmwareType {
FIRMWARE_TYPE_UNKNOWN = 0,
FIRMWARE_TYPE_BASEFLIGHT,
FIRMWARE_TYPE_CLEANFLIGHT
FIRMWARE_TYPE_CLEANFLIGHT,
FIRMWARE_TYPE_BETAFLIGHT
} FirmwareType;

typedef struct flightLogFrameStatistics_t {
Expand Down

0 comments on commit 3c0b9ea

Please sign in to comment.