Merge against latest 2.3

This commit is contained in:
Bertrand Songis
2019-09-17 13:28:42 +02:00
247 changed files with 35085 additions and 42445 deletions
+2 -1
View File
@@ -129,10 +129,11 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint8_t width, uin
memset(dest, 0, BITMAP_BUFFER_SIZE(w, h) - 2);
uint8_t rowSize = (w + 7) / 8;
uint8_t rowSize;
switch (depth) {
case 1:
rowSize = ((w + 31) / 32) * 4;
for (int8_t i=h-1; i>=0; i--) {
result = f_read(&bmpFile, buf, rowSize, &read);
if (result != FR_OK || read != rowSize) {
+1 -6
View File
@@ -183,8 +183,7 @@ void title(const char * s);
title(name)
typedef int choice_t;
choice_t editChoice(coord_t x, coord_t y, const char * label, const char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event);
choice_t editChoice(coord_t x, coord_t y, const char * label, const char *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);
@@ -231,15 +230,11 @@ void drawStatusLine();
#define drawStatusLine()
#endif
#define TEXT_FILENAME_MAXLEN 40
extern char s_text_file[TEXT_FILENAME_MAXLEN];
void menuTextView(event_t event);
void pushMenuTextView(const char *filename);
void pushModelNotes();
void readModelNotes();
#define LABEL(...) (uint8_t)-1
#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)
+21 -2
View File
@@ -922,15 +922,34 @@ void lcdDraw1bitBitmap(coord_t x, coord_t y, const uint8_t * img, uint8_t idx, L
const uint8_t * q = img;
uint8_t w = *q++;
uint8_t hb = ((*q++) + 7) / 8;
uint8_t yShift = y % 8;
bool inv = (att & INVERS) ? true : (att & BLINK ? BLINK_ON_PHASE : false);
q += idx*w*hb;
for (uint8_t yb = 0; yb < hb; yb++) {
uint8_t *p = &displayBuf[(y / 8 + yb) * LCD_W + x];
for (coord_t i=0; i<w; i++){
uint8_t b = *q++;
uint8_t b = inv ? ~(*q++) : *q++;
if (p < DISPLAY_END) {
*p++ = inv ? ~b : b;
if (!yShift) {
*p = b;
}
else {
*p = (*p & ((1 << yShift) - 1)) | (b << yShift);
if (p + LCD_W < DISPLAY_END) {
p[LCD_W] = (p[LCD_W] & (0xFF >> yShift)) | (b >> (8 - yShift));
}
}
}
p++;
}
}
}
+1 -1
View File
@@ -23,7 +23,7 @@
uint8_t editDelay(coord_t y, event_t event, uint8_t attr, const char * str, uint8_t delay)
{
lcdDrawTextAlignedLeft(y, str);
lcdDrawNumber(MIXES_2ND_COLUMN, y, (10/DELAY_STEP)*delay, attr|PREC1|LEFT);
lcdDrawNumber(MIXES_2ND_COLUMN, y, delay, attr|PREC1|LEFT);
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, delay, DELAY_MAX);
return delay;
}
+2 -2
View File
@@ -22,7 +22,7 @@
void menuRadioSpecialFunctions(event_t event)
{
#if defined(PCBTARANIS)
#if defined(NAVIGATION_X7)
const CustomFunctionData * cfn = &g_eeGeneral.customFn[menuVerticalPosition];
if (!CFN_SWITCH(cfn) && menuHorizontalPosition < 0 && event==EVT_KEY_BREAK(KEY_ENTER)) {
menuHorizontalPosition = 0;
@@ -33,7 +33,7 @@ void menuRadioSpecialFunctions(event_t event)
menuSpecialFunctions(event, g_eeGeneral.customFn, &globalFunctionsContext);
#if defined(PCBX7)
#if defined(NAVIGATION_X7)
if (!CFN_SWITCH(cfn) && menuHorizontalPosition == 0 && s_editMode <= 0) {
menuHorizontalPosition = -1;
}
+13 -11
View File
@@ -22,6 +22,15 @@
#define MODELSEL_W LCD_W
void onDeleteModelConfirm(const char * result)
{
if (result == STR_OK) {
storageCheck(true);
eeDeleteModel(menuVerticalPosition); // delete file
s_copyMode = 0;
}
}
void onModelSelectMenu(const char * result)
{
int8_t sub = menuVerticalPosition;
@@ -45,13 +54,14 @@ void onModelSelectMenu(const char * result)
POPUP_WARNING(eeBackupModel(sub));
}
else if (result == STR_RESTORE_MODEL || result == STR_UPDATE_LIST) {
if (!sdListFiles(MODELS_PATH, MODELS_EXT, MENU_LINE_LENGTH-1, NULL)) {
if (sdListFiles(MODELS_PATH, MODELS_EXT, MENU_LINE_LENGTH-1, nullptr))
POPUP_MENU_START(onModelSelectMenu);
else
POPUP_WARNING(STR_NO_MODELS_ON_SD);
}
}
#endif
else if (result == STR_DELETE_MODEL) {
POPUP_CONFIRMATION(STR_DELETEMODEL, nullptr);
POPUP_CONFIRMATION(STR_DELETEMODEL, onDeleteModelConfirm);
SET_WARNING_INFO(modelHeaders[sub].name, sizeof(g_model.header.name), ZCHAR);
}
#if defined(SDCARD)
@@ -68,14 +78,6 @@ void onModelSelectMenu(const char * result)
void menuModelSelect(event_t event)
{
if (warningResult) {
warningResult = 0;
storageCheck(true);
eeDeleteModel(menuVerticalPosition); // delete file
s_copyMode = 0;
event = EVT_ENTRY_UP;
}
event_t _event_ = event;
if ((s_copyMode && EVT_KEY_MASK(event) == KEY_EXIT) || event == EVT_KEY_BREAK(KEY_EXIT) || IS_ROTARY_BREAK(event) || IS_ROTARY_LONG(event)) {
_event_ = 0;
+42 -31
View File
@@ -90,7 +90,7 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_INTERNAL_MODULE_CHANNELS,
ITEM_MODEL_SETUP_INTERNAL_MODULE_NOT_ACCESS_BIND,
ITEM_MODEL_SETUP_INTERNAL_MODULE_PXX2_MODEL_NUM,
#if defined(EXTERNAL_ANTENNA)
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
ITEM_MODEL_SETUP_INTERNAL_MODULE_ANTENNA,
#endif
ITEM_MODEL_SETUP_INTERNAL_MODULE_FAILSAFE,
@@ -224,8 +224,25 @@ inline uint8_t EXTERNAL_MODULE_TYPE_ROW()
#define TRAINER_BLUETOOTH_S_ROW (bluetooth.distantAddr[0] == '\0' ? HIDDEN_ROW : LABEL())
#define IF_BT_TRAINER_ON(x) (g_eeGeneral.bluetoothMode == BLUETOOTH_TRAINER ? (uint8_t)(x) : HIDDEN_ROW)
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
#define EXTERNAL_ANTENNA_ROW ((isModuleXJT(INTERNAL_MODULE) && g_eeGeneral.antennaMode == ANTENNA_MODE_PER_MODEL) ? (uint8_t)0 : HIDDEN_ROW),
void onModelAntennaSwitchConfirm(const char * result)
{
if (result == STR_OK) {
// Switch to external antenna confirmation
g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode = ANTENNA_MODE_EXTERNAL;
globalData.externalAntennaEnabled = true;
storageDirty(EE_MODEL);
}
else {
reusableBuffer.moduleSetup.antennaMode = g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode;
}
}
#else
#define EXTERNAL_ANTENNA_ROW
#endif
#if defined(PCBX7) || defined(PCBX9LITE)
#define ANTENNA_ROW
#if defined(BLUETOOTH)
#define TRAINER_BLUETOOTH_ROW (g_model.trainerData.mode == TRAINER_MODE_MASTER_BLUETOOTH ? TRAINER_BLUETOOTH_M_ROW : (g_model.trainerData.mode == TRAINER_MODE_SLAVE_BLUETOOTH ? TRAINER_BLUETOOTH_S_ROW : HIDDEN_ROW)),
#else
@@ -234,12 +251,10 @@ inline uint8_t EXTERNAL_MODULE_TYPE_ROW()
#define TRAINER_PPM_PARAMS_ROW (g_model.trainerData.mode == TRAINER_MODE_SLAVE ? (uint8_t)2 : HIDDEN_ROW)
#define TRAINER_ROWS LABEL(Trainer), 0, TRAINER_BLUETOOTH_ROW TRAINER_CHANNELS_ROW, TRAINER_PPM_PARAMS_ROW
#elif defined(PCBXLITES)
#define ANTENNA_ROW IF_NOT_PXX2_MODULE(INTERNAL_MODULE, IF_INTERNAL_MODULE_ON(0)),
#define TRAINER_BLUETOOTH_ROW (g_model.trainerData.mode == TRAINER_MODE_MASTER_BLUETOOTH ? TRAINER_BLUETOOTH_M_ROW : (g_model.trainerData.mode == TRAINER_MODE_SLAVE_BLUETOOTH ? TRAINER_BLUETOOTH_S_ROW : HIDDEN_ROW))
#define TRAINER_PPM_PARAMS_ROW (g_model.trainerData.mode == TRAINER_MODE_SLAVE ? (uint8_t)2 : HIDDEN_ROW)
#define TRAINER_ROWS LABEL(Trainer), 0, IF_BT_TRAINER_ON(TRAINER_BLUETOOTH_ROW), TRAINER_CHANNELS_ROW, TRAINER_PPM_PARAMS_ROW
#elif defined(PCBXLITE)
#define ANTENNA_ROW IF_NOT_PXX2_MODULE(INTERNAL_MODULE, IF_INTERNAL_MODULE_ON(0)),
#define TRAINER_BLUETOOTH_ROW (g_model.trainerData.mode == TRAINER_MODE_MASTER_BLUETOOTH ? TRAINER_BLUETOOTH_M_ROW : (g_model.trainerData.mode == TRAINER_MODE_SLAVE_BLUETOOTH ? TRAINER_BLUETOOTH_S_ROW : HIDDEN_ROW))
#define TRAINER_ROWS IF_BT_TRAINER_ON(LABEL(Trainer)), IF_BT_TRAINER_ON(0), IF_BT_TRAINER_ON(TRAINER_BLUETOOTH_ROW), IF_BT_TRAINER_ON(TRAINER_CHANNELS_ROW), HIDDEN_ROW /* xlite has only BT trainer, so never PPM */
#else
@@ -274,7 +289,7 @@ void onBluetoothConnectMenu(const char * result)
INTERNAL_MODULE_CHANNELS_ROWS, \
IF_NOT_ACCESS_MODULE_RF(INTERNAL_MODULE, IF_INTERNAL_MODULE_ON(isModuleRxNumAvailable(INTERNAL_MODULE) ? (uint8_t)2 : (uint8_t)1)), \
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 0), /* RxNum */ \
ANTENNA_ROW \
EXTERNAL_ANTENNA_ROW \
IF_INTERNAL_MODULE_ON(FAILSAFE_ROWS(INTERNAL_MODULE)), /* Failsafe */ \
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 1), /* Range check and Register buttons */ \
IF_PXX2_MODULE(INTERNAL_MODULE, 0), /* Module options */ \
@@ -285,16 +300,6 @@ void onBluetoothConnectMenu(const char * result)
#define INTERNAL_MODULE_ROWS
#endif
#if defined(EXTERNAL_ANTENNA)
void onAntennaSwitchConfirm(const char * result)
{
if (result == STR_OK) {
// Switch to external antenna confirmation
g_model.moduleData[INTERNAL_MODULE].pxx.external_antenna = XJT_EXTERNAL_ANTENNA;
}
}
#endif
void menuModelSetup(event_t event)
{
int8_t old_editMode = s_editMode;
@@ -372,6 +377,9 @@ void menuModelSetup(event_t event)
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) {
memclear(&reusableBuffer.moduleSetup, sizeof(reusableBuffer.moduleSetup));
reusableBuffer.moduleSetup.r9mPower = g_model.moduleData[EXTERNAL_MODULE].pxx.power;
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
reusableBuffer.moduleSetup.antennaMode = g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode;
#endif
}
#if (defined(DSM2) || defined(PXX))
@@ -910,16 +918,16 @@ void menuModelSetup(event_t event)
if (isModuleR9MNonAccess(EXTERNAL_MODULE)) {
if (g_model.moduleData[EXTERNAL_MODULE].subType > MODULE_SUBTYPE_R9M_EU) {
POPUP_WARNING(STR_MODULE_PROTOCOL_FLEX_WARN_LINE1);
SET_WARNING_INFO(STR_R9M_PROTO_WARN_LINE2, sizeof(TR_R9M_PROTO_WARN_LINE2) - 1, 0);
SET_WARNING_INFO(STR_MODULE_PROTOCOL_WARN_LINE2, sizeof(TR_MODULE_PROTOCOL_WARN_LINE2) - 1, 0);
}
#if POPUP_LEVEL >= 3
else if (g_model.moduleData[EXTERNAL_MODULE].subType == MODULE_SUBTYPE_R9M_EU) {
POPUP_WARNING(STR_R9M_PROTO_EU_WARN_LINE1);
SET_WARNING_INFO(STR_R9M_PROTO_WARN_LINE2, sizeof(TR_R9M_PROTO_WARN_LINE2) - 1, 0);
POPUP_WARNING(STR_MODULE_PROTOCOL_EU_WARN_LINE1);
SET_WARNING_INFO(STR_MODULE_PROTOCOL_WARN_LINE2, sizeof(TR_MODULE_PROTOCOL_WARN_LINE2) - 1, 0);
}
else {
POPUP_WARNING(STR_R9M_PROTO_FCC_WARN_LINE1);
SET_WARNING_INFO(STR_R9M_PROTO_WARN_LINE2, sizeof(TR_R9M_PROTO_WARN_LINE2) - 1, 0);
POPUP_WARNING(STR_MODULE_PROTOCOL_FCC_WARN_LINE1);
SET_WARNING_INFO(STR_MODULE_PROTOCOL_WARN_LINE2, sizeof(TR_MODULE_PROTOCOL_WARN_LINE2) - 1, 0);
}
#endif
}
@@ -1379,20 +1387,23 @@ void menuModelSetup(event_t event)
}
break;
#if defined(EXTERNAL_ANTENNA)
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
case ITEM_MODEL_SETUP_INTERNAL_MODULE_ANTENNA:
{
uint8_t newAntennaSel = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_ANTENNASELECTION, STR_VANTENNATYPES, g_model.moduleData[INTERNAL_MODULE].pxx.external_antenna, 0, 1, attr, event);
if (newAntennaSel != g_model.moduleData[INTERNAL_MODULE].pxx.external_antenna && newAntennaSel == XJT_EXTERNAL_ANTENNA) {
POPUP_CONFIRMATION(STR_ANTENNACONFIRM1, onAntennaSwitchConfirm);
const char * w = STR_ANTENNACONFIRM2;
SET_WARNING_INFO(w, strlen(w), 0);
}
else {
g_model.moduleData[INTERNAL_MODULE].pxx.external_antenna = newAntennaSel;
reusableBuffer.moduleSetup.antennaMode = editChoice(MODEL_SETUP_2ND_COLUMN, y, INDENT TR_ANTENNA, STR_ANTENNA_MODES,
reusableBuffer.moduleSetup.antennaMode == ANTENNA_MODE_PER_MODEL ? ANTENNA_MODE_INTERNAL : reusableBuffer.moduleSetup.antennaMode,
ANTENNA_MODE_INTERNAL, ANTENNA_MODE_EXTERNAL, attr, event,
[](int value) { return value != ANTENNA_MODE_PER_MODEL; });
if (event && !s_editMode && reusableBuffer.moduleSetup.antennaMode != g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode) {
if (reusableBuffer.moduleSetup.antennaMode == ANTENNA_MODE_EXTERNAL && !isExternalAntennaEnabled()) {
POPUP_CONFIRMATION(STR_ANTENNACONFIRM1, onModelAntennaSwitchConfirm);
SET_WARNING_INFO(STR_ANTENNACONFIRM2, sizeof(TR_ANTENNACONFIRM2), 0);
}
else {
g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode = reusableBuffer.moduleSetup.antennaMode;
checkExternalAntenna();
}
}
break;
}
#endif
case ITEM_MODEL_SETUP_EXTERNAL_MODULE_OPTIONS:
@@ -70,7 +70,6 @@ void onCustomFunctionsFileSelectionMenu(const char * result)
#endif // SDCARD
#if defined(PCBTARANIS)
void onAdjustGvarSourceLongEnterPress(const char * result)
{
CustomFunctionData * cfn = &g_model.customFn[menuVerticalPosition];
@@ -148,9 +147,8 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
#if defined(PCBTARANIS)
#if defined(PCBXLITE)
if (menuHorizontalPosition==0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) {
killEvents(KEY_ENTER);
if (IS_SHIFT_PRESSED()) { // ENT LONG on xlite brings up switch type menu, so this menu is activated with SHIT + ENT LONG
// ENT LONG on xlite brings up switch type menu, so this menu is activated with SHIT + ENT LONG
if (menuHorizontalPosition==0 && event==EVT_KEY_LONG(KEY_ENTER) && IS_SHIFT_PRESSED() && !READ_ONLY()) {
#else
if (menuHorizontalPosition<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) {
#endif
@@ -172,9 +170,6 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
}
POPUP_MENU_START(onCustomFunctionsMenu);
}
#if defined(PCBXLITE)
}
#endif
#endif // PCBTARANIS
for (uint8_t i=0; i<NUM_BODY_LINES; i++) {
@@ -389,7 +384,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
else if (attr) {
REPEAT_LAST_CURSOR_MOVE();
}
#if defined(PCBX7) || defined(PCBX9LITE)
#if defined(NAVIGATION_X7)
if (active || event==EVT_KEY_LONG(KEY_ENTER)) {
CFN_PARAM(cfn) = CHECK_INCDEC_PARAM(event, val_displayed, val_min, val_max);
if (func == FUNC_ADJUST_GVAR && attr && event==EVT_KEY_LONG(KEY_ENTER)) {
@@ -436,7 +431,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
break;
}
}
#if defined(PCBX7) || defined(PCBX9LITE)
#if defined(NAVIGATION_X7)
if (sub==k && menuHorizontalPosition<0 && CFN_SWITCH(cfn)) {
lcdInvertLine(i+1);
}
+4 -1
View File
@@ -247,12 +247,15 @@ void menuModelTelemetry(event_t event)
case ITEM_TELEMETRY_RSSI_SOURCE: {
lcdDrawTextAlignedLeft(y, INDENT TR_SOURCE);
drawSource(TELEM_COL2, y, g_model.rssiSource ? MIXSRC_FIRST_TELEM + 3 * (g_model.rssiSource - 1) : 0, attr);
if (g_model.rssiSource) {
drawSource(TELEM_COL2, y, MIXSRC_FIRST_TELEM + 3 * (g_model.rssiSource - 1), attr);
TelemetrySensor * sensor = &g_model.telemetrySensors[g_model.rssiSource - 1];
lcdDrawText(lcdNextPos, y, " ", attr);
drawReceiverName(lcdNextPos, y, sensor->frskyInstance.rxIndex >> 2, sensor->frskyInstance.rxIndex & 0x03, attr);
}
else {
lcdDrawText(TELEM_COL2, y, STR_DEFAULT, attr);
}
if (attr) {
g_model.rssiSource = checkIncDec(event, g_model.rssiSource, 0, MAX_TELEMETRY_SENSORS, EE_MODEL | NO_INCDEC_MARKS, isRssiSensorAvailable);
}
@@ -51,7 +51,7 @@ void menuModelSensor(event_t event)
0, // Name
0, // Type
sensor->type == TELEM_TYPE_CALCULATED ? (uint8_t)0 : (uint8_t)1, // ID / Formula
sensor->type == TELEM_TYPE_CALCULATED ? HIDDEN_ROW : LABEL(Receiver), // Receiver name
sensor->type == TELEM_TYPE_CALCULATED ? HIDDEN_ROW : READONLY_ROW, // Receiver name
((sensor->type == TELEM_TYPE_CALCULATED && (sensor->formula == TELEM_FORMULA_DIST)) || sensor->isConfigurable() ? (uint8_t)0 : HIDDEN_ROW), // Unit
(sensor->isPrecConfigurable() && sensor->unit != UNIT_FAHRENHEIT ? (uint8_t)0 : HIDDEN_ROW), // Precision
(sensor->unit >= UNIT_FIRST_VIRTUAL ? HIDDEN_ROW : (uint8_t)0), // Param1
@@ -84,7 +84,6 @@ void menuModelSensor(event_t event)
LcdFlags attr = (sub==k ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0);
switch (k) {
case SENSOR_FIELD_NAME:
editSingleName(SENSOR_2ND_COLUMN, y, STR_NAME, sensor->label, TELEM_LABEL_LEN, event, attr);
break;
@@ -106,7 +105,7 @@ void menuModelSensor(event_t event)
lcdDrawTextAlignedLeft(y, STR_ID);
lcdDrawHexNumber(SENSOR_2ND_COLUMN, y, sensor->id, LEFT|(menuHorizontalPosition==0 ? attr : 0));
lcdDrawHexChar(SENSOR_3RD_COLUMN, y, sensor->instance & 0x1f, LEFT|(menuHorizontalPosition==1 ? attr : 0));
if (attr) {
if (attr && s_editMode > 0) {
switch (menuHorizontalPosition) {
case 0:
CHECK_INCDEC_MODELVAR_ZERO(event, sensor->id, 0xffff);
@@ -143,8 +142,19 @@ void menuModelSensor(event_t event)
break;
case SENSOR_FILED_RECEIVER_NAME:
lcdDrawTextAlignedLeft(y, STR_RECEIVER);
drawReceiverName(SENSOR_2ND_COLUMN, y, sensor->frskyInstance.rxIndex >> 2, sensor->frskyInstance.rxIndex & 0x03, 0);
lcdDrawTextAlignedLeft(y, STR_SOURCE);
if (telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT && sensor->frskyInstance.rxIndex != TELEMETRY_ENDPOINT_SPORT) {
drawReceiverName(SENSOR_2ND_COLUMN, y, sensor->frskyInstance.rxIndex >> 2, sensor->frskyInstance.rxIndex & 0x03, 0);
}
#if defined(HARDWARE_INTERNAL_MODULE)
else if (isModuleUsingSport(INTERNAL_MODULE, g_model.moduleData[INTERNAL_MODULE].type)) {
// far from perfect
lcdDrawText(SENSOR_2ND_COLUMN, y, STR_INTERNAL_MODULE);
}
#endif
else {
lcdDrawText(SENSOR_2ND_COLUMN, y, STR_EXTERNAL_MODULE);
}
break;
case SENSOR_FIELD_UNIT:
+6 -4
View File
@@ -511,14 +511,16 @@ void menuRadioSetup(event_t event)
#if defined(PWR_BUTTON_PRESS)
case ITEM_RADIO_SETUP_PWR_ON_SPEED:
lcdDrawTextAlignedLeft(y, STR_PWR_ON_SPEED);
drawSlider(RADIO_SETUP_2ND_COLUMN, y, LCD_W - 2 - RADIO_SETUP_2ND_COLUMN, g_eeGeneral.pwrOnSpeed +1, 3, attr);
lcdDrawTextAlignedLeft(y, STR_PWR_ON_DELAY);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, 2 - g_eeGeneral.pwrOnSpeed, attr|LEFT);
lcdDrawChar(lcdLastRightPos, y, 's');
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOnSpeed, -1, 2);
break;
case ITEM_RADIO_SETUP_PWR_OFF_SPEED:
lcdDrawTextAlignedLeft(y, STR_PWR_OFF_SPEED);
drawSlider(RADIO_SETUP_2ND_COLUMN, y, LCD_W - 2 - RADIO_SETUP_2ND_COLUMN, g_eeGeneral.pwrOffSpeed +1, 3, attr);
lcdDrawTextAlignedLeft(y, STR_PWR_OFF_DELAY);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, 2 - g_eeGeneral.pwrOffSpeed, attr|LEFT);
lcdDrawChar(lcdLastRightPos, y, 's');
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffSpeed, -1, 2);
break;
#endif
+17 -15
View File
@@ -22,33 +22,35 @@
void menuChannelsView(event_t event)
{
static bool longNames = false;
bool newLongNames = false;
static bool secondPage = false;
static bool mixersView = false;
uint8_t ch;
switch(event)
{
switch (event) {
case EVT_ENTRY:
memclear(&reusableBuffer.viewChannels, sizeof(reusableBuffer.viewChannels));
break;
case EVT_KEY_BREAK(KEY_EXIT):
popMenu();
break;
case EVT_KEY_FIRST(KEY_RIGHT):
case EVT_KEY_FIRST(KEY_LEFT):
secondPage = !secondPage;
reusableBuffer.viewChannels.secondPage = !reusableBuffer.viewChannels.secondPage;
break;
case EVT_KEY_FIRST(KEY_ENTER):
mixersView = !mixersView;
reusableBuffer.viewChannels.mixersView = !reusableBuffer.viewChannels.mixersView;
break;
}
if (secondPage)
if (reusableBuffer.viewChannels.secondPage)
ch = 16;
else
ch = 0;
if (mixersView) {
if (reusableBuffer.viewChannels.mixersView) {
lcdDrawTextAlignedCenter(0, TR_MIXERS_MONITOR);
}
else {
@@ -67,13 +69,13 @@ void menuChannelsView(event_t event)
// Channels
for (uint8_t line=0; line<8; line++) {
uint8_t y = 9+line*7;
int32_t val = (mixersView) ? ex_chans[ch] : channelOutputs[ch];
int32_t val = (reusableBuffer.viewChannels.mixersView) ? ex_chans[ch] : channelOutputs[ch];
uint8_t ofs = (col ? 0 : 1);
// Channel name if present, number if not
uint8_t lenLabel = ZLEN(g_model.limitData[ch].name);
if (lenLabel > 4) {
newLongNames = longNames = true;
newLongNames = reusableBuffer.viewChannels.longNames = true;
}
if (lenLabel > 0)
@@ -83,13 +85,13 @@ void menuChannelsView(event_t event)
// Value
#if defined(PPM_UNIT_US)
uint8_t wbar = (longNames ? 54 : 64);
uint8_t wbar = (reusableBuffer.viewChannels.longNames ? 54 : 64);
lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, PPM_CH_CENTER(ch)+val/2, TINSIZE|RIGHT);
#elif defined(PPM_UNIT_PERCENT_PREC1)
uint8_t wbar = (longNames ? 48 : 58);
uint8_t wbar = (reusableBuffer.viewChannels.longNames ? 48 : 58);
lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val), PREC1|TINSIZE|RIGHT);
#else
uint8_t wbar = (longNames ? 54 : 64);
uint8_t wbar = (reusableBuffer.viewChannels.longNames ? 54 : 64);
lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val)/10, TINSIZE|RIGHT);
#endif
@@ -105,5 +107,5 @@ void menuChannelsView(event_t event)
}
}
longNames = newLongNames;
reusableBuffer.viewChannels.longNames = newLongNames;
}
+17 -10
View File
@@ -50,16 +50,24 @@
#define RSSSI_X (30)
#define RSSSI_Y (31)
#define RSSI_MAX 105
#define TRIM_LEN 23
void drawRSSIGauge()
void drawExternalAntennaAndRSSI()
{
uint8_t bar = (RSSI_MAX - g_model.rssiAlarms.getWarningRssi()) / 4;
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
if (isModuleXJT(INTERNAL_MODULE) && isExternalAntennaEnabled()) {
lcdDrawText(VBATT_X-1, VBATT_Y+8, "E", TINSIZE);
}
#endif
for(uint8_t i=1; i<5; i++) {
if((TELEMETRY_RSSI() - g_model.rssiAlarms.getWarningRssi()) > bar*(i-1)) {
lcdDrawFilledRect(RSSSI_X + i*4, RSSSI_Y - 2*i, 3, 2*i, SOLID, 0);
if (TELEMETRY_RSSI() > 0) {
auto warningRSSI = g_model.rssiAlarms.getWarningRssi();
int8_t value = TELEMETRY_RSSI() - warningRSSI;
uint8_t step = (RSSI_MAX - warningRSSI) / 4;
for (uint8_t i = 1; i < 5; i++) {
if (value > step * (i - 1)) {
lcdDrawFilledRect(RSSSI_X + i * 4, RSSSI_Y - 2 * i + 1, 3, 2 * i - 1, SOLID, 0);
}
}
}
}
@@ -271,6 +279,7 @@ void onMainViewMenu(const char *result)
POPUP_MENU_ADD_ITEM(STR_RESET_TIMER2);
POPUP_MENU_ADD_ITEM(STR_RESET_TIMER3);
POPUP_MENU_ADD_ITEM(STR_RESET_TELEMETRY);
POPUP_MENU_START(onMainViewMenu);
}
else if (result == STR_RESET_TELEMETRY) {
telemetryReset();
@@ -405,10 +414,8 @@ void menuMainView(event_t event)
// Trims sliders
displayTrims(mode);
// RSSI gauge
if (TELEMETRY_RSSI() > 0) {
drawRSSIGauge();
}
// RSSI gauge / external antenna
drawExternalAntennaAndRSSI();
}
if (view_base < VIEW_INPUTS) {
+1 -2
View File
@@ -111,7 +111,6 @@ void menuStatisticsDebug(event_t event)
switch (event) {
case EVT_ENTRY:
case EVT_ENTRY_UP:
enableVBatBridge();
break;
case EVT_KEY_LONG(KEY_ENTER):
@@ -160,7 +159,7 @@ void menuStatisticsDebug(event_t event)
if (IS_RESET_REASON_WATCHDOG()) {
lcdDrawText(LCD_W-8*FW, 0, "WATCHDOG");
}
else if (unexpectedShutdown) {
else if (globalData.unexpectedShutdown) {
lcdDrawText(LCD_W-13*FW, 0, "UNEXP.SHTDOWN");
}
#endif
+2 -2
View File
@@ -70,11 +70,11 @@ void title(const char * s)
lcdDrawText(0, 0, s, INVERS);
}
choice_t editChoice(coord_t x, coord_t y, const char * label, const char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event)
choice_t editChoice(coord_t x, coord_t y, const char * label, const char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event, IsValueAvailable isValueAvailable)
{
drawFieldLabel(x, y, label);
if (values) lcdDrawTextAtIndex(x, y, values, value-min, attr);
if (attr & (~RIGHT)) value = checkIncDec(event, value, min, max, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL);
if (attr & (~RIGHT)) value = checkIncDec(event, value, min, max, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL, isValueAvailable);
return value;
}
+1 -5
View File
@@ -209,7 +209,7 @@ void title(const char * s);
typedef int choice_t;
choice_t editChoice(coord_t x, coord_t y, const char *label, const char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event);
choice_t editChoice(coord_t x, coord_t y, const char *label, const char *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);
@@ -264,8 +264,6 @@ extern char statusLineMsg[STATUS_LINE_LENGTH];
void showStatusLine();
void drawStatusLine();
#define TEXT_FILENAME_MAXLEN 40
extern char s_text_file[TEXT_FILENAME_MAXLEN];
void menuTextView(event_t event);
void pushMenuTextView(const char *filename);
void pushModelNotes();
@@ -273,8 +271,6 @@ void readModelNotes();
void menuChannelsView(event_t event);
#define LABEL(...) (uint8_t)-1
#if defined(ROTARY_ENCODER_NAVIGATION)
#define CURSOR_MOVED_LEFT(event) (event==EVT_ROTARY_LEFT)
#define CURSOR_MOVED_RIGHT(event) (event==EVT_ROTARY_RIGHT)
+1 -1
View File
@@ -44,7 +44,7 @@ const MenuHandlerFunc menuTabModel[] = {
uint8_t editDelay(coord_t y, event_t event, uint8_t attr, const char * str, uint8_t delay)
{
lcdDrawTextAlignedLeft(y, str);
lcdDrawNumber(MIXES_2ND_COLUMN, y, (10/DELAY_STEP)*delay, attr|PREC1|LEFT);
lcdDrawNumber(MIXES_2ND_COLUMN, y, delay, attr|PREC1|LEFT);
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, delay, DELAY_MAX);
return delay;
}
+30 -31
View File
@@ -24,46 +24,45 @@ extern uint8_t g_moduleIdx;
void menuModelFailsafe(event_t event)
{
static uint8_t maxNameLen = 4;
static int8_t lastModel = g_eeGeneral.currModel;
const coord_t barH = (LCD_H - FH) / 8 - 1;
const int lim = (g_model.extendedLimits ? (512 * LIMIT_EXT_PERCENT / 100) : 512) * 2;
const uint8_t channelStart = g_model.moduleData[g_moduleIdx].channelsStart;
uint8_t cols = 1;
uint8_t colW = LCD_W;
if (lastModel != g_eeGeneral.currModel) {
lastModel = g_eeGeneral.currModel;
maxNameLen = 4;
}
switch(event) {
case EVT_ENTRY:
reusableBuffer.modelFailsafe.maxNameLen = 4;
break;
if (event == EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event);
event = 0;
case EVT_KEY_LONG(KEY_ENTER):
killEvents(event);
event = 0;
if (menuVerticalPosition < sentModuleChannels(g_moduleIdx)) {
if (s_editMode) {
g_model.failsafeChannels[menuVerticalPosition] = channelOutputs[menuVerticalPosition+channelStart];
s_editMode = 0;
if (menuVerticalPosition < sentModuleChannels(g_moduleIdx)) {
if (s_editMode) {
g_model.failsafeChannels[menuVerticalPosition] = channelOutputs[menuVerticalPosition+channelStart];
s_editMode = 0;
}
else {
int16_t * failsafe = &g_model.failsafeChannels[menuVerticalPosition];
if (*failsafe < FAILSAFE_CHANNEL_HOLD)
*failsafe = FAILSAFE_CHANNEL_HOLD;
else if (*failsafe == FAILSAFE_CHANNEL_HOLD)
*failsafe = FAILSAFE_CHANNEL_NOPULSE;
else
*failsafe = 0;
}
}
else {
int16_t * failsafe = &g_model.failsafeChannels[menuVerticalPosition];
if (*failsafe < FAILSAFE_CHANNEL_HOLD)
*failsafe = FAILSAFE_CHANNEL_HOLD;
else if (*failsafe == FAILSAFE_CHANNEL_HOLD)
*failsafe = FAILSAFE_CHANNEL_NOPULSE;
else
*failsafe = 0;
// "Outputs => Failsafe" menu item
setCustomFailsafe(g_moduleIdx);
}
}
else {
// "Outputs => Failsafe" menu item
setCustomFailsafe(g_moduleIdx);
}
storageDirty(EE_MODEL);
AUDIO_WARNING1();
SEND_FAILSAFE_NOW(g_moduleIdx);
storageDirty(EE_MODEL);
AUDIO_WARNING1();
SEND_FAILSAFE_NOW(g_moduleIdx);
break;
}
SIMPLE_SUBMENU_NOTITLE(sentModuleChannels(g_moduleIdx) + 1);
@@ -95,7 +94,7 @@ void menuModelFailsafe(event_t event)
const int32_t channelValue = channelOutputs[ch+channelStart];
int32_t failsafeValue = g_model.failsafeChannels[8*col+line];
uint8_t lenLabel = ZLEN(g_model.limitData[ch+channelStart].name);
uint8_t barW = colW - FW * maxNameLen - FWNUM * 3; // default bar width
uint8_t barW = colW - FW * reusableBuffer.modelFailsafe.maxNameLen - FWNUM * 3; // default bar width
#if defined(PPM_UNIT_PERCENT_PREC1)
barW -= FWNUM + 1;
@@ -104,8 +103,8 @@ void menuModelFailsafe(event_t event)
// Channel name if present, number if not
if (lenLabel > 0) {
if (lenLabel > maxNameLen)
maxNameLen = lenLabel;
if (lenLabel > reusableBuffer.modelFailsafe.maxNameLen)
reusableBuffer.modelFailsafe.maxNameLen = lenLabel;
lcdDrawSizedText(x - colW, y, g_model.limitData[ch+channelStart].name, sizeof(g_model.limitData[ch+channelStart].name), ZCHAR | SMLSIZE);
}
else {
+2 -2
View File
@@ -126,12 +126,12 @@ void menuModelFlightModesAll(event_t event)
}
case ITEM_FLIGHT_MODES_FADE_IN:
lcdDrawNumber(32*FW-2, y, (10/DELAY_STEP)*p->fadeIn, attr|PREC1|RIGHT);
lcdDrawNumber(32*FW-2, y, p->fadeIn, attr|PREC1|RIGHT);
if (active) p->fadeIn = checkIncDec(event, p->fadeIn, 0, DELAY_MAX, EE_MODEL|NO_INCDEC_MARKS);
break;
case ITEM_FLIGHT_MODES_FADE_OUT:
lcdDrawNumber(35*FW, y, (10/DELAY_STEP)*p->fadeOut, attr|PREC1|RIGHT);
lcdDrawNumber(35*FW, y, p->fadeOut, attr|PREC1|RIGHT);
if (active) p->fadeOut = checkIncDec(event, p->fadeOut, 0, DELAY_MAX, EE_MODEL|NO_INCDEC_MARKS);
break;
+3 -2
View File
@@ -45,9 +45,10 @@ void onModelSelectMenu(const char * result)
POPUP_WARNING(eeBackupModel(sub));
}
else if (result == STR_RESTORE_MODEL || result == STR_UPDATE_LIST) {
if (!sdListFiles(MODELS_PATH, MODELS_EXT, MENU_LINE_LENGTH-1, NULL)) {
if (sdListFiles(MODELS_PATH, MODELS_EXT, MENU_LINE_LENGTH-1, nullptr))
POPUP_MENU_START(onModelSelectMenu);
else
POPUP_WARNING(STR_NO_MODELS_ON_SD);
}
}
else if (result == STR_DELETE_MODEL) {
char * nametmp = reusableBuffer.modelsel.mainname;
+33 -31
View File
@@ -252,7 +252,7 @@ inline uint8_t EXTERNAL_MODULE_TYPE_ROW()
return 1;
#if defined(MULTIMODULE)
else if (isModuleMultimodule(EXTERNAL_MODULE)) {
return 2 + MULTIMODULE_RFPROTO_COLUMNS(EXTERNAL_MODULE);
return 1 + MULTIMODULE_RFPROTO_COLUMNS(EXTERNAL_MODULE);
}
#endif
else
@@ -384,7 +384,8 @@ void menuModelSetup(event_t event)
MENU_CHECK(menuTabModel, MENU_MODEL_SETUP, ITEM_MODEL_SETUP_LINES_COUNT);
title(STR_MENUSETUP);
if (event == EVT_ENTRY) {
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) {
memclear(&reusableBuffer.moduleSetup, sizeof(reusableBuffer.moduleSetup));
reusableBuffer.moduleSetup.r9mPower = g_model.moduleData[EXTERNAL_MODULE].pxx.power;
}
@@ -397,10 +398,10 @@ void menuModelSetup(event_t event)
int sub = menuVerticalPosition;
for (int i=0; i<NUM_BODY_LINES; ++i) {
for (int i = 0; i < NUM_BODY_LINES; ++i) {
coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH;
uint8_t k = i+menuVerticalOffset;
for (int j=0; j<=k; j++) {
uint8_t k = i + menuVerticalOffset;
for (int j = 0; j <= k; j++) {
if (mstate_tab[j] == HIDDEN_ROW)
k++;
}
@@ -408,7 +409,7 @@ void menuModelSetup(event_t event)
LcdFlags blink = ((s_editMode>0) ? BLINK|INVERS : INVERS);
LcdFlags attr = (sub == k ? blink : 0);
switch(k) {
switch (k) {
case ITEM_MODEL_SETUP_NAME:
editSingleName(MODEL_SETUP_2ND_COLUMN, y, STR_MODELNAME, g_model.header.name, sizeof(g_model.header.name), event, attr);
memcpy(modelHeaders[g_eeGeneral.currModel].name, g_model.header.name, sizeof(g_model.header.name));
@@ -756,7 +757,7 @@ void menuModelSetup(event_t event)
#if defined(INTERNAL_MODULE_PXX1)
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_INTERNAL_MODULE_PROTOCOLS, g_model.moduleData[INTERNAL_MODULE].type, menuHorizontalPosition==0 ? attr : 0);
if (isModuleXJT(INTERNAL_MODULE))
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_XJT_ACCST_RF_PROTOCOLS, 1 + g_model.moduleData[INTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0);
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_XJT_ACCST_RF_PROTOCOLS, 1 + g_model.moduleData[INTERNAL_MODULE].subType, menuHorizontalPosition==1 ? attr : 0);
else if (isModuleISRM(INTERNAL_MODULE))
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_ISRM_RF_PROTOCOLS, 1 + g_model.moduleData[INTERNAL_MODULE].subType, menuHorizontalPosition==1 ? attr : 0);
if (attr) {
@@ -807,7 +808,7 @@ void menuModelSetup(event_t event)
lcdDrawTextAlignedLeft(y, INDENT TR_MODE);
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_EXTERNAL_MODULE_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].type, menuHorizontalPosition==0 ? attr : 0);
if (isModuleXJT(EXTERNAL_MODULE))
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_XJT_ACCST_RF_PROTOCOLS, 1+g_model.moduleData[EXTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0);
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_XJT_ACCST_RF_PROTOCOLS, 1+g_model.moduleData[EXTERNAL_MODULE].subType, menuHorizontalPosition==1 ? attr : 0);
else if (isModuleDSM2(EXTERNAL_MODULE))
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_DSM_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0);
else if (isModuleR9MNonAccess(EXTERNAL_MODULE))
@@ -844,27 +845,28 @@ void menuModelSetup(event_t event)
}
case 1:
if (isModuleDSM2(EXTERNAL_MODULE))
if (isModuleDSM2(EXTERNAL_MODULE)) {
CHECK_INCDEC_MODELVAR(event, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, DSM2_PROTO_LP45, DSM2_PROTO_DSMX);
}
#if defined(MULTIMODULE)
else if (isModuleMultimodule(EXTERNAL_MODULE)) {
int multiRfProto = g_model.moduleData[EXTERNAL_MODULE].multi.customProto == 1 ? MODULE_SUBTYPE_MULTI_CUSTOM : g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol(false);
CHECK_INCDEC_MODELVAR(event, multiRfProto, MODULE_SUBTYPE_MULTI_FIRST, MODULE_SUBTYPE_MULTI_LAST);
if (checkIncDec_Ret) {
g_model.moduleData[EXTERNAL_MODULE].multi.customProto = (multiRfProto == MODULE_SUBTYPE_MULTI_CUSTOM);
if (!g_model.moduleData[EXTERNAL_MODULE].multi.customProto)
g_model.moduleData[EXTERNAL_MODULE].setMultiProtocol(multiRfProto);
g_model.moduleData[EXTERNAL_MODULE].subType = 0;
// Sensible default for DSM2 (same as for ppm): 7ch@22ms + Autodetect settings enabled
if (g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol(true) == MODULE_SUBTYPE_MULTI_DSM2) {
g_model.moduleData[EXTERNAL_MODULE].multi.autoBindMode = 1;
}
else {
g_model.moduleData[EXTERNAL_MODULE].multi.autoBindMode = 0;
}
g_model.moduleData[EXTERNAL_MODULE].multi.optionValue = 0;
else if (isModuleMultimodule(EXTERNAL_MODULE)) {
int multiRfProto = g_model.moduleData[EXTERNAL_MODULE].multi.customProto == 1 ? MODULE_SUBTYPE_MULTI_CUSTOM : g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol(false);
CHECK_INCDEC_MODELVAR(event, multiRfProto, MODULE_SUBTYPE_MULTI_FIRST, MODULE_SUBTYPE_MULTI_LAST);
if (checkIncDec_Ret) {
g_model.moduleData[EXTERNAL_MODULE].multi.customProto = (multiRfProto == MODULE_SUBTYPE_MULTI_CUSTOM);
if (!g_model.moduleData[EXTERNAL_MODULE].multi.customProto)
g_model.moduleData[EXTERNAL_MODULE].setMultiProtocol(multiRfProto);
g_model.moduleData[EXTERNAL_MODULE].subType = 0;
// Sensible default for DSM2 (same as for ppm): 7ch@22ms + Autodetect settings enabled
if (g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol(true) == MODULE_SUBTYPE_MULTI_DSM2) {
g_model.moduleData[EXTERNAL_MODULE].multi.autoBindMode = 1;
}
else {
g_model.moduleData[EXTERNAL_MODULE].multi.autoBindMode = 0;
}
g_model.moduleData[EXTERNAL_MODULE].multi.optionValue = 0;
}
}
#endif
else if (isModuleR9MNonAccess(EXTERNAL_MODULE)) {
g_model.moduleData[EXTERNAL_MODULE].subType = checkIncDec(event, g_model.moduleData[EXTERNAL_MODULE].subType,
@@ -872,7 +874,7 @@ void menuModelSetup(event_t event)
isR9MModeAvailable);
}
else {
g_model.moduleData[EXTERNAL_MODULE].rfProtocol = checkIncDec(event, g_model.moduleData[EXTERNAL_MODULE].rfProtocol,
g_model.moduleData[EXTERNAL_MODULE].subType = checkIncDec(event, g_model.moduleData[EXTERNAL_MODULE].subType,
MODULE_SUBTYPE_PXX1_ACCST_D16, MODULE_SUBTYPE_PXX1_LAST, EE_MODEL,
isRfProtocolAvailable);
}
@@ -907,16 +909,16 @@ void menuModelSetup(event_t event)
if (isModuleR9MNonAccess(EXTERNAL_MODULE)) {
if (g_model.moduleData[EXTERNAL_MODULE].subType > MODULE_SUBTYPE_R9M_EU) {
POPUP_WARNING(STR_MODULE_PROTOCOL_FLEX_WARN_LINE1);
SET_WARNING_INFO(STR_R9M_PROTO_WARN_LINE2, sizeof(TR_R9M_PROTO_WARN_LINE2) - 1, 0);
SET_WARNING_INFO(STR_MODULE_PROTOCOL_WARN_LINE2, sizeof(TR_MODULE_PROTOCOL_WARN_LINE2) - 1, 0);
}
#if POPUP_LEVEL >= 3
else if (g_model.moduleData[EXTERNAL_MODULE].subType == MODULE_SUBTYPE_R9M_EU) {
POPUP_WARNING(STR_R9M_PROTO_EU_WARN_LINE1);
SET_WARNING_INFO(STR_R9M_PROTO_WARN_LINE2, sizeof(TR_R9M_PROTO_WARN_LINE2) - 1, 0);
POPUP_WARNING(STR_MODULE_PROTOCOL_EU_WARN_LINE1);
SET_WARNING_INFO(STR_MODULE_PROTOCOL_WARN_LINE2, sizeof(TR_MODULE_PROTOCOL_WARN_LINE2) - 1, 0);
}
else {
POPUP_WARNING(STR_R9M_PROTO_FCC_WARN_LINE1);
SET_WARNING_INFO(STR_R9M_PROTO_WARN_LINE2, sizeof(TR_R9M_PROTO_WARN_LINE2) - 1, 0);
POPUP_WARNING(STR_MODULE_PROTOCOL_FCC_WARN_LINE1);
SET_WARNING_INFO(STR_MODULE_PROTOCOL_WARN_LINE2, sizeof(TR_MODULE_PROTOCOL_WARN_LINE2) - 1, 0);
}
#endif
}
+4 -1
View File
@@ -238,12 +238,15 @@ void menuModelTelemetry(event_t event)
case ITEM_TELEMETRY_RSSI_SOURCE: {
lcdDrawTextAlignedLeft(y, INDENT TR_SOURCE);
drawSource(TELEM_COL2, y, g_model.rssiSource ? MIXSRC_FIRST_TELEM + 3 * (g_model.rssiSource - 1) : 0, attr);
if (g_model.rssiSource) {
drawSource(TELEM_COL2, y, MIXSRC_FIRST_TELEM + 3 * (g_model.rssiSource - 1), attr);
TelemetrySensor * sensor = &g_model.telemetrySensors[g_model.rssiSource - 1];
lcdDrawText(lcdNextPos, y, " ", attr);
drawReceiverName(lcdNextPos, y, sensor->frskyInstance.rxIndex >> 2, sensor->frskyInstance.rxIndex & 0x03, attr);
}
else {
lcdDrawText(TELEM_COL2, y, STR_DEFAULT, attr);
}
if (attr) {
g_model.rssiSource = checkIncDec(event, g_model.rssiSource, 0, MAX_TELEMETRY_SENSORS, EE_MODEL | NO_INCDEC_MARKS, isRssiSensorAvailable);
}
@@ -25,6 +25,7 @@ enum SensorFields {
SENSOR_FIELD_TYPE,
SENSOR_FIELD_ID,
SENSOR_FIELD_FORMULA=SENSOR_FIELD_ID,
SENSOR_FILED_RECEIVER_NAME,
SENSOR_FIELD_UNIT,
SENSOR_FIELD_PRECISION,
SENSOR_FIELD_PARAM1,
@@ -61,7 +62,23 @@ void menuModelSensor(event_t event)
drawSensorCustomValue(25*FW, 0, s_currIdx, getValue(MIXSRC_FIRST_TELEM+3*s_currIdx));
lcdDrawFilledRect(0, 0, LCD_W, FH, SOLID, FILL_WHITE|GREY_DEFAULT);
SUBMENU(STR_MENUSENSOR, SENSOR_FIELD_MAX, { 0, 0, sensor->type == TELEM_TYPE_CALCULATED ? (uint8_t)0 : (uint8_t)1, SENSOR_UNIT_ROWS, SENSOR_PREC_ROWS, SENSOR_PARAM1_ROWS, SENSOR_PARAM2_ROWS, SENSOR_PARAM3_ROWS, SENSOR_PARAM4_ROWS, SENSOR_AUTOOFFSET_ROWS, SENSOR_ONLYPOS_ROWS, SENSOR_FILTER_ROWS, SENSOR_PERSISTENT_ROWS, 0 });
SUBMENU(STR_MENUSENSOR, SENSOR_FIELD_MAX, {
0, //Name
0, // Type
sensor->type == TELEM_TYPE_CALCULATED ? (uint8_t)0 : (uint8_t)1, // ID / Formula
sensor->type == TELEM_TYPE_CALCULATED ? HIDDEN_ROW : READONLY_ROW, // Receiver name
SENSOR_UNIT_ROWS,
SENSOR_PREC_ROWS,
SENSOR_PARAM1_ROWS,
SENSOR_PARAM2_ROWS,
SENSOR_PARAM3_ROWS,
SENSOR_PARAM4_ROWS,
SENSOR_AUTOOFFSET_ROWS,
SENSOR_ONLYPOS_ROWS,
SENSOR_FILTER_ROWS,
SENSOR_PERSISTENT_ROWS,
0 // Logs
});
for (uint8_t i=0; i<NUM_BODY_LINES; i++) {
coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH;
@@ -130,6 +147,20 @@ void menuModelSensor(event_t event)
}
break;
case SENSOR_FILED_RECEIVER_NAME:
lcdDrawTextAlignedLeft(y, STR_SOURCE);
if (telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT && sensor->frskyInstance.rxIndex != TELEMETRY_ENDPOINT_SPORT) {
drawReceiverName(SENSOR_2ND_COLUMN, y, sensor->frskyInstance.rxIndex >> 2, sensor->frskyInstance.rxIndex & 0x03, 0);
}
else if (isModuleUsingSport(INTERNAL_MODULE, g_model.moduleData[INTERNAL_MODULE].type)) {
// far from perfect
lcdDrawText(SENSOR_2ND_COLUMN, y, STR_INTERNAL_MODULE);
}
else {
lcdDrawText(SENSOR_2ND_COLUMN, y, STR_EXTERNAL_MODULE);
}
break;
case SENSOR_FIELD_UNIT:
lcdDrawTextAlignedLeft(y, STR_UNIT);
lcdDrawTextAtIndex(SENSOR_2ND_COLUMN, y, STR_VTELEMUNIT, sensor->unit, attr);
+7 -5
View File
@@ -472,14 +472,16 @@ void menuRadioSetup(event_t event)
#if defined(PWR_BUTTON_PRESS)
case ITEM_RADIO_SETUP_PWR_ON_SPEED:
lcdDrawTextAlignedLeft(y, STR_PWR_ON_SPEED);
drawSlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOnSpeed +1, 3, attr);
lcdDrawTextAlignedLeft(y, STR_PWR_ON_DELAY);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, 2 - g_eeGeneral.pwrOnSpeed, attr|LEFT);
lcdDrawChar(lcdLastRightPos, y, 's');
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOnSpeed, -1, 2);
break;
case ITEM_RADIO_SETUP_PWR_OFF_SPEED:
lcdDrawTextAlignedLeft(y, STR_PWR_OFF_SPEED);
drawSlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOffSpeed +1, 3, attr);
lcdDrawTextAlignedLeft(y, STR_PWR_OFF_DELAY);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, 2 - g_eeGeneral.pwrOffSpeed, attr|LEFT);
lcdDrawChar(lcdLastRightPos, y, 's');
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffSpeed, -1, 2);
break;
#endif
@@ -528,7 +530,7 @@ void menuRadioSetup(event_t event)
#if defined(FAI_CHOICE)
case ITEM_RADIO_SETUP_FAI:
editCheckBox(g_eeGeneral.fai, RADIO_SETUP_2ND_COLUMN, y, "FAI Mode"), attr, event;
editCheckBox(g_eeGeneral.fai, RADIO_SETUP_2ND_COLUMN, y, "FAI Mode", attr, event);
if (attr && checkIncDec_Ret) {
if (g_eeGeneral.fai)
POPUP_WARNING("FAI\001mode blocked!");
+15 -13
View File
@@ -22,44 +22,46 @@
void menuChannelsView(event_t event)
{
static bool longNames = false;
static bool secondPage = false;
static bool mixersView = false;
uint8_t ch = 0;
uint8_t wbar = (longNames ? 54 : 64);
uint8_t wbar = (reusableBuffer.viewChannels.longNames ? 54 : 64);
int16_t limits = 512 * 2;
#if defined(PPM_UNIT_PERCENT_PREC1)
wbar -= 6;
#endif
switch(event)
{
switch(event) {
case EVT_ENTRY:
memclear(&reusableBuffer.viewChannels, sizeof(reusableBuffer.viewChannels));
break;
case EVT_KEY_BREAK(KEY_EXIT):
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
secondPage = !secondPage;
reusableBuffer.viewChannels.secondPage = !reusableBuffer.viewChannels.secondPage;
break;
case EVT_KEY_FIRST(KEY_ENTER):
mixersView = !mixersView;
reusableBuffer.viewChannels.mixersView = !reusableBuffer.viewChannels.mixersView;
break;
}
if (secondPage)
if (reusableBuffer.viewChannels.secondPage)
ch = 16;
if (mixersView)
if (reusableBuffer.viewChannels.mixersView)
limits *= 2; // this could be handled nicer, but slower, by checking actual range for this mixer
else if (g_model.extendedLimits)
limits *= LIMIT_EXT_PERCENT / 100;
if (mixersView)
if (reusableBuffer.viewChannels.mixersView)
lcdDrawTextAlignedCenter(0, TR_MIXERS_MONITOR);
else
lcdDrawTextAlignedCenter(0, TR_CHANNELS_MONITOR);
@@ -76,13 +78,13 @@ void menuChannelsView(event_t event)
// Channels
for (uint8_t line=0; line < 8; line++) {
const uint8_t y = 9 + line * 7;
const int32_t val = mixersView ? ex_chans[ch] : channelOutputs[ch];
const int32_t val = reusableBuffer.viewChannels.mixersView ? ex_chans[ch] : channelOutputs[ch];
const uint8_t lenLabel = ZLEN(g_model.limitData[ch].name);
// Channel name if present, number if not
if (lenLabel > 0) {
if (lenLabel > 4)
longNames = true;
reusableBuffer.viewChannels.longNames = true;
lcdDrawSizedText(x+1-ofs, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), ZCHAR | SMLSIZE);
}
else {
+2 -12
View File
@@ -342,7 +342,7 @@ void menuMainViewChannelsMonitor(event_t event)
return menuChannelsView(event);
}
void onMainViewMenu(const char *result)
void onMainViewMenu(const char * result)
{
if (result == STR_RESET_TIMER1) {
timerReset(0);
@@ -364,6 +364,7 @@ void onMainViewMenu(const char *result)
POPUP_MENU_ADD_ITEM(STR_RESET_TIMER2);
POPUP_MENU_ADD_ITEM(STR_RESET_TIMER3);
POPUP_MENU_ADD_ITEM(STR_RESET_TELEMETRY);
POPUP_MENU_START(onMainViewMenu);
}
else if (result == STR_RESET_TELEMETRY) {
telemetryReset();
@@ -409,16 +410,6 @@ void displaySwitch(coord_t x, coord_t y, int width, unsigned int index)
}
}
bool isMenuAvailable(int index)
{
if (index == 4) {
return modelHasNotes();
}
else {
return true;
}
}
int getSwitchCount()
{
int count = 0;
@@ -435,7 +426,6 @@ void menuMainView(event_t event)
static bool secondPage = false;
switch(event) {
case EVT_ENTRY:
killEvents(KEY_EXIT);
killEvents(KEY_UP);
+1 -6
View File
@@ -115,12 +115,7 @@ void menuStatisticsDebug(event_t event)
}
#endif
switch(event) {
case EVT_ENTRY:
case EVT_ENTRY_UP:
enableVBatBridge();
break;
switch (event) {
case EVT_KEY_LONG(KEY_ENTER):
g_eeGeneral.globalTimer = 0;
sessionTimer = 0;
+2 -2
View File
@@ -81,11 +81,11 @@ void title(const char * s)
lcdDrawText(0, 0, s, INVERS);
}
choice_t editChoice(coord_t x, coord_t y, const char * label, const char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event)
choice_t editChoice(coord_t x, coord_t y, const char * label, const char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event, IsValueAvailable isValueAvailable)
{
drawFieldLabel(x, y, label);
if (values) lcdDrawTextAtIndex(x, y, values, value-min, attr);
if (attr & (~RIGHT)) value = checkIncDec(event, value, min, max, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL);
if (attr & (~RIGHT)) value = checkIncDec(event, value, min, max, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL, isValueAvailable);
return value;
}
+4
View File
@@ -64,6 +64,10 @@ const uint8_t LBM_TOPMENU_TXBATT[] = {
#include "mask_txbat.lbm"
};
const uint8_t LBM_TOPMENU_ANTENNA[] = {
#include "mask_antenna.lbm"
};
const uint8_t LBM_HTRIM_FRAME[] = {
#include "mask_htrim_frame.lbm"
};
+1
View File
@@ -26,6 +26,7 @@ extern const uint8_t LBM_DOT[];
// Main view icons
extern const uint8_t LBM_TOPMENU_USB[];
extern const uint8_t LBM_TOPMENU_ANTENNA[];
extern const uint8_t LBM_TOPMENU_VOLUME_0[];
extern const uint8_t LBM_TOPMENU_VOLUME_1[];
extern const uint8_t LBM_TOPMENU_VOLUME_2[];
-3
View File
@@ -342,9 +342,6 @@ extern uint8_t popupMenuOffsetType;
extern uint8_t popupMenuSelectedItem;
const char * runPopupMenu(event_t event);
extern void (*popupMenuHandler)(const char * result);
#define TEXT_FILENAME_MAXLEN 40
extern char s_text_file[TEXT_FILENAME_MAXLEN];
void pushMenuTextView(const char * filename);
void pushModelNotes();
void readModelNotes();
+4 -6
View File
@@ -133,15 +133,13 @@ void ModelFlightModesPage::build(FormWindow * window)
// Flight mode fade in / out
new StaticText(group, grid.getLabelSlot(true), "Fade in/out");
auto edit = new NumberEdit(group, grid.getFieldSlot(2, 0), 0, DELAY_MAX,
GET_DEFAULT(g_model.flightModeData[i].fadeIn * (10 / DELAY_STEP)),
SET_VALUE(g_model.flightModeData[i].fadeIn, newValue / (10 / DELAY_STEP)),
GET_DEFAULT(g_model.flightModeData[i].fadeIn),
SET_VALUE(g_model.flightModeData[i].fadeIn, newValue),
PREC1);
edit->setStep(10 / DELAY_STEP);
edit = new NumberEdit(group, grid.getFieldSlot(2, 1), 0, DELAY_MAX,
GET_DEFAULT(g_model.flightModeData[i].fadeOut * (10 / DELAY_STEP)),
SET_VALUE(g_model.flightModeData[i].fadeOut, newValue / (10 / DELAY_STEP)),
GET_DEFAULT(g_model.flightModeData[i].fadeOut),
SET_VALUE(g_model.flightModeData[i].fadeOut, newValue),
PREC1);
edit->setStep(10 / DELAY_STEP);
grid.nextLine();
group->setLastField(FormField::getCurrentField());
+3 -2
View File
@@ -158,14 +158,15 @@ bool menuModelGVars(event_t event)
gvar_t v = fm->gvars[i];
LcdFlags attr = RIGHT | ((sub == i && menuHorizontalPosition == j) ? (s_editMode > 0 ? BLINK | INVERS : INVERS) : 0);
if (j == curfm)
attr |= BOLD;
coord_t x = GVARS_FM_COLUMN(j);
coord_t yval = y;
if (v <= GVAR_MAX && (g_model.gvars[i].prec > 0 || abs(v) >= 1000 || ( abs(v) >= 100 && g_model.gvars[i].unit > 0))) {
attr |= SMLSIZE;
yval += 3;
}
else if (j == curfm) {
attr |= BOLD;
}
if (v <= GVAR_MAX && g_model.gvars[i].unit > 0) {
x -= 9;
lcdDrawText(GVARS_FM_COLUMN(j) - 9, y+5, "%", TINSIZE);
-4
View File
@@ -190,7 +190,6 @@ class MixEditWindow : public Page {
GET_DEFAULT(mix->delayUp),
SET_VALUE(mix->delayUp, newValue),
PREC1);
edit->setStep(10 / DELAY_STEP);
edit->setSuffix("s");
grid.nextLine();
@@ -200,7 +199,6 @@ class MixEditWindow : public Page {
GET_DEFAULT(mix->delayDown),
SET_VALUE(mix->delayDown, newValue),
PREC1);
edit->setStep(10 / DELAY_STEP);
edit->setSuffix("s");
grid.nextLine();
@@ -210,7 +208,6 @@ class MixEditWindow : public Page {
GET_DEFAULT(mix->speedUp),
SET_VALUE(mix->speedUp, newValue),
PREC1);
edit->setStep(10 / DELAY_STEP);
edit->setSuffix("s");
grid.nextLine();
@@ -220,7 +217,6 @@ class MixEditWindow : public Page {
GET_DEFAULT(mix->speedDown),
SET_VALUE(mix->speedDown, newValue),
PREC1);
edit->setStep(10 / DELAY_STEP);
edit->setSuffix("s");
grid.nextLine();
+23 -22
View File
@@ -219,6 +219,27 @@ bool menuModelWizard(event_t event)
}
#endif
void onDeleteModelConfirm(const char * result)
{
if (result == STR_OK) {
if (deleteMode == MODE_DELETE_CATEGORY) {
modelslist.removeCategory(currentCategory);
modelslist.save();
setCurrentCategory(currentCategoryIndex > 0 ? currentCategoryIndex-1 : currentCategoryIndex);
}
else if (deleteMode == MODE_DELETE_MODEL){
int modelIndex = MODEL_INDEX();
modelslist.removeModel(currentCategory, currentModel);
s_copyMode = 0;
putEvent(EVT_REFRESH);
if (modelIndex > 0) {
modelIndex--;
}
setCurrentModel(modelIndex);
}
}
}
void onModelSelectMenu(const char * result)
{
if (result == STR_SELECT_MODEL) {
@@ -233,7 +254,7 @@ void onModelSelectMenu(const char * result)
chainMenu(menuMainView);
}
else if (result == STR_DELETE_MODEL) {
POPUP_CONFIRMATION(STR_DELETEMODEL);
POPUP_CONFIRMATION(STR_DELETEMODEL, onDeleteModelConfirm);
SET_WARNING_INFO(currentModel->modelName, LEN_MODEL_NAME, 0);
deleteMode = MODE_DELETE_MODEL;
}
@@ -279,7 +300,7 @@ void onModelSelectMenu(const char * result)
SET_WARNING_INFO(STR_CAT_NOT_EMPTY, sizeof(TR_CAT_NOT_EMPTY), 0);
}
else {
POPUP_CONFIRMATION(STR_DELETEMODEL);
POPUP_CONFIRMATION(STR_DELETEMODEL, onDeleteModelConfirm);
SET_WARNING_INFO(currentCategory->name, LEN_MODEL_FILENAME, 0);
deleteMode = MODE_DELETE_CATEGORY;
}
@@ -322,26 +343,6 @@ void initModelsList()
bool menuModelSelect(event_t event)
{
if (warningResult) {
warningResult = 0;
if (deleteMode == MODE_DELETE_CATEGORY) {
TRACE("DELETE CATEGORY");
modelslist.removeCategory(currentCategory);
modelslist.save();
setCurrentCategory(currentCategoryIndex > 0 ? currentCategoryIndex-1 : currentCategoryIndex);
}
else if (deleteMode == MODE_DELETE_MODEL){
int modelIndex = MODEL_INDEX();
modelslist.removeModel(currentCategory, currentModel);
s_copyMode = 0;
event = EVT_REFRESH;
if (modelIndex > 0) {
modelIndex--;
}
setCurrentModel(modelIndex);
}
}
const std::list<ModelsCategory*>& cats = modelslist.getCategories();
switch(event) {
case 0:
+8 -8
View File
@@ -831,20 +831,20 @@ void onBindMenu(const char * result)
uint8_t moduleIdx = 0; // TODO (menuVerticalPosition >= ITEM_MODEL_EXTERNAL_MODULE_LABEL ? EXTERNAL_MODULE : INTERNAL_MODULE);
if (result == STR_BINDING_1_8_TELEM_ON) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = false;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = false;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = false;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = false;
}
else if (result == STR_BINDING_1_8_TELEM_OFF) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = true;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = false;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = true;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = false;
}
else if (result == STR_BINDING_9_16_TELEM_ON) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = false;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = true;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = false;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = true;
}
else if (result == STR_BINDING_9_16_TELEM_OFF) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = true;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = true;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = true;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = true;
}
else {
return;
+1 -1
View File
@@ -118,7 +118,7 @@ void RadioToolsPage::checkEvents()
void RadioToolsPage::rebuild(FormWindow * window)
{
FormGridLayout grid;
grid.spacer(8);
grid.spacer(PAGE_PADDING);
grid.setLabelWidth(100);
window->clear();
+1 -1
View File
@@ -36,8 +36,8 @@ void RadioTrainerPage::build(FormWindow * window)
#define TRAINER_LABEL_WIDTH 100
#endif
FormGridLayout grid;
grid.spacer(PAGE_PADDING);
grid.setLabelWidth(TRAINER_LABEL_WIDTH);
grid.nextLine();
for (uint8_t i=0; i<NUM_STICKS; i++) {
uint8_t chan = channelOrder(i+1);
+1 -1
View File
@@ -96,7 +96,7 @@ class FrskyTheme: public Theme
void loadIcons() const
{
#if defined(LOG_TELEMETRY) || defined(WATCHDOG_DISABLED)
#if defined(LOG_TELEMETRY) || !defined(WATCHDOG)
loadMenuIcon(ICON_OPENTX, "mask_opentx_testmode.png", TEXT_COLOR);
#else
loadMenuIcon(ICON_OPENTX, "mask_opentx.png");
+6
View File
@@ -55,6 +55,12 @@ void drawTopBar()
lcdDrawSolidFilledRect(LCD_W-90 + i * 6, 38 - height, 4, height, TELEMETRY_RSSI() >= rssiBarsValue[i] ? MENU_TITLE_COLOR : MENU_TITLE_DISABLE_COLOR);
}
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
if (isModuleXJT(INTERNAL_MODULE) && isExternalAntennaEnabled()) {
lcdDrawBitmapPattern(LCD_W-94, 4, LBM_TOPMENU_ANTENNA, MENU_TITLE_COLOR);
}
#endif
/* Audio volume */
lcdDrawBitmapPattern(LCD_W-130, 4, LBM_TOPMENU_VOLUME_SCALE, MENU_TITLE_DISABLE_COLOR);
if (requiredSpeakerVolume == 0 || g_eeGeneral.beepMode == e_mode_quiet)
@@ -98,7 +98,6 @@ bool menuStatsDebug(event_t event)
switch(event) {
case EVT_ENTRY:
case EVT_ENTRY_UP:
enableVBatBridge();
break;
case EVT_KEY_FIRST(KEY_ENTER):
+8 -81
View File
@@ -20,91 +20,17 @@
#include "opentx.h"
#define TEXT_FILE_MAXSIZE 2048
char s_text_file[TEXT_FILENAME_MAXLEN];
char s_text_screen[NUM_BODY_LINES][LCD_COLS+1];
void readTextFile(int & lines_count)
{
FIL file;
int result;
char c;
unsigned int sz;
int line_length = 0;
int escape = 0;
char escape_chars[2];
int current_line = 0;
memset(s_text_screen, 0, sizeof(s_text_screen));
result = f_open(&file, s_text_file, FA_OPEN_EXISTING | FA_READ);
if (result == FR_OK) {
for (int i=0; i<TEXT_FILE_MAXSIZE && f_read(&file, &c, 1, &sz)==FR_OK && sz==1 && (lines_count==0 || current_line-menuVerticalOffset<NUM_BODY_LINES); i++) {
if (c == '\n') {
++current_line;
line_length = 0;
escape = 0;
}
else if (c!='\r' && current_line>=menuVerticalOffset && current_line-menuVerticalOffset<NUM_BODY_LINES && line_length<LCD_COLS) {
if (c=='\\' && escape==0) {
escape = 1;
continue;
}
else if (c!='\\' && escape>0 && escape<4) {
escape_chars[escape-1] = c;
if (escape == 2 && !strncmp(escape_chars, "up", 2)) {
c = '\300';
escape = 0;
}
else if (escape == 2 && !strncmp(escape_chars, "dn", 2)) {
c = '\301';
escape = 0;
}
else if (escape == 3) {
int val = atoi(escape_chars);
if (val >= 200 && val < 225) {
c = '\200' + val-200;
}
escape = 0;
}
else {
escape++;
continue;
}
}
else if (c=='~') {
c = 'z'+1;
}
else if (c=='\t') {
c = 0x1D; //tab
}
escape = 0;
s_text_screen[current_line-menuVerticalOffset][line_length++] = c;
}
}
if (c != '\n') {
current_line += 1;
}
f_close(&file);
}
if (lines_count == 0) {
lines_count = current_line;
}
}
bool menuTextView(event_t event)
{
static int lines_count;
drawMenuTemplate(STR_TEXT_VIEWER, ICON_OPENTX);
drawMenuTemplate(STR_TEXT_VIEWER, ICON_OPENTX, nullptr, OPTION_MENU_NO_SCROLLBAR);
switch (event) {
case EVT_ENTRY:
menuVerticalOffset = 0;
lines_count = 0;
readTextFile(lines_count);
sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, lines_count);
break;
case EVT_ROTARY_LEFT:
@@ -112,24 +38,25 @@ bool menuTextView(event_t event)
break;
else
menuVerticalOffset--;
readTextFile(lines_count);
sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, lines_count);
break;
case EVT_ROTARY_RIGHT:
if (menuVerticalOffset+NUM_BODY_LINES >= lines_count)
if (menuVerticalOffset + NUM_BODY_LINES >= lines_count)
break;
else
++menuVerticalOffset;
readTextFile(lines_count);
sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, lines_count);
break;
case EVT_KEY_FIRST(KEY_EXIT):
menuVerticalOffset = 0;
popMenu();
break;
}
for (int i=0; i<NUM_BODY_LINES; i++) {
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + i*FH, s_text_screen[i]);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + i*FH, reusableBuffer.viewText.lines[i]);
}
#if 0
@@ -148,7 +75,7 @@ bool menuTextView(event_t event)
void pushMenuTextView(const char *filename)
{
if (strlen(filename) < TEXT_FILENAME_MAXLEN) {
strcpy(s_text_file, filename);
strcpy(reusableBuffer.viewText.filename, filename);
pushMenu(menuTextView);
}
}
+3 -2
View File
@@ -22,6 +22,7 @@
#define _WIDGET_H_
#include <list>
#include <string.h>
#include "zone.h"
#define MAX_WIDGET_OPTIONS 5
@@ -58,7 +59,7 @@ class Widget
virtual const char * getErrorMessage() const
{
return NULL;
return nullptr;
}
inline ZoneOptionValue * getOptionValue(unsigned int index) const
@@ -83,7 +84,7 @@ void registerWidget(const WidgetFactory * factory);
class WidgetFactory
{
public:
WidgetFactory(const char * name, const ZoneOption * options=NULL):
WidgetFactory(const char * name, const ZoneOption * options=nullptr):
name(name),
options(options)
{
@@ -25,7 +25,7 @@
void drawStringWithIndex(coord_t x, coord_t y, const char * str, int idx, LcdFlags flags, const char * prefix, const char * suffix);
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att);
int editChoice(coord_t x, coord_t y, const char * values, int value, int min, int max, LcdFlags attr, event_t event);
int editChoice(coord_t x, coord_t y, const char * values, int value, int min, int max, LcdFlags attr, event_t event, IsValueAvailable isValueAvailable=nullptr);
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, LcdFlags attr, event_t event);
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t event);
void drawFatalErrorScreen(const char * message);
+2 -2
View File
@@ -23,8 +23,8 @@
void menuModelNotes(event_t event)
{
if (event == EVT_ENTRY) {
strcpy(s_text_file, MODELS_PATH "/");
char *buf = strcat_modelname(&s_text_file[sizeof(MODELS_PATH)], g_eeGeneral.currModel);
strcpy(reusableBuffer.viewText.filename, MODELS_PATH "/");
char *buf = strcat_modelname(&reusableBuffer.viewText.filename[sizeof(MODELS_PATH)], g_eeGeneral.currModel);
strcpy(buf, TEXT_EXT);
}
@@ -24,26 +24,26 @@ void onBindMenu(const char * result)
uint8_t moduleIdx = CURRENT_MODULE_EDITED(menuVerticalPosition - HEADER_LINE);
if (result == STR_BINDING_1_8_TELEM_ON) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = false;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = false;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = false;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = false;
if (isModuleR9MLiteNonPro(moduleIdx) && isModuleR9M_LBT(moduleIdx)) {
g_model.moduleData[moduleIdx].pxx.power = R9M_LITE_LBT_POWER_25_8CH;
}
}
else if (result == STR_BINDING_1_8_TELEM_OFF) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = true;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = false;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = true;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = false;
if (isModuleR9MLiteNonPro(moduleIdx) && isModuleR9M_LBT(moduleIdx)) {
g_model.moduleData[moduleIdx].pxx.power = R9M_LITE_LBT_POWER_100_16CH_NOTELEM;
}
}
else if (result == STR_BINDING_9_16_TELEM_ON) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = false;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = true;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = false;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = true;
}
else if (result == STR_BINDING_9_16_TELEM_OFF) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = true;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = true;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = true;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = true;
}
else {
return;
@@ -66,13 +66,13 @@ void startBindMenu(uint8_t moduleIdx)
POPUP_MENU_ADD_ITEM(STR_BINDING_9_16_TELEM_OFF);
}
if (isBindCh9To16Allowed(moduleIdx) && g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16) {
if (isBindCh9To16Allowed(moduleIdx) && g_model.moduleData[moduleIdx].pxx.receiverHigherChannels) {
selection += 1;
if (isTelemAllowedOnBind(moduleIdx))
selection += 1;
}
if (isTelemAllowedOnBind(moduleIdx) && g_model.moduleData[moduleIdx].pxx.receiver_telem_off)
if (isTelemAllowedOnBind(moduleIdx) && g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff)
selection += 1;
POPUP_MENU_SELECT_ITEM(selection);
@@ -298,13 +298,15 @@ void modelSetupModulePxx2ReceiverLine(uint8_t moduleIdx, uint8_t receiverIdx, co
if (moduleState[moduleIdx].mode == MODULE_MODE_BIND) {
if (reusableBuffer.moduleSetup.bindInformation.step == BIND_INIT) {
if (reusableBuffer.moduleSetup.bindInformation.candidateReceiversCount > 0) {
popupMenuItemsCount = min<uint8_t>(reusableBuffer.moduleSetup.bindInformation.candidateReceiversCount, PXX2_MAX_RECEIVERS_PER_MODULE);
for (auto rx = 0; rx < popupMenuItemsCount; rx++) {
popupMenuItems[rx] = reusableBuffer.moduleSetup.bindInformation.candidateReceiversNames[rx];
if (reusableBuffer.moduleSetup.bindInformation.candidateReceiversCount != popupMenuItemsCount) {
CLEAR_POPUP();
popupMenuItemsCount = reusableBuffer.moduleSetup.bindInformation.candidateReceiversCount;
for (auto rx = 0; rx < popupMenuItemsCount; rx++) {
popupMenuItems[rx] = reusableBuffer.moduleSetup.bindInformation.candidateReceiversNames[rx];
}
popupMenuTitle = STR_PXX2_SELECT_RX;
POPUP_MENU_START(onPXX2BindMenu);
}
popupMenuTitle = STR_PXX2_SELECT_RX;
CLEAR_POPUP();
POPUP_MENU_START(onPXX2BindMenu);
}
else {
POPUP_WAIT(STR_WAITING_FOR_RX);
+18 -8
View File
@@ -81,6 +81,9 @@ enum
inline void CLEAR_POPUP()
{
warningText = nullptr;
warningInfoText = nullptr;
popupMenuHandler = nullptr;
popupMenuItemsCount = 0;
}
inline void POPUP_WAIT(const char * s)
@@ -109,11 +112,14 @@ enum
inline void POPUP_CONFIRMATION(const char * s, PopupMenuHandler handler)
{
warningText = s;
warningInfoText = nullptr;
warningType = WARNING_TYPE_CONFIRM;
popupFunc = runPopupWarning;
popupMenuHandler = handler;
if (s != warningText) {
killAllEvents();
warningText = s;
warningInfoText = nullptr;
warningType = WARNING_TYPE_CONFIRM;
popupFunc = runPopupWarning;
popupMenuHandler = handler;
}
}
inline void POPUP_INPUT(const char * s, PopupFunc func)
@@ -146,8 +152,9 @@ enum
inline void POPUP_MENU_ADD_ITEM(const char * s)
{
popupMenuOffsetType = MENU_OFFSET_INTERNAL;
if (popupMenuItemsCount < POPUP_MENU_MAX_LINES)
if (popupMenuItemsCount < POPUP_MENU_MAX_LINES) {
popupMenuItems[popupMenuItemsCount++] = s;
}
}
#if defined(SDCARD)
@@ -163,8 +170,11 @@ inline void POPUP_MENU_SELECT_ITEM(uint8_t index)
inline void POPUP_MENU_START(PopupMenuHandler handler)
{
popupMenuHandler = handler;
AUDIO_KEY_PRESS();
if (handler != popupMenuHandler) {
killAllEvents();
AUDIO_KEY_PRESS();
popupMenuHandler = handler;
}
}
#endif // _STDLCD_POPUPS_H_
+43 -1
View File
@@ -18,7 +18,7 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include <opentx.h>
#if defined(PCBSKY9X)
#define HW_SETTINGS_COLUMN (2+(15*FW))
@@ -169,6 +169,10 @@ enum {
ITEM_RADIO_HARDWARE_BLUETOOTH_NAME,
#endif
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
ITEM_RADIO_HARDWARE_EXTERNAL_ANTENNA,
#endif
#if defined(AUX_SERIAL)
ITEM_RADIO_HARDWARE_AUX_SERIAL_MODE,
#endif
@@ -221,6 +225,23 @@ enum {
#define BLUETOOTH_ROWS uint8_t(IS_BLUETOOTH_CHIP_PRESENT() ? 0 : HIDDEN_ROW), uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_TELEMETRY ? -1 : HIDDEN_ROW), uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ? HIDDEN_ROW : -1), uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ? HIDDEN_ROW : -1), uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ? HIDDEN_ROW : 0),
#endif
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
#define EXTERNAL_ANTENNA_ROW 0,
void onHardwareAntennaSwitchConfirm(const char * result)
{
if (result == STR_OK) {
// Switch to external antenna confirmation
g_eeGeneral.antennaMode = reusableBuffer.radioHardware.antennaMode;
storageDirty(EE_GENERAL);
}
else {
reusableBuffer.radioHardware.antennaMode = g_eeGeneral.antennaMode;
}
}
#else
#define EXTERNAL_ANTENNA_ROW
#endif
#if defined(PCBX9LITE)
#define SWITCH_TYPE_MAX(sw) (sw == MIXSRC_SD-MIXSRC_FIRST_SWITCH ? SWITCH_2POS : SWITCH_3POS)
#elif defined(PCBXLITES)
@@ -298,6 +319,8 @@ void menuRadioHardware(event_t event)
BLUETOOTH_ROWS
EXTERNAL_ANTENNA_ROW
AUX_SERIAL_ROWS
0 /* ADC filter */,
@@ -324,6 +347,9 @@ void menuRadioHardware(event_t event)
}
else if (event == EVT_ENTRY) {
enableVBatBridge();
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
reusableBuffer.radioHardware.antennaMode = g_eeGeneral.antennaMode;
#endif
}
for (uint8_t i=0; i<NUM_BODY_LINES; i++) {
@@ -546,6 +572,22 @@ void menuRadioHardware(event_t event)
break;
#endif
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
case ITEM_RADIO_HARDWARE_EXTERNAL_ANTENNA:
reusableBuffer.radioHardware.antennaMode = editChoice(HW_SETTINGS_COLUMN2, y, STR_ANTENNA, STR_ANTENNA_MODES, reusableBuffer.radioHardware.antennaMode, ANTENNA_MODE_INTERNAL, ANTENNA_MODE_EXTERNAL, attr, event);
if (!s_editMode && reusableBuffer.radioHardware.antennaMode != g_eeGeneral.antennaMode) {
if (!isExternalAntennaEnabled() && (reusableBuffer.radioHardware.antennaMode == ANTENNA_MODE_EXTERNAL || (reusableBuffer.radioHardware.antennaMode == ANTENNA_MODE_PER_MODEL && g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode == ANTENNA_MODE_EXTERNAL))) {
POPUP_CONFIRMATION(STR_ANTENNACONFIRM1, onHardwareAntennaSwitchConfirm);
SET_WARNING_INFO(STR_ANTENNACONFIRM2, sizeof(TR_ANTENNACONFIRM2), 0);
}
else {
g_eeGeneral.antennaMode = reusableBuffer.radioHardware.antennaMode;
checkExternalAntenna();
}
}
break;
#endif
#if defined(AUX_SERIAL)
case ITEM_RADIO_HARDWARE_AUX_SERIAL_MODE:
g_eeGeneral.auxSerialMode = editChoice(HW_SETTINGS_COLUMN2, y, STR_AUX_SERIAL_MODE, STR_AUX_SERIAL_MODES, g_eeGeneral.auxSerialMode, 0, UART_MODE_MAX, attr, event);
+12 -12
View File
@@ -21,11 +21,15 @@
#include "opentx.h"
#include "io/frsky_firmware_update.h"
#define REFRESH_FILES() do { reusableBuffer.sdManager.offset = 65535; menuVerticalPosition = 0; } while(0)
#define NODE_TYPE(fname) fname[SD_SCREEN_FILE_LENGTH+1]
#define IS_DIRECTORY(fname) ((bool)(!NODE_TYPE(fname)))
#define IS_FILE(fname) ((bool)(NODE_TYPE(fname)))
inline void REFRESH_FILES()
{
reusableBuffer.sdManager.offset = 65535;
}
void menuRadioSdManagerInfo(event_t event)
{
SIMPLE_SUBMENU(STR_SD_INFO_TITLE, 1);
@@ -288,7 +292,7 @@ void menuRadioSdManager(event_t _event)
break;
case EVT_ENTRY_UP:
menuVerticalOffset = reusableBuffer.sdManager.offset;
REFRESH_FILES();
break;
#if defined(PCBX9) || defined(RADIO_X7) // TODO NO_MENU_KEY
@@ -421,23 +425,19 @@ void menuRadioSdManager(event_t _event)
FILINFO fno;
DIR dir;
if (menuVerticalOffset == 0) {
reusableBuffer.sdManager.offset = 0;
memset(reusableBuffer.sdManager.lines, 0, sizeof(reusableBuffer.sdManager.lines));
}
else if (menuVerticalOffset == reusableBuffer.sdManager.count-NUM_BODY_LINES) {
reusableBuffer.sdManager.offset = menuVerticalOffset;
memset(reusableBuffer.sdManager.lines, 0, sizeof(reusableBuffer.sdManager.lines));
}
else if (menuVerticalOffset > reusableBuffer.sdManager.offset) {
if (menuVerticalOffset == reusableBuffer.sdManager.offset + 1) {
memmove(reusableBuffer.sdManager.lines[0], reusableBuffer.sdManager.lines[1], (NUM_BODY_LINES-1)*sizeof(reusableBuffer.sdManager.lines[0]));
memset(reusableBuffer.sdManager.lines[NUM_BODY_LINES-1], 0xff, SD_SCREEN_FILE_LENGTH);
NODE_TYPE(reusableBuffer.sdManager.lines[NUM_BODY_LINES-1]) = 1;
}
else {
else if (menuVerticalOffset == reusableBuffer.sdManager.offset - 1) {
memmove(reusableBuffer.sdManager.lines[1], reusableBuffer.sdManager.lines[0], (NUM_BODY_LINES-1)*sizeof(reusableBuffer.sdManager.lines[0]));
memset(reusableBuffer.sdManager.lines[0], 0, sizeof(reusableBuffer.sdManager.lines[0]));
}
else {
reusableBuffer.sdManager.offset = menuVerticalOffset;
memset(reusableBuffer.sdManager.lines, 0, sizeof(reusableBuffer.sdManager.lines));
}
reusableBuffer.sdManager.count = 0;
+6 -10
View File
@@ -85,16 +85,16 @@ void menuRadioTools(event_t event)
uint8_t index = 0;
#if defined(PXX2)
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER))
if (isPXX2ModuleOptionAvailable(reusableBuffer.radioTools.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER))
addRadioModuleTool(index++, STR_SPECTRUM_ANALYSER_INT, menuRadioSpectrumAnalyser, INTERNAL_MODULE);
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER))
if (isPXX2ModuleOptionAvailable(reusableBuffer.radioTools.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER))
addRadioModuleTool(index++, STR_POWER_METER_INT, menuRadioPowerMeter, INTERNAL_MODULE);
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER))
if (isPXX2ModuleOptionAvailable(reusableBuffer.radioTools.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER))
addRadioModuleTool(index++, STR_SPECTRUM_ANALYSER_EXT, menuRadioSpectrumAnalyser, EXTERNAL_MODULE);
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER))
if (isPXX2ModuleOptionAvailable(reusableBuffer.radioTools.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER))
addRadioModuleTool(index++, STR_POWER_METER_EXT, menuRadioPowerMeter, EXTERNAL_MODULE);
#endif
@@ -102,11 +102,6 @@ void menuRadioTools(event_t event)
FILINFO fno;
DIR dir;
#if defined(CROSSFIRE)
if(isFileAvailable(SCRIPTS_TOOLS_PATH "/CROSSFIRE/crossfire.lua"))
addRadioScriptTool(index++, SCRIPTS_TOOLS_PATH "/CROSSFIRE/crossfire.lua");
#endif
FRESULT res = f_opendir(&dir, SCRIPTS_TOOLS_PATH);
if (res == FR_OK) {
for (;;) {
@@ -121,6 +116,7 @@ void menuRadioTools(event_t event)
if (isRadioScriptTool(fno.fname))
addRadioScriptTool(index++, path);
}
f_closedir(&dir);
}
#endif
@@ -129,4 +125,4 @@ void menuRadioTools(event_t event)
}
reusableBuffer.radioTools.linesCount = index;
}
}
+12 -88
View File
@@ -20,80 +20,6 @@
#include "opentx.h"
#define TEXT_FILE_MAXSIZE 2048
char s_text_file[TEXT_FILENAME_MAXLEN];
char s_text_screen[LCD_LINES-1][LCD_COLS+1];
void readTextFile(int & lines_count)
{
FIL file;
int result;
char c;
unsigned int sz;
int line_length = 0;
int escape = 0;
char escape_chars[4] = {0};
int current_line = 0;
memset(s_text_screen, 0, sizeof(s_text_screen));
result = f_open(&file, s_text_file, FA_OPEN_EXISTING | FA_READ);
if (result == FR_OK) {
for (int i=0; i<TEXT_FILE_MAXSIZE && f_read(&file, &c, 1, &sz)==FR_OK && sz==1 && (lines_count==0 || current_line-menuVerticalOffset<LCD_LINES-1); i++) {
if (c == '\n') {
++current_line;
line_length = 0;
escape = 0;
}
else if (c!='\r' && current_line>=menuVerticalOffset && current_line-menuVerticalOffset<LCD_LINES-1 && line_length<LCD_COLS) {
if (c=='\\' && escape==0) {
escape = 1;
continue;
}
else if (c!='\\' && escape>0 && escape<4) {
escape_chars[escape-1] = c;
if (escape == 2 && !strncmp(escape_chars, "up", 2)) {
c = '\300';
escape = 0;
}
else if (escape == 2 && !strncmp(escape_chars, "dn", 2)) {
c = '\301';
escape = 0;
}
else if (escape == 3) {
int val = atoi(escape_chars);
if (val >= 200 && val < 225) {
c = '\200' + val-200;
}
escape = 0;
}
else {
escape++;
continue;
}
}
else if (c=='~') {
c = 'z'+1;
}
else if (c=='\t') {
c = 0x1D; //tab
}
escape = 0;
s_text_screen[current_line-menuVerticalOffset][line_length++] = c;
}
}
if (c != '\n') {
current_line += 1;
}
f_close(&file);
}
if (lines_count == 0) {
lines_count = current_line;
}
}
#if defined(ROTARY_ENCODER_NAVIGATION)
#define EVT_KEY_NEXT_LINE EVT_ROTARY_RIGHT
#define EVT_KEY_PREVIOUS_LINE EVT_ROTARY_LEFT
@@ -106,8 +32,8 @@ void readModelNotes()
{
LED_ERROR_BEGIN();
strcpy(s_text_file, MODELS_PATH "/");
char *buf = strcat_modelname(&s_text_file[sizeof(MODELS_PATH)], g_eeGeneral.currModel);
strcpy(reusableBuffer.viewText.filename, MODELS_PATH "/");
char *buf = strcat_modelname(&reusableBuffer.viewText.filename[sizeof(MODELS_PATH)], g_eeGeneral.currModel);
strcpy(buf, TEXT_EXT);
waitKeysReleased();
@@ -126,13 +52,11 @@ void readModelNotes()
void menuTextView(event_t event)
{
static int lines_count;
switch (event) {
case EVT_ENTRY:
menuVerticalOffset = 0;
lines_count = 0;
readTextFile(lines_count);
reusableBuffer.viewText.linesCount = 0;
sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount);
break;
case EVT_KEY_PREVIOUS_LINE:
@@ -140,15 +64,15 @@ void menuTextView(event_t event)
break;
else
menuVerticalOffset--;
readTextFile(lines_count);
sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount);
break;
case EVT_KEY_NEXT_LINE:
if (menuVerticalOffset+LCD_LINES-1 >= lines_count)
if (menuVerticalOffset+LCD_LINES-1 >= reusableBuffer.viewText.linesCount)
break;
else
++menuVerticalOffset;
readTextFile(lines_count);
sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount);
break;
case EVT_KEY_BREAK(KEY_EXIT):
@@ -157,10 +81,10 @@ void menuTextView(event_t event)
}
for (int i=0; i<LCD_LINES-1; i++) {
lcdDrawText(0, i*FH+FH+1, s_text_screen[i], FIXEDWIDTH);
lcdDrawText(0, i*FH+FH+1, reusableBuffer.viewText.lines[i], FIXEDWIDTH);
}
char * title = s_text_file;
char * title = reusableBuffer.viewText.filename;
#if defined(SIMU)
if (!strncmp(title, "./", 2)) title += 2;
#else
@@ -169,15 +93,15 @@ void menuTextView(event_t event)
lcdDrawText(LCD_W/2, 0, getBasename(title), CENTERED);
lcdInvertLine(0);
if (lines_count > LCD_LINES-1) {
drawVerticalScrollbar(LCD_W-1, FH, LCD_H-FH, menuVerticalOffset, lines_count, LCD_LINES-1);
if (reusableBuffer.viewText.linesCount > LCD_LINES-1) {
drawVerticalScrollbar(LCD_W-1, FH, LCD_H-FH, menuVerticalOffset, reusableBuffer.viewText.linesCount, LCD_LINES-1);
}
}
void pushMenuTextView(const char *filename)
{
if (strlen(filename) < TEXT_FILENAME_MAXLEN) {
strcpy(s_text_file, filename);
strcpy(reusableBuffer.viewText.filename, filename);
pushMenu(menuTextView);
}
}
+12 -4
View File
@@ -539,7 +539,7 @@ bool isPxx2IsrmChannelsCountAllowed(int channels)
bool isModuleUsingSport(uint8_t moduleBay, uint8_t moduleType)
{
switch(moduleType) {
switch (moduleType) {
case MODULE_TYPE_NONE:
case MODULE_TYPE_SBUS:
case MODULE_TYPE_PPM:
@@ -717,7 +717,7 @@ bool isTrainerModeAvailable(int mode)
return false;
#endif
#if !defined(PCBSKY9X) && !defined(TRAINER_BATTERY_COMPARTMENT)
#if defined(PCBTARANIS) && !defined(TRAINER_BATTERY_COMPARTMENT)
if (mode == TRAINER_MODE_MASTER_BATTERY_COMPARTMENT)
return false;
#endif
@@ -787,6 +787,7 @@ const char STR_SUBTYPE_FRSKY[] = "\007""D16\0 ""D8\0 ""D16 8ch""V8\0
const char STR_SUBTYPE_HISKY[] = "\005""Std\0 ""HK310";
const char STR_SUBTYPE_V2X2[] = "\006""Std\0 ""JXD506";
const char STR_SUBTYPE_DSM[] = "\006""2 22ms""2 11ms""X 22ms""X 11ms";
const char STR_SUBTYPE_DEVO[] = "\004""8ch\0""10ch""12ch""6ch\0""7ch\0";
const char STR_SUBTYPE_YD717[] = "\007""Std\0 ""SkyWlkr""Syma X4""XINXUN\0""NIHUI\0 ";
const char STR_SUBTYPE_KN[] = "\006""WLtoys""FeiLun";
const char STR_SUBTYPE_SYMAX[] = "\003""Std""X5C";
@@ -807,10 +808,13 @@ const char STR_SUBTYPE_H83D[] = "\007""Std\0 ""H20H\0 ""H20Mini""H30Min
const char STR_SUBTYPE_CORONA[] = "\005""V1\0 ""V2\0 ""FD V3";
const char STR_SUBTYPE_HITEC[] = "\007""Optima\0""Opt Hub""Minima\0";
const char STR_SUBTYPE_BUGS_MINI[] = "\006""Std\0 ""Bugs3H";
const char STR_SUBTYPE_TRAXXAS[] = "\004""6519";
const char STR_SUBTYPE_E01X[] = "\005""E012\0""E015\0""E016H";
const char STR_SUBTYPE_GD00X[] = "\005""GD_V1""GD_V2";
const char STR_SUBTYPE_REDPINE[] = "\004""Fast""Slow";
const char STR_SUBTYPE_POTENSIC[] = "\003""A20""---";
const char STR_SUBTYPE_POTENSIC[] = "\003""A20";
const char STR_SUBTYPE_ZSX[] = "\007""280JJRC";
const char STR_SUBTYPE_FLYZONE[] = "\005""FZ410";
const mm_protocol_definition multi_protocols[] = {
@@ -820,6 +824,7 @@ const mm_protocol_definition multi_protocols[] = {
{MODULE_SUBTYPE_MULTI_HISKY, 1, false, STR_SUBTYPE_HISKY, nullptr},
{MODULE_SUBTYPE_MULTI_V2X2, 1, false, STR_SUBTYPE_V2X2, nullptr},
{MODULE_SUBTYPE_MULTI_DSM2, 3, false, STR_SUBTYPE_DSM, nullptr},
{MODULE_SUBTYPE_MULTI_DEVO, 4, false, STR_SUBTYPE_DEVO, STR_MULTI_FIXEDID},
{MODULE_SUBTYPE_MULTI_YD717, 4, false, STR_SUBTYPE_YD717, nullptr},
{MODULE_SUBTYPE_MULTI_KN, 1, false, STR_SUBTYPE_KN, nullptr},
{MODULE_SUBTYPE_MULTI_SYMAX, 1, false, STR_SUBTYPE_SYMAX, nullptr},
@@ -842,12 +847,15 @@ const mm_protocol_definition multi_protocols[] = {
{MODULE_SUBTYPE_MULTI_CORONA, 2, false, STR_SUBTYPE_CORONA, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_HITEC, 2, false, STR_SUBTYPE_HITEC, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_BUGS_MINI, 1, false, STR_SUBTYPE_BUGS_MINI, nullptr},
{MODULE_SUBTYPE_MULTI_TRAXXAS, 0, false, STR_SUBTYPE_TRAXXAS, nullptr},
{MODULE_SUBTYPE_MULTI_E01X, 2, false, STR_SUBTYPE_E01X, nullptr},
{MODULE_SUBTYPE_MULTI_V911S, 0, false, NO_SUBTYPE, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_GD00X, 1, false, STR_SUBTYPE_GD00X, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_KF606, 0, false, NO_SUBTYPE, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_REDPINE, 1, false, STR_SUBTYPE_REDPINE, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_POTENSIC, 1, false, STR_SUBTYPE_POTENSIC, nullptr},
{MODULE_SUBTYPE_MULTI_POTENSIC, 0, false, STR_SUBTYPE_POTENSIC, nullptr},
{MODULE_SUBTYPE_MULTI_ZSX, 0, false, STR_SUBTYPE_ZSX, nullptr},
{MODULE_SUBTYPE_MULTI_FLYZONE, 0, false, STR_SUBTYPE_FLYZONE, nullptr},
{MM_RF_CUSTOM_SELECTED, 7, true, NO_SUBTYPE, STR_MULTI_OPTION},
// Sentinel and default for protocols not listed above (MM_RF_CUSTOM is 0xff)
+6
View File
@@ -28,6 +28,7 @@
#define READONLY_ROW ((uint8_t)-1)
#define TITLE_ROW READONLY_ROW
#define LABEL(...) READONLY_ROW
#define HIDDEN_ROW ((uint8_t)-2)
#if defined(ROTARY_ENCODER_NAVIGATION)
@@ -75,6 +76,7 @@ bool isSwitchAvailableInMixes(int swtch);
bool isSwitchAvailableInTimers(int swtch);
bool isR9MModeAvailable(int mode);
bool isPxx2IsrmChannelsCountAllowed(int channels);
bool isModuleUsingSport(uint8_t moduleBay, uint8_t moduleType);
bool isExternalModuleAvailable(int moduleType);
bool isInternalModuleAvailable(int moduleType);
bool isRfProtocolAvailable(int protocol);
@@ -156,7 +158,11 @@ inline bool MULTIMODULE_HAS_SUBTYPE(uint8_t moduleIdx)
}
inline uint8_t MULTIMODULE_RFPROTO_COLUMNS(uint8_t moduleIdx)
{
#if LCD_W < 212
return (g_model.moduleData[moduleIdx].multi.customProto ? (uint8_t) 1 : MULTIMODULE_HAS_SUBTYPE(g_model.moduleData[moduleIdx].getMultiProtocol(true)) ? (uint8_t) 0 : HIDDEN_ROW);
#else
return (g_model.moduleData[moduleIdx].multi.customProto ? (uint8_t) 2 : MULTIMODULE_HAS_SUBTYPE(g_model.moduleData[moduleIdx].getMultiProtocol(true)) ? (uint8_t) 1 : 0);
#endif
}
#define MULTIMODULE_SUBTYPE_ROWS(x) isModuleMultimodule(x) ? MULTIMODULE_RFPROTO_COLUMNS(x) : HIDDEN_ROW,
#define MULTIMODULE_HASOPTIONS(x) (getMultiProtocolDefinition(x)->optionsstr != nullptr)