Rotary encoder refactoring
This commit is contained in:
+3
-54
@@ -496,15 +496,6 @@ void modelDefault(uint8_t id)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FLIGHT_MODES) && defined(ROTARY_ENCODERS)
|
||||
for (int p=1; p<MAX_FLIGHT_MODES; p++) {
|
||||
for (int i=0; i<ROTARY_ENCODERS; i++) {
|
||||
g_model.flightModeData[p].rotaryEncoders[i] = ROTARY_ENCODER_MAX+1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(EEPROM)
|
||||
strcpy(g_model.header.name, "\015\361\374\373\364");
|
||||
g_model.header.name[5] = '\033' + id/10;
|
||||
@@ -648,36 +639,6 @@ bool setTrimValue(uint8_t phase, uint8_t idx, int trim)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#if defined(ROTARY_ENCODERS)
|
||||
uint8_t getRotaryEncoderFlightMode(uint8_t idx)
|
||||
{
|
||||
uint8_t phase = mixerCurrentFlightMode;
|
||||
for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) {
|
||||
if (phase == 0) return 0;
|
||||
int16_t value = flightModeAddress(phase)->rotaryEncoders[idx];
|
||||
if (value <= ROTARY_ENCODER_MAX) return phase;
|
||||
uint8_t result = value-ROTARY_ENCODER_MAX-1;
|
||||
if (result >= phase) result++;
|
||||
phase = result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16_t getRotaryEncoder(uint8_t idx)
|
||||
{
|
||||
return flightModeAddress(getRotaryEncoderFlightMode(idx))->rotaryEncoders[idx];
|
||||
}
|
||||
|
||||
void incRotaryEncoder(uint8_t idx, int8_t inc)
|
||||
{
|
||||
rotencValue[idx] += inc;
|
||||
int16_t *value = &(flightModeAddress(getRotaryEncoderFlightMode(idx))->rotaryEncoders[idx]);
|
||||
*value = limit((int16_t)-RESX, (int16_t)(*value + (inc * 8)), (int16_t)+RESX);
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
#endif
|
||||
|
||||
getvalue_t convert16bitsTelemValue(source_t channel, ls_telemetry_value_t value)
|
||||
{
|
||||
return value;
|
||||
@@ -1366,10 +1327,6 @@ void evalTrims()
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t mSwitchDuration[1+NUM_ROTARY_ENCODERS] = { 0 };
|
||||
#define CFN_PRESSLONG_DURATION 100
|
||||
|
||||
|
||||
uint8_t s_mixer_first_run_done = false;
|
||||
|
||||
void doMixerCalculations()
|
||||
@@ -1766,20 +1723,12 @@ void moveTrimsToOffsets() // copy state of 3 primary to subtrim
|
||||
AUDIO_WARNING2();
|
||||
}
|
||||
|
||||
#if defined(ROTARY_ENCODERS)
|
||||
volatile rotenc_t rotencValue[ROTARY_ENCODERS] = {0};
|
||||
#elif defined(ROTARY_ENCODER_NAVIGATION)
|
||||
volatile rotenc_t rotencValue[1] = {0};
|
||||
#endif
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
uint8_t rotencSpeed;
|
||||
volatile rotenc_t rotencValue = 0;
|
||||
uint8_t rotencSpeed;
|
||||
#endif
|
||||
|
||||
|
||||
#define OPENTX_INIT_ARGS
|
||||
|
||||
void opentxInit(OPENTX_INIT_ARGS)
|
||||
void opentxInit()
|
||||
{
|
||||
TRACE("opentxInit");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user