mirror of
https://github.com/opentx/opentx.git
synced 2025-07-13 11:29:51 +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
|
MODEL_HEADER_BITMAP_FIELD
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#if NUM_TRIMS_KEYS <= 8
|
||||||
|
typedef uint8_t trimstate_t;
|
||||||
|
#else
|
||||||
|
typedef uint16_t trimstate_t;
|
||||||
|
#endif
|
||||||
#if defined(COLORLCD)
|
#if defined(COLORLCD)
|
||||||
typedef uint32_t swconfig_t;
|
typedef uint32_t swconfig_t;
|
||||||
typedef uint32_t swarnstate_t;
|
typedef uint32_t swarnstate_t;
|
||||||
|
|
|
@ -514,6 +514,7 @@ void evalLogicalSwitches(bool isCurrentFlightmode)
|
||||||
}
|
}
|
||||||
|
|
||||||
swarnstate_t switches_states = 0;
|
swarnstate_t switches_states = 0;
|
||||||
|
trimstate_t trims_states = 0;
|
||||||
swsrc_t getMovedSwitch()
|
swsrc_t getMovedSwitch()
|
||||||
{
|
{
|
||||||
static tmr10ms_t s_move_last_time = 0;
|
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
|
// Multipos
|
||||||
for (int i = 0; i < NUM_XPOTS; i++) {
|
for (int i = 0; i < NUM_XPOTS; i++) {
|
||||||
if (IS_POT_MULTIPOS(POT1 + i)) {
|
if (IS_POT_MULTIPOS(POT1 + i)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue