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:
Raphael Coeffic
2023-06-25 14:32:39 +02:00
committed by Malte Langermann
parent b6dd3a0ef8
commit 2b100e0eb5
323 changed files with 12812 additions and 22301 deletions
+48 -163
View File
@@ -25,6 +25,8 @@
#include "gui_common.h"
#include "menus.h"
#include "popups.h"
#include "navigation/navigation.h"
#include "common/stdlcd/draw_functions.h"
#define MENUS_SCROLLBAR_WIDTH 0
@@ -57,147 +59,49 @@ extern uint8_t noHighlightCounter;
void drawSlider(coord_t x, coord_t y, uint8_t width, uint8_t value, uint8_t max, uint8_t attr);
void drawSlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr);
extern int8_t checkIncDec_Ret; // global helper vars
#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
#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)
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)
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 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(PCBTARANIS)
#define CURSOR_ON_LINE() (menuHorizontalPosition < 0)
#else
#define CURSOR_ON_LINE() (0)
#endif
void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow);
void check_simple(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menuTabSize, vertpos_t maxrow);
void check_submenu_simple(event_t event, uint8_t maxrow);
void title(const char * s);
#define MENU_TAB(...) const uint8_t mstate_tab[] = __VA_ARGS__
#define MENU_CHECK(tab, menu, lines_count) \
check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, (lines_count)-HEADER_LINE)
#define MENU(name, tab, menu, lines_count, ...) \
MENU_TAB(__VA_ARGS__); \
MENU_CHECK(tab, menu, 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)-HEADER_LINE)
#define SIMPLE_MENU_NOTITLE(tab, menu, lines_count) \
check_simple(event, menu, tab, DIM(tab), (lines_count)-HEADER_LINE)
#define SIMPLE_SUBMENU_NOTITLE(lines_count) \
check_submenu_simple(event, (lines_count)-HEADER_LINE)
#define SUBMENU(name, lines_count, ...) \
MENU_TAB(__VA_ARGS__); \
check(event, 0, nullptr, 0, mstate_tab, DIM(mstate_tab)-1, (lines_count)-HEADER_LINE); \
title(name)
#define SIMPLE_MENU(name, tab, menu, lines_count) \
SIMPLE_MENU_NOTITLE(tab, menu, lines_count); \
title(name)
#define SIMPLE_SUBMENU(name, lines_count) \
SIMPLE_SUBMENU_NOTITLE(lines_count); \
title(name)
typedef int choice_t;
choice_t editChoice(coord_t x, coord_t y, const char * label, const char *const *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event, IsValueAvailable isValueAvailable = nullptr);
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const char * label, LcdFlags attr, event_t event);
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t event);
choice_t editChoice(coord_t x, coord_t y, const char *label,
const char *const *values, choice_t value, choice_t min,
choice_t max, LcdFlags attr, event_t event,
IsValueAvailable isValueAvailable = nullptr);
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const char *label,
LcdFlags attr, event_t event);
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr,
event_t event);
#if defined(GVARS)
#define GVAR_MENU_ITEM(x, y, v, min, max, attr, editflags, event) editGVarFieldValue(x, y, v, min, max, attr, editflags, event)
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, event_t event);
void drawGVarValue(coord_t x, coord_t y, uint8_t gvar, gvar_t value, LcdFlags flags=0);
void editGVarValue(coord_t x, coord_t y, event_t event, uint8_t gvar, uint8_t flightMode, LcdFlags flags);
#define displayGVar(x, y, v, min, max) GVAR_MENU_ITEM(x, y, v, min, max, 0, 0, 0)
#else
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, event_t event);
#define GVAR_MENU_ITEM(x, y, v, min, max, attr, editflags, event) editGVarFieldValue(x, y, v, min, max, attr, event)
#define GVAR_MENU_ITEM(x, y, v, min, max, attr, editflags, event) \
editGVarFieldValue(x, y, v, min, max, attr, editflags, event)
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min,
int16_t max, LcdFlags attr, uint8_t editflags,
event_t event);
void drawGVarValue(coord_t x, coord_t y, uint8_t gvar, gvar_t value,
LcdFlags flags = 0);
void editGVarValue(coord_t x, coord_t y, event_t event, uint8_t gvar,
uint8_t flightMode, LcdFlags flags);
#define displayGVar(x, y, v, min, max) \
GVAR_MENU_ITEM(x, y, v, min, max, 0, 0, 0)
#else // GVARS
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min,
int16_t max, LcdFlags attr, event_t event);
#define GVAR_MENU_ITEM(x, y, v, min, max, attr, editflags, event) \
editGVarFieldValue(x, y, v, min, max, attr, event)
#define displayGVar(x, y, v, min, max) lcdDraw8bitsNumber(x, y, v)
#endif
void gvarWeightItem(coord_t x, coord_t y, MixData * md, LcdFlags attr, event_t event);
@@ -210,10 +114,12 @@ void editSingleName(coord_t x, coord_t y, const char *label, char *name,
uint8_t old_editMode);
uint8_t editDelay(coord_t y, event_t event, uint8_t attr, const char * str, uint8_t delay);
#define EDIT_DELAY(x, y, event, attr, str, delay) editDelay(y, event, attr, str, delay)
#define COPY_MODE 1
#define MOVE_MODE 2
#define COPY_MODE 1
#define MOVE_MODE 2
extern uint8_t s_copyMode;
extern int8_t s_copySrcRow;
extern int8_t s_copyTgtOfs;
@@ -243,33 +149,9 @@ void readModelNotes();
void menuChannelsView(event_t event);
void menuChannelsViewCommon(event_t event);
#define CURSOR_MOVED_LEFT(event) (IS_ROTARY_LEFT(event) || EVT_KEY_MASK(event) == KEY_LEFT)
#define CURSOR_MOVED_RIGHT(event) (IS_ROTARY_RIGHT(event) || EVT_KEY_MASK(event) == KEY_RIGHT)
void repeatLastCursorMove(event_t event);
#if defined(ROTARY_ENCODER_NAVIGATION)
#define IS_ROTARY_LEFT(evt) (evt == EVT_ROTARY_LEFT)
#define IS_ROTARY_RIGHT(evt) (evt == EVT_ROTARY_RIGHT)
#define IS_ROTARY_BREAK(evt) (evt == EVT_ROTARY_BREAK)
#define IS_ROTARY_LONG(evt) (evt == EVT_ROTARY_LONG)
#define IS_ROTARY_EVENT(evt) (EVT_KEY_MASK(evt) >= 0x0e)
void repeatLastCursorMove(event_t event);
#define REPEAT_LAST_CURSOR_MOVE() { if (EVT_KEY_MASK(event) >= 0x0e) pushEvent(event); else repeatLastCursorMove(event); }
#else
#define IS_ROTARY_LEFT(evt) (0)
#define IS_ROTARY_RIGHT(evt) (0)
#define IS_ROTARY_BREAK(evt) (0)
#define IS_ROTARY_LONG(evt) (0)
#define IS_ROTARY_EVENT(evt) (0)
void repeatLastCursorMove(event_t event);
#define REPEAT_LAST_CURSOR_MOVE() repeatLastCursorMove(event)
#endif
// TODO enum
#if defined(PCBX7) || defined(PCBX9LITE)
#define EDIT_MODE_INIT 0
#else
#define EDIT_MODE_INIT -1
#endif
#define EDIT_MODE_INIT 0
extern uint8_t editNameCursorPos;
@@ -280,6 +162,7 @@ uint8_t getMixesCount();
void insertMix(uint8_t idx);
void deleteMix(uint8_t idx);
void onSwitchLongEnterPress(const char *result);
void onSourceLongEnterPress(const char *result);
uint8_t switchToMix(uint8_t source);
@@ -291,6 +174,8 @@ extern const unsigned char sticks[] ;
void drawSplash();
void drawScreenIndex(uint8_t index, uint8_t count, uint8_t attr);
void drawStick(coord_t centrex, int16_t xval, int16_t yval);
void drawWheel(coord_t centrex, int16_t wval);
void drawThrottle(coord_t centrex, int16_t tval);
void drawPotsBars();
void doMainScreenGraphics();
+8 -89
View File
@@ -35,6 +35,9 @@
#if !defined(BOOT)
#include "opentx.h"
#include "hal/switch_driver.h"
#include "hal/adc_driver.h"
#include "switches.h"
#endif
pixel_t displayBuf[DISPLAY_BUFFER_SIZE] __DMA;
@@ -707,7 +710,7 @@ void putsVBat(coord_t x, coord_t y, LcdFlags att)
void drawSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att)
{
if (idx == MIXSRC_NONE) {
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, 0, att); // TODO macro
lcdDrawText(x, y, STR_EMPTY, att);
}
else if (idx <= MIXSRC_LAST_INPUT) {
lcdDrawChar(x+2, y+1, CHR_INPUT, TINSIZE);
@@ -734,98 +737,14 @@ void drawSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att)
}
}
#endif
else if (idx <= MIXSRC_LAST_POT) {
idx = idx - MIXSRC_Rud;
if (g_eeGeneral.anaNames[idx][0]) {
if (idx < MIXSRC_FIRST_POT-MIXSRC_Rud )
lcdDrawSizedText(x, y, STR_CHAR_STICK, 2, att);
else if (idx <= MIXSRC_LAST_POT-MIXSRC_Rud )
lcdDrawSizedText(x, y, STR_CHAR_POT, 2, att);
else
lcdDrawSizedText(x, y, STR_CHAR_SLIDER, 2, att);
lcdDrawSizedText(lcdNextPos, y, g_eeGeneral.anaNames[idx], LEN_ANA_NAME, att);
}
else {
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx + 1, att);
}
}
else if (idx >= MIXSRC_FIRST_SWITCH && idx <= MIXSRC_LAST_SWITCH) {
#if defined(FUNCTION_SWITCHES)
if(idx >= MIXSRC_FIRST_FS_SWITCH) {
idx = idx-(MIXSRC_FIRST_SWITCH+NUM_REGULAR_SWITCHES);
if (ZEXIST(g_model.switchNames[idx])) {
lcdDrawSizedText(x, y, STR_CHAR_SWITCH, 2, att);
lcdDrawSizedText(lcdNextPos, y, g_model.switchNames[idx], LEN_SWITCH_NAME, att);
}
else {
char s[LEN_SWITCH_NAME] = {'S', 'W'};
s[LEN_SWITCH_NAME-1] = '1' + idx;
lcdDrawSizedText(x, y, STR_CHAR_SWITCH, 2, att);
lcdDrawSizedText(lcdNextPos, y, s, LEN_SWITCH_NAME, att);
}
}
else {
idx = idx-MIXSRC_FIRST_SWITCH;
if (ZEXIST(g_eeGeneral.switchNames[idx])) {
lcdDrawSizedText(x, y, STR_CHAR_SWITCH, 2, att);
lcdDrawSizedText(lcdNextPos, y, g_eeGeneral.switchNames[idx], LEN_SWITCH_NAME, att);
}
else
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx + MIXSRC_FIRST_SWITCH - MIXSRC_Rud + 1, att);
}
#else
idx = idx-MIXSRC_FIRST_SWITCH;
if (ZEXIST(g_eeGeneral.switchNames[idx])) {
lcdDrawSizedText(x, y, STR_CHAR_SWITCH, 2, att); //switch symbol
lcdDrawSizedText(lcdNextPos, y, g_eeGeneral.switchNames[idx], LEN_SWITCH_NAME, att);
}
else
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx + MIXSRC_FIRST_SWITCH - MIXSRC_Rud + 1, att);
#endif
}
else if (idx < MIXSRC_SW1)
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1, att);
else if (idx <= MIXSRC_LAST_LOGICAL_SWITCH)
drawSwitch(x, y, SWSRC_SW1+idx-MIXSRC_SW1, att);
else if (idx < MIXSRC_CH1)
drawStringWithIndex(x, y, STR_PPM_TRAINER, idx-MIXSRC_FIRST_TRAINER+1, att);
else if (idx <= MIXSRC_LAST_CH) {
if (ZEXIST(g_model.limitData[idx-MIXSRC_CH1].name) && (att & STREXPANDED)) {
char s[LEN_CHANNEL_NAME + 3];
strcpy(s, STR_CHAR_CHANNEL);
strcat(s, g_model.limitData[idx-MIXSRC_CH1].name);
lcdDrawSizedText(x, y, s, LEN_CHANNEL_NAME+2, att);
} else {
drawStringWithIndex(x, y, STR_CH, idx-MIXSRC_CH1+1, att);
}
}
else if (idx <= MIXSRC_LAST_GVAR) {
drawStringWithIndex(x, y, STR_GV, idx-MIXSRC_GVAR1+1, att);
}
else if (idx < MIXSRC_FIRST_TIMER) {
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1-MAX_LOGICAL_SWITCHES-MAX_TRAINER_CHANNELS-MAX_OUTPUT_CHANNELS-MAX_GVARS, att);
}
else if (idx <= MIXSRC_LAST_TIMER) {
if(ZEXIST(g_model.timers[idx-MIXSRC_FIRST_TIMER].name)) {
lcdDrawSizedText(x, y, g_model.timers[idx-MIXSRC_FIRST_TIMER].name, LEN_TIMER_NAME, att);
}
else {
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1-MAX_LOGICAL_SWITCHES-MAX_TRAINER_CHANNELS-MAX_OUTPUT_CHANNELS-MAX_GVARS, att);
}
}
else {
idx -= MIXSRC_FIRST_TELEM;
div_t qr = div(idx, 3);
lcdDrawSizedText(x, y, g_model.telemetrySensors[qr.quot].label, TELEM_LABEL_LEN, att);
if (qr.rem) lcdDrawChar(lcdLastRightPos, y, qr.rem==2 ? '+' : '-', att);
lcdDrawText(x, y, getSourceString(idx), att);
}
}
void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
{
lcdDrawTextAtIndex(x, y, STR_RETA123, idx-1, att);
lcdDrawText(x, y, getAnalogShortLabel(idx), att);
}
void drawModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att)
@@ -873,10 +792,10 @@ void drawShortTrimMode(coord_t x, coord_t y, uint8_t fm, uint8_t idx, LcdFlags a
uint8_t mode = v.mode;
uint8_t p = v.mode >> 1;
if (mode == TRIM_MODE_NONE) {
putsChnLetter(x, y, idx+1, att);
putsChnLetter(x, y, idx, att);
}
else {
lcdDrawChar(x, y, '0'+p, att);
lcdDrawChar(x, y, '0' + p, att);
}
}
+1 -1
View File
@@ -126,7 +126,7 @@ void drawTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att=0);
void drawShortTrimMode(coord_t x, coord_t y, uint8_t mode, uint8_t idx, LcdFlags att);
#define putsChn(x, y, idx, att) drawSource(x, y, MIXSRC_CH1+idx-1, att)
#define putsChn(x, y, idx, att) drawSource(x, y, MIXSRC_FIRST_CH + idx - 1, att)
void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags attr);
void putsVolts(coord_t x, coord_t y, uint16_t volts, LcdFlags att);
+1
View File
@@ -70,6 +70,7 @@ void menuRadioTrainer(event_t event);
void menuRadioVersion(event_t event);
void menuRadioDiagKeys(event_t event);
void menuRadioDiagAnalogs(event_t event);
void menuRadioDiagFS(event_t event);
void menuRadioHardware(event_t event);
void menuRadioTools(event_t event);
void menuRadioSpectrumAnalyser(event_t event);
+3 -4
View File
@@ -20,6 +20,7 @@
*/
#include "opentx.h"
#include "hal/rotary_encoder.h"
void runPopupCurvePreset(event_t event)
{
@@ -122,9 +123,7 @@ void menuModelCurveOne(event_t event)
lcdDrawNumber(INDENT_WIDTH, 6*FH+1, 5+crv.points, LEFT|attr);
lcdDrawText(lcdLastRightPos, 6*FH+1, STR_PTS, attr);
if (attr) {
#if defined(ROTARY_ENCODER_NAVIGATION)
rotencSpeed = ROTENC_LOWSPEED;
#endif
rotaryEncoderResetAccel();
int8_t count = checkIncDecModel(event, crv.points, -3, 12); // 2pts - 17pts
if (checkIncDec_Ret) {
int8_t newPoints[MAX_POINTS_PER_CURVE];
@@ -174,7 +173,7 @@ void menuModelCurveOne(event_t event)
break;
#elif defined(NAVIGATION_XLITE)
case EVT_KEY_FIRST(KEY_ENTER):
if (IS_SHIFT_PRESSED()) {
if (keysGetState(KEY_SHIFT)) {
pushMenu(menuChannelsView);
killEvents(event);
}
@@ -118,7 +118,7 @@ void menuModelCustomScriptOne(event_t event)
scriptInputsOutputs[s_currIdx].inputsCount + 1) {
lcdDrawTextAlignedLeft(y, STR_OUTPUTS);
if (attr) {
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
} else if (i <= ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL +
scriptInputsOutputs[s_currIdx].inputsCount +
+1 -1
View File
@@ -262,7 +262,7 @@ void menuModelDisplay(event_t event)
}
}
if (attr && menuHorizontalPosition == NUM_LINE_ITEMS) {
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
}
break;
+33 -57
View File
@@ -111,15 +111,14 @@ void menuModelFlightModeOne(event_t event)
case ITEM_MODEL_FLIGHT_MODE_TRIMS:
lcdDrawTextAlignedLeft(y, STR_TRIMS);
for (uint8_t t = 0; t < NUM_STICKS; t++) {
drawTrimMode(MIXES_2ND_COLUMN + (t*2*FW), y, s_currIdx, t, menuHorizontalPosition == t ? attr : 0);
#if defined(NAVIGATION_9X)
if (s_editMode > 0 && attr && menuHorizontalPosition == t) {
#else
if (s_editMode >= 0 && attr && menuHorizontalPosition == t) {
#endif
trim_t & v = fm->trim[t];
v.mode = checkIncDec(event, v.mode==TRIM_MODE_NONE ? -1 : v.mode, -1, k==0 ? 0 : 2*MAX_FLIGHT_MODES-1, EE_MODEL, isTrimModeAvailable);
{
auto trims = keysGetMaxTrims();
for (uint8_t t = 0; t < trims; t++) {
drawTrimMode(MIXES_2ND_COLUMN + (t*2*FW), y, s_currIdx, t, menuHorizontalPosition == t ? attr : 0);
if (s_editMode > 0 && attr && menuHorizontalPosition == t) {
trim_t & v = fm->trim[t];
v.mode = checkIncDec(event, v.mode==TRIM_MODE_NONE ? -1 : v.mode, -1, k==0 ? 0 : 2*MAX_FLIGHT_MODES-1, EE_MODEL, isTrimModeAvailable);
}
}
}
break;
@@ -188,64 +187,41 @@ void menuModelFlightModeOne(event_t event)
void menuModelFlightModesAll(event_t event)
{
SIMPLE_MENU(STR_MENUFLIGHTMODES, menuTabModel, MENU_MODEL_FLIGHT_MODES, HEADER_LINE+MAX_FLIGHT_MODES+1);
SIMPLE_MENU(STR_MENUFLIGHTMODES, menuTabModel, MENU_MODEL_FLIGHT_MODES,
HEADER_LINE+MAX_FLIGHT_MODES+1);
int8_t sub = menuVerticalPosition - HEADER_LINE;
switch (event) {
case EVT_KEY_FIRST(KEY_ENTER):
if (sub == MAX_FLIGHT_MODES) {
s_editMode = 0;
trimsCheckTimer = 200; // 2 seconds
}
// no break
#if !defined(PCBX7)
case EVT_KEY_FIRST(KEY_RIGHT):
#endif
if (sub >= 0 && sub < MAX_FLIGHT_MODES) {
s_currIdx = sub;
pushMenu(menuModelFlightModeOne);
}
break;
// "Check trims" button
if (sub == MAX_FLIGHT_MODES && event == EVT_KEY_FIRST(KEY_ENTER)) {
s_editMode = 0;
trimsCheckTimer = 200; // 2 seconds
}
// Flight mode lines
if (sub >= 0 && sub < MAX_FLIGHT_MODES &&
(event == EVT_KEY_FIRST(KEY_ENTER) || event == EVT_KEY_FIRST(KEY_RIGHT))) {
s_currIdx = sub;
pushMenu(menuModelFlightModeOne);
}
uint8_t att;
for (uint8_t i=0; i<MAX_FLIGHT_MODES; i++) {
int8_t y = 1 + (1+i-menuVerticalOffset)*FH;
if (y<1*FH+1 || y>(LCD_LINES-1)*FH+1) continue;
att = (i==sub ? INVERS : 0);
FlightModeData * p = flightModeAddress(i);
drawFlightMode(0, y, i+1, att|(getFlightMode()==i ? BOLD : 0));
#if defined(PCBTARANIS)
for (uint8_t i = 0; i < MAX_FLIGHT_MODES; i++) {
int8_t y = 1 + (1 + i - menuVerticalOffset) * FH;
if (y < 1 * FH + 1 || y > (LCD_LINES - 1) * FH + 1) continue;
att = (i == sub ? INVERS : 0);
FlightModeData* p = flightModeAddress(i);
drawFlightMode(0, y, i + 1, att | (getFlightMode() == i ? BOLD : 0));
lcdDrawSizedText(NAME_POS, y, p->name, sizeof(p->name), 0);
#else
lcdDrawSizedText(4*FW+NAME_OFS, y, p->name, sizeof(p->name), 0);
#endif
if (i == 0) {
for (uint8_t t=0; t<NUM_STICKS; t++) {
#if defined(PCBTARANIS)
drawTrimMode(TRIMS_POS+t*FW*2, y, i, t, 0);
#else
drawShortTrimMode((9+LEN_FLIGHT_MODE_NAME+t)*FW+TRIMS_OFS, y, i, t, 0);
#endif
}
}
else {
#if defined(PCBTARANIS)
drawSwitch(SWITCH_POS, y, p->swtch, 0);
for (uint8_t t=0; t<NUM_STICKS; t++) {
drawTrimMode(TRIMS_POS+t*FW*2, y, i, t, 0);
}
#else
drawSwitch((4+LEN_FLIGHT_MODE_NAME)*FW+SWITCH_OFS, y, p->swtch, 0);
for (uint8_t t=0; t<NUM_STICKS; t++) {
drawShortTrimMode((9+LEN_FLIGHT_MODE_NAME+t)*FW+TRIMS_OFS, y, i, t, 0);
}
#endif
auto trims = min(keysGetMaxTrims(), (uint8_t)MAX_STICKS);
if (i > 0) drawSwitch(SWITCH_POS, y, p->swtch, 0);
for (uint8_t t = 0; t < trims; t++) {
drawTrimMode(TRIMS_POS + t * FW * 2, y, i, t, 0);
}
if (p->fadeIn || p->fadeOut) {
lcdDrawChar(LCD_W-FW, y, (p->fadeIn && p->fadeOut) ? '*' : (p->fadeIn ? 'I' : 'O'));
lcdDrawChar(LCD_W - FW, y,
(p->fadeIn && p->fadeOut) ? '*' : (p->fadeIn ? 'I' : 'O'));
}
}
+14 -6
View File
@@ -68,7 +68,7 @@ void menuModelExpoOne(event_t event)
killEvents(event);
}
#elif defined(NAVIGATION_XLITE)
if (event == EVT_KEY_FIRST(KEY_ENTER) && IS_SHIFT_PRESSED()) {
if (event == EVT_KEY_FIRST(KEY_ENTER) && keysGetState(KEY_SHIFT)) {
pushMenu(menuChannelsView);
killEvents(event);
}
@@ -159,12 +159,20 @@ void menuModelExpoOne(event_t event)
break;
case EXPO_FIELD_TRIM:
uint8_t notStick = (ed->srcRaw > MIXSRC_Ail);
int8_t trimSource = -ed->trimSource;
lcdDrawTextAlignedLeft(y, STR_TRIM);
lcdDrawTextAtIndex(EXPO_ONE_2ND_COLUMN, y, STR_VMIXTRIMS, (notStick && trimSource == 0) ? 0 : trimSource + 1, RIGHT | (menuHorizontalPosition==0 ? attr : 0));
if (attr)
ed->trimSource = -checkIncDecModel(event, trimSource, notStick ? TRIM_ON : -TRIM_OFF, -TRIM_LAST);
{
const char* trim_str = getTrimSourceLabel(ed->srcRaw, ed->trimSource);
LcdFlags flags = RIGHT | (menuHorizontalPosition==0 ? attr : 0);
lcdDrawText(EXPO_ONE_2ND_COLUMN, y, trim_str, flags);
if (attr) {
int8_t min = TRIM_ON;
if (ed->srcRaw >= MIXSRC_FIRST_STICK && ed->srcRaw <= MIXSRC_LAST_STICK) {
min = -TRIM_OFF;
}
ed->trimSource = -checkIncDecModel(event, -ed->trimSource, min, keysGetMaxTrims());
}
}
break;
}
y += FH;
@@ -60,7 +60,7 @@ void menuModelLogicalSwitchOne(event_t event)
LogicalSwitchData * cs = lswAddress(s_currIdx);
uint8_t sw = SWSRC_SW1+s_currIdx;
uint8_t sw = SWSRC_FIRST_LOGICAL_SWITCH+s_currIdx;
uint8_t cstate = lswFamily(cs->func);
drawSwitch(14*FW, 0, sw, (getSwitch(sw) ? BOLD : 0));
@@ -209,7 +209,7 @@ void menuModelLogicalSwitchOne(event_t event)
if (cstate == LS_FAMILY_EDGE) {
lcdDrawText(CSWONE_2ND_COLUMN, y, STR_NA);
if (attr) {
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
break;
}
@@ -285,7 +285,7 @@ void menuModelLogicalSwitches(event_t event)
LogicalSwitchData * cs = lswAddress(k);
// CSW name
uint8_t sw = SWSRC_SW1+k;
uint8_t sw = SWSRC_FIRST_LOGICAL_SWITCH+k;
drawSwitch(0, y, sw, (sub==k ? INVERS : 0) | (getSwitch(sw) ? BOLD : 0));
+1 -1
View File
@@ -99,7 +99,7 @@ void menuModelMixOne(event_t event)
killEvents(event);
}
#elif defined(NAVIGATION_XLITE)
if (event == EVT_KEY_FIRST(KEY_ENTER) && IS_SHIFT_PRESSED()) {
if (event == EVT_KEY_FIRST(KEY_ENTER) && keysGetState(KEY_SHIFT)) {
pushMenu(menuChannelsView);
killEvents(event);
}
+40 -47
View File
@@ -90,10 +90,35 @@ void onModelSelectMenu(const char * result)
#endif
}
static void moveToFreeModelSlot(bool forward, int8_t& sub, int8_t oldSub)
{
int8_t next_ofs = s_copyTgtOfs + oldSub - menuVerticalPosition;
if (next_ofs == MAX_MODELS || next_ofs == -MAX_MODELS) next_ofs = 0;
if (s_copySrcRow < 0 && s_copyMode == COPY_MODE) {
s_copySrcRow = oldSub;
// find a hole (in the first empty slot above / below)
sub = findEmptyModel(s_copySrcRow, forward);
if (sub < 0) {
// no free room for duplicating the model
AUDIO_ERROR();
sub = oldSub;
s_copyMode = 0;
}
next_ofs = 0;
menuVerticalPosition = sub;
}
s_copyTgtOfs = next_ofs;
}
void menuModelSelect(event_t event)
{
// Suppress "edit mode": model select has none
// Suppress exit in "copy mode": handled in this function
event_t _event_ = event;
if ((s_copyMode && IS_KEY_EVT(event, KEY_EXIT)) || event == EVT_KEY_BREAK(KEY_EXIT) || IS_ROTARY_BREAK(event) || IS_ROTARY_LONG(event)) {
if ((s_copyMode && IS_KEY_EVT(event, KEY_EXIT)) ||
event == EVT_KEY_BREAK(KEY_EXIT) || event == EVT_KEY_BREAK(KEY_ENTER) ||
event == EVT_KEY_LONG(KEY_ENTER)) {
_event_ = 0;
}
@@ -179,7 +204,9 @@ void menuModelSelect(event_t event)
s_copyMode = 0;
event = EVT_ENTRY_UP;
}
else if (event == EVT_KEY_LONG(KEY_ENTER) || IS_ROTARY_BREAK(event)) {
else if (event == EVT_KEY_BREAK(KEY_ENTER) ||
event == EVT_KEY_LONG(KEY_ENTER)) {
s_copyMode = 0;
killEvents(event);
if (g_eeGeneral.currModel != sub) {
@@ -232,57 +259,25 @@ void menuModelSelect(event_t event)
chainMenu(menuModelSetup);
break;
#else
#if defined(ROTARY_ENCODER_NAVIGATION)
case EVT_ROTARY_LEFT:
case EVT_ROTARY_RIGHT:
#endif
case EVT_KEY_FIRST(KEY_LEFT):
case EVT_KEY_FIRST(KEY_RIGHT):
#if defined(ROTARY_ENCODER_NAVIGATION)
if ((!IS_ROTARY_RIGHT(event) && !IS_ROTARY_LEFT(event)) || s_editMode < 0) {
#endif
if (sub == g_eeGeneral.currModel) {
chainMenu((IS_ROTARY_RIGHT(event) || event == EVT_KEY_FIRST(KEY_RIGHT)) ? menuModelSetup : menuTabModel[DIM(menuTabModel)-1].menuFunc);
}
else {
bool forward = (event == EVT_KEY_FIRST(KEY_RIGHT));
chainMenu(forward ? menuModelSetup
: menuTabModel[DIM(menuTabModel) - 1].menuFunc);
} else {
AUDIO_WARNING2();
}
break;
#if defined(ROTARY_ENCODER_NAVIGATION)
}
// no break
#endif
#endif
}
#if defined(ROTARY_ENCODER_NAVIGATION) && defined(NAVIGATION_X7)
case EVT_ROTARY_LEFT:
case EVT_ROTARY_RIGHT:
#endif
case EVT_KEY_FIRST(KEY_UP):
case EVT_KEY_REPT(KEY_UP):
case EVT_KEY_FIRST(KEY_DOWN):
case EVT_KEY_REPT(KEY_DOWN):
if (s_copyMode) {
int8_t next_ofs = s_copyTgtOfs + oldSub - menuVerticalPosition;
if (next_ofs == MAX_MODELS || next_ofs == -MAX_MODELS)
next_ofs = 0;
if (s_copySrcRow < 0 && s_copyMode==COPY_MODE) {
s_copySrcRow = oldSub;
// find a hole (in the first empty slot above / below)
sub = findEmptyModel(s_copySrcRow, IS_ROTARY_RIGHT(event) || event==EVT_KEY_FIRST(KEY_DOWN));
if (sub < 0) {
// no free room for duplicating the model
AUDIO_ERROR();
sub = oldSub;
s_copyMode = 0;
}
next_ofs = 0;
menuVerticalPosition = sub;
}
s_copyTgtOfs = next_ofs;
}
break;
if (s_copyMode) {
if (IS_PREVIOUS_EVENT(event)) {
moveToFreeModelSlot(false, sub, oldSub);
} else if (IS_NEXT_EVENT(event)) {
moveToFreeModelSlot(true, sub, oldSub);
}
}
#if defined(EEPROM)
@@ -295,8 +290,6 @@ void menuModelSelect(event_t event)
uint8_t sz = menuSize(menuTabModel, DIM(menuTabModel));
#if defined(NAVIGATION_X7)
drawScreenIndex(MENU_MODEL_SELECT, sz, 0);
#elif defined(ROTARY_ENCODER_NAVIGATION)
drawScreenIndex(MENU_MODEL_SELECT, sz, (sub == g_eeGeneral.currModel) ? ((IS_ROTARY_ENCODER_NAVIGATION_ENABLE() && s_editMode < 0) ? INVERS|BLINK : INVERS) : 0);
#else
drawScreenIndex(MENU_MODEL_SELECT, sz, (sub == g_eeGeneral.currModel) ? INVERS : 0);
#endif
+41 -36
View File
@@ -21,6 +21,9 @@
#include "opentx.h"
#include "mixer_scheduler.h"
#include "hal/adc_driver.h"
#include "hal/switch_driver.h"
#include "switches.h"
#if defined(USBJ_EX)
#include "usb_joystick.h"
@@ -44,18 +47,16 @@
uint8_t g_moduleIdx;
#if defined(PCBTARANIS)
uint8_t getSwitchWarningsCount()
{
uint8_t count = 0;
for (int i=0; i<NUM_SWITCHES - NUM_FUNCTIONS_SWITCHES; ++i) {
for (int i = 0; i < switchGetMaxSwitches(); ++i) {
if (SWITCH_WARNING_ALLOWED(i)) {
++count;
}
}
return count;
}
#endif
enum MenuModelSetupItems {
ITEM_MODEL_SETUP_NAME,
@@ -329,7 +330,7 @@ inline uint8_t TIMER_ROW(uint8_t timer, uint8_t value)
return HIDDEN_ROW;
}
#define POT_WARN_ROWS PREFLIGHT_ROW(((g_model.potsWarnMode) ? (uint8_t)(NUM_POTS+NUM_SLIDERS) : (uint8_t)0))
#define POT_WARN_ROWS PREFLIGHT_ROW(((g_model.potsWarnMode) ? adcGetMaxInputs(ADC_INPUT_POT) : (uint8_t)0))
#define TIMER_ROWS(x) \
1, TIMER_ROW(x,0), \
@@ -504,14 +505,9 @@ void editTimerCountdown(int timerIdx, coord_t y, LcdFlags attr, event_t event)
#define EXTERNAL_MODULE_ROWS
#endif
#if defined(PCBTARANIS)
#define WARN_ROWS \
SW_WARN_ROWS, /* Switch warning */ \
POT_WARN_ROWS, /* Pot warning */
#else
#define WARN_ROWS \
PREFLIGHT_ROW((NUM_SWITCHES - 1), /* Switch warning */
#endif
#define WARN_ROWS \
SW_WARN_ROWS, /* Switch warning */ \
POT_WARN_ROWS, /* Pot warning */
#if defined(USBJ_EX)
inline uint8_t USB_JOYSTICK_EXTROW()
@@ -585,7 +581,7 @@ void menuModelSetup(event_t event)
PREFLIGHT_ROW(0), // Custom position for throttle warning value
WARN_ROWS
NUM_STICKS + NUM_POTS + NUM_SLIDERS - 1, // Center beeps
uint8_t(NAVIGATION_LINE_BY_LINE | (adcGetInputOffset(ADC_INPUT_POT + 1) - 1)), // Center beeps
0, // ADC Jitter filter
@@ -795,7 +791,8 @@ void menuModelSetup(event_t event)
{
int index = k - ITEM_MODEL_SETUP_SW1;
int config = FSWITCH_CONFIG(index);
lcdDrawTextAtIndex(INDENT_WIDTH, y, STR_VSRCRAW, MIXSRC_FIRST_SWITCH + NUM_REGULAR_SWITCHES - MIXSRC_Rud + index + 1, menuHorizontalPosition < 0 ? attr : 0);
lcdDrawSizedText(INDENT_WIDTH, y, STR_CHAR_SWITCH, 2, menuHorizontalPosition < 0 ? attr : 0);
drawStringWithIndex(lcdNextPos, y, STR_FUNC_SW, index, menuHorizontalPosition < 0 ? attr : 0);
if (ZEXIST(g_model.switchNames[index]) || (attr && s_editMode > 0 && menuHorizontalPosition == 0))
editName(35, y, g_model.switchNames[index], LEN_SWITCH_NAME, event, menuHorizontalPosition == 0 ? attr : 0, 0, old_editMode);
else
@@ -822,7 +819,7 @@ void menuModelSetup(event_t event)
}
}
else if (attr && menuHorizontalPosition == 3) { // Non visible checkbox
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
break;
}
@@ -891,7 +888,7 @@ void menuModelSetup(event_t event)
if (attr)
CHECK_INCDEC_MODELVAR_ZERO_CHECK(
event, g_model.thrTraceSrc,
NUM_POTS + NUM_SLIDERS + MAX_OUTPUT_CHANNELS,
adcGetMaxInputs(ADC_INPUT_POT) + MAX_OUTPUT_CHANNELS,
isThrottleSourceAvailable);
uint8_t idx = throttleSource2Source(g_model.thrTraceSrc);
@@ -907,7 +904,7 @@ void menuModelSetup(event_t event)
case ITEM_MODEL_SETUP_THROTTLE_TRIM_SWITCH:
lcdDrawText(INDENT_WIDTH, y, STR_TTRIM_SW);
if (attr)
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.thrTrimSw, NUM_TRIMS - 1);
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.thrTrimSw, keysGetMaxTrims() - 1);
drawSource(MODEL_SETUP_2ND_COLUMN+20, y, g_model.getThrottleStickTrimSource(), attr);
break;
@@ -939,7 +936,7 @@ void menuModelSetup(event_t event)
case ITEM_MODEL_SETUP_SWITCHES_WARNING2:
if (i==0) {
if (CURSOR_MOVED_LEFT(event))
if (IS_PREVIOUS_EVENT(event))
menuVerticalOffset--;
else
menuVerticalOffset++;
@@ -948,13 +945,12 @@ void menuModelSetup(event_t event)
case ITEM_MODEL_SETUP_SWITCHES_WARNING1:
{
#define FIRSTSW_STR (&STR_VSRCRAW[MIXSRC_FIRST_SWITCH-MIXSRC_FIRST_STICK+1])
uint8_t switchWarningsCount = getSwitchWarningsCount();
//uint8_t length = STR_VSRCRAW[0];
horzpos_t l_posHorz = menuHorizontalPosition;
if (i>=NUM_BODY_LINES-2 && getSwitchWarningsCount() > MAX_SWITCH_PER_LINE*(NUM_BODY_LINES-i)) {
if (CURSOR_MOVED_LEFT(event))
if (IS_PREVIOUS_EVENT(event))
menuVerticalOffset--;
else
menuVerticalOffset++;
@@ -987,7 +983,7 @@ void menuModelSetup(event_t event)
getMovedSwitch();
// Mask switches enabled for warnings
swarnstate_t sw_mask = 0;
for(uint8_t i=0; i<NUM_SWITCHES; i++) {
for(uint8_t i = 0; i < switchGetMaxSwitches(); i++) {
if (SWITCH_WARNING_ALLOWED(i))
if (g_model.switchWarningState & (0x07 << (3 * i)))
sw_mask |= (0x07 << (3 * i));
@@ -1003,7 +999,7 @@ void menuModelSetup(event_t event)
}
int current = 0;
for (int i = 0; i < NUM_SWITCHES - NUM_FUNCTIONS_SWITCHES; i++) {
for (int i = 0; i < switchGetMaxSwitches(); i++) {
if (SWITCH_WARNING_ALLOWED(i)) {
div_t qr = div(current, MAX_SWITCH_PER_LINE);
if (!READ_ONLY() && event == EVT_KEY_BREAK(KEY_ENTER) && attr &&
@@ -1019,9 +1015,10 @@ void menuModelSetup(event_t event)
s_editMode = 0;
#endif
}
lcdDrawSizedText(
lcdDrawChar(
MODEL_SETUP_2ND_COLUMN + qr.rem * ((2 * FW) + 1),
y + FH * qr.quot, FIRSTSW_STR[i] + sizeof(STR_CHAR_SWITCH), 1,
y + FH * qr.quot, switchGetLetter(i),
attr && (menuHorizontalPosition == current) ? INVERS : 0);
lcdDrawText(lcdNextPos, y + FH * qr.quot,
getSwitchWarnSymbol(states & 0x03));
@@ -1066,30 +1063,38 @@ void menuModelSetup(event_t event)
}
if (g_model.potsWarnMode) {
coord_t x = MODEL_SETUP_2ND_COLUMN+28;
for (int i=0; i<NUM_POTS+NUM_SLIDERS; ++i) {
if (i<NUM_XPOTS && !IS_POT_SLIDER_AVAILABLE(POT1+i)) {
if (attr && (menuHorizontalPosition==i+1)) REPEAT_LAST_CURSOR_MOVE();
uint8_t max_pots = adcGetMaxInputs(ADC_INPUT_POT);
for (int i = 0; i < max_pots; ++i) {
if (!IS_POT_SLIDER_AVAILABLE(i)) {
// skip non configured pot
if (attr && (menuHorizontalPosition==i+1)) repeatLastCursorMove(event);
}
else {
LcdFlags flags = ((menuHorizontalPosition==i+1) && attr) ? BLINK : 0;
if ((!attr || menuHorizontalPosition >= 0) && (g_model.potsWarnEnabled & (1 << i))) {
if ((!attr || menuHorizontalPosition >= 0) &&
(g_model.potsWarnEnabled & (1 << i))) {
flags |= INVERS;
}
// skip "---" (+1) and source symbol (+2)
const char* source = STR_VSRCRAW[NUM_STICKS + 1 + i] + 2;
lcdDrawSizedText(x, y, source, UINT8_MAX, flags);
lcdDrawText(x, y, getPotLabel(i), flags);
x = lcdNextPos+3;
}
}
}
break;
case ITEM_MODEL_SETUP_BEEP_CENTER:
case ITEM_MODEL_SETUP_BEEP_CENTER: {
lcdDrawTextAlignedLeft(y, STR_BEEPCTR);
for (uint8_t i = 0; i < NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) {
uint8_t input_max = adcGetMaxInputs(ADC_INPUT_MAIN) + adcGetMaxInputs(ADC_INPUT_POT);
for (uint8_t i = 0; i < input_max; i++) {
coord_t x = MODEL_SETUP_2ND_COLUMN + i*FW;
lcdDrawTextAtIndex(x, y, STR_RETA123, i, ((menuHorizontalPosition==i) && attr) ? BLINK | INVERS : (((g_model.beepANACenter & ((BeepANACenter)1<<i)) || (attr && CURSOR_ON_LINE())) ? INVERS : 0 ) );
LcdFlags flags = 0;
if ((menuHorizontalPosition == i) && attr)
flags = BLINK | INVERS;
else if (ANALOG_CENTER_BEEP(x) || (attr && CURSOR_ON_LINE()))
flags = INVERS;
lcdDrawText(x, y, getAnalogShortLabel(i), flags);
}
if (attr) {
if (event == EVT_KEY_BREAK(KEY_ENTER)) {
@@ -1100,7 +1105,7 @@ void menuModelSetup(event_t event)
}
}
}
break;
} break;
case ITEM_MODEL_SETUP_USE_JITTER_FILTER:
g_model.jitterFilter = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_JITTER_FILTER, STR_ADCFILTERVALUES, g_model.jitterFilter, 0, 2, attr, event);
@@ -1970,7 +1975,7 @@ void menuModelSetup(event_t event)
if (isModuleTypeR9MLiteNonPro(module.type)) { // R9M lite FCC has only one power value, so displayed for info only
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_R9M_LITE_FCC_POWER_VALUES, 0, LEFT);
if (attr) {
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
}
else {
@@ -153,7 +153,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
#if defined(PCBTARANIS)
#if defined(PCBXLITE)
// ENT LONG on xlite brings up switch type menu, so this menu is activated with SHIFT + ENT LONG
if (menuHorizontalPosition==0 && event==EVT_KEY_LONG(KEY_ENTER) && IS_SHIFT_PRESSED() && !READ_ONLY()) {
if (menuHorizontalPosition==0 && event==EVT_KEY_LONG(KEY_ENTER) && keysGetState(KEY_SHIFT) && !READ_ONLY()) {
#else
if (menuHorizontalPosition<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) {
#endif
@@ -203,7 +203,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
case 1:
if (CFN_SWITCH(cfn)) {
lcdDrawTextAtIndex(MODEL_SPECIAL_FUNC_2ND_COLUMN, y, STR_VFSWFUNC, func, attr);
lcdDrawText(MODEL_SPECIAL_FUNC_2ND_COLUMN, y, funcGetLabel(func), attr);
if (active) {
CFN_FUNC(cfn) = checkIncDec(event, CFN_FUNC(cfn), 0, FUNC_MAX-1, eeFlags, isAssignableFunctionAvailable);
if (checkIncDec_Ret) CFN_RESET(cfn);
@@ -212,7 +212,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
else {
j = 4; // skip other fields
if (sub==k && menuHorizontalPosition > 0) {
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
}
break;
@@ -227,31 +227,31 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
else
#endif
if (func == FUNC_TRAINER) {
maxParam = NUM_STICKS + 1;
maxParam = MAX_STICKS + 1;
uint8_t param = CFN_CH_INDEX(cfn);
if (param == 0)
lcdDrawText(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, STR_STICKS, attr);
else if (param == NUM_STICKS + 1)
else if (param == MAX_STICKS + 1)
lcdDrawText(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, STR_CHANS, attr);
else
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, MIXSRC_Rud + param - 1, attr);
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, MIXSRC_FIRST_STICK + param - 1, attr);
}
#if defined(GVARS)
else if (func == FUNC_ADJUST_GVAR) {
maxParam = MAX_GVARS-1;
maxParam = MAX_GVARS - 1;
drawStringWithIndex(lcdNextPos + 2, y, STR_GV, CFN_GVAR_INDEX(cfn)+1, attr);
if (active) CFN_GVAR_INDEX(cfn) = checkIncDec(event, CFN_GVAR_INDEX(cfn), 0, maxParam, eeFlags);
break;
}
#endif // GVARS
else if (func == FUNC_SET_TIMER) {
maxParam = MAX_TIMERS-1;
maxParam = MAX_TIMERS - 1;
lcdDrawTextAtIndex(lcdNextPos, y, STR_VFSWRESET, CFN_TIMER_INDEX(cfn), attr);
if (active) CFN_TIMER_INDEX(cfn) = checkIncDec(event, CFN_TIMER_INDEX(cfn), 0, maxParam, eeFlags);
break;
}
else if (attr) {
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_CH_INDEX(cfn), maxParam);
break;
@@ -406,7 +406,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
}
#endif // GVARS
else if (attr) {
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
#if defined(NAVIGATION_X7)
if (active || event==EVT_KEY_LONG(KEY_ENTER)) {
@@ -456,7 +456,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
}
}
else if (attr) {
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
break;
}
+1 -169
View File
@@ -21,175 +21,7 @@
#include "opentx.h"
#include "hal/adc_driver.h"
#define XPOT_DELTA 10
#define XPOT_DELAY 10 /* cycles */
void menuCommonCalib(event_t event)
{
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) { // get low and high values for sticks, pots and sliders
int16_t vt = anaIn(i);
reusableBuffer.calib.loVals[i] = min(vt, reusableBuffer.calib.loVals[i]);
reusableBuffer.calib.hiVals[i] = max(vt, reusableBuffer.calib.hiVals[i]);
if (i >= POT1 && i <= POT_LAST) {
if (IS_POT_WITHOUT_DETENT(i)) {
reusableBuffer.calib.midVals[i] = (reusableBuffer.calib.hiVals[i] + reusableBuffer.calib.loVals[i]) / 2;
}
#if defined(PCBTARANIS)
uint8_t idx = i - POT1;
int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount;
if (IS_POT_MULTIPOS(i) && count <= XPOTS_MULTIPOS_COUNT) {
// use raw analog value for multipos calibraton, anaIn() already has multipos decoded value
vt = getAnalogValue(i) >> 1;
if (reusableBuffer.calib.xpotsCalib[idx].lastCount == 0 ||
vt < reusableBuffer.calib.xpotsCalib[idx].lastPosition - XPOT_DELTA ||
vt > reusableBuffer.calib.xpotsCalib[idx].lastPosition + XPOT_DELTA) {
reusableBuffer.calib.xpotsCalib[idx].lastPosition = vt;
reusableBuffer.calib.xpotsCalib[idx].lastCount = 1;
}
else {
if (reusableBuffer.calib.xpotsCalib[idx].lastCount < 255)
reusableBuffer.calib.xpotsCalib[idx].lastCount++;
}
if (reusableBuffer.calib.xpotsCalib[idx].lastCount == XPOT_DELAY) {
int16_t position = reusableBuffer.calib.xpotsCalib[idx].lastPosition;
bool found = false;
for (int j=0; j<count; j++) {
int16_t step = reusableBuffer.calib.xpotsCalib[idx].steps[j];
if (position >= step-XPOT_DELTA && position <= step+XPOT_DELTA) {
found = true;
break;
}
}
if (!found) {
if (count < XPOTS_MULTIPOS_COUNT) {
reusableBuffer.calib.xpotsCalib[idx].steps[count] = position;
}
reusableBuffer.calib.xpotsCalib[idx].stepsCount += 1;
}
}
}
#endif
}
}
menuCalibrationState = reusableBuffer.calib.state; // make sure we don't scroll while calibrating
switch (event) {
case EVT_ENTRY:
case EVT_KEY_BREAK(KEY_EXIT):
reusableBuffer.calib.state = CALIB_START;
break;
case EVT_KEY_BREAK(KEY_ENTER):
reusableBuffer.calib.state++;
break;
}
switch (reusableBuffer.calib.state) {
case CALIB_START:
// START CALIBRATION
if (!READ_ONLY()) {
lcdDrawTextAlignedLeft(MENU_HEADER_HEIGHT+2*FH, STR_MENUTOSTART);
}
break;
case CALIB_SET_MIDPOINT:
// SET MIDPOINT
lcdDrawText(0*FW, MENU_HEADER_HEIGHT+FH, STR_SETMIDPOINT, INVERS);
lcdDrawTextAlignedLeft(MENU_HEADER_HEIGHT+2*FH, STR_MENUWHENDONE);
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) {
reusableBuffer.calib.loVals[i] = 15000;
reusableBuffer.calib.hiVals[i] = -15000;
#if defined(PCBTARANIS)
#if defined(FLYSKY_GIMBAL)
if (globalData.flyskygimbals && (i < FIRST_ANALOG_ADC_FS) )
{
reusableBuffer.calib.midVals[i] = anaIn(i);
}
else
#endif
{
reusableBuffer.calib.midVals[i] = getAnalogValue(i) >> 1;
}
if (i<NUM_XPOTS) {
reusableBuffer.calib.xpotsCalib[i].stepsCount = 0;
reusableBuffer.calib.xpotsCalib[i].lastCount = 0;
}
#else
reusableBuffer.calib.midVals[i] = anaIn(i);
#endif
}
break;
case CALIB_MOVE_STICKS:
// MOVE STICKS/POTS
lcdDrawText(0*FW, MENU_HEADER_HEIGHT+FH, STR_MOVESTICKSPOTS, INVERS);
lcdDrawTextAlignedLeft(MENU_HEADER_HEIGHT+2*FH, STR_MENUWHENDONE);
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) {
if (abs(reusableBuffer.calib.loVals[i]-reusableBuffer.calib.hiVals[i]) > 50) {
g_eeGeneral.calib[i].mid = reusableBuffer.calib.midVals[i];
int16_t v = reusableBuffer.calib.midVals[i] - reusableBuffer.calib.loVals[i];
g_eeGeneral.calib[i].spanNeg = v - v/STICK_TOLERANCE;
v = reusableBuffer.calib.hiVals[i] - reusableBuffer.calib.midVals[i];
g_eeGeneral.calib[i].spanPos = v - v/STICK_TOLERANCE;
}
}
#if defined(PCBTARANIS)
for (uint8_t i=POT1; i<=POT_LAST; i++) {
int idx = i - POT1;
int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount;
if (IS_POT_MULTIPOS(i)) {
if (count > 1 && count <= XPOTS_MULTIPOS_COUNT) {
for (int j=0; j<count; j++) {
for (int k=j+1; k<count; k++) {
if (reusableBuffer.calib.xpotsCalib[idx].steps[k] < reusableBuffer.calib.xpotsCalib[idx].steps[j]) {
SWAP(reusableBuffer.calib.xpotsCalib[idx].steps[j], reusableBuffer.calib.xpotsCalib[idx].steps[k]);
}
}
}
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[i];
calib->count = count - 1;
for (int j=0; j<calib->count; j++) {
calib->steps[j] = (reusableBuffer.calib.xpotsCalib[idx].steps[j+1] + reusableBuffer.calib.xpotsCalib[idx].steps[j]) >> 5;
}
}
}
}
#endif
break;
case CALIB_STORE:
#if defined(RADIO_BOXER)
for (uint8_t i=POT1; i<=POT_LAST; i++) {
int idx = i - POT1;
if (IS_POT_MULTIPOS(i)) {
int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount;
if (count < XPOTS_MULTIPOS_COUNT)
{
// load 6-pos calib with factory data if 6-pos was not manually calibrated
constexpr int16_t factoryValues[]= {0x5,0xd,0x16,0x1f,0x28};
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[POT3];
calib->count = 5;
for (int j=0; j<calib->count ; j++) {
calib->steps[j] = factoryValues[j];
}
}
}
}
#endif
g_eeGeneral.chkSum = evalChkSum();
storageDirty(EE_GENERAL);
reusableBuffer.calib.state = CALIB_FINISHED;
break;
default:
reusableBuffer.calib.state = CALIB_START;
break;
}
doMainScreenGraphics();
}
#include "gui/common/stdlcd/calibration.h"
void menuRadioCalibration(event_t event)
{
+9 -27
View File
@@ -20,18 +20,14 @@
*/
#include "opentx.h"
#include "../../hal/adc_driver.h"
#if defined(FLYSKY_GIMBAL)
#include "flysky_gimbal_driver.h"
#endif
#include "hal/adc_driver.h"
#define HOLDANAVALUEFRAMES 4 /* 4* 50ms = 200 ms update rate */
void menuRadioDiagAnalogs(event_t event)
{
static int8_t entryCount = 0;
static int16_t lastShownAnalogValue[NUM_STICKS+NUM_POTS+NUM_SLIDERS];
static uint16_t lastShownAnalogValue[MAX_ANALOG_INPUTS];
enum ANAVIEWS{
ANAVIEW_FIRST,
@@ -50,12 +46,9 @@ void menuRadioDiagAnalogs(event_t event)
#endif
switch (event) {
case EVT_KEY_FIRST(KEY_UP):
#if defined(KEYS_GPIO_REG_PAGEDN)
case EVT_KEY_FIRST(KEY_RIGHT):
case EVT_KEY_BREAK(KEY_PAGEDN):
#elif defined(NAVIGATION_X7)
case EVT_KEY_BREAK(KEY_PAGE):
#endif
{
if (viewpage == ANAVIEW_LAST)
viewpage = ANAVIEW_FIRST;
@@ -65,12 +58,9 @@ void menuRadioDiagAnalogs(event_t event)
break;
}
case EVT_KEY_FIRST(KEY_DOWN):
#if defined(KEYS_GPIO_REG_PAGEUP)
case EVT_KEY_FIRST(KEY_LEFT):
case EVT_KEY_BREAK(KEY_PAGEUP):
#elif defined(NAVIGATION_X7)
case EVT_KEY_LONG(KEY_PAGE):
#endif
{
if (viewpage == ANAVIEW_FIRST)
viewpage = ANAVIEW_LAST;
@@ -94,10 +84,10 @@ void menuRadioDiagAnalogs(event_t event)
coord_t y = MENU_HEADER_HEIGHT + 1;
lcdDrawTextAlignedLeft(y, STICKS_PWM_ENABLED() ? STR_PWM_STICKS_POTS_SLIDERS
: STR_STICKS_POTS_SLIDERS);
lcdDrawTextAlignedLeft(y, STR_STICKS_POTS_SLIDERS);
for (uint8_t i = 0; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
for (uint8_t i = 0; i < adcGetMaxInputs(ADC_INPUT_ALL); i++) {
// TODO: if available
uint8_t x;
if (i & 1) {
x = LCD_W / 2 + INDENT_WIDTH;
@@ -110,15 +100,7 @@ void menuRadioDiagAnalogs(event_t event)
switch (viewpage) {
case (ANAVIEW_RAWLOWFPS):
if (entryCount == 0) {
#if !defined(SIMU) && defined(FLYSKY_GIMBAL)
if (globalData.flyskygimbals && i < FIRST_ANALOG_ADC_FS)
{
lastShownAnalogValue[i] = hall_raw_values[i];
} else
#endif
{
lastShownAnalogValue[i] = getAnalogValue(i); // Update value
}
lastShownAnalogValue[i] = getAnalogValue(i); // Update value
}
lcdDrawNumber(x+3*FW-1, y, lastShownAnalogValue[i],
LEADING0|LEFT, 4);
@@ -129,7 +111,7 @@ void menuRadioDiagAnalogs(event_t event)
break;
}
lcdDrawNumber(x+10*FW-1, y,
(int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256,
(int16_t)calibratedAnalogs[i]*25/256,
RIGHT);
}
+65 -39
View File
@@ -20,18 +20,56 @@
*/
#include "opentx.h"
#include "hal/rotary_encoder.h"
#include "hal/switch_driver.h"
#include "hal/key_driver.h"
#include "switches.h"
void displayKeyState(uint8_t x, uint8_t y, uint8_t key)
{
uint8_t t = keys[key].state();
uint8_t t = keysGetState(key);
lcdDrawChar(x, y, t+'0', t ? INVERS : 0);
}
#if !defined(PCBTARANIS)
void displaySwitchState(uint8_t x, uint8_t y, uint8_t sw)
void displayTrimState(uint8_t x, uint8_t y, uint8_t trim)
{
swsrc_t t = switchState(sw);
lcdDrawChar(x, y, (t ? '1' : '0'), t ? INVERS : 0);
uint8_t t = keysGetTrimState(trim);
lcdDrawChar(x, y, t+'0', t ? INVERS : 0);
}
static EnumKeys get_ith_key(uint8_t i)
{
auto supported_keys = keysGetSupported();
for (uint8_t k = 0; k < MAX_KEYS; k++) {
if (supported_keys & (1 << k)) {
if (i-- == 0) return (EnumKeys)k;
}
}
// should not get here,
// we assume: i < keysGetMaxKeys()
return (EnumKeys)0;
}
#if defined(FUNCTION_SWITCHES)
void menuRadioDiagFS(event_t event)
{
constexpr coord_t FS_1ST_COLUMN = 40;
constexpr coord_t FS_2ND_COLUMN = 70;
constexpr coord_t FS_3RD_COLUMN = 100;
SIMPLE_SUBMENU(STR_MENU_FSWITCH, 1);
lcdDrawText(FS_1ST_COLUMN, MENU_HEADER_HEIGHT + 1, "Phys");
lcdDrawText(FS_2ND_COLUMN, MENU_HEADER_HEIGHT + 1, "Log");
lcdDrawText(FS_3RD_COLUMN, MENU_HEADER_HEIGHT + 1, "Led");
for(uint8_t i=0; i < NUM_FUNCTIONS_SWITCHES; i++) {
coord_t y = 2*FH + i*FH;
lcdDrawText(INDENT_WIDTH, y, STR_CHAR_SWITCH, 0);
lcdDrawText(lcdNextPos, y, switchGetName(i+switchGetMaxSwitches()), 0);
lcdDrawNumber(FS_1ST_COLUMN + 2, y, getFSPhysicalState(i));
lcdDrawNumber(FS_2ND_COLUMN + 5, y, getFSLogicalState(i));
lcdDrawNumber(FS_3RD_COLUMN + 5, y, getFSLedState(i));
}
}
#endif
@@ -41,62 +79,50 @@ void menuRadioDiagKeys(event_t event)
lcdDrawText(14*FW, MENU_HEADER_HEIGHT + 1, STR_VTRIM);
for (uint8_t i=0; i<10; i++) {
for (uint8_t i = 0; i < 10; i++) {
coord_t y;
if (i < NUM_TRIMS_KEYS) {
y = MENU_HEADER_HEIGHT + 1 + FH + FH*(i/2);
if (i&1) lcdDraw1bitBitmap(14*FW, y, sticks, i/2, 0);
displayKeyState(i&1? 20*FW : 18*FW, y, TRM_BASE+i);
if (i < keysGetMaxTrims() * 2) {
y = MENU_HEADER_HEIGHT + 1 + FH + FH * (i / 2);
if (i & 1) lcdDraw1bitBitmap(14 * FW, y, sticks, i / 2, 0);
displayTrimState(i & 1 ? 20 * FW : 18 * FW, y, i);
}
if (i <= KEY_MAX) {
if (i == 7) { // T8 8th key???
if (i < keysGetMaxKeys()) {
auto k = get_ith_key(i);
if (i >= 7) { // max 7 lines on display
y = MENU_HEADER_HEIGHT + 1 + FH * 6;
lcdDrawTextAtIndex(8, y, STR_VKEYS, i, 0);
lcdDrawText(8, y, keysGetLabel(k), 0);
displayKeyState(lcdNextPos + 10, y, i);
}
else {
y = MENU_HEADER_HEIGHT + 1 + FH * i;
lcdDrawTextAtIndex(0, y, STR_VKEYS, i, 0);
lcdDrawText(0, y, keysGetLabel(k), 0);
displayKeyState(5 * FW + 2, y, i);
}
}
#if (NUM_SWITCHES > 6)
if (i < NUM_SWITCHES) {
if (i < switchGetMaxSwitches()) {
if (SWITCH_EXISTS(i)) {
y = (i > 4) ? FH*(i-4)+1 : MENU_HEADER_HEIGHT + FH*i + 1;
getvalue_t val = getValue(MIXSRC_FIRST_SWITCH+i);
getvalue_t sw = ((val < 0) ? 3*i+1 : ((val == 0) ? 3*i+2 : 3*i+3));
drawSwitch(i > 4 ? 11*FW-5: 8*FW-9, y, sw, 0, false);
y = (i > 4) ? FH * (i - 4) + 1 : MENU_HEADER_HEIGHT + FH * i + 1;
getvalue_t val = getValue(MIXSRC_FIRST_SWITCH + i);
getvalue_t sw =
((val < 0) ? 3 * i + 1 : ((val == 0) ? 3 * i + 2 : 3 * i + 3));
drawSwitch(i > 4 ? 11 * FW - 5 : 8 * FW - 9, y, sw, 0, false);
}
}
#else
if (i < NUM_SWITCHES) {
if (SWITCH_EXISTS(i)) {
y = (NUM_SWITCHES - NUM_FUNCTIONS_SWITCHES > 6 ? 0 : MENU_HEADER_HEIGHT) + FH*i;
getvalue_t val = getValue(MIXSRC_FIRST_SWITCH+i);
getvalue_t sw = ((val < 0) ? 3*i+1 : ((val == 0) ? 3*i+2 : 3*i+3));
drawSwitch(8*FW+4, y, sw, 0);
}
}
#endif
}
#if defined(FUNCTION_SWITCHES) && defined(DEBUG)
lcdDrawText(LCD_W / 2 , LCD_H - 2 * FH, "Phys");
lcdDrawText(LCD_W / 2 , LCD_H - 1 * FH, "Log");
for (uint8_t i = 0; i < NUM_FUNCTIONS_SWITCHES; i++) {
lcdDrawNumber(LCD_W / 2 + 20 + (i + 1) * FW , LCD_H - 2 * FH, getFSPhysicalState(i));
lcdDrawNumber(LCD_W / 2 + 20 + (i + 1) * FW , LCD_H - 1 * FH, getFSLogicalState(i));
}
#if defined(AUTOSWITCH)
lcdDrawText(13*FW+FWNUM, LCD_H - FH + 1,"Last");
swsrc_t swtch = getMovedSwitch();
if (swtch)
drawSwitch(17*FW+FWNUM+2, LCD_H - FH + 1, swtch, 0);
#endif
#if defined(ROTARY_ENCODER_NAVIGATION)
coord_t y = LCD_H - FH + 1;
lcdDrawText(8*FW-9, y, STR_ROTARY_ENCODER);
lcdDrawNumber(12*FW+FWNUM+2, y, rotencValue / ROTARY_ENCODER_GRANULARITY, RIGHT);
lcdDrawNumber(12*FW+FWNUM+2, y, rotaryEncoderGetValue(), RIGHT);
#endif
}
+49 -42
View File
@@ -23,6 +23,8 @@
#include "opentx.h"
#include "tasks/mixer_task.h"
#include "hal/adc_driver.h"
#include "input_mapping.h"
const unsigned char sticks[] = {
#include "sticks.lbm"
@@ -48,6 +50,12 @@ const unsigned char sticks[] = {
#define CASE_BATTGRAPH(x)
#endif
#if !defined(SURFACE_RTADIO)
#define CASE_TX_MODE(x) x,
#else
#define CASE_TX_MODE(x)
#endif
enum {
CASE_RTCLOCK(ITEM_RADIO_SETUP_DATE)
CASE_RTCLOCK(ITEM_RADIO_SETUP_TIME)
@@ -104,8 +112,10 @@ enum {
CASE_JACK_DETECT(ITEM_RADIO_SETUP_JACK_MODE)
ITEM_RADIO_SETUP_RX_CHANNEL_ORD,
CASE_ROTARY_ENCODER(ITEM_RADIO_SETUP_ROTARY_ENC_MODE)
#if !defined(SURFACE_RADIO)
ITEM_RADIO_SETUP_STICK_MODE_LABELS,
ITEM_RADIO_SETUP_STICK_MODE,
#endif
ITEM_VIEW_OPTIONS_LABEL,
ITEM_VIEW_OPTIONS_RADIO_TAB,
ITEM_VIEW_OPTIONS_GF,
@@ -121,12 +131,6 @@ enum {
ITEM_RADIO_SETUP_MAX
};
#if defined(FRSKY_STICKS) && !defined(PCBTARANIS)
#define COL_TX_MODE 0
#else
#define COL_TX_MODE LABEL(TX_MODE)
#endif
uint8_t viewOptCheckBox(coord_t y, const char* title, uint8_t value, uint8_t attr, event_t event)
{
lcdDrawText(INDENT_WIDTH, y, title);
@@ -139,9 +143,11 @@ void menuRadioSetup(event_t event)
struct gtm t;
gettime(&t);
if ((menuVerticalPosition==ITEM_RADIO_SETUP_DATE+HEADER_LINE || menuVerticalPosition==ITEM_RADIO_SETUP_TIME+HEADER_LINE) &&
(s_editMode>0) &&
(event==EVT_KEY_FIRST(KEY_ENTER) || event==EVT_KEY_FIRST(KEY_EXIT) || IS_ROTARY_BREAK(event) || IS_ROTARY_LONG(event))) {
if ((menuVerticalPosition == ITEM_RADIO_SETUP_DATE + HEADER_LINE ||
menuVerticalPosition == ITEM_RADIO_SETUP_TIME + HEADER_LINE) &&
(s_editMode > 0) &&
(event == EVT_KEY_FIRST(KEY_ENTER) || event == EVT_KEY_LONG(KEY_ENTER) ||
event == EVT_KEY_FIRST(KEY_EXIT))) {
// set the date and time into RTC chip
rtcSetTime(&t);
}
@@ -198,7 +204,9 @@ void menuRadioSetup(event_t event)
0, // USB mode
CASE_JACK_DETECT(0) // Jack mode
CASE_ROTARY_ENCODER(0)
0, COL_TX_MODE, 0,
0,
CASE_TX_MODE(LABEL(TX_MODE))
CASE_TX_MODE(0)
LABEL(ViewOptions), LABEL(RadioMenuTabs), 0, 0, LABEL(ModelMenuTabs), CASE_HELI(0) CASE_FLIGHT_MODES(0) 0, 0, 0, CASE_LUA_MODEL_SCRIPTS(0) 0,
1/*to force edit mode*/});
@@ -661,31 +669,47 @@ void menuRadioSetup(event_t event)
case ITEM_RADIO_SETUP_RX_CHANNEL_ORD:
lcdDrawTextAlignedLeft(y, STR_DEF_CHAN_ORD); // RAET->AETR
for (uint8_t i=1; i<=4; i++) {
putsChnLetter(RADIO_SETUP_2ND_COLUMN - FW + i*FW, y, channelOrder(i), attr);
{
for (uint8_t i = 0; i < adcGetMaxInputs(ADC_INPUT_MAIN); i++) {
putsChnLetter(RADIO_SETUP_2ND_COLUMN + i*FW, y, inputMappingChannelOrder(i), attr);
}
if (attr) {
auto max_order = inputMappingGetMaxChannelOrder() - 1;
CHECK_INCDEC_GENVAR(event, g_eeGeneral.templateSetup, 0, max_order);
}
}
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.templateSetup, 0, 23);
break;
#if !defined(SURFACE_RADIO)
case ITEM_RADIO_SETUP_STICK_MODE_LABELS:
lcdDrawTextAlignedLeft(y, STR_MODE);
for (uint8_t i=0; i<4; i++) {
lcdDraw1bitBitmap(5*FW+i*(4*FW+2), y, sticks, i, 0);
#if defined(FRSKY_STICKS) && !defined(PCBTARANIS)
if (g_eeGeneral.stickReverse & (1<<i)) {
lcdDrawFilledRect(5*FW+i*(4*FW+2), y, 3*FW, FH-1);
}
#endif
}
#if defined(FRSKY_STICKS) && !defined(PCBTARANIS)
if (attr) {
s_editMode = 0;
CHECK_INCDEC_GENVAR(event, g_eeGeneral.stickReverse, 0, 15);
lcdDrawRect(5*FW-1, y-1, 16*FW+2, 9);
}
#endif
break;
case ITEM_RADIO_SETUP_STICK_MODE:
lcdDrawChar(2*FW, y, '1'+reusableBuffer.generalSettings.stickMode, attr);
{
auto controls = adcGetMaxInputs(ADC_INPUT_MAIN);
auto mode = reusableBuffer.generalSettings.stickMode;
for (uint8_t i = 0; i < controls; i++) {
source_t src = MIXSRC_FIRST_STICK + inputMappingConvertMode(mode, i);
drawSource((5 * FW - 3) + i * (4 * FW + 2), y, src, 0);
}
}
if (attr && s_editMode > 0) {
CHECK_INCDEC_GENVAR(event, reusableBuffer.generalSettings.stickMode, 0, 3);
} else if (reusableBuffer.generalSettings.stickMode !=
g_eeGeneral.stickMode) {
mixerTaskStop();
g_eeGeneral.stickMode = reusableBuffer.generalSettings.stickMode;
checkThrottleStick();
mixerTaskStart();
waitKeysReleased();
}
break;
#endif
#if defined(ROTARY_ENCODER_NAVIGATION)
case ITEM_RADIO_SETUP_ROTARY_ENC_MODE:
lcdDrawTextAlignedLeft(y, STR_ROTARY_ENC_MODE);
@@ -705,23 +729,6 @@ void menuRadioSetup(event_t event)
break;
#endif
case ITEM_RADIO_SETUP_STICK_MODE:
lcdDrawChar(2*FW, y, '1'+reusableBuffer.generalSettings.stickMode, attr);
for (uint8_t i=0; i<NUM_STICKS; i++) {
drawSource((5*FW-3)+i*(4*FW+2), y, MIXSRC_Rud + *(modn12x3 + 4*reusableBuffer.generalSettings.stickMode + i), 0);
}
if (attr && s_editMode>0) {
CHECK_INCDEC_GENVAR(event, reusableBuffer.generalSettings.stickMode, 0, 3);
}
else if (reusableBuffer.generalSettings.stickMode != g_eeGeneral.stickMode) {
mixerTaskStop();
g_eeGeneral.stickMode = reusableBuffer.generalSettings.stickMode;
checkThrottleStick();
mixerTaskStart();
waitKeysReleased();
}
break;
case ITEM_VIEW_OPTIONS_LABEL:
lcdDrawTextAlignedLeft(y, STR_ENABLED_FEATURES);
break;
+150 -103
View File
@@ -20,6 +20,11 @@
*/
#include "opentx.h"
#include "hal/adc_driver.h"
#include "hal/switch_driver.h"
#include "switches.h"
#include "input_mapping.h"
#define BIGSIZE DBLSIZE
#if defined (PCBTARANIS)
@@ -76,38 +81,58 @@ void drawExternalAntennaAndRSSI()
void drawPotsBars()
{
// Optimization by Mike Blandford
for (uint8_t x = LCD_W / 2 - (NUM_POTS + NUM_SLIDERS - 1) * 5 / 2 - 1, i = NUM_STICKS; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; x += 5, i++) {
uint8_t max_pots = adcGetMaxInputs(ADC_INPUT_POT);
uint8_t offset = adcGetInputOffset(ADC_INPUT_POT);
uint8_t configured_pots = 0;
for (uint8_t i = 0; i < max_pots; i++) {
if (IS_POT_SLIDER_AVAILABLE(i)) {
uint8_t len = ((calibratedAnalogs[i] + RESX) * BAR_HEIGHT / (RESX * 2)) + 1l; // calculate once per loop
V_BAR(x, LCD_H - 8, len);
configured_pots ++;
}
}
uint8_t lines = configured_pots > 3 ? 2 : 1;
uint8_t cols = configured_pots > 4 ? 3 : configured_pots % 2 ? 3 : 2;
coord_t xstart = LCD_W / 2 - (cols % 2 ? 5 : 3);
for (uint8_t i = 0; i < max_pots; i++) {
if (IS_POT_SLIDER_AVAILABLE(i)) {
coord_t x = xstart + (i % cols) * 5;
coord_t y = i >= cols ? (LCD_H - 8 - BAR_HEIGHT / 2) : (LCD_H - 8);
auto v = calibratedAnalogs[offset + i] + RESX;
uint8_t len = (v * BAR_HEIGHT / (RESX * 2 * lines)) + 1l;
V_BAR(x, y, len);
}
}
}
void doMainScreenGraphics()
{
int16_t calibStickVert = calibratedAnalogs[CONVERT_MODE(1)];
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
#if defined(SURFACE_RADIO)
drawWheel(LBOX_CENTERX, calibratedAnalogs[ADC_MAIN_ST]);
drawThrottle(RBOX_CENTERX, calibratedAnalogs[ADC_MAIN_TH]);
#else
int16_t calibStickVert = calibratedAnalogs[ADC_MAIN_LV];
if (g_model.throttleReversed && inputMappingConvertMode(ADC_MAIN_LV) == THR_STICK)
calibStickVert = -calibStickVert;
drawStick(LBOX_CENTERX, calibratedAnalogs[CONVERT_MODE(0)], calibStickVert);
drawStick(LBOX_CENTERX, calibratedAnalogs[ADC_MAIN_LH], calibStickVert);
calibStickVert = calibratedAnalogs[CONVERT_MODE(2)];
if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK)
calibStickVert = calibratedAnalogs[ADC_MAIN_RV];
if (g_model.throttleReversed && inputMappingConvertMode(ADC_MAIN_RV) == THR_STICK)
calibStickVert = -calibStickVert;
drawStick(RBOX_CENTERX, calibratedAnalogs[CONVERT_MODE(3)], calibStickVert);
#if defined(HARDWARE_POT1)
drawPotsBars();
drawStick(RBOX_CENTERX, calibratedAnalogs[ADC_MAIN_RH], calibStickVert);
#endif
drawPotsBars();
}
void displayTrims(uint8_t phase)
{
for (uint8_t i = 0; i < 4; i++) {
static coord_t x[4] = {TRIM_LH_X, TRIM_LV_X, TRIM_RV_X, TRIM_RH_X};
static uint8_t vert[4] = {0, 1, 1, 0};
for (uint8_t i = 0; i < keysGetMaxTrims(); i++) {
static coord_t x[] = {TRIM_LH_X, TRIM_LV_X, TRIM_RV_X, TRIM_RH_X, TRIM_LH_X, TRIM_LV_X, TRIM_RH_X, TRIM_RV_X};
static uint8_t vert[] = {0, 1, 1, 0, 0, 1, 0, 1};
coord_t xm, ym;
uint8_t stickIndex = CONVERT_MODE(i);
uint8_t stickIndex = inputMappingConvertMode(i);
xm = x[stickIndex];
uint8_t att = ROUND;
int16_t val = getTrimValue(phase, i);
@@ -132,51 +157,91 @@ void displayTrims(uint8_t phase)
if (vert[i]) {
ym = 31;
lcdDrawSolidVerticalLine(xm, ym - TRIM_LEN, TRIM_LEN * 2 + 1);
if (i != 2 || !g_model.thrTrim) {
lcdDrawSolidVerticalLine(xm - 1, ym - 1, 3);
lcdDrawSolidVerticalLine(xm + 1, ym - 1, 3);
if (i < 4)
lcdDrawSolidVerticalLine(xm, ym - TRIM_LEN, TRIM_LEN * 2 + 1);
if (keysGetMaxTrims() <= 4) {
if (i != 2 || !g_model.thrTrim) {
lcdDrawSolidVerticalLine(xm - 1, ym - 1, 3);
lcdDrawSolidVerticalLine(xm + 1, ym - 1, 3);
}
ym -= val;
lcdDrawFilledRect(xm - 3, ym - 3, 7, 7, SOLID, att | ERASE);
if (dir >= 0) {
lcdDrawSolidHorizontalLine(xm - 1, ym - 1, 3);
}
if (dir <= 0) {
lcdDrawSolidHorizontalLine(xm - 1, ym + 1, 3);
}
if (exttrim) {
lcdDrawSolidHorizontalLine(xm - 1, ym, 3);
}
if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && dir != 0) {
if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS ||
(trimsDisplayTimer > 0 && (trimsDisplayMask & (1 << i)))) {
lcdDrawNumber(dir > 0 ? 12 : 40, xm - 2, -abs(dir),
TINSIZE | VERTICAL);
}
}
lcdDrawSquare(xm - 3, ym - 3, 7, att);
}
ym -= val;
lcdDrawFilledRect(xm - 3, ym - 3, 7, 7, SOLID, att | ERASE);
if (dir >= 0) {
lcdDrawSolidHorizontalLine(xm - 1, ym - 1, 3);
}
if (dir <= 0) {
lcdDrawSolidHorizontalLine(xm - 1, ym + 1, 3);
}
if (exttrim) {
lcdDrawSolidHorizontalLine(xm - 1, ym, 3);
}
if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && dir != 0) {
if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS || (trimsDisplayTimer > 0 && (trimsDisplayMask & (1 << i)))) {
lcdDrawNumber(dir > 0 ? 12 : 40, xm - 2, -abs(dir), TINSIZE | VERTICAL);
else {
ym -= val;
if ((i > 4 && xm < LCD_W / 2) || (i < 4 && xm > LCD_W / 2) ) {
lcdDrawSolidVerticalLine(xm - 1, ym, 1);
lcdDrawSolidVerticalLine(xm - 2, ym - 1, 3);
lcdDrawSolidVerticalLine(xm - 3, ym - 2, 5);
}
else {
lcdDrawSolidVerticalLine(xm + 1, ym, 1);
lcdDrawSolidVerticalLine(xm + 2, ym - 1, 3);
lcdDrawSolidVerticalLine(xm + 3, ym - 2, 5);
}
}
}
else {
ym = 60;
lcdDrawSolidHorizontalLine(xm - TRIM_LEN, ym, TRIM_LEN * 2 + 1);
lcdDrawSolidHorizontalLine(xm - 1, ym - 1, 3);
lcdDrawSolidHorizontalLine(xm - 1, ym + 1, 3);
xm += val;
lcdDrawFilledRect(xm - 3, ym - 3, 7, 7, SOLID, att | ERASE);
if (dir >= 0) {
lcdDrawSolidVerticalLine(xm + 1, ym - 1, 3);
if (i < 4)
lcdDrawSolidHorizontalLine(xm - TRIM_LEN, ym, TRIM_LEN * 2 + 1);
if (keysGetMaxTrims() <= 4) {
lcdDrawSolidHorizontalLine(xm - 1, ym - 1, 3);
lcdDrawSolidHorizontalLine(xm - 1, ym + 1, 3);
xm += val;
lcdDrawFilledRect(xm - 3, ym - 3, 7, 7, SOLID, att | ERASE);
if (dir >= 0) {
lcdDrawSolidVerticalLine(xm + 1, ym - 1, 3);
}
if (dir <= 0) {
lcdDrawSolidVerticalLine(xm - 1, ym - 1, 3);
}
if (exttrim) {
lcdDrawSolidVerticalLine(xm, ym - 1, 3);
}
if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && dir != 0) {
if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS ||
(trimsDisplayTimer > 0 && (trimsDisplayMask & (1 << i)))) {
lcdDrawNumber(
(stickIndex == 0 ? (dir > 0 ? TRIM_LH_POS : TRIM_LH_NEG)
: (dir > 0 ? TRIM_RH_POS : TRIM_RH_NEG)),
ym - 2, -abs(dir), TINSIZE);
}
}
lcdDrawSquare(xm - 3, ym - 3, 7, att);
}
if (dir <= 0) {
lcdDrawSolidVerticalLine(xm - 1, ym - 1, 3);
}
if (exttrim) {
lcdDrawSolidVerticalLine(xm, ym - 1, 3);
}
if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && dir != 0) {
if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS || (trimsDisplayTimer > 0 && (trimsDisplayMask & (1 << i)))) {
lcdDrawNumber((stickIndex == 0 ? (dir > 0 ? TRIM_LH_POS : TRIM_LH_NEG) : (dir > 0 ? TRIM_RH_POS : TRIM_RH_NEG)), ym - 2, -abs(dir), TINSIZE);
else {
xm += val;
if (i > 3) {
lcdDrawSolidHorizontalLine(xm, ym + 1, 1);
lcdDrawSolidHorizontalLine(xm - 1, ym + 2, 3);
lcdDrawSolidHorizontalLine(xm - 2, ym + 3, 5);
}
else {
lcdDrawSolidHorizontalLine(xm, ym - 1, 1);
lcdDrawSolidHorizontalLine(xm - 1, ym - 2, 3);
lcdDrawSolidHorizontalLine(xm - 2, ym - 3, 5);
}
}
}
lcdDrawSquare(xm - 3, ym - 3, 7, att);
}
}
@@ -489,66 +554,48 @@ void menuMainView(event_t event)
if (view == VIEW_INPUTS) {
// Sticks + Pots
doMainScreenGraphics();
// Switches
#if defined(PCBX9LITES)
static const uint8_t x[NUM_SWITCHES-2] = {2*FW-2, 2*FW-2, 17*FW+1, 2*FW-2, 17*FW+1};
static const uint8_t y[NUM_SWITCHES-2] = {4*FH+1, 5*FH+1, 5*FH+1, 6*FH+1, 6*FH+1};
for (int i=0; i<NUM_SWITCHES - 2; ++i) {
// -> 2 columns: one for each side
// -> 4 slots on each side (3 normal / 1 small)
uint8_t switches = switchGetMaxSwitches();
uint8_t configured_switches = 0;
for (uint8_t i = 0; i < switches; i++) {
if (SWITCH_EXISTS(i)) {
getvalue_t val = getValue(MIXSRC_FIRST_SWITCH + i);
getvalue_t sw = ((val < 0) ? 3 * i + 1 : ((val == 0) ? 3 * i + 2 : 3 * i + 3));
drawSwitch(x[i], y[i], sw, 0, false);
configured_switches ++;
}
}
drawSmallSwitch(29, 5*FH+1, 4, SW_SF);
drawSmallSwitch(16*FW+1, 5*FH+1, 4, SW_SG);
#elif defined(PCBX9LITE)
static const uint8_t x[NUM_SWITCHES] = {2 * FW - 2, 2 * FW - 2, 16 * FW + 1, 2 * FW - 2, 16 * FW + 1};
static const uint8_t y[NUM_SWITCHES] = {4 * FH + 1, 5 * FH + 1, 5 * FH + 1, 6 * FH + 1, 6 * FH + 1};
for (int i = 0; i < NUM_SWITCHES; ++i) {
if (SWITCH_EXISTS(i)) {
getvalue_t val = getValue(MIXSRC_FIRST_SWITCH + i);
getvalue_t sw = ((val < 0) ? 3 * i + 1 : ((val == 0) ? 3 * i + 2 : 3 * i + 3));
drawSwitch(x[i], y[i], sw, 0, false);
}
}
#elif defined(PCBXLITES)
static const uint8_t x[NUM_SWITCHES] = {2*FW-2, 16*FW+1, 2*FW-2, 16*FW+1, 2*FW-2, 16*FW+1};
static const uint8_t y[NUM_SWITCHES] = {4*FH+1, 4*FH+1, 6*FH+1, 6*FH+1, 5*FH+1, 5*FH+1};
for (int i=0; i<NUM_SWITCHES; ++i) {
if (SWITCH_EXISTS(i)) {
getvalue_t val = getValue(MIXSRC_FIRST_SWITCH + i);
getvalue_t sw = ((val < 0) ? 3 * i + 1 : ((val == 0) ? 3 * i + 2 : 3 * i + 3));
drawSwitch(x[i], y[i], sw, 0, false);
}
}
#elif defined(PCBTARANIS)
uint8_t switches = min(NUM_SWITCHES- NUM_FUNCTIONS_SWITCHES, 6);
for (int i = 0; i < switches; ++i) {
if (SWITCH_EXISTS(i)) {
uint8_t x = 2 * FW - 2, y = 4 * FH + i * FH + 1;
if (i >= switches / 2) {
x = 16 * FW + 1;
y -= (switches / 2) * FH;
if (configured_switches < 9) {
for (int i = 0; i < switches; ++i) {
if (SWITCH_EXISTS(i)) {
auto switch_display = switchGetDisplayPosition(i);
if (switch_display.row >= 3) {
drawSmallSwitch(switch_display.col == 0 ? 28 : 16 * FW + 1,
5 * FH + 1, 4, i);
}
else {
coord_t x = switch_display.col == 0 ? 2 * FW - 2 : 16 * FW + 7;
coord_t y = 33 + switch_display.row * FH;
getvalue_t val = getValue(MIXSRC_FIRST_SWITCH + i);
getvalue_t sw =
((val < 0) ? 3 * i + 1
: ((val == 0) ? 3 * i + 2 : 3 * i + 3));
drawSwitch(x, y, sw, 0, false);
}
}
getvalue_t val = getValue(MIXSRC_FIRST_SWITCH + i);
getvalue_t sw = ((val < 0) ? 3 * i + 1 : ((val == 0) ? 3 * i + 2 : 3 * i + 3));
drawSwitch(x, y, sw, 0, false);
}
}
#else
// The ID0 3-POS switch is merged with the TRN switch
for (uint8_t i = SWSRC_THR; i <= SWSRC_TRN; i++) {
int8_t sw = (i == SWSRC_TRN ? (switchState(SW_ID0) ? SWSRC_ID0 : (switchState(SW_ID1) ? SWSRC_ID1 : SWSRC_ID2)) : i);
uint8_t x = 2 * FW - 2, y = i * FH + 1;
if (i >= SWSRC_AIL) {
x = 17 * FW - 1;
y -= 3 * FH;
else {
for (int i = 0; i < switches; ++i) {
if (SWITCH_EXISTS(i)) {
auto switch_display = switchGetDisplayPosition(i);
coord_t x = (switch_display.col == 0 ? 8 : 96) + switch_display.row * 5;
drawSmallSwitch(x, 5 * FH + 1, 4, i);
}
}
drawSwitch(x, y, sw, getSwitch(i) ? INVERS : 0, false);
}
#endif
}
else {
// Logical Switches
@@ -556,7 +603,7 @@ void menuMainView(event_t event)
uint8_t y = LCD_H - 20;
for (uint8_t line = 0; line < 2; line++) {
for (uint8_t column = 0; column < MAX_LOGICAL_SWITCHES / 2; column++) {
int8_t len = getSwitch(SWSRC_SW1 + index) ? 10 : 1;
int8_t len = getSwitch(SWSRC_FIRST_LOGICAL_SWITCH + index) ? 10 : 1;
uint8_t x = (16 + 3 * column);
lcdDrawSolidVerticalLine(x - 1, y - len, len);
lcdDrawSolidVerticalLine(x, y - len, len);
+2 -3
View File
@@ -22,6 +22,8 @@
#include "opentx.h"
#include "tasks.h"
#include "hal/adc_driver.h"
#if defined(BLUETOOTH)
#include "bluetooth_driver.h"
#endif
@@ -60,9 +62,6 @@ void menuStatisticsView(event_t event)
#endif
break;
#if !defined(PCBTARANIS)
case EVT_KEY_LONG(KEY_MENU): // historical
#endif
case EVT_KEY_LONG(KEY_ENTER):
g_eeGeneral.globalTimer = 0;
storageDirty(EE_GENERAL);
+28
View File
@@ -21,6 +21,34 @@
#include "opentx.h"
// For surface radio
void drawWheel(coord_t centrex, int16_t tval)
{
constexpr coord_t BOX_CENTERY = (LCD_H - 9 - BOX_WIDTH / 2);
constexpr coord_t MARKER_WIDTH = 5;
lcdDrawSquare(centrex-BOX_WIDTH/2, BOX_CENTERY-BOX_WIDTH/2, BOX_WIDTH);
lcdDrawSolidHorizontalLine(centrex - MARKER_WIDTH /2 , BOX_CENTERY, MARKER_WIDTH);
coord_t x1 = centrex - MARKER_WIDTH - tval / 300;
coord_t x2 = centrex - MARKER_WIDTH + tval / 300;
lcdDrawLine( x1, BOX_CENTERY+BOX_WIDTH / MARKER_WIDTH, x2, BOX_CENTERY-BOX_WIDTH / MARKER_WIDTH, SOLID, FORCE);
lcdDrawLine( x1 + BOX_WIDTH/2, BOX_CENTERY+BOX_WIDTH / MARKER_WIDTH,
x2 + BOX_WIDTH / 2, BOX_CENTERY-BOX_WIDTH / MARKER_WIDTH, SOLID, FORCE);
#undef BOX_CENTERY
#undef MARKER_WIDTH
}
// For surface radio
void drawThrottle(coord_t centrex, int16_t wval)
{
constexpr coord_t BOX_CENTERY = (LCD_H - 9 - BOX_WIDTH / 2);
constexpr coord_t MARKER_WIDTH = 5;
lcdDrawSquare(centrex-BOX_WIDTH/2, BOX_CENTERY-BOX_WIDTH/2, BOX_WIDTH);
lcdDrawSolidHorizontalLine(centrex - MARKER_WIDTH, BOX_CENTERY, 2 * MARKER_WIDTH + 1);
coord_t tsize = wval / 150;
lcdDrawLine( centrex - tsize, BOX_CENTERY, centrex, BOX_CENTERY + tsize, SOLID, FORCE);
lcdDrawLine( centrex + tsize, BOX_CENTERY, centrex, BOX_CENTERY + tsize, SOLID, FORCE);
}
void drawStick(coord_t centrex, int16_t xval, int16_t yval)
{
#define BOX_CENTERY (LCD_H-9-BOX_WIDTH/2)