mirror of
https://github.com/opentx/opentx.git
synced 2025-07-19 14:25:11 +03:00
Issue #592 - All boards will have this feature available, it costs only
50bytes on stock board (I saved more in this same branch)
This commit is contained in:
parent
4a20329b2b
commit
cae4d1ecf6
10 changed files with 67 additions and 67 deletions
|
@ -199,7 +199,7 @@ int ConvertSwitch_215_to_216(int swtch)
|
||||||
if (swtch <= SWSRC_LAST_SWITCH)
|
if (swtch <= SWSRC_LAST_SWITCH)
|
||||||
return swtch;
|
return swtch;
|
||||||
else
|
else
|
||||||
return swtch + 4 + (2*6); // 4 trims and 2 * 6-pos added as switches
|
return swtch + (2*4) + (2*6); // 4 trims and 2 * 6-pos added as switches
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
inline int ConvertSwitch_215_to_216(int swtch)
|
inline int ConvertSwitch_215_to_216(int swtch)
|
||||||
|
@ -207,7 +207,7 @@ inline int ConvertSwitch_215_to_216(int swtch)
|
||||||
if (swtch <= SWSRC_LAST_SWITCH)
|
if (swtch <= SWSRC_LAST_SWITCH)
|
||||||
return swtch;
|
return swtch;
|
||||||
else
|
else
|
||||||
return swtch + 4 + 1; // 4 trims and REa added
|
return swtch + (2*4) + 1; // 4 trims and REa added
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -4233,7 +4233,7 @@ void menuModelCustomSwitchOne(uint8_t event)
|
||||||
{
|
{
|
||||||
lcd_putsLeft(y, STR_V1);
|
lcd_putsLeft(y, STR_V1);
|
||||||
int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM;
|
int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM;
|
||||||
if (cstate == CS_VBOOL) {
|
if (cstate == CS_VBOOL || cstate == CS_VSTICKY) {
|
||||||
putsSwitches(CSWONE_2ND_COLUMN, y, cs->v1, attr);
|
putsSwitches(CSWONE_2ND_COLUMN, y, cs->v1, attr);
|
||||||
v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1;
|
v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1;
|
||||||
}
|
}
|
||||||
|
@ -4253,7 +4253,7 @@ void menuModelCustomSwitchOne(uint8_t event)
|
||||||
{
|
{
|
||||||
lcd_putsLeft(y, STR_V2);
|
lcd_putsLeft(y, STR_V2);
|
||||||
int8_t v2_min=0, v2_max=MIXSRC_LAST_TELEM;
|
int8_t v2_min=0, v2_max=MIXSRC_LAST_TELEM;
|
||||||
if (cstate == CS_VBOOL) {
|
if (cstate == CS_VBOOL || cstate == CS_VSTICKY) {
|
||||||
putsSwitches(CSWONE_2ND_COLUMN, y, cs->v2, attr);
|
putsSwitches(CSWONE_2ND_COLUMN, y, cs->v2, attr);
|
||||||
v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1;
|
v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1;
|
||||||
}
|
}
|
||||||
|
@ -4358,7 +4358,7 @@ void menuModelCustomSwitches(uint8_t event)
|
||||||
// CSW params
|
// CSW params
|
||||||
uint8_t cstate = cswFamily(cs->func);
|
uint8_t cstate = cswFamily(cs->func);
|
||||||
|
|
||||||
if (cstate == CS_VBOOL) {
|
if (cstate == CS_VBOOL || cstate == CS_VSTICKY) {
|
||||||
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0);
|
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0);
|
||||||
putsSwitches(CSW_3RD_COLUMN, y, cs->v2, 0);
|
putsSwitches(CSW_3RD_COLUMN, y, cs->v2, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1193,7 +1193,6 @@ enum SwitchSources {
|
||||||
SWSRC_P26 = SWSRC_P21+5,
|
SWSRC_P26 = SWSRC_P21+5,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CPUARM)
|
|
||||||
SWSRC_FIRST_TRIM,
|
SWSRC_FIRST_TRIM,
|
||||||
SWSRC_TrimRudLeft = SWSRC_FIRST_TRIM,
|
SWSRC_TrimRudLeft = SWSRC_FIRST_TRIM,
|
||||||
SWSRC_TrimRudRight,
|
SWSRC_TrimRudRight,
|
||||||
|
@ -1204,7 +1203,6 @@ enum SwitchSources {
|
||||||
SWSRC_TrimAilLeft,
|
SWSRC_TrimAilLeft,
|
||||||
SWSRC_TrimAilRight,
|
SWSRC_TrimAilRight,
|
||||||
SWSRC_LAST_TRIM = SWSRC_TrimAilRight,
|
SWSRC_LAST_TRIM = SWSRC_TrimAilRight,
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PCBSKY9X)
|
#if defined(PCBSKY9X)
|
||||||
SWSRC_REa,
|
SWSRC_REa,
|
||||||
|
|
|
@ -1390,11 +1390,9 @@ bool getSwitch(int8_t swtch)
|
||||||
result = POT_POSITION(cs_idx-SWSRC_P11);
|
result = POT_POSITION(cs_idx-SWSRC_P11);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(CPUARM)
|
|
||||||
else if (cs_idx <= SWSRC_LAST_TRIM) {
|
else if (cs_idx <= SWSRC_LAST_TRIM) {
|
||||||
result = readTrims() & (1 << (cs_idx-SWSRC_FIRST_TRIM));
|
result = trimDown(cs_idx-SWSRC_FIRST_TRIM);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if ROTARY_ENCODERS > 0
|
#if ROTARY_ENCODERS > 0
|
||||||
else if (cs_idx == SWSRC_REa) {
|
else if (cs_idx == SWSRC_REa) {
|
||||||
result = REA_DOWN();
|
result = REA_DOWN();
|
||||||
|
|
|
@ -806,6 +806,7 @@ enum PowerState {
|
||||||
};
|
};
|
||||||
|
|
||||||
bool switchState(EnumKeys enuk);
|
bool switchState(EnumKeys enuk);
|
||||||
|
uint8_t trimDown(uint8_t idx);
|
||||||
void readKeysAndTrims();
|
void readKeysAndTrims();
|
||||||
|
|
||||||
uint16_t evalChkSum();
|
uint16_t evalChkSum();
|
||||||
|
|
|
@ -255,41 +255,7 @@ bool switchState(EnumKeys enuk)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE void readKeysAndTrims()
|
static const pm_uchar crossTrim[] PROGMEM = {
|
||||||
{
|
|
||||||
/* Original keys were connected to PORTB as follows:
|
|
||||||
|
|
||||||
Bit Key
|
|
||||||
7 other use
|
|
||||||
6 LEFT
|
|
||||||
5 RIGHT
|
|
||||||
4 UP
|
|
||||||
3 DOWN
|
|
||||||
2 EXIT
|
|
||||||
1 MENU
|
|
||||||
0 other use
|
|
||||||
*/
|
|
||||||
|
|
||||||
uint8_t enuk = KEY_MENU;
|
|
||||||
|
|
||||||
#if defined(ROTARY_ENCODERS)
|
|
||||||
keys[BTN_REa].input(REA_DOWN(), BTN_REa);
|
|
||||||
keys[BTN_REb].input(REB_DOWN(), BTN_REb);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8_t tin = ~PINL;
|
|
||||||
uint8_t in;
|
|
||||||
in = (tin & 0x0f) << 3;
|
|
||||||
in |= (tin & 0x30) >> 3;
|
|
||||||
|
|
||||||
for (int i=1; i<7; i++) {
|
|
||||||
//INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6
|
|
||||||
keys[enuk].input(in & (1<<i), (EnumKeys)enuk);
|
|
||||||
++enuk;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trim switches ...
|
|
||||||
static const pm_uchar crossTrim[] PROGMEM = {
|
|
||||||
1<<INP_J_TRM_LH_DWN,
|
1<<INP_J_TRM_LH_DWN,
|
||||||
1<<INP_J_TRM_LH_UP,
|
1<<INP_J_TRM_LH_UP,
|
||||||
1<<INP_J_TRM_LV_DWN,
|
1<<INP_J_TRM_LV_DWN,
|
||||||
|
@ -298,15 +264,41 @@ FORCEINLINE void readKeysAndTrims()
|
||||||
1<<INP_J_TRM_RV_UP,
|
1<<INP_J_TRM_RV_UP,
|
||||||
1<<INP_J_TRM_RH_DWN,
|
1<<INP_J_TRM_RH_DWN,
|
||||||
1<<INP_J_TRM_RH_UP
|
1<<INP_J_TRM_RH_UP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uint8_t trimDown(uint8_t idx)
|
||||||
|
{
|
||||||
|
uint8_t in = ~PIND;
|
||||||
|
return (in & pgm_read_byte(crossTrim+idx));
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCEINLINE void readKeysAndTrims()
|
||||||
|
{
|
||||||
|
uint8_t enuk = KEY_MENU;
|
||||||
|
|
||||||
|
// User buttons ...
|
||||||
|
uint8_t tin = ~PINL;
|
||||||
|
uint8_t in;
|
||||||
|
in = (tin & 0x0f) << 3;
|
||||||
|
in |= (tin & 0x30) >> 3;
|
||||||
|
for (int i=1; i<7; i++) {
|
||||||
|
// INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6
|
||||||
|
keys[enuk].input(in & (1<<i), (EnumKeys)enuk);
|
||||||
|
++enuk;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trims ...
|
||||||
in = ~PINJ;
|
in = ~PINJ;
|
||||||
|
|
||||||
for (int i=0; i<8; i++) {
|
for (int i=0; i<8; i++) {
|
||||||
// INP_D_TRM_RH_UP 0 .. INP_D_TRM_LH_UP 7
|
// INP_D_TRM_RH_UP 0 .. INP_D_TRM_LH_UP 7
|
||||||
keys[enuk].input(in & pgm_read_byte(crossTrim+i), (EnumKeys)enuk);
|
keys[enuk].input(in & pgm_read_byte(crossTrim+i), (EnumKeys)enuk);
|
||||||
++enuk;
|
++enuk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(ROTARY_ENCODERS)
|
||||||
|
keys[BTN_REa].input(REA_DOWN(), BTN_REa);
|
||||||
|
keys[BTN_REb].input(REB_DOWN(), BTN_REb);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ROTARY_ENCODERS <= 2
|
#if ROTARY_ENCODERS <= 2
|
||||||
|
|
|
@ -113,6 +113,11 @@ uint32_t readTrims()
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t trimDown(uint8_t idx)
|
||||||
|
{
|
||||||
|
return readTrims() & (1 << idx);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t keyDown()
|
uint8_t keyDown()
|
||||||
{
|
{
|
||||||
return (~readKeys() & 0x7E) || REA_DOWN();
|
return (~readKeys() & 0x7E) || REA_DOWN();
|
||||||
|
|
|
@ -234,25 +234,8 @@ bool switchState(EnumKeys enuk)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SIMU
|
// Trim switches ...
|
||||||
FORCEINLINE
|
static const pm_uchar crossTrim[] PROGMEM ={
|
||||||
#endif
|
|
||||||
void readKeysAndTrims()
|
|
||||||
{
|
|
||||||
uint8_t enuk = KEY_MENU;
|
|
||||||
|
|
||||||
// User buttons ...
|
|
||||||
uint8_t in = ~PINB;
|
|
||||||
|
|
||||||
for(int i=1; i<7; i++)
|
|
||||||
{
|
|
||||||
//INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6
|
|
||||||
keys[enuk].input(in & (1<<i),(EnumKeys)enuk);
|
|
||||||
++enuk;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trim switches ...
|
|
||||||
static const pm_uchar crossTrim[] PROGMEM ={
|
|
||||||
1<<INP_D_TRM_LH_DWN, // bit 7
|
1<<INP_D_TRM_LH_DWN, // bit 7
|
||||||
1<<INP_D_TRM_LH_UP,
|
1<<INP_D_TRM_LH_UP,
|
||||||
1<<INP_D_TRM_LV_DWN,
|
1<<INP_D_TRM_LV_DWN,
|
||||||
|
@ -261,10 +244,28 @@ void readKeysAndTrims()
|
||||||
1<<INP_D_TRM_RV_UP,
|
1<<INP_D_TRM_RV_UP,
|
||||||
1<<INP_D_TRM_RH_DWN,
|
1<<INP_D_TRM_RH_DWN,
|
||||||
1<<INP_D_TRM_RH_UP // bit 0
|
1<<INP_D_TRM_RH_UP // bit 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uint8_t trimDown(uint8_t idx)
|
||||||
|
{
|
||||||
|
uint8_t in = ~PIND;
|
||||||
|
return (in & pgm_read_byte(crossTrim+idx));
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCEINLINE void readKeysAndTrims()
|
||||||
|
{
|
||||||
|
uint8_t enuk = KEY_MENU;
|
||||||
|
|
||||||
|
// User buttons ...
|
||||||
|
uint8_t in = ~PINB;
|
||||||
|
for (int i=1; i<7; i++) {
|
||||||
|
// INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6
|
||||||
|
keys[enuk].input(in & (1<<i), (EnumKeys)enuk);
|
||||||
|
++enuk;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trims ...
|
||||||
in = ~PIND;
|
in = ~PIND;
|
||||||
|
|
||||||
for (int i=0; i<8; i++) {
|
for (int i=0; i<8; i++) {
|
||||||
// INP_D_TRM_RH_UP 0 .. INP_D_TRM_LH_UP 7
|
// INP_D_TRM_RH_UP 0 .. INP_D_TRM_LH_UP 7
|
||||||
keys[enuk].input(in & pgm_read_byte(crossTrim+i), (EnumKeys)enuk);
|
keys[enuk].input(in & pgm_read_byte(crossTrim+i), (EnumKeys)enuk);
|
||||||
|
|
|
@ -92,6 +92,11 @@ uint32_t readTrims()
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t trimDown(uint8_t idx)
|
||||||
|
{
|
||||||
|
return readTrims() & (1 << idx);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t keyDown()
|
uint8_t keyDown()
|
||||||
{
|
{
|
||||||
return ~readKeys() & 0x7E ;
|
return ~readKeys() & 0x7E ;
|
||||||
|
|
|
@ -155,7 +155,7 @@
|
||||||
#define TR_CSWSTICKY "Stcky"
|
#define TR_CSWSTICKY "Stcky"
|
||||||
#else
|
#else
|
||||||
#define TR_CSWTIMER "Tim\0 "
|
#define TR_CSWTIMER "Tim\0 "
|
||||||
#define TR_CSWSTICKY "Stky\0"
|
#define TR_CSWSTICKY "Glue\0"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LEN_VCSWFUNC "\005"
|
#define LEN_VCSWFUNC "\005"
|
||||||
|
@ -357,7 +357,7 @@
|
||||||
#elif defined(CPUARM)
|
#elif defined(CPUARM)
|
||||||
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW
|
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW
|
||||||
#else
|
#else
|
||||||
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_ROTENC_SWITCHES TR_CUSTOMSW
|
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HELI)
|
#if defined(HELI)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue