[BRANCH] Created possibility to increase GVARS number; is set to 9

Warning!!!
==========
Be aware this version is in branch and is not supported currently by Companion9x. Whatever you configure will be lost in final version!

Because EEPROM interpretation changes anyway because of higher offset and weight values possible in this branch, I tried to align the bits a little bit different to allow a higher number of GVARS. The code change is nearly flash neutral. It costs only 18 bytes flash, but would us allow to either increase range for weight and offset further, or allow more GVARS.
I set it to 9 for this branch now. Please try and report.
It's very easy now to adjust the GVARS number by changing the constant in myeeprom.h. Just change the MAX_GVARS constant for your build in myeeprom.h in the beginning of the file.
The lower MAX_GVARS the higher is the possible number for weight and offset and vice versa.
That is quite likely too complicated for conversion so we need to agree maximum for GVARS.
Not sure in the moment, but this is a branch only and is just to play with it.
Not sure how Bertrand would like this anyway, so may be removed at all.
This commit is contained in:
open.20.fsguruh@xoxy.net
2013-03-03 13:57:30 +00:00
parent 214bc9c4d4
commit 9f2b486152
5 changed files with 106 additions and 61 deletions
+24 -9
View File
@@ -677,34 +677,49 @@ int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t
}
#if defined(GVARS)
int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event) // @@@ open.20.fsguruh
int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event)
{
uint8_t delta = (max <= 100 ? GV1_SMALL-1 : GV1_LARGE-1);
uint16_t delta = GV_GET_GV1_VALUE(max);
bool invers = (attr & INVERS);
if (invers && event == EVT_KEY_LONG(KEY_ENTER)) {
s_editMode = !s_editMode;
value = (value > max ? GET_GVAR(value, min, max, s_perout_flight_phase) : delta+1);
value = ( GV_IS_GV_VALUE(value,min,max) ? GET_GVAR(value, min, max, s_perout_flight_phase) : delta);
eeDirty(EE_MODEL);
}
if (value > max) {
if ( GV_IS_GV_VALUE(value,min,max) ) {
if (attr & LEFT)
attr -= LEFT; /* because of ZCHAR */
else
x -= 2*FW+FWNUM;
int8_t idx = value - delta;
int8_t idx = (int16_t) GV_INDEX_CALC_DELTA(value,delta);
if (invers) {
CHECK_INCDEC_MODELVAR(event, idx, -4, +5);
value = (int16_t)idx + delta;
CHECK_INCDEC_MODELVAR(event, idx, -MAX_GVARS, MAX_GVARS-1);
}
if (idx <= 0) { idx = 1-idx; lcd_putcAtt(x-6, y, '-', attr); }
/* sometimes this implementation was smaller, but sometimes not....
value=delta+(int16_t) idx;
if (idx < 0) {idx = -1-idx; lcd_putcAtt(x-6, y, '-', attr); }
else value|=~(delta-1);
idx++; */
if (idx < 0) {
value=(int16_t) GV_CALC_VALUE_IDX_NEG(idx,delta); idx=-idx; lcd_putcAtt(x-6, y, '-', attr);
} else {
value = (int16_t) GV_CALC_VALUE_IDX_POS(idx,delta); idx++;
}
putsStrIdx(x, y, STR_GV, idx, attr);
}
else {
lcd_outdezAtt(x, y, value, attr);
if (invers) value = checkIncDec(event, value, min, max,EE_MODEL); // as proposed, no change to makro, but directly call this function
if (invers) value = checkIncDec(event, value, min, max,EE_MODEL);
}
return value;
}
#else
int8_t gvarMenuItem(uint8_t x, uint8_t y, int8_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event)
{