mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 00:35:18 +03:00
Fixes #3770
This commit is contained in:
parent
4d44eb97f5
commit
d44f98d677
9 changed files with 260 additions and 225 deletions
|
@ -718,9 +718,9 @@ swsrc_t getMovedSwitch();
|
|||
#endif
|
||||
|
||||
#if !defined(CPUARM)
|
||||
uint8_t getTrimFlightPhase(uint8_t phase, uint8_t idx);
|
||||
uint8_t getTrimFlightMode(uint8_t phase, uint8_t idx);
|
||||
#else
|
||||
#define getTrimFlightPhase(phase, idx) (phase)
|
||||
#define getTrimFlightMode(phase, idx) (phase)
|
||||
#endif
|
||||
|
||||
#if defined(GVARS)
|
||||
|
@ -752,65 +752,7 @@ int getTrimValue(uint8_t phase, uint8_t idx);
|
|||
#define ROTARY_ENCODER_GRANULARITY (2)
|
||||
#endif
|
||||
|
||||
#if defined(GVARS)
|
||||
#if defined(PCBSTD)
|
||||
int16_t getGVarFieldValue(int16_t x, int16_t min, int16_t max);
|
||||
void setGVarValue(uint8_t x, int8_t value);
|
||||
#define GET_GVAR(x, min, max, fm) getGVarFieldValue(x, min, max)
|
||||
#define SET_GVAR(idx, val, fm) setGVarValue(idx, val)
|
||||
#else
|
||||
uint8_t getGVarFlightMode(uint8_t fm, uint8_t gv);
|
||||
int16_t getGVarFieldValue(int16_t x, int16_t min, int16_t max, int8_t fm);
|
||||
int32_t getGVarFieldValuePrec1(int16_t x, int16_t min, int16_t max, int8_t fm);
|
||||
int16_t getGVarValue(int8_t gv, int8_t fm);
|
||||
int32_t getGVarValuePrec1(int8_t gv, int8_t fm);
|
||||
void setGVarValue(uint8_t x, int16_t value, int8_t fm);
|
||||
#define GET_GVAR(x, min, max, fm) getGVarFieldValue(x, min, max, fm)
|
||||
#define SET_GVAR(idx, val, fm) setGVarValue(idx, val, fm)
|
||||
#define GVAR_DISPLAY_TIME 100 /*1 second*/;
|
||||
#define GET_GVAR_PREC1(x, min, max, fm) getGVarFieldValuePrec1(x, min, max, fm)
|
||||
extern uint8_t gvarDisplayTimer;
|
||||
extern uint8_t gvarLastChanged;
|
||||
#endif
|
||||
#else
|
||||
#define GET_GVAR(x, ...) (x)
|
||||
#define GET_GVAR_PREC1(x, ...) (x*10)
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define GV_GET_GV1_VALUE(max) ( (max<=GV_RANGESMALL && min>=GV_RANGESMALL_NEG) ? GV1_SMALL : GV1_LARGE )
|
||||
#define GV_INDEX_CALCULATION(x,max) ( (max<=GV_RANGESMALL && min>=GV_RANGESMALL_NEG) ? (uint8_t) x-GV1_SMALL : ((x&(GV1_LARGE*2-1))-GV1_LARGE) )
|
||||
#define GV_IS_GV_VALUE(x,min,max) ( (max>GV1_SMALL || min<-GV1_SMALL) ? (x>GV_RANGELARGE || x<GV_RANGELARGE_NEG) : (x>max) || (x<min) )
|
||||
#else
|
||||
#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_IS_GV_VALUE(x,min,max) ( (x>max) || (x<min) )
|
||||
#endif
|
||||
|
||||
#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 GV_RANGESMALL (GV1_SMALL - (RESERVE_RANGE_FOR_GVARS+1))
|
||||
#define GV_RANGESMALL_NEG (-GV1_SMALL + (RESERVE_RANGE_FOR_GVARS+1))
|
||||
#define GV_RANGELARGE (GV1_LARGE - (RESERVE_RANGE_FOR_GVARS+1))
|
||||
#define GV_RANGELARGE_NEG (-GV1_LARGE + (RESERVE_RANGE_FOR_GVARS+1))
|
||||
#if defined(CPUARM)
|
||||
// the define GV1_LARGE marks the highest bit value used for this variables
|
||||
// because this would give too big numbers for ARM, we limit it further for
|
||||
// offset and weight
|
||||
#define GV_RANGELARGE_WEIGHT (GV_RANGE_WEIGHT)
|
||||
#define GV_RANGELARGE_WEIGHT_NEG (-GV_RANGE_WEIGHT)
|
||||
#define GV_RANGELARGE_OFFSET (GV_RANGE_OFFSET)
|
||||
#define GV_RANGELARGE_OFFSET_NEG (-GV_RANGE_OFFSET)
|
||||
#else
|
||||
// for stock we just use as much as possible
|
||||
#define GV_RANGELARGE_WEIGHT GV_RANGELARGE
|
||||
#define GV_RANGELARGE_WEIGHT_NEG GV_RANGELARGE_NEG
|
||||
#define GV_RANGELARGE_OFFSET GV_RANGELARGE
|
||||
#define GV_RANGELARGE_OFFSET_NEG GV_RANGELARGE_NEG
|
||||
#endif
|
||||
#include "gvars.h"
|
||||
|
||||
extern uint16_t sessionTimer;
|
||||
extern uint16_t s_timeCumThr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue