1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-16 21:05:26 +03:00

Add gyro settings computations

This commit is contained in:
3djc 2019-04-04 10:43:43 +02:00
parent ca8fa60874
commit d775a91545
5 changed files with 9 additions and 5 deletions

View file

@ -60,12 +60,12 @@ void menuRadioDiagAnalogs(event_t event)
lcdDrawText(x, y, "X:"); lcdDrawText(x, y, "X:");
lcdDrawNumber(x+3*FW-1, y, gyro.outputs[0] * 180 / 1024); lcdDrawNumber(x+3*FW-1, y, gyro.outputs[0] * 180 / 1024);
lcdDrawChar(lcdNextPos, y, '@'); lcdDrawChar(lcdNextPos, y, '@');
lcdDrawNumber(x+10*FW-1, y, gyro.outputs[0], RIGHT); lcdDrawNumber(x+10*FW-1, y, gyro.scaled_outputs[0], RIGHT);
x = LCD_W/2 + INDENT_WIDTH; x = LCD_W/2 + INDENT_WIDTH;
lcdDrawText(x, y, "Y:"); lcdDrawText(x, y, "Y:");
lcdDrawNumber(x+3*FW-1, y, gyro.outputs[1] * 180 / 1024); lcdDrawNumber(x+3*FW-1, y, gyro.outputs[1] * 180 / 1024);
lcdDrawChar(lcdNextPos, y, '@'); lcdDrawChar(lcdNextPos, y, '@');
lcdDrawNumber(x+10*FW-1, y, gyro.outputs[1], RIGHT); lcdDrawNumber(x+10*FW-1, y, gyro.scaled_outputs[1], RIGHT);
#endif #endif
// RAS // RAS

View file

@ -66,5 +66,8 @@ void Gyro::wakeup()
outputs[0] = rad2RESX(atan2f(accValues[1], accValues[2])); outputs[0] = rad2RESX(atan2f(accValues[1], accValues[2]));
outputs[1] = rad2RESX(atan2f(-accValues[0], accValues[2])); outputs[1] = rad2RESX(atan2f(-accValues[0], accValues[2]));
scaled_outputs[0] = limit(-RESX, (int)(outputs[0] - g_eeGeneral.gyroOffset * RESX/180) * (180 / (GYRO_MAX_DEFAULT + g_eeGeneral.gyroMax)), RESX);
scaled_outputs[1] = limit(-RESX, outputs[1] * (180 / (GYRO_MAX_DEFAULT + g_eeGeneral.gyroMax)), RESX);
// TRACE("%d %d", values[0], values[1]); // TRACE("%d %d", values[0], values[1]);
} }

View file

@ -44,6 +44,7 @@ class Gyro {
public: public:
int16_t outputs[2]; int16_t outputs[2];
int16_t scaled_outputs[2];
void wakeup(); void wakeup();
}; };

View file

@ -317,7 +317,7 @@ getvalue_t getValue(mixsrc_t i)
#if defined(GYRO) #if defined(GYRO)
else if (i <= MIXSRC_GYRO2) { else if (i <= MIXSRC_GYRO2) {
return gyro.outputs[i - MIXSRC_GYRO1]; return gyro.scaled_outputs[i - MIXSRC_GYRO1];
} }
#endif #endif

View file

@ -813,7 +813,7 @@ int gyroInit();
int gyroRead(uint8_t buffer[GYRO_BUFFER_LENGTH]); int gyroRead(uint8_t buffer[GYRO_BUFFER_LENGTH]);
#define GYRO_MAX_DEFAULT 30 #define GYRO_MAX_DEFAULT 30
#define GYRO_MAX_RANGE 60 #define GYRO_MAX_RANGE 60
#define GYRO_OFFSET_MIN 10 #define GYRO_OFFSET_MIN -30
#define GYRO_OFFSET_MAX 90 #define GYRO_OFFSET_MAX 10
#endif // _BOARD_H_ #endif // _BOARD_H_