[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:
+31
-3
@@ -812,21 +812,49 @@ void incRotaryEncoder(uint8_t idx, int8_t inc);
|
||||
void setGVarValue(uint8_t x, int8_t value);
|
||||
#define GET_GVAR(x, min, max, p) getGVarValue(x, min, max)
|
||||
#define SET_GVAR(idx, val, p) setGVarValue(idx, val)
|
||||
#define GV1_SMALL 128
|
||||
#define GV1_LARGE 256
|
||||
#else
|
||||
uint8_t getGVarFlightPhase(uint8_t phase, uint8_t idx);
|
||||
int16_t getGVarValue(int16_t x, int16_t min, int16_t max, int8_t phase);
|
||||
void setGVarValue(uint8_t x, int8_t value, int8_t phase);
|
||||
#define GET_GVAR(x, min, max, p) getGVarValue(x, min, max, p)
|
||||
#define SET_GVAR(idx, val, p) setGVarValue(idx, val, p)
|
||||
// @@@ open.20.fsguruh may have different recalculation formula in future to allow higher ranges?
|
||||
#define GV1_SMALL 128
|
||||
#define GV1_LARGE 256
|
||||
#endif
|
||||
#define GV1_SMALL 123
|
||||
// @@@ open.20.fsguruh
|
||||
#define GV1_LARGE 251
|
||||
|
||||
// depends if we want free ranges for use, if no MAX_GVARS are smaller
|
||||
// if not this would assume a max for GVARS instead using MAX_GVARS
|
||||
#define GV_RANGESMALL (GV1_SMALL - (MAX_GVARS+1))
|
||||
#define GV_RANGESMALL_NEG (-GV1_SMALL + (MAX_GVARS+1))
|
||||
#define GV_RANGELARGE (GV1_LARGE - (MAX_GVARS+1))
|
||||
#define GV_RANGELARGE_NEG (-GV1_LARGE + (MAX_GVARS+1))
|
||||
|
||||
#define GV_IS_GV_VALUE(x,min,max) ( (x>max) || (x<min) )
|
||||
#define GV_GET_GV1_VALUE(max) ( (max<=GV_RANGESMALL) ? GV1_SMALL : GV1_LARGE )
|
||||
#define GV_INDEX_CALCULATION(x,max) ( (max <= GV1_SMALL) ? (uint8_t) x-GV1_SMALL : \
|
||||
( (x&(GV1_LARGE*2-1))-GV1_LARGE ) )
|
||||
#define GV_INDEX_CALC_DELTA(x,delta) ((x&(delta*2-1)) - delta)
|
||||
|
||||
#define GV_CALC_VALUE_IDX_POS(idx,delta) (-delta+idx)
|
||||
#define GV_CALC_VALUE_IDX_NEG(idx,delta) (delta+idx)
|
||||
|
||||
#define GVAR_DISPLAY_TIME 100 /*1 second*/;
|
||||
extern uint8_t s_gvar_timer;
|
||||
extern uint8_t s_gvar_last;
|
||||
#else
|
||||
#define GET_GVAR(x, ...) (x)
|
||||
|
||||
// can be used also without GVARS for allowed parameter ranges (makes -500 +500 range for weight unneccessary)
|
||||
// do we want to allow wider ranges without GVARS? Would cause a conversion problem later on, a lot of options needs to be check to do it right
|
||||
#define GV1_SMALL 128
|
||||
#define GV1_LARGE 256
|
||||
#define GV_RANGESMALL (GV1_SMALL-1)
|
||||
#define GV_RANGESMALL_NEG (-GV1_SMALL+1)
|
||||
#define GV_RANGELARGE (GV1_LARGE-1)
|
||||
#define GV_RANGELARGE_NEG (-GV1_LARGE+1)
|
||||
#endif
|
||||
|
||||
extern uint16_t s_timeCumTot;
|
||||
|
||||
Reference in New Issue
Block a user