X10 extra switches sticks (#6423)

[X10] 2 extra sticks switches + 2 extra pots
This commit is contained in:
Bertrand Songis
2019-05-17 20:42:41 +02:00
committed by GitHub
parent 11cb2ea29b
commit 794fe32006
27 changed files with 390 additions and 166 deletions
+60 -26
View File
@@ -107,14 +107,6 @@ extern uint16_t sessionTimer;
#define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(TRAINER_DETECT_GPIO, TRAINER_DETECT_GPIO_PIN) == Bit_RESET)
#endif
#if defined(PCBX10)
#define NUM_SLIDERS 2
#define NUM_PWMSTICKS 4
#else
#define NUM_SLIDERS 4
#define NUM_PWMSTICKS 0
#endif
// Board driver
void boardPreInit(void);
void boardInit(void);
@@ -142,19 +134,6 @@ void delay_ms(uint32_t ms);
#define IS_FIRMWARE_COMPATIBLE_WITH_BOARD() (!IS_HORUS_PROD())
#endif
#if NUM_PWMSTICKS > 0
PACK(typedef struct {
uint8_t sticksPwmDisabled : 1;
uint8_t pxx2Enabled : 1;
}) HardwareOptions;
#else
PACK(typedef struct {
uint8_t pxx2Enabled : 1;
}) HardwareOptions;
#endif
extern HardwareOptions hardwareOptions;
// SD driver
#define BLOCK_SIZE 512 /* Block Size in Bytes */
#if !defined(SIMU) || defined(SIMU_DISKIO)
@@ -300,8 +279,12 @@ enum EnumSwitches
SW_SF,
SW_SG,
SW_SH,
SW_GMBL,
SW_GMBR,
NUM_SWITCHES
};
#define STORAGE_NUM_SWITCHES 10
#define IS_3POS(x) ((x) != SW_SF && (x) != SW_SH)
enum EnumSwitchesPositions
@@ -330,8 +313,20 @@ enum EnumSwitchesPositions
SW_SH0,
SW_SH1,
SW_SH2,
SW_SGMBL0,
SW_SGMBL1,
SW_SGMBL2,
SW_SGMBR0,
SW_SGMBR1,
SW_SGMBR2,
NUM_SWITCHES_POSITIONS
};
#if defined(__cplusplus)
static_assert(NUM_SWITCHES_POSITIONS == NUM_SWITCHES * 3, "Wrong switches positions count");
#endif
void keysInit(void);
uint8_t keyState(uint8_t index);
uint32_t switchState(uint8_t index);
@@ -384,8 +379,26 @@ void watchdogInit(unsigned int duration);
#endif
// ADC driver
#if defined(PCBX10)
#define NUM_POTS 5
#else
#define NUM_POTS 3
#endif
#define NUM_XPOTS NUM_POTS
#define STORAGE_NUM_POTS 5
#if defined(PCBX10)
#define NUM_SLIDERS 2
#define NUM_PWMSTICKS 4
#else
#define NUM_SLIDERS 4
#define NUM_PWMSTICKS 0
#endif
#define STORAGE_NUM_SLIDERS 4
enum Analogs {
STICK1,
STICK2,
@@ -395,7 +408,10 @@ enum Analogs {
POT1 = POT_FIRST,
POT2,
POT3,
POT_LAST = POT3,
#if defined(PCBX10)
EXT1,
EXT2,
#endif
SLIDER_FIRST,
SLIDER1 = SLIDER_FIRST,
SLIDER2,
@@ -410,12 +426,16 @@ enum Analogs {
#endif
SLIDER_LAST = SLIDER_FIRST + NUM_SLIDERS - 1,
TX_VOLTAGE,
#if defined(PCBX12S)
MOUSE1, // TODO why after voltage?
MOUSE2,
#endif
NUM_ANALOGS,
TX_RTC = NUM_ANALOGS
};
#define POT_LAST (SLIDER_FIRST - 1)
enum CalibratedAnalogs {
CALIBRATED_STICK1,
CALIBRATED_STICK2,
@@ -445,12 +465,13 @@ void adcInit(void);
void adcRead(void);
uint16_t getRTCBattVoltage();
uint16_t getAnalogValue(uint8_t index);
#define NUM_MOUSE_ANALOGS 2
#if defined(PCBX10)
#define NUM_DUMMY_ANAS 2
#if defined(PCBX12S)
#define NUM_MOUSE_ANALOGS 2
#else
#define NUM_DUMMY_ANAS 0
#define NUM_MOUSE_ANALOGS 0
#endif
#define STORAGE_NUM_MOUSE_ANALOGS 2
#if NUM_PWMSTICKS > 0
#define STICKS_PWM_ENABLED() (!hardwareOptions.sticksPwmDisabled)
@@ -636,4 +657,17 @@ extern DMAFifo<512> telemetryFifo;
extern DMAFifo<32> serial2RxFifo;
#endif
#if NUM_PWMSTICKS > 0
PACK(typedef struct {
uint8_t sticksPwmDisabled : 1;
uint8_t pxx2Enabled : 1;
}) HardwareOptions;
#else
PACK(typedef struct {
uint8_t pxx2Enabled : 1;
}) HardwareOptions;
#endif
extern HardwareOptions hardwareOptions;
#endif // _BOARD_HORUS_H_