From 76406f1f9c9033fd3e711ee76300ed581499423b Mon Sep 17 00:00:00 2001 From: bsongis Date: Wed, 22 Feb 2012 17:56:38 +0000 Subject: [PATCH] Some new fields now inflight modifiable: DR/EXPOS expo / weight, MIXER weight / offset --- src/main_views.cpp | 6 ++++-- src/menus.cpp | 12 +++++++----- src/menus.h | 15 +++++++++++---- src/model_menus.cpp | 26 ++++++++++++++------------ src/o9xstrings.cpp | 5 ++++- src/o9xstrings.h | 8 +++++++- src/open9x.cpp | 14 +++++++------- src/translations/en.h | 9 ++++++--- src/translations/fr.h | 9 ++++++--- 9 files changed, 66 insertions(+), 38 deletions(-) diff --git a/src/main_views.cpp b/src/main_views.cpp index 6d056f9a1..7722591d7 100644 --- a/src/main_views.cpp +++ b/src/main_views.cpp @@ -583,11 +583,13 @@ void menuMainView(uint8_t event) #ifdef NAVIGATION_RE1 check_rotary_encoder(); if (s_warning) { + int8_t value = (((uint8_t)(*s_inflight_value)) >> s_inflight_bitshift) - s_inflight_shift; if (p1valdiff) { - *s_inflight_value = s_inflight_shift + checkIncDecModel(event, (*s_inflight_value)-s_inflight_shift, s_inflight_min, s_inflight_max); + value = checkIncDecModel(event, value, s_inflight_min, s_inflight_max); + *s_inflight_value = (((uint8_t)(*s_inflight_value)) & ((1 << s_inflight_bitshift) - 1)) + ((s_inflight_shift + value) << s_inflight_bitshift); } displayBox(); - lcd_outdezAtt(16, 4*FH, (int8_t)(*s_inflight_value-s_inflight_shift), LEFT); + lcd_outdezAtt(16, 4*FH, value, LEFT); } #endif diff --git a/src/menus.cpp b/src/menus.cpp index 688217e48..63e2845a0 100644 --- a/src/menus.cpp +++ b/src/menus.cpp @@ -486,14 +486,15 @@ void displayBox() #ifdef NAVIGATION_RE1 int8_t *s_inflight_value = NULL; -int16_t s_inflight_min; -int16_t s_inflight_max; -int16_t s_inflight_shift; +int8_t s_inflight_min; +int8_t s_inflight_max; +int8_t s_inflight_shift; +uint8_t s_inflight_bitshift; const pm_char *s_inflight_label; -void checkInFlightIncDecModel(uint8_t event, int8_t *value, int16_t i_min, int16_t i_max, int8_t i_shift, const pm_char *label) +void checkInFlightIncDecModel(uint8_t event, int8_t *value, int8_t i_min, int8_t i_max, int8_t i_shift, const pm_char *label, uint8_t bitshift) { - *value = i_shift + checkIncDecModel(event, (*value)-i_shift, i_min, i_max); + *value = (((uint8_t)(*value)) & ((1 << bitshift) - 1)) + ((i_shift + checkIncDecModel(event, (((uint8_t)(*value)) >> bitshift)-i_shift, i_min, i_max)) << bitshift); if (event == EVT_KEY_LONG(BTN_RE1)) { if (value == s_inflight_value) { @@ -505,6 +506,7 @@ void checkInFlightIncDecModel(uint8_t event, int8_t *value, int16_t i_min, int16 s_inflight_max = i_max; s_inflight_shift = i_shift; s_inflight_label = label; + s_inflight_bitshift = bitshift; } } } diff --git a/src/menus.h b/src/menus.h index 3e7de8cb0..738894fc9 100644 --- a/src/menus.h +++ b/src/menus.h @@ -108,18 +108,25 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max); #ifdef NAVIGATION_RE1 extern int8_t *s_inflight_value; extern const pm_char *s_inflight_label; -extern int16_t s_inflight_min; -extern int16_t s_inflight_max; -extern int16_t s_inflight_shift; +extern int8_t s_inflight_min; +extern int8_t s_inflight_max; +extern int8_t s_inflight_shift; +extern uint8_t s_inflight_bitshift; +#define PREPARE_INFLIGHT_BITFIELD(a) int8_t *bitfield = (a) #define INFLIGHT(val) (s_inflight_value==&val ? SURROUNDED : 0) -void checkInFlightIncDecModel(uint8_t event, int8_t *value, int16_t i_min, int16_t i_max, int8_t i_shift, const pm_char *label); +void checkInFlightIncDecModel(uint8_t event, int8_t *value, int8_t i_min, int8_t i_max, int8_t i_shift, const pm_char *label, uint8_t bitshift=0); #define CHECK_INFLIGHT_INCDEC_MODELVAR(event, var, imin, imax, ishift, label) \ checkInFlightIncDecModel(event, &var, imin, imax, ishift, label) +#define CHECK_INFLIGHT_INCDEC_MODELVAR_BITFIELD(event, var, imin, imax, ishift, label, bitshift) \ + checkInFlightIncDecModel(event, bitfield, imin, imax, ishift, label, bitshift); void check_rotary_encoder(); #else +#define PREPARE_INFLIGHT_BITFIELD(a) #define INFLIGHT(val) 0 #define CHECK_INFLIGHT_INCDEC_MODELVAR(event, var, min, max, shift, label) \ var = shift+checkIncDecModel(event,var-(shift),min,max) +#define CHECK_INFLIGHT_INCDEC_MODELVAR_BITFIELD(event, var, min, max, shift, label, bitshift) \ + var = shift+checkIncDecModel(event,var-(shift),min,max) #endif // Menus related stuff ... diff --git a/src/model_menus.cpp b/src/model_menus.cpp index d0b22396f..27f2e1128 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -1103,19 +1103,21 @@ bool swapExpoMix(uint8_t expo, uint8_t &idx, uint8_t up) inline void editExpoVals(uint8_t event, uint8_t which, bool edit, uint8_t y, uint8_t idt) { uint8_t invBlk = edit ? INVERS : 0; - // if(edit && stopBlink) invBlk = INVERS; ExpoData *ed = expoaddress(idt); // TODO volatile switch(which) { case 0: - lcd_outdezAtt(9*FW+5, y, ed->weight, invBlk); - if(edit) CHECK_INCDEC_MODELVAR(event, ed->weight, 0, 100); + { + PREPARE_INFLIGHT_BITFIELD(&ed->expo - 1); + lcd_outdezAtt(9*FW+5, y, ed->weight, invBlk|INFLIGHT(*bitfield)); + if (edit) CHECK_INFLIGHT_INCDEC_MODELVAR_BITFIELD(event, ed->weight, 0, 100, 0, STR_DRWEIGHT, 1); + } break; case 1: - lcd_outdezAtt(9*FW+5, y, ed->expo, invBlk); - if(edit) CHECK_INCDEC_MODELVAR(event, ed->expo, -100, 100); + lcd_outdezAtt(9*FW+5, y, ed->expo, invBlk|INFLIGHT(ed->expo)); + if (edit) CHECK_INFLIGHT_INCDEC_MODELVAR(event, ed->expo, -100, 100, 0, STR_DREXPO); break; case 2: { @@ -1195,14 +1197,14 @@ void menuProcMixOne(uint8_t event) if(attr) CHECK_INCDEC_MODELVAR(event, md2->srcRaw, 1,NUM_XCHNRAW); break; case 1: - lcd_puts( 2*FW,y,STR_WEIGHT); - lcd_outdezAtt(FW*10,y,md2->weight,attr|LEFT); - if(attr) CHECK_INCDEC_MODELVAR(event, md2->weight, -125,125); + lcd_puts(2*FW, y, STR_WEIGHT); + lcd_outdezAtt(FW*10, y, md2->weight, attr|LEFT|INFLIGHT(md2->weight)); + if (attr) CHECK_INFLIGHT_INCDEC_MODELVAR(event, md2->weight, -125, 125, 0, STR_MIXERWEIGHT); break; case 2: - lcd_puts( 2*FW,y,STR_OFFSET); - lcd_outdezAtt(FW*10,y,md2->sOffset,attr|LEFT); - if(attr) CHECK_INCDEC_MODELVAR( event, md2->sOffset, -125,125); + lcd_puts(2*FW, y, STR_OFFSET); + lcd_outdezAtt(FW*10, y, md2->sOffset, attr|LEFT|INFLIGHT(md2->sOffset)); + if (attr) CHECK_INFLIGHT_INCDEC_MODELVAR(event, md2->sOffset, -125, 125, 0, STR_MIXEROFFSET); break; case 3: // TODO hidden when src is not a STICK as it has no sense @@ -1346,7 +1348,7 @@ void menuProcExpoMix(uint8_t expo, uint8_t _event_) event -= KEY_EXIT; } - TITLEP(expo ? STR_DREXPO : STR_MIXER); + TITLEP(expo ? STR_MENUDREXPO : STR_MIXER); lcd_outdezAtt(lcd_lastPos+2*FW+FW/2, 0, getExpoMixCount(expo)); lcd_puts(lcd_lastPos, 0, expo ? PSTR("/14") : PSTR("/32")); SIMPLE_MENU_NOTITLE(menuTabModel, expo ? e_ExposAll : e_MixAll, s_maxLines); diff --git a/src/o9xstrings.cpp b/src/o9xstrings.cpp index d72714b4d..bcd1e2ac5 100644 --- a/src/o9xstrings.cpp +++ b/src/o9xstrings.cpp @@ -134,7 +134,6 @@ const pm_char STR_DELAYDOWN[] PROGMEM = TR_DELAYDOWN; const pm_char STR_DELAYUP[] PROGMEM = TR_DELAYUP; const pm_char STR_SLOWDOWN[] PROGMEM = TR_SLOWDOWN; const pm_char STR_SLOWUP[] PROGMEM = TR_SLOWUP; -const pm_char STR_DREXPO[] PROGMEM = TR_DREXPO; const pm_char STR_MIXER[] PROGMEM = TR_MIXER; const pm_char STR_COPYTRIMMENU[] PROGMEM = TR_COPYTRIMMENU; const pm_char STR_CV[] PROGMEM = TR_CV; @@ -273,6 +272,10 @@ const pm_char STR_SYNCMENU[] PROGMEM = TR_SYNCMENU; #if defined(NAVIGATION_RE1) const pm_char STR_BACK[] PROGMEM = TR_BACK; +const pm_char STR_MIXERWEIGHT[] PROGMEM = TR_MIXERWEIGHT; +const pm_char STR_MIXEROFFSET[] PROGMEM = TR_MIXEROFFSET; +const pm_char STR_DRWEIGHT[] PROGMEM = TR_DRWEIGHT; +const pm_char STR_DREXPO[] PROGMEM = TR_DREXPO; const pm_char STR_MINLIMIT[] PROGMEM = TR_MINLIMIT; const pm_char STR_MAXLIMIT[] PROGMEM = TR_MAXLIMIT; #endif diff --git a/src/o9xstrings.h b/src/o9xstrings.h index cb49ece85..8d410cfdd 100644 --- a/src/o9xstrings.h +++ b/src/o9xstrings.h @@ -216,7 +216,6 @@ extern const pm_char STR_DELAYDOWN[]; extern const pm_char STR_DELAYUP[]; extern const pm_char STR_SLOWDOWN[]; extern const pm_char STR_SLOWUP[]; -extern const pm_char STR_DREXPO[]; extern const pm_char STR_MIXER[]; extern const pm_char STR_COPYTRIMMENU[]; extern const pm_char STR_CV[]; @@ -325,8 +324,15 @@ extern const pm_char STR_MENUSTAT[]; extern const pm_char STR_MENUDEBUG[]; extern const pm_char STR_RXNUM[]; extern const pm_char STR_SYNCMENU[]; +#endif + +#ifdef NAVIGATION_RE1 extern const pm_char STR_BACK[]; #define LEN_BACK PSIZE(TR_BACK) +extern const pm_char STR_MIXERWEIGHT[]; +extern const pm_char STR_MIXEROFFSET[]; +extern const pm_char STR_DRWEIGHT[]; +extern const pm_char STR_DREXPO[]; extern const pm_char STR_MINLIMIT[]; extern const pm_char STR_MAXLIMIT[]; #endif diff --git a/src/open9x.cpp b/src/open9x.cpp index 5f3ee1a90..960b0cf77 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -2288,19 +2288,19 @@ int main(void) EIMSK = (3<