1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-24 00:35:18 +03:00

CopyTrimsToOffset function added - #1323

This commit is contained in:
bsongis 2014-06-19 23:52:50 +02:00
parent b1f44d7101
commit 6908509d79
15 changed files with 43 additions and 3 deletions

View file

@ -3853,6 +3853,9 @@ void onLimitsMenu(const char *result)
else if (result == STR_COPY_STICKS_TO_OFS) { else if (result == STR_COPY_STICKS_TO_OFS) {
copySticksToOffset(ch); copySticksToOffset(ch);
} }
else if (result == STR_COPY_TRIMS_TO_OFS) {
copyTrimsToOffset(ch);
}
} }
#endif #endif
@ -3929,6 +3932,7 @@ void menuModelLimits(uint8_t event)
if (sub==k && m_posHorz < 0 && event==EVT_KEY_LONG(KEY_ENTER)) { if (sub==k && m_posHorz < 0 && event==EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event); killEvents(event);
MENU_ADD_ITEM(STR_RESET); MENU_ADD_ITEM(STR_RESET);
MENU_ADD_ITEM(STR_COPY_TRIMS_TO_OFS);
MENU_ADD_ITEM(STR_COPY_STICKS_TO_OFS); MENU_ADD_ITEM(STR_COPY_STICKS_TO_OFS);
menuHandler = onLimitsMenu; menuHandler = onLimitsMenu;
} }

View file

@ -3054,13 +3054,11 @@ void copySticksToOffset(uint8_t ch)
{ {
pauseMixerCalculations(); pauseMixerCalculations();
int32_t zero = (int32_t)channelOutputs[ch]; int32_t zero = (int32_t)channelOutputs[ch];
int32_t old = chans[ch];
evalFlightModeMixes(e_perout_mode_nosticks+e_perout_mode_notrainer, 0); evalFlightModeMixes(e_perout_mode_nosticks+e_perout_mode_notrainer, 0);
int32_t val = chans[ch]; int32_t val = chans[ch];
LimitData *ld = limitAddress(ch); LimitData *ld = limitAddress(ch);
limit_min_max_t lim = LIMIT_MIN(ld); limit_min_max_t lim = LIMIT_MIN(ld);
TRACE("%d vs %d chan=%d vs %d - lim=%d", zero, channelOutputs[ch], val, old, lim);
if (val < 0) { if (val < 0) {
val = -val; val = -val;
lim = LIMIT_MIN(ld); lim = LIMIT_MIN(ld);
@ -3075,6 +3073,31 @@ void copySticksToOffset(uint8_t ch)
eeDirty(EE_MODEL); eeDirty(EE_MODEL);
} }
void copyTrimsToOffset(uint8_t ch)
{
int16_t zero;
pauseMixerCalculations();
evalFlightModeMixes(e_perout_mode_noinput, 0); // do output loop - zero input sticks and trims
zero = applyLimits(ch, chans[ch]);
evalFlightModeMixes(e_perout_mode_noinput-e_perout_mode_notrims, 0); // do output loop - only trims
int16_t output = applyLimits(ch, chans[ch]) - zero;
int16_t v = g_model.limitData[ch].offset;
if (g_model.limitData[ch].revert) output = -output;
#if defined(CPUARM)
v += (output * 125) / 128;
#else
v += output;
#endif
g_model.limitData[ch].offset = limit((int16_t)-1000, (int16_t)v, (int16_t)1000); // make sure the offset doesn't go haywire
resumeMixerCalculations();
eeDirty(EE_MODEL);
}
void moveTrimsToOffsets() // copy state of 3 primary to subtrim void moveTrimsToOffsets() // copy state of 3 primary to subtrim
{ {
int16_t zeros[NUM_CHNOUT]; int16_t zeros[NUM_CHNOUT];

View file

@ -1176,6 +1176,7 @@ void applyDefaultTemplate();
void incSubtrim(uint8_t idx, int16_t inc); void incSubtrim(uint8_t idx, int16_t inc);
void instantTrim(); void instantTrim();
FORCEINLINE void evalTrims(); FORCEINLINE void evalTrims();
void copyTrimsToOffset(uint8_t ch);
void copySticksToOffset(uint8_t ch); void copySticksToOffset(uint8_t ch);
void moveTrimsToOffsets(); void moveTrimsToOffsets();

View file

@ -520,6 +520,7 @@ const pm_char STR_BLCOLOR[] PROGMEM = TR_BLCOLOR;
const pm_char STR_PTS[] PROGMEM = TR_PTS; const pm_char STR_PTS[] PROGMEM = TR_PTS;
const pm_char STR_SMOOTH[] PROGMEM = TR_SMOOTH; const pm_char STR_SMOOTH[] PROGMEM = TR_SMOOTH;
const pm_char STR_COPY_STICKS_TO_OFS[] PROGMEM = TR_COPY_STICKS_TO_OFS; const pm_char STR_COPY_STICKS_TO_OFS[] PROGMEM = TR_COPY_STICKS_TO_OFS;
const pm_char STR_COPY_TRIMS_TO_OFS[] PROGMEM = TR_COPY_TRIMS_TO_OFS;
const pm_char STR_TOP_BAR[] PROGMEM = TR_TOP_BAR; const pm_char STR_TOP_BAR[] PROGMEM = TR_TOP_BAR;
const pm_char STR_ALTITUDE[] PROGMEM = TR_ALTITUDE; const pm_char STR_ALTITUDE[] PROGMEM = TR_ALTITUDE;
const pm_char STR_SCALE[] PROGMEM = TR_SCALE; const pm_char STR_SCALE[] PROGMEM = TR_SCALE;

View file

@ -701,6 +701,7 @@ extern const pm_char STR_BLCOLOR[];
extern const pm_char STR_PTS[]; extern const pm_char STR_PTS[];
extern const pm_char STR_SMOOTH[]; extern const pm_char STR_SMOOTH[];
extern const pm_char STR_COPY_STICKS_TO_OFS[]; extern const pm_char STR_COPY_STICKS_TO_OFS[];
extern const pm_char STR_COPY_TRIMS_TO_OFS[];
extern const pm_char STR_TOP_BAR[]; extern const pm_char STR_TOP_BAR[];
extern const pm_char STR_ALTITUDE[]; extern const pm_char STR_ALTITUDE[];
extern const pm_char STR_SCALE[]; extern const pm_char STR_SCALE[];

View file

@ -804,6 +804,7 @@
#define TR_PTS " b." #define TR_PTS " b."
#define TR_SMOOTH "Hladká" #define TR_SMOOTH "Hladká"
#define TR_COPY_STICKS_TO_OFS "Kopírovat stick do subtrimu" #define TR_COPY_STICKS_TO_OFS "Kopírovat stick do subtrimu"
#define TR_COPY_TRIMS_TO_OFS "Copy trims to subtrim"
#define TR_PERSISTENT_MAH TR(INDENT "Str mAh", INDENT "Ukládat mAh") #define TR_PERSISTENT_MAH TR(INDENT "Str mAh", INDENT "Ukládat mAh")
#define TR_PREFLIGHT "Předletová kontrola" #define TR_PREFLIGHT "Předletová kontrola"
#define TR_CHECKLIST INDENT "Zobrazit poznámky" #define TR_CHECKLIST INDENT "Zobrazit poznámky"

View file

@ -804,6 +804,7 @@
#define TR_PTS "Pts" #define TR_PTS "Pts"
#define TR_SMOOTH "Runden" #define TR_SMOOTH "Runden"
#define TR_COPY_STICKS_TO_OFS "Kopie Stick to Servo-Mitte" // "Trims => Offset" #define TR_COPY_STICKS_TO_OFS "Kopie Stick to Servo-Mitte" // "Trims => Offset"
#define TR_COPY_TRIMS_TO_OFS "Copy trims to subtrim"
#define TR_PERSISTENT_MAH INDENT "Speichern mAh" #define TR_PERSISTENT_MAH INDENT "Speichern mAh"
#define TR_PREFLIGHT "----Preflight Checks----" #define TR_PREFLIGHT "----Preflight Checks----"
#define TR_CHECKLIST INDENT "Display Checklist" #define TR_CHECKLIST INDENT "Display Checklist"

View file

@ -803,7 +803,8 @@
#define TR_PT "pt" #define TR_PT "pt"
#define TR_PTS "pts" #define TR_PTS "pts"
#define TR_SMOOTH "Smooth" #define TR_SMOOTH "Smooth"
#define TR_COPY_STICKS_TO_OFS "Copy Stick To Subtrim" #define TR_COPY_STICKS_TO_OFS "Copy sticks to subtrim"
#define TR_COPY_TRIMS_TO_OFS "Copy trims to subtrim"
#define TR_PERSISTENT_MAH TR(INDENT "Str mAh", INDENT "Persistent mAh") #define TR_PERSISTENT_MAH TR(INDENT "Str mAh", INDENT "Persistent mAh")
#define TR_PREFLIGHT "Preflight Checks" #define TR_PREFLIGHT "Preflight Checks"
#define TR_CHECKLIST TR(INDENT "Checklist", INDENT "Display Checklist") #define TR_CHECKLIST TR(INDENT "Checklist", INDENT "Display Checklist")

View file

@ -804,6 +804,7 @@
#define TR_PTS "pts" #define TR_PTS "pts"
#define TR_SMOOTH "Smooth" #define TR_SMOOTH "Smooth"
#define TR_COPY_STICKS_TO_OFS "Copy Sticks To Offset" #define TR_COPY_STICKS_TO_OFS "Copy Sticks To Offset"
#define TR_COPY_TRIMS_TO_OFS "Copy trims to subtrim"
#define TR_PERSISTENT_MAH INDENT "Valor mAh" #define TR_PERSISTENT_MAH INDENT "Valor mAh"
#define TR_PREFLIGHT "Preflight Checks" #define TR_PREFLIGHT "Preflight Checks"
#define TR_CHECKLIST INDENT "Display Checklist" #define TR_CHECKLIST INDENT "Display Checklist"

View file

@ -804,6 +804,7 @@
#define TR_PTS "pts" #define TR_PTS "pts"
#define TR_SMOOTH "Smooth" #define TR_SMOOTH "Smooth"
#define TR_COPY_STICKS_TO_OFS "Copy Sticks To Offset" #define TR_COPY_STICKS_TO_OFS "Copy Sticks To Offset"
#define TR_COPY_TRIMS_TO_OFS "Copy trims to subtrim"
#define TR_PERSISTENT_MAH INDENT "Store mAh" #define TR_PERSISTENT_MAH INDENT "Store mAh"
#define TR_PREFLIGHT "Preflight Checks" #define TR_PREFLIGHT "Preflight Checks"
#define TR_CHECKLIST INDENT "Display Checklist" #define TR_CHECKLIST INDENT "Display Checklist"

View file

@ -804,6 +804,7 @@
#define TR_PTS "pts" #define TR_PTS "pts"
#define TR_SMOOTH "Lissage" #define TR_SMOOTH "Lissage"
#define TR_COPY_STICKS_TO_OFS "Manche vers subtrim" #define TR_COPY_STICKS_TO_OFS "Manche vers subtrim"
#define TR_COPY_TRIMS_TO_OFS "Trim vers subtrim"
#define TR_PERSISTENT_MAH TR(INDENT "Enr. mAh", INDENT "Enregistrer mAh") #define TR_PERSISTENT_MAH TR(INDENT "Enr. mAh", INDENT "Enregistrer mAh")
#define TR_PREFLIGHT "Vérifications avant vol" #define TR_PREFLIGHT "Vérifications avant vol"
#define TR_CHECKLIST TR(INDENT "Notes", INDENT "Afficher notes") #define TR_CHECKLIST TR(INDENT "Notes", INDENT "Afficher notes")

View file

@ -804,6 +804,7 @@
#define TR_PTS "pti" #define TR_PTS "pti"
#define TR_SMOOTH "Smussa" #define TR_SMOOTH "Smussa"
#define TR_COPY_STICKS_TO_OFS "Copia Stick su Offset" #define TR_COPY_STICKS_TO_OFS "Copia Stick su Offset"
#define TR_COPY_TRIMS_TO_OFS "Copy trims to subtrim"
#define TR_PERSISTENT_MAH INDENT "Memo mAh" #define TR_PERSISTENT_MAH INDENT "Memo mAh"
#define TR_PREFLIGHT "Controlli Prevolo" #define TR_PREFLIGHT "Controlli Prevolo"
#define TR_CHECKLIST INDENT "Mostra Checklist" #define TR_CHECKLIST INDENT "Mostra Checklist"

View file

@ -804,6 +804,7 @@
#define TR_PTS "pkty" #define TR_PTS "pkty"
#define TR_SMOOTH "Gładka" #define TR_SMOOTH "Gładka"
#define TR_COPY_STICKS_TO_OFS "Skopiuj Stick Do Offsetu" #define TR_COPY_STICKS_TO_OFS "Skopiuj Stick Do Offsetu"
#define TR_COPY_TRIMS_TO_OFS "Copy trims to subtrim"
#define TR_PERSISTENT_MAH TR(INDENT "Zap. mAh", INDENT "Zapisz mAh") #define TR_PERSISTENT_MAH TR(INDENT "Zap. mAh", INDENT "Zapisz mAh")
#define TR_PREFLIGHT "Lista Ostrzeżeń" #define TR_PREFLIGHT "Lista Ostrzeżeń"
#define TR_CHECKLIST TR(INDENT "Czeklista",INDENT "Pokaż Listę Ostrzeżeń") #define TR_CHECKLIST TR(INDENT "Czeklista",INDENT "Pokaż Listę Ostrzeżeń")

View file

@ -804,6 +804,7 @@
#define TR_PTS "pts" #define TR_PTS "pts"
#define TR_SMOOTH "Smooth" #define TR_SMOOTH "Smooth"
#define TR_COPY_STICKS_TO_OFS "Copy Sticks To Offset" #define TR_COPY_STICKS_TO_OFS "Copy Sticks To Offset"
#define TR_COPY_TRIMS_TO_OFS "Copy trims to subtrim"
#define TR_PERSISTENT_MAH INDENT "Store mAh" #define TR_PERSISTENT_MAH INDENT "Store mAh"
#define TR_PREFLIGHT "Preflight Checks" #define TR_PREFLIGHT "Preflight Checks"
#define TR_CHECKLIST INDENT "Display Checklist" #define TR_CHECKLIST INDENT "Display Checklist"

View file

@ -804,6 +804,7 @@
#define TR_PTS "pkt" #define TR_PTS "pkt"
#define TR_SMOOTH "Mjuk" #define TR_SMOOTH "Mjuk"
#define TR_COPY_STICKS_TO_OFS "Spara sticks som offset" #define TR_COPY_STICKS_TO_OFS "Spara sticks som offset"
#define TR_COPY_TRIMS_TO_OFS "Copy trims to subtrim"
#define TR_PERSISTENT_MAH INDENT "Lagra mAh" #define TR_PERSISTENT_MAH INDENT "Lagra mAh"
#define TR_PREFLIGHT "Startkontroller" #define TR_PREFLIGHT "Startkontroller"
#define TR_CHECKLIST TR(INDENT "Checklista", INDENT "Visa Checklista") #define TR_CHECKLIST TR(INDENT "Checklista", INDENT "Visa Checklista")