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

Gyro scaled output result not needed in RAM

This commit is contained in:
Bertrand Songis 2019-04-05 15:28:36 +02:00
parent 167849cee8
commit 73fa1c59b1
4 changed files with 17 additions and 8 deletions

View file

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

View file

@ -67,8 +67,5 @@ void Gyro::wakeup()
outputs[0] = rad2RESX(atan2f(accValues[1], 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]);
}

View file

@ -44,8 +44,17 @@ class Gyro {
public:
int16_t outputs[2];
int16_t scaled_outputs[2];
void wakeup();
int16_t scaledX()
{
return limit(-RESX, (int)(outputs[0] - g_eeGeneral.gyroOffset * RESX/180) * (180 / (GYRO_MAX_DEFAULT + g_eeGeneral.gyroMax)), RESX);
}
int16_t scaledY()
{
return limit(-RESX, outputs[1] * (180 / (GYRO_MAX_DEFAULT + g_eeGeneral.gyroMax)), RESX);
}
};
extern Gyro gyro;

View file

@ -316,8 +316,11 @@ getvalue_t getValue(mixsrc_t i)
}
#if defined(GYRO)
else if (i <= MIXSRC_GYRO2) {
return gyro.scaled_outputs[i - MIXSRC_GYRO1];
else if (i == MIXSRC_GYRO1) {
return gyro.scaledX();
}
else if (i == MIXSRC_GYRO2) {
return gyro.scaledY();
}
#endif