Skip to content

Commit

Permalink
Merge pull request #6625 from iNavFlight/dzikuvx-return-pid-value-via…
Browse files Browse the repository at this point in the history
…-msp

Add ability to read Programming PID status via MSP
  • Loading branch information
DzikuVx authored Feb 21, 2021
2 parents 15321e9 + 67572fe commit ea756aa
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/main/fc/fc_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,11 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF
sbufWriteU16(dst, programmingPids(i)->gains.FF);
}
break;
case MSP2_INAV_PROGRAMMING_PID_STATUS:
for (int i = 0; i < MAX_PROGRAMMING_PID_COUNT; i++) {
sbufWriteU32(dst, programmingPidGetOutput(i));
}
break;
#endif
case MSP2_COMMON_MOTOR_MIXER:
for (uint8_t i = 0; i < MAX_SUPPORTED_MOTORS; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/msp/msp_protocol_v2_inav.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#define MSP2_INAV_GVAR_STATUS 0x2027
#define MSP2_INAV_PROGRAMMING_PID 0x2028
#define MSP2_INAV_SET_PROGRAMMING_PID 0x2029
#define MSP2_INAV_PROGRAMMING_PID_STATUS 0x202A

#define MSP2_PID 0x2030
#define MSP2_SET_PID 0x2031
Expand All @@ -79,4 +80,3 @@
#define MSP2_INAV_SET_SAFEHOME 0x2039

#define MSP2_INAV_MISC2 0x203A

2 changes: 1 addition & 1 deletion src/main/programming/pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void programmingPidInit(void)
}
}

int programmingPidGetOutput(uint8_t i) {
int32_t programmingPidGetOutput(uint8_t i) {
return programmingPidState[constrain(i, 0, MAX_PROGRAMMING_PID_COUNT)].output;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/programming/pid.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ typedef struct programmingPidState_s {
void programmingPidUpdateTask(timeUs_t currentTimeUs);
void programmingPidInit(void);
void programmingPidReset(void);
int programmingPidGetOutput(uint8_t i);
int32_t programmingPidGetOutput(uint8_t i);

0 comments on commit ea756aa

Please sign in to comment.