[MERGED] bring in advantages from branch to trunk; Performance optimizations

This combines now the changes from branch PerformanceOptimizations to trunk
Mainly this change should do following:
- Flash savings should be around 224 bytes for stock
- Added option ARITHMETIC_OVERFLOW_CHECK to prevent overflows.
  Still not bulletproof, but codecost is about 50 bytes
- Increases mix speed about 25 - 30% depending on task for stock
  Also increased for other boards, but they may not notice...
- Increased ranges for weight and offset from +-125% to +-245%
- Easier now to increase number of GVARS if needed; Just increase GVAR_MAX in myeeprom.h.
  But!!!! EEPROM layout changes and may not be compatible. Do this for own proposes.
  Till now we do not know how we handle this in future.
- Corrected Timer for stock if used together with AUDIO or VOICE option
- See comments below, what I potentially forgotten...

Be aware this version is currently not compatible to companion9x. But the version before wasn't either. Work is current in progress to tie this up.
This commit is contained in:
open.20.fsguruh@xoxy.net
2013-03-10 19:51:19 +00:00
7 changed files with 642 additions and 219 deletions
+26 -11
View File
@@ -695,39 +695,54 @@ 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, int8_t min, int8_t max, LcdFlags attr, uint8_t event)
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) CHECK_INCDEC_MODELVAR(event, value, min, max);
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, int8_t min, int8_t max, LcdFlags attr, uint8_t event)
int8_t gvarMenuItem(uint8_t x, uint8_t y, int8_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event)
{
lcd_outdezAtt(x, y, value, attr);
if (attr&INVERS) CHECK_INCDEC_MODELVAR(event, value, min, max);
if (attr&INVERS) value = checkIncDec(event, value, min, max,EE_MODEL);
return value;
}
#endif