1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

New type swsrc_t introduced

This commit is contained in:
Bertrand Songis 2015-08-28 14:44:09 +02:00
parent 3920cc6919
commit ef56bf3cb4
8 changed files with 16 additions and 14 deletions

View file

@ -727,7 +727,7 @@ void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att)
} }
} }
void putsSwitches(coord_t x, coord_t y, int8_t idx, LcdFlags att) void putsSwitches(coord_t x, coord_t y, swsrc_t idx, LcdFlags att)
{ {
if (idx == SWSRC_OFF) if (idx == SWSRC_OFF)
return lcd_putsiAtt(x, y, STR_OFFON, 0, att); return lcd_putsiAtt(x, y, STR_OFFON, 0, att);
@ -803,7 +803,7 @@ void putsCurve(coord_t x, coord_t y, int8_t idx, LcdFlags att)
putsStrIdx(x, y, STR_CV, idx, att); putsStrIdx(x, y, STR_CV, idx, att);
} }
void putsTimerMode(coord_t x, coord_t y, int8_t mode, LcdFlags att) void putsTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att)
{ {
if (mode >= 0) { if (mode >= 0) {
if (mode < TMRMODE_COUNT) if (mode < TMRMODE_COUNT)

View file

@ -167,7 +167,7 @@ void lcd_outdez8(coord_t x, coord_t y, int8_t val);
void putsStrIdx(coord_t x, coord_t y, const pm_char *str, uint8_t idx, LcdFlags att=0); void putsStrIdx(coord_t x, coord_t y, const pm_char *str, uint8_t idx, LcdFlags att=0);
void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att); void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att);
void putsSwitches(coord_t x, coord_t y, int8_t swtch, LcdFlags att=0); void putsSwitches(coord_t x, coord_t y, swsrc_t swtch, LcdFlags att=0);
void putsStickName(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0); void putsStickName(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
void putsMixerSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att=0); void putsMixerSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att=0);
void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att=0); void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
@ -175,7 +175,7 @@ void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
void putsCurveRef(coord_t x, coord_t y, CurveRef &curve, LcdFlags att); void putsCurveRef(coord_t x, coord_t y, CurveRef &curve, LcdFlags att);
#endif #endif
void putsCurve(coord_t x, coord_t y, int8_t idx, LcdFlags att=0); void putsCurve(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
void putsTimerMode(coord_t x, coord_t y, int8_t mode, LcdFlags att=0); void putsTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att=0);
void putsTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att); void putsTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att);
#define putsChn(x, y, idx, att) putsMixerSource(x, y, MIXSRC_CH1+idx-1, att) #define putsChn(x, y, idx, att) putsMixerSource(x, y, MIXSRC_CH1+idx-1, att)

View file

@ -142,15 +142,15 @@ void editTimerMode(int timerIdx, coord_t y, LcdFlags attr, uint8_t event)
switch (m_posHorz) { switch (m_posHorz) {
case 0: case 0:
{ {
int8_t timerMode = timer->mode; swsrc_t timerMode = timer->mode;
if (timerMode < 0) timerMode -= TMRMODE_COUNT-1; if (timerMode < 0) timerMode -= TMRMODE_COUNT-1;
CHECK_INCDEC_MODELVAR_CHECK(event, timerMode, -TMRMODE_COUNT-SWSRC_LAST+1, TMRMODE_COUNT+SWSRC_LAST-1, isSwitchAvailableInTimers); CHECK_INCDEC_MODELVAR_CHECK(event, timerMode, -TMRMODE_COUNT-SWSRC_LAST+1, TMRMODE_COUNT+SWSRC_LAST-1, isSwitchAvailableInTimers);
if (timerMode < 0) timerMode += TMRMODE_COUNT-1; if (timerMode < 0) timerMode += TMRMODE_COUNT-1;
timer->mode = timerMode; timer->mode = timerMode;
#if defined(AUTOSWITCH) #if defined(AUTOSWITCH)
if (s_editMode>0) { if (s_editMode>0) {
int8_t val = timer->mode - (TMRMODE_COUNT-1); swsrc_t val = timer->mode - (TMRMODE_COUNT-1);
int8_t switchVal = checkIncDecMovedSwitch(val); swsrc_t switchVal = checkIncDecMovedSwitch(val);
if (val != switchVal) { if (val != switchVal) {
timer->mode = switchVal + (TMRMODE_COUNT-1); timer->mode = switchVal + (TMRMODE_COUNT-1);
eeDirty(EE_MODEL); eeDirty(EE_MODEL);

View file

@ -176,7 +176,7 @@ extern const CheckIncDecStops &stopsSwitch;
(val), (val+1) (val), (val+1)
int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int i_flags=0, IsValueAvailable isValueAvailable=NULL, const CheckIncDecStops &stops=stops100); int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int i_flags=0, IsValueAvailable isValueAvailable=NULL, const CheckIncDecStops &stops=stops100);
int8_t checkIncDecMovedSwitch(int8_t val); swsrc_t checkIncDecMovedSwitch(swsrc_t val);
#define checkIncDecModel(event, i_val, i_min, i_max) checkIncDec(event, i_val, i_min, i_max, EE_MODEL) #define checkIncDecModel(event, i_val, i_min, i_max) checkIncDec(event, i_val, i_min, i_max, EE_MODEL)
#define checkIncDecModelZero(event, i_val, i_max) checkIncDec(event, i_val, 0, i_max, EE_MODEL) #define checkIncDecModelZero(event, i_val, i_max) checkIncDec(event, i_val, 0, i_max, EE_MODEL)
#define checkIncDecGen(event, i_val, i_min, i_max) checkIncDec(event, i_val, i_min, i_max, EE_GENERAL) #define checkIncDecGen(event, i_val, i_min, i_max) checkIncDec(event, i_val, i_min, i_max, EE_GENERAL)

View file

@ -45,10 +45,10 @@ uint8_t calibrationState;
int checkIncDecSelection = 0; int checkIncDecSelection = 0;
#if defined(AUTOSWITCH) #if defined(AUTOSWITCH)
int8_t checkIncDecMovedSwitch(int8_t val) swsrc_t checkIncDecMovedSwitch(swsrc_t val)
{ {
if (s_editMode>0) { if (s_editMode>0) {
int8_t swtch = getMovedSwitch(); swsrc_t swtch = getMovedSwitch();
if (swtch) { if (swtch) {
div_t info = switchInfo(swtch); div_t info = switchInfo(swtch);
if (IS_TOGGLE(info.quot)) { if (IS_TOGGLE(info.quot)) {

View file

@ -116,7 +116,7 @@
#define MAX_FLIGHT_MODES 9 #define MAX_FLIGHT_MODES 9
#define MAX_MIXERS 64 #define MAX_MIXERS 64
#define MAX_EXPOS 64 #define MAX_EXPOS 64
#define NUM_LOGICAL_SWITCH 32 // number of custom switches #define NUM_LOGICAL_SWITCH 32 // number of logical switches
#define NUM_CFN 64 // number of functions assigned to switches #define NUM_CFN 64 // number of functions assigned to switches
#define MAX_SCRIPTS 7 #define MAX_SCRIPTS 7
#define MAX_INPUTS 32 #define MAX_INPUTS 32

View file

@ -416,6 +416,7 @@
typedef int32_t rotenc_t; typedef int32_t rotenc_t;
typedef int32_t getvalue_t; typedef int32_t getvalue_t;
typedef uint32_t mixsrc_t; typedef uint32_t mixsrc_t;
typedef int8_t swsrc_t;
#else #else
#define tmr10ms_t uint16_t #define tmr10ms_t uint16_t
extern volatile tmr10ms_t g_tmr10ms; extern volatile tmr10ms_t g_tmr10ms;
@ -430,6 +431,7 @@
typedef int8_t rotenc_t; typedef int8_t rotenc_t;
typedef int16_t getvalue_t; typedef int16_t getvalue_t;
typedef uint8_t mixsrc_t; typedef uint8_t mixsrc_t;
typedef int8_t swsrc_t;
#endif #endif
#if defined(NAVIGATION_STICKS) #if defined(NAVIGATION_STICKS)
@ -766,7 +768,7 @@ void logicalSwitchesReset();
#endif #endif
extern swarnstate_t switches_states; extern swarnstate_t switches_states;
int8_t getMovedSwitch(); swsrc_t getMovedSwitch();
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
#define GET_MOVED_SOURCE_PARAMS uint8_t min #define GET_MOVED_SOURCE_PARAMS uint8_t min

View file

@ -552,10 +552,10 @@ void evalLogicalSwitches(bool isCurrentPhase)
#endif #endif
swarnstate_t switches_states = 0; swarnstate_t switches_states = 0;
int8_t getMovedSwitch() swsrc_t getMovedSwitch()
{ {
static tmr10ms_t s_move_last_time = 0; static tmr10ms_t s_move_last_time = 0;
int8_t result = 0; swsrc_t result = 0;
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
for (int i=0; i<NUM_SWITCHES; i++) { for (int i=0; i<NUM_SWITCHES; i++) {