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
+40 -150
View File
@@ -26,6 +26,8 @@
#include "lcd.h"
#include "menus.h"
#include "popups.h"
#include "navigation/navigation.h"
#include "common/stdlcd/draw_functions.h"
#define HEADER_LINE 0
@@ -76,153 +78,45 @@ void showAlertBox(const char * title, const char * text, const char * action, ui
void doMainScreenGraphics();
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)
#define NAVIGATION_LINE_BY_LINE 0x40
#define CURSOR_ON_LINE() (menuHorizontalPosition<0)
#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 maxrow, uint8_t flags=0);
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)
#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)
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)
void drawGVarValue(coord_t x, coord_t y, uint8_t gvar, gvar_t value, LcdFlags flags=0);
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);
#define GVAR_MENU_ITEM(x, y, v, min, max, lcdattr, editflags, event) editGVarFieldValue(x, y, v, min, max, lcdattr, editflags, event)
#define displayGVar(x, y, v, min, max) GVAR_MENU_ITEM(x, y, v, min, max, 0, 0, 0)
#else
#define GVAR_MENU_ITEM(x, y, v, min, max, lcdattr, editflags, event) editGVarFieldValue(x, y, v, min, max, lcdattr, event)
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, event_t event);
#define displayGVar(x, y, v, min, max) lcdDrawNumber(x, y, v)
void drawGVarValue(coord_t x, coord_t y, uint8_t gvar, gvar_t value,
LcdFlags flags = 0);
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);
#define GVAR_MENU_ITEM(x, y, v, min, max, lcdattr, editflags, event) \
editGVarFieldValue(x, y, v, min, max, lcdattr, editflags, event)
#define displayGVar(x, y, v, min, max) \
GVAR_MENU_ITEM(x, y, v, min, max, 0, 0, 0)
#else // GVARS
#define GVAR_MENU_ITEM(x, y, v, min, max, lcdattr, editflags, event) \
editGVarFieldValue(x, y, v, min, max, lcdattr, event)
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min,
int16_t max, LcdFlags attr, event_t event);
#define displayGVar(x, y, v, min, max) lcdDrawNumber(x, y, v)
#endif
void gvarWeightItem(coord_t x, coord_t y, MixData * md, LcdFlags attr, event_t event);
@@ -239,12 +133,14 @@ 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(y, event, attr, str, delay) editDelay(y, event, attr, str, delay)
void copySelection(char * dst, const char * src, uint8_t size);
#define COPY_MODE 1
#define MOVE_MODE 2
extern uint8_t s_copyMode;
extern int8_t s_copySrcRow;
extern int8_t s_copyTgtOfs;
@@ -252,10 +148,10 @@ extern uint8_t s_currIdx;
extern uint8_t s_currIdxSubMenu;
extern uint16_t s_currSrcRaw;
extern uint16_t s_currScale;
extern uint8_t s_maxLines;
extern uint8_t s_copySrcIdx;
extern uint8_t s_copySrcCh;
extern int8_t s_currCh;
extern uint8_t s_maxLines;
uint8_t getExposCount();
void deleteExpo(uint8_t idx);
@@ -277,18 +173,12 @@ void readModelNotes();
void menuChannelsView(event_t event);
#if defined(ROTARY_ENCODER_NAVIGATION)
#define CURSOR_MOVED_LEFT(event) (event==EVT_ROTARY_LEFT)
#define CURSOR_MOVED_RIGHT(event) (event==EVT_ROTARY_RIGHT)
#else
#define CURSOR_MOVED_LEFT(event) (EVT_KEY_MASK(event) == KEY_LEFT)
#define CURSOR_MOVED_RIGHT(event) (EVT_KEY_MASK(event) == KEY_RIGHT)
#endif
void repeatLastCursorMove(event_t event);
#define REPEAT_LAST_CURSOR_MOVE() { if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) pushEvent(event); else menuHorizontalPosition = 0; }
#define POS_HORZ_INIT(posVert) ((COLATTR(posVert) & NAVIGATION_LINE_BY_LINE) ? -1 : 0)
#define EDIT_MODE_INIT 0 // TODO enum
void onSwitchLongEnterPress(const char *result);
void onSourceLongEnterPress(const char *result);
uint8_t switchToMix(uint8_t source);
+43 -42
View File
@@ -34,6 +34,9 @@
#if !defined(BOOT)
#include "opentx.h"
#include "hal/switch_driver.h"
#include "hal/adc_driver.h"
#include "switches.h"
#endif
#if (defined(PCBX9E) || defined(PCBX9DP)) && defined(LCD_DUAL_BUFFER)
@@ -615,18 +618,15 @@ void putsVBat(coord_t x, coord_t y, LcdFlags att)
putsVolts(x, y, g_vbat100mV, att);
}
void drawStickName(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
void drawMainControlLabel(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
{
// Skip "---": idx + 1
// Skip source symbol: + 2
const char* stickName = STR_VSRCRAW[idx + 1] + 2;
lcdDrawSizedText(x, y, stickName, UINT8_MAX, att);
lcdDrawSizedText(x, y, getMainControlLabel(idx), UINT8_MAX, 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);
@@ -654,54 +654,55 @@ void drawSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att)
}
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_FIRST_SLIDER-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);
lcdDrawText(x, y, getSourceString(idx), att);
}
else if (idx >= MIXSRC_FIRST_SWITCH && idx <= MIXSRC_LAST_SWITCH) {
idx = idx - MIXSRC_FIRST_SWITCH;
if (g_eeGeneral.switchNames[idx][0]) {
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);
}
lcdDrawText(x, y, getSourceString(idx), att);
}
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) {
drawStringWithIndex(x, y, STR_CH, idx-MIXSRC_CH1+1, att);
if (ZEXIST(g_model.limitData[idx-MIXSRC_CH1].name) && (att & STREXPANDED)) {
else if (idx <= MIXSRC_LAST_LOGICAL_SWITCH) {
idx -= MIXSRC_FIRST_LOGICAL_SWITCH;
drawSwitch(x, y, idx + SWSRC_FIRST_LOGICAL_SWITCH, att);
} else if (idx <= MIXSRC_LAST_TRAINER) {
idx -= MIXSRC_FIRST_TRAINER;
drawStringWithIndex(x, y, STR_PPM_TRAINER, idx + 1, att);
} else if (idx <= MIXSRC_LAST_CH) {
idx -= MIXSRC_FIRST_CH;
drawStringWithIndex(x, y, STR_CH, idx + 1, att);
if (ZEXIST(g_model.limitData[idx].name) && (att & STREXPANDED)) {
lcdDrawChar(lcdLastRightPos, y, ' ', att|SMLSIZE);
lcdDrawSizedText(lcdLastRightPos+3, y, g_model.limitData[idx-MIXSRC_CH1].name, LEN_CHANNEL_NAME, att|SMLSIZE);
lcdDrawSizedText(lcdLastRightPos+3, y, g_model.limitData[idx].name, LEN_CHANNEL_NAME, att|SMLSIZE);
}
}
else if (idx <= MIXSRC_LAST_GVAR) {
drawStringWithIndex(x, y, STR_GV, idx-MIXSRC_GVAR1+1, att);
idx -= MIXSRC_FIRST_GVAR - 1;
drawStringWithIndex(x, y, STR_GV, idx, 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);
// Built-in sources: TX Voltage, Time, GPS (+ reserved)
const char* src_str;
switch(idx) {
case MIXSRC_TX_VOLTAGE:
src_str = STR_SRC_BATT;
break;
case MIXSRC_TX_TIME:
src_str = STR_SRC_TIME;
break;
case MIXSRC_TX_GPS:
src_str = STR_SRC_BATT;
break;
default:
src_str = "";
break;
}
lcdDrawText(x, y, src_str, 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);
idx -= MIXSRC_FIRST_TIMER;
if(g_model.timers[idx].name[0]) {
lcdDrawSizedText(x, y, g_model.timers[idx].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);
drawStringWithIndex(x, y, STR_SRC_TIMER, idx, att);
}
}
else {
@@ -714,7 +715,7 @@ void drawSource(coord_t x, coord_t y, uint32_t idx, LcdFlags 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)
+2 -2
View File
@@ -123,12 +123,12 @@ void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags mode=0);
void drawModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att);
void drawSwitch(coord_t x, coord_t y, int32_t swtch, LcdFlags att=0, bool autoBold = true);
void drawStickName(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
void drawMainControlLabel(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
void drawSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att=0);
void drawCurveName(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
void drawTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att=0);
#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);
+2 -3
View File
@@ -20,6 +20,7 @@
*/
#include "opentx.h"
#include "hal/rotary_encoder.h"
void runPopupCurvePreset(event_t event)
{
@@ -128,9 +129,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];
+1 -1
View File
@@ -265,7 +265,7 @@ void menuModelDisplay(event_t event)
}
}
if (attr && menuHorizontalPosition == NUM_LINE_ITEMS) {
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
}
break;
+13 -4
View File
@@ -150,11 +150,20 @@ void menuModelExpoOne(event_t event)
break;
case EXPO_FIELD_TRIM:
uint8_t not_stick = (ed->srcRaw > MIXSRC_Ail);
int8_t trimSource = -ed->trimSource;
lcdDrawTextAlignedLeft(y, STR_TRIM);
lcdDrawTextAtIndex(EXPO_ONE_2ND_COLUMN, y, STR_VMIXTRIMS, (not_stick && trimSource == 0) ? 0 : trimSource + 1, menuHorizontalPosition==0 ? attr : 0);
if (attr) ed->trimSource = -checkIncDecModel(event, trimSource, not_stick ? 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;
@@ -109,7 +109,7 @@ void menuModelLogicalSwitches(event_t event)
LogicalSwitchData * cs = lswAddress(k);
// CSW name
unsigned int sw = SWSRC_SW1+k;
unsigned int sw = SWSRC_FIRST_LOGICAL_SWITCH+k;
drawSwitch(0, y, sw, (getSwitch(sw) ? BOLD : 0) | ((sub==k && CURSOR_ON_LINE()) ? INVERS : 0));
// CSW func
@@ -189,7 +189,7 @@ void menuModelLogicalSwitches(event_t event)
if (cstate == LS_FAMILY_EDGE) {
lcdDrawText(CSW_6TH_COLUMN, y, STR_NA);
if (attr && horz == LS_FIELD_DELAY) {
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
}
else if (cs->delay > 0) {
@@ -200,7 +200,7 @@ void menuModelLogicalSwitches(event_t event)
}
if (attr && horz == LS_FIELD_V3 && cstate != LS_FAMILY_EDGE) {
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
if (s_editMode>0 && attr) {
+39 -35
View File
@@ -79,6 +79,27 @@ void onModelSelectMenu(const char * result)
}
}
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)
{
if (warningResult) {
@@ -89,10 +110,13 @@ void menuModelSelect(event_t event)
event = EVT_ENTRY_UP;
}
event_t _event_ = ((event==EVT_KEY_BREAK(KEY_ENTER) || event==EVT_KEY_LONG(KEY_ENTER)) ? 0 : event);
if ((s_copyMode && EVT_KEY_MASK(event) == KEY_EXIT) || event == EVT_KEY_BREAK(KEY_EXIT)) {
_event_ -= KEY_EXIT;
// 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) || event == EVT_KEY_BREAK(KEY_ENTER) ||
event == EVT_KEY_LONG(KEY_ENTER)) {
_event_ = 0;
}
int8_t oldSub = menuVerticalPosition;
@@ -101,7 +125,7 @@ void menuModelSelect(event_t event)
if (s_editMode > 0) s_editMode = 0;
int sub = menuVerticalPosition;
int8_t sub = menuVerticalPosition;
switch (event) {
case EVT_ENTRY:
@@ -208,39 +232,19 @@ void menuModelSelect(event_t event)
case EVT_KEY_BREAK(KEY_PAGE):
case EVT_KEY_LONG(KEY_PAGE):
chainMenu(event == EVT_KEY_BREAK(KEY_PAGE) ? menuModelSetup : menuTabModel[DIM(menuTabModel)-1].menuFunc);
chainMenu(event == EVT_KEY_BREAK(KEY_PAGE)
? menuModelSetup
: menuTabModel[DIM(menuTabModel) - 1].menuFunc);
killEvents(event);
break;
}
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 defined(ROTARY_ENCODER_NAVIGATION)
case EVT_ROTARY_LEFT:
case EVT_ROTARY_RIGHT:
#endif
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, event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(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)
+40 -29
View File
@@ -19,8 +19,13 @@
* GNU General Public License for more details.
*/
#include "hal/adc_driver.h"
#include "hal/adc_driver.h"
#include "hal/switch_driver.h"
#include "opentx.h"
#include "mixer_scheduler.h"
#include "switches.h"
#if defined(USBJ_EX)
#include "usb_joystick.h"
@@ -35,7 +40,7 @@ uint8_t g_moduleIdx;
uint8_t getSwitchWarningsCount()
{
uint8_t count = 0;
for (int i=0; i<NUM_SWITCHES; ++i) {
for (int i = 0; i < switchGetMaxSwitches(); ++i) {
if (SWITCH_WARNING_ALLOWED(i)) {
++count;
}
@@ -396,20 +401,21 @@ inline uint8_t EXTERNAL_MODULE_TYPE_ROW()
#elif TIMERS == 3
#define TIMERS_ROWS TIMER_ROWS(0), TIMER_ROWS(1), TIMER_ROWS(2)
#endif
#if defined(PCBX9E)
#define SW_WARN_ROWS \
PREFLIGHT_ROW(uint8_t(NAVIGATION_LINE_BY_LINE|(getSwitchWarningsCount()-1))), \
PREFLIGHT_ROW(uint8_t(getSwitchWarningsCount() > 8 ? TITLE_ROW : HIDDEN_ROW)), \
PREFLIGHT_ROW(uint8_t(getSwitchWarningsCount() > 16 ? TITLE_ROW : HIDDEN_ROW))
#define POT_WARN_ROWS \
PREFLIGHT_ROW(uint8_t(g_model.potsWarnMode ? NAVIGATION_LINE_BY_LINE|(NUM_POTS+NUM_SLIDERS) : 0)), \
PREFLIGHT_ROW(uint8_t(g_model.potsWarnMode ? NAVIGATION_LINE_BY_LINE|(MAX_POTS) : 0)), \
PREFLIGHT_ROW(uint8_t(g_model.potsWarnMode ? TITLE_ROW : HIDDEN_ROW))
#define TOPLCD_ROWS 0,
#else
#define SW_WARN_ROWS \
PREFLIGHT_ROW(uint8_t(NAVIGATION_LINE_BY_LINE|getSwitchWarningsCount()))
#define POT_WARN_ROWS \
PREFLIGHT_ROW(uint8_t(g_model.potsWarnMode ? NAVIGATION_LINE_BY_LINE|(NUM_POTS+NUM_SLIDERS) : 0))
PREFLIGHT_ROW(uint8_t(g_model.potsWarnMode ? NAVIGATION_LINE_BY_LINE|(MAX_POTS) : 0))
#define TOPLCD_ROWS
#endif
@@ -537,7 +543,7 @@ void menuModelSetup(event_t event)
SW_WARN_ROWS, // Switch warning
POT_WARN_ROWS, // Pot warning
NAVIGATION_LINE_BY_LINE | (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
@@ -796,7 +802,7 @@ void menuModelSetup(event_t event)
if (attr)
CHECK_INCDEC_MODELVAR_ZERO_CHECK(
event, g_model.thrTraceSrc,
NUM_POTS + NUM_SLIDERS + MAX_OUTPUT_CHANNELS,
MAX_POTS + MAX_OUTPUT_CHANNELS,
isThrottleSourceAvailable);
uint8_t idx = throttleSource2Source(g_model.thrTraceSrc);
@@ -811,7 +817,7 @@ void menuModelSetup(event_t event)
case ITEM_MODEL_SETUP_THROTTLE_TRIM_SWITCH:
lcdDrawTextAlignedLeft(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, MAX_TRIMS - 1);
drawSource(MODEL_SETUP_2ND_COLUMN, y, g_model.getThrottleStickTrimSource(), attr);
break;
@@ -846,7 +852,7 @@ void menuModelSetup(event_t event)
case ITEM_MODEL_SETUP_SWITCHES_WARNING3:
case ITEM_MODEL_SETUP_POTS_WARNING2:
if (i==0) {
if (CURSOR_MOVED_LEFT(event))
if (IS_PREVIOUS_EVENT(event))
menuVerticalOffset--;
else
menuVerticalOffset++;
@@ -858,7 +864,7 @@ void menuModelSetup(event_t event)
{
#if defined(PCBX9E)
if (i>=NUM_BODY_LINES-2 && getSwitchWarningsCount() > 8*(NUM_BODY_LINES-i)) {
if (CURSOR_MOVED_LEFT(event))
if (IS_PREVIOUS_EVENT(event))
menuVerticalOffset--;
else
menuVerticalOffset++;
@@ -881,7 +887,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));
@@ -899,7 +905,7 @@ void menuModelSetup(event_t event)
LcdFlags line = attr;
int current = 0;
for (int i=0; i<NUM_SWITCHES; i++) {
for (int i = 0; i < switchGetMaxSwitches(); i++) {
if (SWITCH_WARNING_ALLOWED(i)) {
div_t qr = div(current, 8);
if (!READ_ONLY() && event == EVT_KEY_BREAK(KEY_ENTER) && line &&
@@ -935,7 +941,7 @@ void menuModelSetup(event_t event)
case ITEM_MODEL_SETUP_POTS_WARNING:
#if defined(PCBX9E)
if (i==NUM_BODY_LINES-1 && g_model.potsWarnMode) {
if (CURSOR_MOVED_LEFT(event))
if (IS_PREVIOUS_EVENT(event))
menuVerticalOffset--;
else
menuVerticalOffset++;
@@ -971,25 +977,25 @@ 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 {
#if defined(PCBX9E)
if (i == NUM_XPOTS) {
if (max_pots > 5 && i == 3) {
y += FH;
x = MODEL_SETUP_2ND_COLUMN;
}
#endif
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;
}
}
@@ -1003,17 +1009,22 @@ void menuModelSetup(event_t event)
}
break;
case ITEM_MODEL_SETUP_BEEP_CENTER:
{
case ITEM_MODEL_SETUP_BEEP_CENTER: {
lcdDrawTextAlignedLeft(y, STR_BEEPCTR);
coord_t x = MODEL_SETUP_2ND_COLUMN;
for (int i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) {
if (i>=POT1 && i<POT1+NUM_XPOTS && !IS_POT_SLIDER_AVAILABLE(i)) {
if (attr && menuHorizontalPosition == i) REPEAT_LAST_CURSOR_MOVE();
uint8_t pot_offset = adcGetInputOffset(ADC_INPUT_POT);
uint8_t max_inputs = adcGetMaxInputs(ADC_INPUT_MAIN) + adcGetMaxInputs(ADC_INPUT_POT);
for (uint8_t i = 0; i < max_inputs; i++) {
coord_t x = MODEL_SETUP_2ND_COLUMN + i*FW;
if ( i >= pot_offset && IS_POT_MULTIPOS(i - pot_offset) ) {
if (attr && menuHorizontalPosition == i) repeatLastCursorMove(event);
continue;
}
lcdDrawTextAtIndex(x, y, STR_RETA123, i, ((menuHorizontalPosition==i) && attr) ? BLINK|INVERS : (((g_model.beepANACenter & ((BeepANACenter)1<<i)) || (attr && CURSOR_ON_LINE())) ? INVERS : 0 ) );
x += FW;
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 && CURSOR_ON_CELL) {
if (event==EVT_KEY_BREAK(KEY_ENTER)) {
@@ -195,7 +195,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
case ITEM_CUSTOM_FUNCTIONS_FUNCTION:
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) {
func = CFN_FUNC(cfn) = checkIncDec(event, CFN_FUNC(cfn), 0, FUNC_MAX-1, eeFlags, isAssignableFunctionAvailable);
if (checkIncDec_Ret) CFN_RESET(cfn);
@@ -204,7 +204,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
else {
j = ITEM_CUSTOM_FUNCTIONS_LAST; // skip other fields
if (sub==k && menuHorizontalPosition > 0) {
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
}
break;
@@ -219,14 +219,14 @@ 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) {
@@ -243,7 +243,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
break;
}
else if (attr) {
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_CH_INDEX(cfn), maxParam);
break;
@@ -388,7 +388,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
}
#endif
else if (attr) {
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
if (active || event==EVT_KEY_LONG(KEY_ENTER)) {
@@ -436,7 +436,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
}
}
else if (attr) {
REPEAT_LAST_CURSOR_MOVE();
repeatLastCursorMove(event);
}
break;
}
+14 -152
View File
@@ -21,6 +21,7 @@
#include "opentx.h"
#include "hal/adc_driver.h"
#include "gui/common/stdlcd/calibration.h"
#define XPOT_DELTA 10
#define XPOT_DELAY 10 /* cycles */
@@ -30,168 +31,28 @@
void drawPotsBars()
{
// Optimization by Mike Blandford
for (uint8_t x=LCD_W/2-(NUM_POTS+NUM_SLIDERS)/2*BAR_SPACING+BAR_SPACING/2, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; x+=BAR_SPACING, i++) {
uint8_t max_pots = adcGetMaxInputs(ADC_INPUT_POT);
uint8_t offset = adcGetInputOffset(ADC_INPUT_POT);
for (uint8_t x = LCD_W / 2 - max_pots / 2 * BAR_SPACING + BAR_SPACING / 2,
i = 0;
i < max_pots; x += BAR_SPACING, 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);
drawStickName(x-2, LCD_H-6, i, TINSIZE);
// calculate once per loop
auto v = calibratedAnalogs[offset + i] + RESX;
uint8_t len = (v * BAR_HEIGHT / (RESX * 2)) + 1l;
V_BAR(x, LCD_H - 8, len);
lcdDrawText(x - 2, LCD_H - 6, getPotLabel(i), TINSIZE);
}
}
}
void menuCommonCalib(event_t event)
{
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) { // get low and high vals for sticks and trims
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;
}
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;
}
}
}
}
}
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;
reusableBuffer.calib.midVals[i] = getAnalogValue(i) >> 1;
if (i<NUM_XPOTS) {
reusableBuffer.calib.xpotsCalib[i].stepsCount = 0;
reusableBuffer.calib.xpotsCalib[i].lastCount = 0;
}
}
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;
}
}
break;
case CALIB_STORE:
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;
}
}
else {
g_eeGeneral.potsConfig &= ~(0x03<<(2*idx));
}
}
}
g_eeGeneral.chkSum = evalChkSum();
storageDirty(EE_GENERAL);
reusableBuffer.calib.state = CALIB_FINISHED;
break;
default:
reusableBuffer.calib.state = CALIB_START;
break;
}
doMainScreenGraphics();
drawPotsBars();
#if 0
for (int i=POT1; i<=POT_LAST; i++) {
uint8_t steps = 0;
if (reusableBuffer.calib.state == CALIB_MOVE_STICKS) {
steps = reusableBuffer.calib.xpotsCalib[i-POT1].stepsCount;
}
else if (IS_POT_MULTIPOS(i)) {
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[i];
steps = calib->count + 1;
}
if (steps > 0 && steps <= XPOTS_MULTIPOS_COUNT) {
lcdDrawNumber(LCD_W/2-2+(i-POT1)*5, LCD_H-6, steps, TINSIZE|RIGHT);
}
}
#endif
}
void menuRadioCalibration(event_t event)
{
check_submenu_simple(event, 0);
title(STR_MENUCALIBRATION);
menuCommonCalib(READ_ONLY() ? 0 : event);
drawPotsBars();
if (menuEvent) {
menuCalibrationState = CALIB_START;
}
@@ -207,5 +68,6 @@ void menuFirstCalib(event_t event)
lcdDrawText(LCD_W / 2, 0, STR_MENUCALIBRATION, CENTERED);
lcdInvertLine(0);
menuCommonCalib(event);
drawPotsBars();
}
}
+4 -4
View File
@@ -27,7 +27,7 @@
void menuRadioDiagAnalogs(event_t event)
{
static int8_t entryCount = 0;
static uint16_t lastShownAnalogValue[NUM_STICKS+NUM_POTS+NUM_SLIDERS];
static uint16_t lastShownAnalogValue[MAX_ANALOG_INPUTS];
enum ANAVIEWS{
ANAVIEW_FIRST,
@@ -53,7 +53,7 @@ void menuRadioDiagAnalogs(event_t event)
case (ANAVIEW_RAWLOWFPS): SIMPLE_SUBMENU(STR_MENU_RADIO_ANALOGS_RAWLOWFPS, 0); break;
}
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) {
for (uint8_t i = 0; i < MAX_ANALOG_INPUTS; i++) {
coord_t y = MENU_HEADER_HEIGHT + 1 + (i/2)*FH;
uint8_t x = i&1 ? LCD_W/2 + FW : 0;
lcdDrawNumber(x, y, i+1, LEADING0|LEFT, 2);
@@ -75,9 +75,9 @@ void menuRadioDiagAnalogs(event_t event)
#if defined(JITTER_MEASURE)
lcdDrawNumber(x+10*FW-1, y, rawJitter[i].get(), RIGHT);
lcdDrawNumber(x+13*FW-1, y, avgJitter[i].get(), RIGHT);
lcdDrawNumber(x+17*FW-1, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256, RIGHT);
lcdDrawNumber(x+17*FW-1, y, (int16_t)calibratedAnalogs[i]*25/256, RIGHT);
#else
lcdDrawNumber(x+10*FW-1, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256, RIGHT);
lcdDrawNumber(x+10*FW-1, y, (int16_t)calibratedAnalogs[i]*25/256, RIGHT);
#endif
}
+33 -10
View File
@@ -21,32 +21,55 @@
#include "opentx.h"
#include "hal/rotary_encoder.h"
#include "hal/switch_driver.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);
}
void displayTrimState(uint8_t x, uint8_t y, uint8_t trim)
{
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;
}
void menuRadioDiagKeys(event_t event)
{
SIMPLE_SUBMENU(STR_MENU_RADIO_SWITCHES, 1);
lcdDrawText(24*FW, MENU_HEADER_HEIGHT + 1, STR_VTRIM);
for (uint8_t i = 0; i < NUM_TRIMS_KEYS; i++) {
for (uint8_t i = 0; i < keysGetMaxTrims() * 2; i++) {
coord_t y = MENU_HEADER_HEIGHT + 1 + FH + FH * (i / 2);
if (i & 1)
lcdDraw1bitBitmap(24 * FW, y, sticks, i / 2, 0);
displayKeyState(i & 1 ? 30 * FW : 28 * FW, y, TRM_BASE + i);
if (i & 1) lcdDraw1bitBitmap(24 * FW, y, sticks, i / 2, 0);
displayTrimState(i & 1 ? 30 * FW : 28 * FW, y, i);
}
for (uint8_t i = 0; i <= KEY_MAX; i++) {
for (uint8_t i = 0; i < keysGetMaxKeys(); i++) {
auto k = get_ith_key(i);
coord_t 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);
}
for (uint8_t i = 0, cnt = 0; i < NUM_SWITCHES; i++) {
for (uint8_t i = 0, cnt = 0; i < switchGetMaxSwitches(); i++) {
if (SWITCH_EXISTS(i)) {
div_t qr = div(cnt++, 6);
coord_t x = 4 * FH * qr.quot;
@@ -58,8 +81,8 @@ void menuRadioDiagKeys(event_t event)
}
#if defined(ROTARY_ENCODER_NAVIGATION)
coord_t y = MENU_HEADER_HEIGHT + 1 + FH*KEY_COUNT;
coord_t y = MENU_HEADER_HEIGHT + 1 + FH * MAX_KEYS;
lcdDrawText(0, y, STR_ROTARY_ENCODER);
lcdDrawNumber(5*FW+FWNUM+2, y, rotencValue / ROTARY_ENCODER_GRANULARITY, RIGHT);
lcdDrawNumber(5 * FW + FWNUM + 2, y, rotaryEncoderGetValue(), RIGHT);
#endif
}
+28 -16
View File
@@ -19,10 +19,13 @@
* GNU General Public License for more details.
*/
#include "hal/adc_driver.h"
#define LANGUAGE_PACKS_DEFINITION
#include "opentx.h"
#include "tasks/mixer_task.h"
#include "input_mapping.h"
const unsigned char sticks[] = {
#include "sticks.lbm"
@@ -608,10 +611,15 @@ 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 - FW + 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;
case ITEM_RADIO_SETUP_STICK_MODE_LABELS:
@@ -641,19 +649,23 @@ void menuRadioSetup(event_t event)
#endif
case ITEM_RADIO_SETUP_STICK_MODE:
lcdDrawChar(2*FW, y, '1'+reusableBuffer.generalSettings.stickMode, attr);
for (uint8_t i=0; i<4; i++) {
drawStickName((6+4*i)*FW, y, *(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();
{
auto& mode = reusableBuffer.generalSettings.stickMode;
lcdDrawChar(2*FW, y, '1' + mode, attr);
for (uint8_t i=0; i<4; i++) {
auto ctrl = inputMappingConvertMode(mode, i);
drawMainControlLabel((6+4*i)*FW, y, ctrl, 0);
}
if (attr && s_editMode > 0) {
CHECK_INCDEC_GENVAR(event, mode, 0, 3);
}
else if (mode != g_eeGeneral.stickMode) {
mixerTaskStop();
g_eeGeneral.stickMode = mode;
checkThrottleStick();
mixerTaskStart();
waitKeysReleased();
}
}
break;
+2 -4
View File
@@ -40,12 +40,10 @@ void menuChannelsView(event_t event)
popMenu();
break;
case EVT_KEY_FIRST(KEY_RIGHT):
case EVT_KEY_FIRST(KEY_LEFT):
#if defined(ROTARY_ENCODER_NAVIGATION)
case EVT_ROTARY_LEFT:
case EVT_ROTARY_RIGHT:
#endif
case EVT_KEY_FIRST(KEY_PLUS):
case EVT_KEY_FIRST(KEY_MINUS):
reusableBuffer.viewChannels.secondPage = !reusableBuffer.viewChannels.secondPage;
break;
+90 -59
View File
@@ -21,6 +21,11 @@
#include "opentx.h"
#include "hal/trainer_driver.h"
#include "hal/adc_driver.h"
#include "hal/switch_driver.h"
#include "switches.h"
#include "input_mapping.h"
#define BIGSIZE MIDSIZE
#define LBOX_CENTERX (BOX_WIDTH/2 + 16)
@@ -73,24 +78,24 @@ const unsigned char icons[] = {
void doMainScreenGraphics()
{
int16_t calibStickVert = calibratedAnalogs[CONVERT_MODE(1)];
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
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);
drawStick(RBOX_CENTERX, calibratedAnalogs[ADC_MAIN_RH], calibStickVert);
}
void displayTrims(uint8_t phase)
{
for (unsigned int i=0; i<NUM_STICKS; i++) {
coord_t x[4] = { TRIM_LH_X, TRIM_LV_X, TRIM_RV_X, TRIM_RH_X };
uint8_t vert[4] = { 0, 1, 1, 0 };
for (unsigned int i = 0; i < MAX_STICKS; i++) {
coord_t x[] = { TRIM_LH_X, TRIM_LV_X, TRIM_RV_X, TRIM_RH_X };
uint8_t vert[] = { 0, 1, 1, 0 };
coord_t xm, ym;
unsigned int stickIndex = CONVERT_MODE(i);
unsigned int stickIndex = inputMappingConvertMode(i);
xm = x[stickIndex];
uint32_t att = ROUND;
@@ -164,26 +169,45 @@ void displayTrims(uint8_t phase)
}
}
// Pots & sliders
// X9E: only sliders (1 to 4)
// Other: POT1, POT2, SLIDERS1 and SLIDER2
//
static const coord_t _pot_slots[] = {
3, LCD_H / 2 + 1, // SLIDER1 (x,y)
LCD_W - 5, LCD_H / 2 + 1, // SLIDER2 (x,y)
3, 1, // SLIDER3 (x,y)
LCD_W - 5, 1, // SLIDER4 (x,y)
};
void drawSliders()
{
for (uint8_t i = NUM_STICKS; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
uint8_t slot_idx = 0;
uint8_t max_pots = adcGetMaxInputs(ADC_INPUT_POT);
uint8_t offset = adcGetInputOffset(ADC_INPUT_POT);
for (uint8_t i = 0; i < max_pots; i++) {
// TODO: move this into board implementation
#if defined(PCBX9E)
if (i < SLIDER1)
continue; // TODO change and display more values
coord_t x = ((i==SLIDER1 || i==SLIDER3) ? 3 : LCD_W-5);
int8_t y = (i<SLIDER3 ? LCD_H/2+1 : 1);
// Only sliders
if (!IS_SLIDER(i)) continue;
#else
if (i == POT3)
continue;
coord_t x = ((i==POT1 || i==SLIDER1) ? 3 : LCD_W-5);
int8_t y = (i>=SLIDER1 ? LCD_H/2+1 : 1);
// Skip POT3
if (i == 2) continue;
#endif
lcdDrawSolidVerticalLine(x, y, LCD_H/2-2);
lcdDrawSolidVerticalLine(x+1, y, LCD_H/2-2);
coord_t x = _pot_slots[slot_idx++];
coord_t y = _pot_slots[slot_idx++];
lcdDrawSolidVerticalLine(x, y, LCD_H / 2 - 2);
lcdDrawSolidVerticalLine(x + 1, y, LCD_H / 2 - 2);
// calculate once per loop
y += LCD_H / 2 - 4;
y -= ((calibratedAnalogs[i]+RESX)*(LCD_H/2-4)/(RESX*2)); // calculate once per loop
lcdDrawSolidVerticalLine(x-1, y, 2);
lcdDrawSolidVerticalLine(x+2, y, 2);
y -= ((calibratedAnalogs[offset + i] + RESX) * (LCD_H / 2 - 4) / (RESX * 2));
lcdDrawSolidVerticalLine(x - 1, y, 2);
lcdDrawSolidVerticalLine(x + 2, y, 2);
}
}
@@ -417,17 +441,6 @@ void displaySwitch(coord_t x, coord_t y, int width, unsigned int index)
}
}
int getSwitchCount()
{
int count = 0;
for (int i=0; i<NUM_SWITCHES; ++i) {
if (SWITCH_EXISTS(i)) {
++count;
}
}
return count;
}
void menuMainView(event_t event)
{
static bool secondPage = false;
@@ -435,8 +448,8 @@ void menuMainView(event_t event)
switch(event) {
case EVT_ENTRY:
killEvents(KEY_EXIT);
killEvents(KEY_UP);
killEvents(KEY_DOWN);
killEvents(KEY_PLUS);
killEvents(KEY_MINUS);
// no break
case EVT_ENTRY_UP:
@@ -485,8 +498,8 @@ void menuMainView(event_t event)
#endif
break;
case EVT_KEY_FIRST(KEY_RIGHT):
case EVT_KEY_FIRST(KEY_LEFT):
case EVT_KEY_FIRST(KEY_PLUS):
case EVT_KEY_FIRST(KEY_MINUS):
#if defined(ROTARY_ENCODER_NAVIGATION)
case EVT_ROTARY_LEFT:
case EVT_ROTARY_RIGHT:
@@ -514,34 +527,52 @@ void menuMainView(event_t event)
lcdDrawBitmap(BITMAP_X, BITMAP_Y, modelBitmap);
// Switches
if (getSwitchCount() > 8) {
for (int i=0; i<NUM_SWITCHES; ++i) {
div_t qr = div(i, 9);
if (g_model.view == VIEW_INPUTS) {
div_t qr2 = div(qr.rem, 5);
if (i >= 14) qr2.rem += 1;
const coord_t x[4] = { 50, 142 };
const coord_t y[4] = { 25, 42, 25, 42 };
displaySwitch(x[qr.quot]+qr2.rem*4, y[qr2.quot], 3, i);
}
else {
displaySwitch(17+qr.rem*6, 25+qr.quot*17, 5, i);
// Regular radio
// -> 2 columns: one for each side
// -> 8 slots on each side (2 columns of 4)
uint8_t switches = switchGetMaxSwitches();
if (getSwitchCount() > 16) { // beware, there is a desired col/row swap in this special mode
for (int i = 0; i < switches; ++i) {
if (SWITCH_EXISTS(i)) {
auto switch_display = switchGetDisplayPosition(i);
if (g_model.view == VIEW_INPUTS) {
coord_t x = 50 + (switch_display.row % 5) * 4 +
(switch_display.col == 0 ? 0 : 93) +
(switch_display.row < 5 ? 0 : 2);
coord_t y = switch_display.row < 5 ? 25 : 40;
displaySwitch(x, y, 3, i);
} else {
displaySwitch(17 + switch_display.row * 6,
25 + switch_display.col * 17, 5, i);
}
}
}
}
else {
int index = 0;
for (int i=0; i<NUM_SWITCHES; ++i) {
coord_t shiftright = switchGetMaxRow(1) < 4 ? 20 : 0;
for (int 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((g_model.view == VIEW_INPUTS) ? (index<4 ? 8*FW+1 : 23*FW+2) : (index<4 ? 3*FW+1 : 8*FW-2), (index%4)*FH+3*FH, sw, 0, false);
index++;
auto switch_display = switchGetDisplayPosition(i);
if (g_model.view == VIEW_INPUTS) {
coord_t x = (switch_display.col == 0 ? 50 : 125) +
(switch_display.row < 4 ? 0 : 20) +
(switch_display.col == 0 ? 0 : shiftright);
coord_t y = 25 + (switch_display.row % 4) * 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);
}
else {
displaySwitch(17 + switch_display.row * 6,
25 + switch_display.col * 17, 5, i);
}
}
}
}
if (g_model.view == VIEW_TIMERS) {
if (g_model.view == VIEW_TIMERS) {
displayTimers();
}
else if (g_model.view == VIEW_INPUTS) {
@@ -566,7 +597,7 @@ void menuMainView(event_t event)
lcdDrawSolidHorizontalLine(x, y+6, 4);
lcdDrawSolidHorizontalLine(x, y+7, 4);
}
else if (getSwitch(SWSRC_SW1+sw)) {
else if (getSwitch(SWSRC_FIRST_LOGICAL_SWITCH+sw)) {
lcdDrawFilledRect(x, y, 4, 8);
}
else {
+9 -8
View File
@@ -19,6 +19,7 @@
* GNU General Public License for more details.
*/
#include "hal/adc_driver.h"
#include "opentx.h"
#include "tasks.h"
@@ -32,12 +33,12 @@ void menuStatisticsView(event_t event)
title(STR_MENUSTAT);
switch(event) {
case EVT_KEY_FIRST(KEY_UP):
case EVT_KEY_FIRST(KEY_PLUS):
case EVT_KEY_BREAK(KEY_PAGE):
chainMenu(menuStatisticsDebug);
break;
case EVT_KEY_FIRST(KEY_DOWN):
case EVT_KEY_FIRST(KEY_MINUS):
case EVT_KEY_LONG(KEY_PAGE):
killEvents(event);
#if defined(DEBUG_TRACE_BUFFER)
@@ -133,13 +134,13 @@ void menuStatisticsDebug(event_t event)
maxMixerDuration = 0;
break;
case EVT_KEY_FIRST(KEY_UP):
case EVT_KEY_FIRST(KEY_PLUS):
case EVT_KEY_BREAK(KEY_PAGE):
disableVBatBridge();
chainMenu(menuStatisticsDebug2);
break;
case EVT_KEY_FIRST(KEY_DOWN):
case EVT_KEY_FIRST(KEY_MINUS):
case EVT_KEY_LONG(KEY_PAGE):
killEvents(event);
disableVBatBridge();
@@ -214,7 +215,7 @@ void menuStatisticsDebug2(event_t event)
title(STR_MENUDEBUG);
switch(event) {
case EVT_KEY_FIRST(KEY_UP):
case EVT_KEY_FIRST(KEY_PLUS):
case EVT_KEY_BREAK(KEY_PAGE):
#if defined(DEBUG_TRACE_BUFFER)
chainMenu(menuTraceBuffer);
@@ -223,7 +224,7 @@ void menuStatisticsDebug2(event_t event)
#endif
return;
case EVT_KEY_FIRST(KEY_DOWN):
case EVT_KEY_FIRST(KEY_MINUS):
case EVT_KEY_LONG(KEY_PAGE):
killEvents(event);
chainMenu(menuStatisticsDebug);
@@ -257,13 +258,13 @@ void menuTraceBuffer(event_t event)
killEvents(event);
break;
case EVT_KEY_FIRST(KEY_DOWN):
case EVT_KEY_FIRST(KEY_MINUS):
case EVT_KEY_LONG(KEY_PAGE):
killEvents(event);
chainMenu(menuStatisticsDebug2);
break;
case EVT_KEY_FIRST(KEY_UP):
case EVT_KEY_FIRST(KEY_PLUS):
case EVT_KEY_BREAK(KEY_PAGE):
chainMenu(menuStatisticsView);
return;