refact: ADC, switches and keys
Add "hardware_defs" target to dump hardware defines from hal.h per target Fixed hal.h definitions for switches & ADC inputs Tools to generate hardware definitions from current hal.h generator: add support for EXTx and analog switches WiP Add generated header to hardware_defs target Add support for ADC input direction and index per GPIO port Incredible: it compiles Removed StdPeriph ADC driver Works on QX7 Works on TX16S (VBat missing) Switch driver using generated switches for stm32 targets Switch driver with generated switches for simu Use switch names from switch driver Fixed single conversion handling Fixed horus VBat reading Added switch name Fix warnings about bitfield offsets and GCC 4.4 This is caused by bitfields that cross type boundaries. In this particular case, it happens as the bitfield is not defined the same in `rtc_backup.cpp`. Switches has already been moved to generic driver Jitter measurement for each sample, not just for oversampled values Moved periph clock init to the ADC driver ADC & GPIOs. Add switchInit() to init pins Fix NV14 CMake Fix taranis target Fix NV14 (again) Model audio files: use new interface for switch index Fix X9-lite Fix simu headers Fix getSwitchName() Add support for ADC switches Fix switch warning YAML Test only switches which are defined Conversions tests for QX7 only on QX7 Fix X12S Fix function switch names Enable ADC periph clock before initialising channels NV14: offset inputs for the sticks & fix switches WiP: get rid of VSRCRAW and some more Simu shall use normal ADC driver fix x7 fix nv14 Fix 9x nav fix 212x64 fix xlite fix x9e fix simu lib fix unit tests fix x7 tests PWM stick values should be written directly into adcValues ... just like FlySky sticks. fix x12s fix nv14 Add some support for SPI ADC (only unit tests) Remove `jq` usage fix generate_yaml.py for newer libclang fix pot config fix stick names Some YAML generator improvements Max 16 Pots on COLORLCD Fix some source names Use 10 bits for switches to prevent overflow Removed horus constants for switches & ADC inputs Fix unit tests Fix curve edit Fix libsimulator Fix function switches (tpro) Refine ADC & analog API Moved hardware definitions scripts and templates into own dir cleanup API refine Fix unit tests Mixer: apply calibration only on required inputs Place ADC switches after all other ADC inputs Fix X12S Remove useless TR_POTS_VSRCRAW, TR_SW_VSRCRAW, and TR_VSRCRAW Cleanup redundant generated YAML parsers Fixes Boxer rebase Add boxer to generate-hw-defs.sh Obsolete LUA exports Add boxer ADC_DIRECTION Split generate_hw_defs.py into multiple files Some cleanup (+ LUA switches) Fix AXIS definitions Fixed translation strings declarations Some rebase fixes Remove some useless StdPeriph drivers fix: set pin mode to reset state on usart deinit fix: use canonical names for calibration data fix: ADC driver does not care about unconfigured inputs fix X12S ADC Add support for ADC conversion chaining Better X12S ADC implem Moved X12S ADC driver to HAL/LL Improve ADC driver separation Fixed taranis & nv14 Moved PWM gimbals to HAL/LL Removed useless TR_EXTRA_VSRCRAW Fixed include guards Small fixes Renamed control inputs Moved internal and external module pulse driver def to boards Move more things to the generic_stm32 board Remove STR_VMIXTRIMS Added analog labels Generate main control names Misuse labels / short labels for main controls Backward compatibility: sliders and legacy names New keys driver Let's get rid of StdPeriph headers in simu Add jinja2 to CI workflows Use `grep` instead of `sed` chore: add python jinja2 oto msys setup script Removed more static definitions and use dynamic ones instead Fixes X9E Fix x7 nav too 212 switch display Fix default sliders Removed NUM_STICKS 212 switch display working nicely Surface radio 'stick' replacements fix: switch, trim & rotary pin init Remove old key drivers Removed VKEYS Removed ETX_FOURCC Fixed SURFACE_NAME Removed TR_VSWITCHES & TR_TRIMS_SWITCHES Fix xpot switches Store calibrated analogs in physical order Use getSourceString in drawSource Implement missing YAML read/write Fix isSourceAvailableInInputs() Fix isSourceAvailable() Some surface fixes Fix CLI debug Ported colour UI of analog diagnostics to new ADC API Small fixes Better input mapping Minor tpro fixes Fix trims available Remove TX mode choice on surface radio Rename surface controls Channel order alignement Fix throttle warning Fix checkTrims() Fix pot config casting issue Fix IS_SWITCH_FS() Fixed input mapping Fix fswitch auto-switch Fixed storing / reading function switches in YAML Fix enableVBatBridge() / disableVBatBridge() Fix interesting mode conversion Fix sources issues Fix special funnction list Proper function switch handling 128 GUI improvements Fix compilation Boxer cosmetics 128 hardware screen cosmetic Fix TX12 switches More switches fixes Simplify CPU type handling Fix flash size Fixed page-up / page-down in libopenui
This commit is contained in:
committed by
Malte Langermann
parent
b6dd3a0ef8
commit
2b100e0eb5
+41
-97
@@ -22,7 +22,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "debounce.h"
|
||||
#include "definitions.h"
|
||||
#include "opentx_types.h"
|
||||
#include "opentx_helpers.h"
|
||||
@@ -246,52 +245,33 @@ enum RotaryEncoderMode {
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#if defined(PCBFRSKY) || defined(PCBFLYSKY)
|
||||
#define SWSRC_THR SWSRC_SB2
|
||||
#define SWSRC_GEA SWSRC_SG2
|
||||
#define SWSRC_ID0 SWSRC_SA0
|
||||
#define SWSRC_ID1 SWSRC_SA1
|
||||
#define SWSRC_ID2 SWSRC_SA2
|
||||
#define IS_MOMENTARY(sw) false // TODO
|
||||
#else
|
||||
#define SW_DSM2_BIND SW_TRN
|
||||
#endif
|
||||
|
||||
#include "myeeprom.h"
|
||||
#include "curves.h"
|
||||
|
||||
void memswap(void * a, void * b, uint8_t size);
|
||||
|
||||
#if defined(PCBX9D) || defined(PCBX9DP) || defined(PCBX9E) || defined(PCBHORUS)
|
||||
#define POT_CONFIG(x) ((g_eeGeneral.potsConfig >> (2*((x)-POT1)))&0x03)
|
||||
#define IS_POT_MULTIPOS(x) (IS_POT(x) && POT_CONFIG(x)==POT_MULTIPOS_SWITCH)
|
||||
#define IS_POT_WITHOUT_DETENT(x) (IS_POT(x) && POT_CONFIG(x)==POT_WITHOUT_DETENT)
|
||||
#define IS_SLIDER_AVAILABLE(x) ((x) == SLIDER1 || (x) == SLIDER2 || (IS_SLIDER(x) && (g_eeGeneral.slidersConfig & (0x01 << ((x)-SLIDER1)))))
|
||||
#define IS_POT_AVAILABLE(x) (IS_POT(x) && POT_CONFIG(x)!=POT_NONE)
|
||||
#define IS_POT_SLIDER_AVAILABLE(x) (IS_POT_AVAILABLE(x) || IS_SLIDER_AVAILABLE(x))
|
||||
#define IS_MULTIPOS_CALIBRATED(cal) (cal->count>0 && cal->count<XPOTS_MULTIPOS_COUNT)
|
||||
#elif defined(PCBX7) || defined(PCBXLITE) || defined(PCBNV14)
|
||||
#define POT_CONFIG(x) ((g_eeGeneral.potsConfig >> (2*((x)-POT1)))&0x03)
|
||||
#define IS_POT_MULTIPOS(x) (IS_POT(x) && POT_CONFIG(x)==POT_MULTIPOS_SWITCH)
|
||||
#define IS_POT_WITHOUT_DETENT(x) (IS_POT(x) && POT_CONFIG(x)==POT_WITHOUT_DETENT)
|
||||
#define IS_POT_AVAILABLE(x) (IS_POT(x) && POT_CONFIG(x)!=POT_NONE)
|
||||
#define IS_POT_SLIDER_AVAILABLE(x) (IS_POT_AVAILABLE(x))
|
||||
#define IS_MULTIPOS_CALIBRATED(cal) (cal->count>0 && cal->count<XPOTS_MULTIPOS_COUNT)
|
||||
#else
|
||||
#define IS_POT_MULTIPOS(x) (false)
|
||||
#define IS_POT_WITHOUT_DETENT(x) (true)
|
||||
#define IS_POT_SLIDER_AVAILABLE(x) (true)
|
||||
#define IS_MULTIPOS_CALIBRATED(cal) (false)
|
||||
#endif
|
||||
// TODO: move these config check macros somewhere else
|
||||
#define POT_CONFIG(x) \
|
||||
((g_eeGeneral.potsConfig >> POT_CONFIG_POS(x)) & POT_CFG_MASK)
|
||||
|
||||
#if NUM_XPOTS > 0
|
||||
#define IS_SWITCH_MULTIPOS(x) (SWSRC_FIRST_MULTIPOS_SWITCH <= (x) && (x) <= SWSRC_LAST_MULTIPOS_SWITCH)
|
||||
#else
|
||||
#define IS_SWITCH_MULTIPOS(x) (false)
|
||||
#endif
|
||||
#define IS_POT_MULTIPOS(x) (POT_CONFIG(x) == POT_MULTIPOS_SWITCH)
|
||||
#define IS_POT_WITHOUT_DETENT(x) (POT_CONFIG(x) == POT_WITHOUT_DETENT)
|
||||
#define IS_SLIDER(x) (POT_CONFIG(x) == POT_SLIDER_WITH_DETENT)
|
||||
#define IS_POT_AVAILABLE(x) (POT_CONFIG(x) != POT_NONE)
|
||||
#define IS_POT_SLIDER_AVAILABLE(x) (IS_POT_AVAILABLE(x))
|
||||
#define IS_MULTIPOS_CALIBRATED(cal) (cal->count > 0 && cal->count < XPOTS_MULTIPOS_COUNT)
|
||||
|
||||
#define GET_LOWRES_POT_POSITION(i) (getValue(MIXSRC_FIRST_POT+(i)) >> 4)
|
||||
#define SAVE_POT_POSITION(i) g_model.potsWarnPosition[i] = GET_LOWRES_POT_POSITION(i)
|
||||
#define IS_SWITCH_MULTIPOS(x) \
|
||||
(SWSRC_FIRST_MULTIPOS_SWITCH <= (x) && (x) <= SWSRC_LAST_MULTIPOS_SWITCH)
|
||||
|
||||
#define GET_LOWRES_POT_POSITION(i) (getValue(MIXSRC_FIRST_POT + (i)) >> 4)
|
||||
|
||||
#define SAVE_POT_POSITION(i) \
|
||||
g_model.potsWarnPosition[i] = GET_LOWRES_POT_POSITION(i)
|
||||
|
||||
#define ANALOG_CENTER_BEEP(x) \
|
||||
(g_model.beepANACenter & ((BeepANACenter)1 << (x)))
|
||||
|
||||
#define PPM_CENTER 1500
|
||||
|
||||
@@ -342,26 +322,6 @@ struct CustomFunctionsContext {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern const uint8_t bchout_ar[];
|
||||
extern const uint8_t modn12x3[];
|
||||
|
||||
//convert from mode 1 to mode stickMode
|
||||
//NOTICE! => 0..3 -> 0..3
|
||||
#define RUD_STICK 0
|
||||
#define ELE_STICK 1
|
||||
#define THR_STICK 2
|
||||
#define AIL_STICK 3
|
||||
#define CONVERT_MODE(x) (((x)<=AIL_STICK) ? *(modn12x3 + 4*g_eeGeneral.stickMode + (x)) : (x) )
|
||||
|
||||
#if defined(PCBXLITE)
|
||||
#define CONVERT_MODE_TRIMS(x) (((x) == RUD_STICK) ? AIL_STICK : ((x) == AIL_STICK) ? RUD_STICK : (x))
|
||||
#else
|
||||
#define CONVERT_MODE_TRIMS(x) CONVERT_MODE(x)
|
||||
#endif
|
||||
|
||||
extern uint8_t channelOrder(uint8_t x);
|
||||
extern uint8_t channelOrder(uint8_t setup, uint8_t x);
|
||||
|
||||
#define THRCHK_DEADBAND 16
|
||||
|
||||
inline bool SPLASH_NEEDED()
|
||||
@@ -408,10 +368,9 @@ extern uint8_t heartbeat;
|
||||
#include "keys.h"
|
||||
#include "pwr.h"
|
||||
|
||||
#if defined(PCBFRSKY) || defined(PCBNV14)
|
||||
div_t switchInfo(int switchPosition);
|
||||
extern uint8_t potsPos[NUM_XPOTS];
|
||||
#endif
|
||||
// #if defined(PCBFRSKY) || defined(PCBNV14)
|
||||
// extern uint8_t potsPos[NUM_XPOTS];
|
||||
// #endif
|
||||
|
||||
bool trimDown(uint8_t idx);
|
||||
|
||||
@@ -490,24 +449,6 @@ void per10ms();
|
||||
|
||||
getvalue_t getValue(mixsrc_t i, bool* valid = nullptr);
|
||||
|
||||
#define GETSWITCH_MIDPOS_DELAY 1
|
||||
bool getSwitch(swsrc_t swtch, uint8_t flags=0);
|
||||
|
||||
void logicalSwitchesTimerTick();
|
||||
void logicalSwitchesReset();
|
||||
|
||||
void evalLogicalSwitches(bool isCurrentFlightmode=true);
|
||||
void logicalSwitchesCopyState(uint8_t src, uint8_t dst);
|
||||
|
||||
#if defined(PCBFRSKY) || defined(PCBFLYSKY)
|
||||
void getSwitchesPosition(bool startup);
|
||||
#else
|
||||
#define getSwitchesPosition(...)
|
||||
#endif
|
||||
|
||||
extern swarnstate_t switches_states;
|
||||
swsrc_t getMovedSwitch();
|
||||
|
||||
int8_t getMovedSource(uint8_t min);
|
||||
#define GET_MOVED_SOURCE(min, max) getMovedSource(min)
|
||||
|
||||
@@ -520,7 +461,7 @@ int8_t getMovedSource(uint8_t min);
|
||||
#define getTrimFlightMode(phase, idx) (phase)
|
||||
|
||||
#if defined(GVARS)
|
||||
extern int8_t trimGvar[NUM_TRIMS];
|
||||
extern int8_t trimGvar[MAX_TRIMS];
|
||||
#define TRIM_REUSED(idx) trimGvar[idx] >= 0
|
||||
#else
|
||||
#define TRIM_REUSED(idx) 0
|
||||
@@ -711,7 +652,7 @@ inline bool isMixActive(uint8_t mix)
|
||||
|
||||
enum FunctionsActive {
|
||||
FUNCTION_TRAINER_STICK1,
|
||||
FUNCTION_TRAINER_CHANNELS = FUNCTION_TRAINER_STICK1 + NUM_STICKS,
|
||||
FUNCTION_TRAINER_CHANNELS = FUNCTION_TRAINER_STICK1 + MAX_STICKS,
|
||||
FUNCTION_INSTANT_TRIM,
|
||||
FUNCTION_VARIO,
|
||||
#if defined(SDCARD)
|
||||
@@ -744,6 +685,9 @@ inline void customFunctionsReset()
|
||||
modelFunctionsContext.reset();
|
||||
}
|
||||
|
||||
const char* funcGetLabel(uint8_t func);
|
||||
|
||||
|
||||
#include "telemetry/telemetry.h"
|
||||
#include "crc.h"
|
||||
|
||||
@@ -867,9 +811,7 @@ constexpr uint8_t OPENTX_START_NO_CHECKS = 0x04;
|
||||
#if defined(STATUS_LEDS)
|
||||
#define LED_ERROR_BEGIN() ledRed()
|
||||
// Green is preferred "ready to use" color for these radios
|
||||
#if defined(RADIO_T8) || defined(RADIO_COMMANDO8) || defined(RADIO_TLITE) || \
|
||||
defined(RADIO_TPRO) || defined(RADIO_TX12) || defined(RADIO_TX12MK2) || \
|
||||
defined(RADIO_ZORRO) || defined(RADIO_BOXER)
|
||||
#if defined(MANUFACTURER_RADIOMASTER) || defined(MANUFACTURER_JUMPER) || defined(RADIO_COMMANDO8)
|
||||
#define LED_ERROR_END() ledGreen()
|
||||
#define LED_BIND() ledBlue()
|
||||
#else
|
||||
@@ -931,18 +873,20 @@ union ReusableBuffer
|
||||
} moduleSetup;
|
||||
|
||||
struct {
|
||||
int16_t midVals[NUM_STICKS+NUM_POTS+NUM_SLIDERS+STORAGE_NUM_MOUSE_ANALOGS];
|
||||
int16_t loVals[NUM_STICKS+NUM_POTS+NUM_SLIDERS+STORAGE_NUM_MOUSE_ANALOGS];
|
||||
int16_t hiVals[NUM_STICKS+NUM_POTS+NUM_SLIDERS+STORAGE_NUM_MOUSE_ANALOGS];
|
||||
uint8_t state;
|
||||
#if defined(PCBFRSKY)
|
||||
struct {
|
||||
uint8_t stepsCount;
|
||||
int16_t steps[XPOTS_MULTIPOS_COUNT];
|
||||
uint8_t lastCount;
|
||||
int16_t lastPosition;
|
||||
} xpotsCalib[NUM_XPOTS];
|
||||
#endif
|
||||
union {
|
||||
struct {
|
||||
int16_t midVal;
|
||||
int16_t loVal;
|
||||
int16_t hiVal;
|
||||
} input;
|
||||
struct {
|
||||
uint8_t stepsCount;
|
||||
int16_t steps[XPOTS_MULTIPOS_COUNT];
|
||||
uint8_t lastCount;
|
||||
int16_t lastPosition;
|
||||
} xpot;
|
||||
} inputs[MAX_ANALOG_INPUTS];
|
||||
} calib;
|
||||
|
||||
#if defined(SDCARD)
|
||||
|
||||
Reference in New Issue
Block a user