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
188 lines
6.0 KiB
C
188 lines
6.0 KiB
C
/*
|
|
* Copyright (C) EdgeTX
|
|
*
|
|
* Based on code named
|
|
* opentx - https://github.com/opentx/opentx
|
|
* th9x - http://code.google.com/p/th9x
|
|
* er9x - http://code.google.com/p/er9x
|
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
|
*
|
|
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
struct CheckIncDecStops
|
|
{
|
|
const int count;
|
|
const int stops[];
|
|
int min() const
|
|
{
|
|
return stops[0];
|
|
}
|
|
int max() const
|
|
{
|
|
return stops[count-1];
|
|
}
|
|
bool contains(int value) const
|
|
{
|
|
for (int i=0; i<count; ++i) {
|
|
int stop = stops[i];
|
|
if (value == stop)
|
|
return true;
|
|
else if (value < stop)
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
};
|
|
|
|
extern const CheckIncDecStops &stops100;
|
|
extern const CheckIncDecStops &stops1000;
|
|
extern const CheckIncDecStops &stopsSwitch;
|
|
|
|
#define INIT_STOPS(var, ...) \
|
|
const int _ ## var[] = { __VA_ARGS__ }; \
|
|
const CheckIncDecStops &var = (const CheckIncDecStops&)_ ## var;
|
|
|
|
#define CATEGORY_END(val) \
|
|
(val), (val+1)
|
|
|
|
extern int8_t checkIncDec_Ret; // global helper vars
|
|
|
|
#define CURSOR_ON_LINE() (menuHorizontalPosition < 0)
|
|
|
|
#define EDIT_SELECT_FIELD 0
|
|
#define EDIT_MODIFY_FIELD 1
|
|
#define EDIT_MODIFY_STRING 2
|
|
extern int8_t s_editMode; // global editmode
|
|
|
|
// checkIncDec flags
|
|
// we leave room for EE_MODEL and EE_GENERAL
|
|
#define NO_INCDEC_MARKS 0x04
|
|
#define INCDEC_SWITCH 0x08
|
|
#define INCDEC_SOURCE 0x10
|
|
#define INCDEC_REP10 0x40
|
|
#define NO_DBLKEYS 0x80
|
|
|
|
int checkIncDec(event_t event, int val, int i_min, int i_max,
|
|
unsigned int i_flags = 0, IsValueAvailable isValueAvailable = nullptr,
|
|
const CheckIncDecStops &stops = stops100);
|
|
|
|
#define checkIncDecModel(event, i_val, i_min, i_max) \
|
|
checkIncDec(event, i_val, i_min, i_max, EE_MODEL)
|
|
|
|
#define checkIncDecModelZero(event, i_val, i_max) \
|
|
checkIncDec(event, i_val, 0, i_max, EE_MODEL)
|
|
|
|
#define checkIncDecGen(event, i_val, i_min, i_max) \
|
|
checkIncDec(event, i_val, i_min, i_max, EE_GENERAL)
|
|
|
|
#define NAVIGATION_LINE_BY_LINE 0x40
|
|
|
|
#define CHECK_FLAG_NO_SCREEN_INDEX 1
|
|
|
|
void check(event_t event, uint8_t curr, const MenuHandler *menuTab,
|
|
uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax,
|
|
vertpos_t rowcount, uint8_t flags = 0);
|
|
|
|
#define INCDEC_DECLARE_VARS(f) \
|
|
uint8_t incdecFlag = (f); \
|
|
IsValueAvailable isValueAvailable = nullptr
|
|
|
|
#define INCDEC_SET_FLAG(f) incdecFlag = (f)
|
|
|
|
#define INCDEC_ENABLE_CHECK(fn) isValueAvailable = fn
|
|
|
|
#define CHECK_INCDEC_PARAM(event, var, min, max) \
|
|
checkIncDec(event, var, min, max, incdecFlag, isValueAvailable)
|
|
|
|
#define CHECK_INCDEC_MODELVAR(event, var, min, max) \
|
|
var = checkIncDecModel(event, var, min, max)
|
|
|
|
#define CHECK_INCDEC_MODELVAR_ZERO(event, var, max) \
|
|
var = checkIncDecModelZero(event, var, max)
|
|
|
|
#define CHECK_INCDEC_MODELVAR_CHECK(event, var, min, max, check) \
|
|
var = checkIncDec(event, var, min, max, EE_MODEL, check)
|
|
|
|
#define CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, var, max, check) \
|
|
var = checkIncDec(event, var, 0, max, EE_MODEL, check)
|
|
|
|
#define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER))
|
|
#define CHECK_INCDEC_SWITCH(event, var, min, max, flags, available) \
|
|
var = checkIncDec(event, var, min, max, (flags)|INCDEC_SWITCH, available)
|
|
#define CHECK_INCDEC_MODELSWITCH(event, var, min, max, available) \
|
|
CHECK_INCDEC_SWITCH(event, var, min, max, EE_MODEL, available)
|
|
|
|
#define CHECK_INCDEC_MODELSOURCE(event, var, min, max) \
|
|
var = checkIncDec(event, var, min, max, EE_MODEL|INCDEC_SOURCE|NO_INCDEC_MARKS, isSourceAvailable)
|
|
|
|
#define CHECK_INCDEC_GENVAR(event, var, min, max) \
|
|
var = checkIncDecGen(event, var, min, max)
|
|
|
|
#if defined(AUTOSWITCH)
|
|
swsrc_t checkIncDecMovedSwitch(swsrc_t val);
|
|
#endif
|
|
|
|
void repeatLastCursorMove(event_t event);
|
|
|
|
void onSwitchLongEnterPress(const char * result);
|
|
void onSourceLongEnterPress(const char * result);
|
|
|
|
void check_submenu_simple(event_t event, uint8_t rowcount);
|
|
|
|
void check_simple(event_t event, uint8_t curr, const MenuHandler *menuTab,
|
|
uint8_t menuTabSize, vertpos_t rowcount);
|
|
|
|
|
|
#define MENU_TAB_ARRAY_NAME mstate_tab
|
|
#define MENU_TAB_ARRAY_TYPE const uint8_t
|
|
#define MENU_TAB_ARRAY_DEF MENU_TAB_ARRAY_TYPE MENU_TAB_ARRAY_NAME
|
|
#define MENU_TAB(...) MENU_TAB_ARRAY_DEF[] = __VA_ARGS__
|
|
|
|
#define MENU_CHECK(tab, menu, lines_count) \
|
|
check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, lines_count)
|
|
|
|
#define MENU_CHECK_FLAGS(tab, menu, flags, lines_count) \
|
|
check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, lines_count, flags)
|
|
|
|
#define MENU(name, tab, menu, lines_count, ...) \
|
|
MENU_TAB(__VA_ARGS__); \
|
|
MENU_CHECK(tab, menu, lines_count); \
|
|
title(name)
|
|
|
|
#define MENU_FLAGS(name, tab, menu, flags, lines_count, ...) \
|
|
MENU_TAB(__VA_ARGS__); \
|
|
MENU_CHECK_FLAGS(tab, menu, flags, lines_count); \
|
|
title(name)
|
|
|
|
#define SIMPLE_MENU(name, tab, menu, lines_count) \
|
|
check_simple(event, menu, tab, DIM(tab), lines_count); \
|
|
title(name)
|
|
|
|
#define SUBMENU_NOTITLE(lines_count, ...) \
|
|
MENU_TAB(__VA_ARGS__); \
|
|
check(event, 0, nullptr, 0, mstate_tab, DIM(mstate_tab)-1, lines_count);
|
|
|
|
#define SUBMENU(name, lines_count, ...) \
|
|
MENU_TAB(__VA_ARGS__); \
|
|
check(event, 0, nullptr, 0, mstate_tab, DIM(mstate_tab)-1, lines_count); \
|
|
title(name)
|
|
|
|
#define SIMPLE_SUBMENU_NOTITLE(lines_count) \
|
|
check_submenu_simple(event, lines_count)
|
|
|
|
#define SIMPLE_SUBMENU(name, lines_count) \
|
|
SIMPLE_SUBMENU_NOTITLE(lines_count); \
|
|
title(name)
|