mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 01:35:21 +03:00
Telemetry refactoring continued
This commit is contained in:
parent
40783acc36
commit
bfbee05b25
28 changed files with 346 additions and 358 deletions
|
@ -577,15 +577,7 @@ uint8_t getRotaryEncoderFlightPhase(uint8_t idx)
|
|||
uint8_t phase = s_current_mixer_flight_mode;
|
||||
for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) {
|
||||
if (phase == 0) return 0;
|
||||
#if ROTARY_ENCODERS > 2
|
||||
int16_t value;
|
||||
if(idx<(NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA))
|
||||
value = phaseAddress(phase)->rotaryEncoders[idx];
|
||||
else
|
||||
value = g_model.rotaryEncodersExtra[phase][idx-(NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)];
|
||||
#else
|
||||
int16_t value = phaseAddress(phase)->rotaryEncoders[idx];
|
||||
#endif
|
||||
if (value <= ROTARY_ENCODER_MAX) return phase;
|
||||
uint8_t result = value-ROTARY_ENCODER_MAX-1;
|
||||
if (result >= phase) result++;
|
||||
|
@ -596,25 +588,13 @@ uint8_t getRotaryEncoderFlightPhase(uint8_t idx)
|
|||
|
||||
int16_t getRotaryEncoder(uint8_t idx)
|
||||
{
|
||||
#if ROTARY_ENCODERS > 2
|
||||
if(idx >= (NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA))
|
||||
return g_model.rotaryEncodersExtra[getRotaryEncoderFlightPhase(idx)][idx-(NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)];
|
||||
#endif
|
||||
return phaseAddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx];
|
||||
}
|
||||
|
||||
void incRotaryEncoder(uint8_t idx, int8_t inc)
|
||||
{
|
||||
g_rotenc[idx] += inc;
|
||||
#if ROTARY_ENCODERS > 2
|
||||
int16_t *value;
|
||||
if (idx < (NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA))
|
||||
value = &(phaseAddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]);
|
||||
else
|
||||
value = &(g_model.rotaryEncodersExtra[getRotaryEncoderFlightPhase(idx)][idx-(NUM_ROTARY_ENCODERS - NUM_ROTARY_ENCODERS_EXTRA)]);
|
||||
#else
|
||||
int16_t *value = &(phaseAddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]);
|
||||
#endif
|
||||
*value = limit((int16_t)-1024, (int16_t)(*value + (inc * 8)), (int16_t)+1024);
|
||||
eeDirty(EE_MODEL);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue