mirror of
https://github.com/opentx/opentx.git
synced 2025-07-12 19:10:19 +03:00
Add trims autoswitch
This commit is contained in:
parent
a933903e6b
commit
3479b5eb8d
2 changed files with 16 additions and 0 deletions
|
@ -502,6 +502,11 @@ PACK(struct ModelHeader {
|
|||
MODEL_HEADER_BITMAP_FIELD
|
||||
});
|
||||
|
||||
#if NUM_TRIMS_KEYS <= 8
|
||||
typedef uint8_t trimstate_t;
|
||||
#else
|
||||
typedef uint16_t trimstate_t;
|
||||
#endif
|
||||
#if defined(COLORLCD)
|
||||
typedef uint32_t swconfig_t;
|
||||
typedef uint32_t swarnstate_t;
|
||||
|
|
|
@ -514,6 +514,7 @@ void evalLogicalSwitches(bool isCurrentFlightmode)
|
|||
}
|
||||
|
||||
swarnstate_t switches_states = 0;
|
||||
trimstate_t trims_states = 0;
|
||||
swsrc_t getMovedSwitch()
|
||||
{
|
||||
static tmr10ms_t s_move_last_time = 0;
|
||||
|
@ -532,6 +533,16 @@ swsrc_t getMovedSwitch()
|
|||
}
|
||||
}
|
||||
}
|
||||
// Trim switches
|
||||
for (int i = 0; i < NUM_TRIMS_KEYS; i++) {
|
||||
trimstate_t mask = ((trimstate_t) 0x01 << i);
|
||||
uint8_t prev = (trims_states & mask) >> i;
|
||||
uint8_t next = getSwitch(SWSRC_FIRST_TRIM + i);
|
||||
if (prev != next) {
|
||||
trims_states = (trims_states & (~mask)) | ((trimstate_t) next << i);
|
||||
result = SWSRC_FIRST_TRIM + i;
|
||||
}
|
||||
}
|
||||
// Multipos
|
||||
for (int i = 0; i < NUM_XPOTS; i++) {
|
||||
if (IS_POT_MULTIPOS(POT1 + i)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue