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
+3 -3
View File
@@ -32,7 +32,7 @@ option(AUTOSOURCE "Automatic source detection in menus" ON)
option(AUTOSWITCH "Automatic switch detection in menus" ON)
option(SEMIHOSTING "Enable debugger semihosting" OFF)
option(JITTER_MEASURE "Enable ADC jitter measurement" OFF)
option(WATCHDOG_DISABLED "Disable hardware Watchdog" OFF)
option(WATCHDOG "Enable hardware Watchdog" ON)
if(SDL_FOUND)
option(SIMU_AUDIO "Enable simulator audio." ON)
endif()
@@ -232,8 +232,8 @@ if(JITTER_MEASURE)
add_definitions(-DJITTER_MEASURE)
endif()
if(WATCHDOG_DISABLED)
add_definitions(-DWATCHDOG_DISABLED)
if(WATCHDOG)
add_definitions(-DWATCHDOG)
endif()
if(SIMU_AUDIO)
+1 -1
View File
@@ -529,7 +529,7 @@ void audioTask(void * pdata)
RTOS_WAIT_MS(1000); // 1s
#endif
if (!unexpectedShutdown) {
if (!globalData.unexpectedShutdown) {
AUDIO_HELLO();
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

+1 -1
View File
@@ -54,6 +54,7 @@ class Bluetooth
public:
void writeString(const char * str);
char * readline(bool error_reset = true);
void write(const uint8_t * data, uint8_t length);
void forwardTelemetry(const uint8_t * packet);
void wakeup();
@@ -66,7 +67,6 @@ class Bluetooth
protected:
void pushByte(uint8_t byte);
uint8_t read(uint8_t * data, uint8_t size, uint32_t timeout=1000/*ms*/);
void write(const uint8_t * data, uint8_t length);
void appendTrainerByte(uint8_t data);
void processTrainerFrame(const uint8_t * buffer);
void processTrainerByte(uint8_t data);
+2 -3
View File
@@ -191,8 +191,8 @@ enum TrainerMode {
#if defined(PCBTARANIS)
TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE,
TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE,
#endif
TRAINER_MODE_MASTER_BATTERY_COMPARTMENT,
#endif
#if defined(BLUETOOTH)
TRAINER_MODE_MASTER_BLUETOOTH,
TRAINER_MODE_SLAVE_BLUETOOTH,
@@ -482,7 +482,6 @@ enum SwitchSources {
SWSRC_SR2,
#endif
#if defined(PCBSKY9X)
SWSRC_ID0 = SWSRC_FIRST_SWITCH,
SWSRC_ID1,
@@ -501,7 +500,7 @@ enum SwitchSources {
#if NUM_XPOTS > 0
SWSRC_FIRST_MULTIPOS_SWITCH,
SWSRC_LAST_MULTIPOS_SWITCH = SWSRC_FIRST_MULTIPOS_SWITCH + (NUM_POTS * XPOTS_MULTIPOS_COUNT) - 1,
SWSRC_LAST_MULTIPOS_SWITCH = SWSRC_FIRST_MULTIPOS_SWITCH + (NUM_XPOTS * XPOTS_MULTIPOS_COUNT) - 1,
#endif
SWSRC_FIRST_TRIM,
+27 -27
View File
@@ -323,6 +323,9 @@ PACK(struct VarioData {
* Telemetry Sensor structure
*/
#define TELEMETRY_ENDPOINT_NONE 0xFF
#define TELEMETRY_ENDPOINT_SPORT 0x07
PACK(struct TelemetrySensor {
union {
uint16_t id; // data identifier, for FrSky we can reuse existing ones. Source unit is derived from type.
@@ -383,18 +386,17 @@ PACK(struct TelemetrySensor {
int32_t getPrecDivisor() const;
bool isSameInstance(TelemetryProtocol protocol, uint8_t instance)
{
if (this->instance == instance)
return true;
if (protocol == PROTOCOL_TELEMETRY_FRSKY_SPORT) {
if (((this->instance ^ instance) & 0x9F) == 0) {
if (((this->instance ^ instance) & 0x9F) == 0 && (this->instance >> 5) != TELEMETRY_ENDPOINT_SPORT && (instance >> 5) != TELEMETRY_ENDPOINT_SPORT) {
this->instance = instance; // update the instance in case we had telemetry switching
return true;
}
else {
return false;
}
}
else {
return this->instance == instance;
}
return false;
}
);
});
@@ -422,16 +424,13 @@ PACK(struct TrainerModuleData {
#define MM_RF_CUSTOM_SELECTED 0xff
PACK(struct ModuleData {
uint8_t type:4;
// TODO some refactoring is needed, rfProtocol is only used by DSM2 and MULTI, it could be merged with subType
int8_t rfProtocol:4;
uint8_t channelsStart;
int8_t channelsCount; // 0=8 channels
union {
struct {
uint8_t failsafeMode:4; // only 3 bits used
uint8_t subType:3;
uint8_t invertedSerial:1; // telemetry serial inverted from standard
};
};
uint8_t failsafeMode:4; // only 3 bits used
uint8_t subType:3;
uint8_t invertedSerial:1; // telemetry serial inverted from standard
union {
uint8_t raw[PXX2_MAX_RECEIVERS_PER_MODULE * PXX2_LEN_RX_NAME + 1];
@@ -452,10 +451,9 @@ PACK(struct ModuleData {
NOBACKUP(struct {
uint8_t power:2; // 0=10 mW, 1=100 mW, 2=500 mW, 3=1W
uint8_t spare1:2;
uint8_t receiver_telem_off:1; // false = receiver telem enabled
uint8_t receiver_channel_9_16:1; // false = pwm out 1-8, true 9-16
uint8_t external_antenna:1; // false = internal antenna, true = external antenna
uint8_t fast:1; // TODO: to be used later by external module (fast means serial @ high speed)
uint8_t receiverTelemetryOff:1; // false = receiver telem enabled
uint8_t receiverHigherChannels:1; // false = pwm out 1-8, true 9-16
int8_t antennaMode:2;
uint8_t spare2;
} pxx);
NOBACKUP(struct {
@@ -668,7 +666,7 @@ PACK(struct TrainerData {
#define SPLASH_MODE uint8_t splashMode:1; uint8_t splashSpare:2
#endif
#if defined(PCBXLITES) || defined(PCBHORUS)
#if defined(PCBXLITES)
#define GYRO_FIELDS \
int8_t gyroMax; \
int8_t gyroOffset;
@@ -685,13 +683,13 @@ PACK(struct TrainerData {
NOBACKUP(char switchNames[STORAGE_NUM_SWITCHES][LEN_SWITCH_NAME]); \
NOBACKUP(char anaNames[NUM_STICKS + STORAGE_NUM_POTS + STORAGE_NUM_SLIDERS][LEN_ANA_NAME]); \
NOBACKUP(char currModelFilename[LEN_MODEL_FILENAME+1]); \
NOBACKUP(uint8_t spare4:1); \
NOBACKUP(uint8_t spare5:1); \
NOBACKUP(uint8_t blOffBright:7); \
NOBACKUP(char bluetoothName[LEN_BLUETOOTH_NAME]);
#elif defined(PCBTARANIS) || defined(PCBNV14)
#if defined(STORAGE_BLUETOOTH)
#define BLUETOOTH_FIELDS \
uint8_t spare4; \
uint8_t spare5; \
char bluetoothName[LEN_BLUETOOTH_NAME];
#else
#define BLUETOOTH_FIELDS
@@ -709,7 +707,7 @@ PACK(struct TrainerData {
#elif defined(PCBSKY9X)
#define EXTRA_GENERAL_FIELDS \
int8_t txCurrentCalibration; \
int8_t spare4; \
int8_t spare5; \
uint8_t mAhWarn; \
uint16_t mAhUsed; \
int8_t temperatureCalib; \
@@ -735,7 +733,7 @@ PACK(struct TrainerData {
#if defined(BUZZER)
#define BUZZER_FIELD int8_t buzzerMode:2 // -2=quiet, -1=only alarms, 0=no keys, 1=all (only used on AVR radios without audio hardware)
#else
#define BUZZER_FIELD int8_t spare3:2
#define BUZZER_FIELD int8_t spare4:2
#endif
PACK(struct RadioData {
@@ -747,7 +745,9 @@ PACK(struct RadioData {
N_HORUS_FIELD(uint8_t contrast);
NOBACKUP(uint8_t vBatWarn);
NOBACKUP(int8_t txVoltageCalibration);
NOBACKUP(int8_t backlightMode);
uint8_t backlightMode:3;
int8_t antennaMode:2;
int8_t spare1:3;
NOBACKUP(TrainerData trainer);
NOBACKUP(uint8_t view); // index of view in main screen
NOBACKUP(BUZZER_FIELD); /* 2bits */
@@ -768,7 +768,7 @@ PACK(struct RadioData {
NOBACKUP(uint8_t templateSetup); // RETA order for receiver channels
NOBACKUP(int8_t PPM_Multiplier);
NOBACKUP(int8_t hapticLength);
N_HORUS_FIELD(N_TARANIS_FIELD(uint8_t spare1));
N_HORUS_FIELD(N_TARANIS_FIELD(uint8_t spare2));
N_HORUS_FIELD(N_TARANIS_FIELD(uint8_t stickReverse));
NOBACKUP(int8_t beepLength:3);
NOBACKUP(int8_t hapticStrength:3);
@@ -791,7 +791,7 @@ PACK(struct RadioData {
NOBACKUP(uint8_t disableRssiPoweroffAlarm:1);
NOBACKUP(uint8_t USBMode:2);
NOBACKUP(uint8_t jackMode:2);
NOBACKUP(uint8_t spare2:1);
NOBACKUP(uint8_t spare3:1);
NOBACKUP(char ttsLanguage[2]);
NOBACKUP(int8_t beepVolume:4);
NOBACKUP(int8_t wavVolume:4);
@@ -945,7 +945,7 @@ static inline void check_struct()
CHKSIZE(RadioData, 735);
CHKSIZE(ModelData, 5301);
#elif defined(PCBHORUS)
CHKSIZE(RadioData, 883);
CHKSIZE(RadioData, 881);
CHKSIZE(ModelData, 9736);
#endif
+1 -1
View File
@@ -41,7 +41,7 @@ void loadFonts();
extern const unsigned char font_5x7[];
extern const unsigned char font_10x14[];
#if defined(BOLD_FONT) && !defined(BOOT)
#if defined(BOLD_FONT) && !defined(BOOT)
#define BOLD_SPECIFIC_FONT
extern const unsigned char font_5x7_B[];
#endif
+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)
+16 -6
View File
@@ -96,12 +96,12 @@ void FrskyDeviceFirmwareUpdate::processFrame(const uint8_t * frame)
}
}
#if defined(PCBHORUS)
bool FrskyDeviceFirmwareUpdate::readBuffer(uint8_t * buffer, uint8_t count, uint32_t timeout)
{
watchdogSuspend(timeout);
switch(module) {
#if defined(INTMODULE_USART)
case INTERNAL_MODULE:
{
uint32_t elapsed = 0;
@@ -118,7 +118,6 @@ bool FrskyDeviceFirmwareUpdate::readBuffer(uint8_t * buffer, uint8_t count, uint
}
break;
}
#endif
default:
break;
@@ -126,6 +125,7 @@ bool FrskyDeviceFirmwareUpdate::readBuffer(uint8_t * buffer, uint8_t count, uint
return true;
}
#endif
const uint8_t * FrskyDeviceFirmwareUpdate::readFullDuplexFrame(ModuleFifo & fifo, uint32_t timeout)
{
@@ -177,7 +177,7 @@ const uint8_t * FrskyDeviceFirmwareUpdate::readFrame(uint32_t timeout)
RTOS_WAIT_MS(1);
switch(module) {
#if defined(INTMODULE_USART)
#if defined(INTMODULE_USART) && !(defined(PCBXLITE) && !defined(PCBXLITES))
case INTERNAL_MODULE:
return readFullDuplexFrame(intmoduleFifo, timeout);
#endif
@@ -236,7 +236,7 @@ void FrskyDeviceFirmwareUpdate::sendFrame()
}
switch(module) {
#if defined(INTMODULE_USART)
#if defined(INTMODULE_USART) && !(defined(PCBXLITE) && !defined(PCBXLITES))
case INTERNAL_MODULE:
return intmoduleSendBuffer(outputTelemetryBuffer.data, ptr - outputTelemetryBuffer.data);
#endif
@@ -288,6 +288,11 @@ const char * FrskyDeviceFirmwareUpdate::sendReqVersion()
return "Version request failed";
}
// X12S / X10 IXJT = use TX + RX @ 38400 bauds with BOOTCMD pin inverted
// X10 / X10 ISRM = use TX + RX @ 57600 bauds (no BOOTCMD)
// X9D / X9D+ / X9E / XLite IXJT = use S.PORT @ 57600 bauds
// XLite PRO / X9Lite / X9D+ 2019 ISRM = use TX + RX @ 57600 bauds
const char * FrskyDeviceFirmwareUpdate::doFlashFirmware(const char * filename, ProgressHandler progressHandler)
{
FIL file;
@@ -305,7 +310,8 @@ const char * FrskyDeviceFirmwareUpdate::doFlashFirmware(const char * filename, P
f_close(&file);
return "Format error";
}
} else {
}
else {
#if defined(PCBHORUS)
information.productId = FIRMWARE_ID_XJT;
#endif
@@ -314,6 +320,7 @@ const char * FrskyDeviceFirmwareUpdate::doFlashFirmware(const char * filename, P
#if defined(PCBHORUS)
if (module == INTERNAL_MODULE && information.productId == FIRMWARE_ID_XJT) {
INTERNAL_MODULE_ON();
RTOS_WAIT_MS(1);
intmoduleSerialStart(38400, true);
GPIO_SetBits(INTMODULE_BOOTCMD_GPIO, INTMODULE_BOOTCMD_GPIO_PIN);
result = uploadFileToHorusXJT(filename, &file, progressHandler);
@@ -324,7 +331,10 @@ const char * FrskyDeviceFirmwareUpdate::doFlashFirmware(const char * filename, P
#endif
switch (module) {
#if defined(INTMODULE_USART)
#if defined(INTMODULE_USART) && !(defined(PCBXLITE) && !defined(PCBXLITES))
// on XLite we don't use TX + RX but the S.PORT line
// this ifdef can be removed if we use .frsk instead of .frk
// theorically it should be possible to use an ISRM module in an XLite
case INTERNAL_MODULE:
intmoduleSerialStart(57600, true);
break;
+1 -1
View File
@@ -39,7 +39,7 @@
event_t s_evt;
struct t_inactivity inactivity = {0};
struct InactivityData inactivity = {0};
Key keys[NUM_KEYS];
event_t getEvent(bool trim)
+27 -2
View File
@@ -120,7 +120,7 @@ Return the time since the radio was started in multiple of 10ms
@retval number Number of 10ms ticks since the radio was started Example:
run time: 12.54 seconds, return value: 1254
The timer internally uses a 32-bit counter which is enough for 30 years so
The timer internally uses a 32-bit counter which is enough for 497 days so
overflows will not happen.
@status current Introduced in 2.0.0
@@ -203,11 +203,17 @@ static int luaGetRtcTime(lua_State * L)
static void luaPushLatLon(lua_State* L, TelemetrySensor & telemetrySensor, TelemetryItem & telemetryItem)
/* result is lua table containing members ["lat"] and ["lon"] as lua_Number (doubles) in decimal degrees */
{
lua_createtable(L, 0, 4);
lua_createtable(L, 0, 5);
lua_pushtablenumber(L, "lat", telemetryItem.gps.latitude * 0.000001); // floating point multiplication is faster than division
lua_pushtablenumber(L, "pilot-lat", telemetryItem.pilotLatitude * 0.000001);
lua_pushtablenumber(L, "lon", telemetryItem.gps.longitude * 0.000001);
lua_pushtablenumber(L, "pilot-lon", telemetryItem.pilotLongitude * 0.000001);
int8_t delay = telemetryItem.getDelaySinceLastValue();
if (delay >= 0)
lua_pushtableinteger(L, "delay", delay);
else
lua_pushtablenil(L, "delay");
}
static void luaPushTelemetryDateTime(lua_State* L, TelemetrySensor & telemetrySensor, TelemetryItem & telemetryItem)
@@ -1351,6 +1357,24 @@ static int luaGetRSSI(lua_State * L)
return 3;
}
/*luadoc
@function chdir(directory)
Change the working directory
@param directory (string) New working directory
@status current Introduced in 2.3.0
*/
static int luaChdir(lua_State * L)
{
const char * directory = luaL_optstring(L, 1, nullptr);
f_chdir(directory);
return 0;
}
/*luadoc
@function loadScript(file [, mode], [,env])
@@ -1548,6 +1572,7 @@ const luaL_Reg opentxLib[] = {
{ "defaultChannel", luaDefaultChannel },
{ "getRSSI", luaGetRSSI },
{ "killEvents", luaKillEvents },
{ "chdir", luaChdir },
{ "loadScript", luaLoadScript },
{ "getUsage", luaGetUsage },
{ "resetGlobalTimer", luaResetGlobalTimer },
+1 -1
View File
@@ -541,7 +541,7 @@ Draw a bitmap at (x,y)
@param name (string) full path to the bitmap on SD card (i.e. “/IMAGES/test.bmp”)
@notice Only available on Taranis X9 series. Maximum image size if 106 x 64 pixels (width x height).
@notice Maximum image size is [display width / 2] x [display height] pixels.
@status current Introduced in 2.0.0
*/
+5 -5
View File
@@ -86,7 +86,7 @@ static int luaModelSetInfo(lua_State *L)
Get RF module parameters
`rfProtocol` values:
`subType` values:
* -1 OFF
* 0 D16
* 1 D8
@@ -97,7 +97,7 @@ Get RF module parameters
@retval nil requested module does not exist
@retval table module parameters:
* `rfProtocol` (number) protocol index
* `subType` (number) protocol index
* `modelId` (number) receiver number
* `firstChannel` (number) start channel (0 is CH1)
* `channelsCount` (number) number of channels sent to module
@@ -110,7 +110,7 @@ static int luaModelGetModule(lua_State *L)
if (idx < NUM_MODULES) {
ModuleData & module = g_model.moduleData[idx];
lua_newtable(L);
lua_pushtableinteger(L, "rfProtocol", module.rfProtocol);
lua_pushtableinteger(L, "subType", module.subType);
lua_pushtableinteger(L, "modelId", g_model.header.modelId[idx]);
lua_pushtableinteger(L, "firstChannel", module.channelsStart);
lua_pushtableinteger(L, "channelsCount", module.channelsCount + 8);
@@ -145,8 +145,8 @@ static int luaModelSetModule(lua_State *L)
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
luaL_checktype(L, -2, LUA_TSTRING); // key is string
const char * key = luaL_checkstring(L, -2);
if (!strcmp(key, "rfProtocol")) {
module.rfProtocol = luaL_checkinteger(L, -1);
if (!strcmp(key, "subType")) {
module.subType = luaL_checkinteger(L, -1);
}
else if (!strcmp(key, "modelId")) {
g_model.header.modelId[idx] = luaL_checkinteger(L, -1);
+13 -8
View File
@@ -636,18 +636,22 @@ bool luaLoadMixScript(uint8_t index)
bool luaLoadFunctionScript(uint8_t index, uint8_t ref)
{
if ((ref >= SCRIPT_GFUNC_FIRST) && g_model.noGlobalFunctions)
return false;
CustomFunctionData * fn;
CustomFunctionData & fn = (ref < SCRIPT_GFUNC_FIRST ? g_model.customFn[index] : g_eeGeneral.customFn[index]);
if (ref < SCRIPT_GFUNC_FIRST)
fn = &g_model.customFn[index];
else if (!g_model.noGlobalFunctions)
fn = &g_eeGeneral.customFn[index];
else
return true;
if (fn.func == FUNC_PLAY_SCRIPT && ZEXIST(fn.play.name)) {
if (fn->func == FUNC_PLAY_SCRIPT && ZEXIST(fn->play.name)) {
if (luaScriptsCount < MAX_SCRIPTS) {
ScriptInternalData & sid = scriptInternalData[luaScriptsCount++];
sid.reference = ref + index;
sid.state = SCRIPT_NOFILE;
char filename[sizeof(SCRIPTS_FUNCS_PATH) + LEN_FUNCTION_NAME + sizeof(SCRIPT_EXT)] = SCRIPTS_FUNCS_PATH "/";
strncpy(filename + sizeof(SCRIPTS_FUNCS_PATH), fn.play.name, LEN_FUNCTION_NAME);
strncpy(filename + sizeof(SCRIPTS_FUNCS_PATH), fn->play.name, LEN_FUNCTION_NAME);
filename[sizeof(SCRIPTS_FUNCS_PATH) + LEN_FUNCTION_NAME] = '\0';
strcat(filename + sizeof(SCRIPTS_FUNCS_PATH), SCRIPT_EXT);
if (luaLoad(lsScripts, filename, sid) == SCRIPT_PANIC) {
@@ -1127,10 +1131,11 @@ bool readToolName(char * toolName, const char * filename)
return "Error opening file";
}
if (f_read(&file, &buffer, sizeof(buffer), &count) != FR_OK) {
f_close(&file);
FRESULT res = f_read(&file, &buffer, sizeof(buffer), &count);
f_close(&file);
if (res != FR_OK)
return false;
}
const char * tns = "TNS|";
auto * start = std::search(buffer, buffer + sizeof(buffer), tns, tns + 4);
+14 -10
View File
@@ -301,7 +301,7 @@ void guiMain(event_t evt)
#else
if (!refreshNeeded) {
DEBUG_TIMER_START(debugTimerMenus);
while (1) {
while (true) {
// normal GUI from menus
const char * warn = warningText;
uint8_t menu = popupMenuItemsCount;
@@ -324,7 +324,10 @@ void guiMain(event_t evt)
const char * result = runPopupMenu(evt);
if (result) {
TRACE("popupMenuHandler(%s)", result);
popupMenuHandler(result);
auto handler = popupMenuHandler;
if (result != STR_UPDATE_LIST)
CLEAR_POPUP();
handler(result);
if (menuEvent == 0) {
evt = EVT_REFRESH;
continue;
@@ -400,7 +403,6 @@ void handleGui(event_t event) {
}
}
menuHandlers[menuLevel](event);
// todo drawStatusLine(); here???
}
else
#endif
@@ -464,7 +466,10 @@ void guiMain(event_t evt)
const char * result = runPopupMenu(evt);
if (result) {
TRACE("popupMenuHandler(%s)", result);
popupMenuHandler(result);
auto handler = popupMenuHandler;
if (result != STR_UPDATE_LIST)
CLEAR_POPUP();
handler(result);
}
}
@@ -503,24 +508,23 @@ void perMain()
#endif
#if defined(RAMBACKUP)
if (unexpectedShutdown) {
if (globalData.unexpectedShutdown) {
drawFatalErrorScreen(STR_EMERGENCY_MODE);
return;
}
#endif
#if defined(STM32)
static bool sdcard_present_before = SD_CARD_PRESENT();
bool sdcard_present_now = SD_CARD_PRESENT();
if (sdcard_present_now && !sdcard_present_before) {
bool sdcardPresent = SD_CARD_PRESENT();
if (sdcardPresent && !globalData.sdcardPresent) {
sdMount();
}
sdcard_present_before = sdcard_present_now;
globalData.sdcardPresent = sdcardPresent;
#endif
#if !defined(EEPROM)
// In case the SD card is removed during the session
if (!SD_CARD_PRESENT() && !unexpectedShutdown) {
if (!SD_CARD_PRESENT() && !globalData.unexpectedShutdown) {
drawFatalErrorScreen(STR_NO_SDCARD);
return;
}
+31 -32
View File
@@ -547,8 +547,8 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
{
evalInputs(mode);
if (tick10ms) evalLogicalSwitches(mode==e_perout_mode_normal);
if (tick10ms)
evalLogicalSwitches(mode==e_perout_mode_normal);
#if defined(HELI)
int heliEleValue = getValue(g_model.swashR.elevatorSource);
@@ -614,7 +614,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
}
#endif
memclear(chans, sizeof(chans)); // All outputs to 0
memclear(chans, sizeof(chans)); // all outputs to 0
//========== MIXER LOOP ===============
uint8_t lv_mixWarning = 0;
@@ -624,27 +624,27 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
bitfield_channels_t dirtyChannels = (bitfield_channels_t)-1; // all dirty when mixer starts
do {
bitfield_channels_t passDirtyChannels = 0;
for (uint8_t i=0; i<MAX_MIXERS; i++) {
#if defined(BOLD_FONT)
if (mode==e_perout_mode_normal && pass==0) swOn[i].activeMix = 0;
if (mode == e_perout_mode_normal && pass == 0)
swOn[i].activeMix = 0;
#endif
MixData *md = mixAddress(i);
MixData * md = mixAddress(i);
if (md->srcRaw == 0) break;
if (md->srcRaw == 0)
break;
mixsrc_t stickIndex = md->srcRaw - MIXSRC_Rud;
if (!(dirtyChannels & ((bitfield_channels_t)1 << md->destCh))) continue;
if (!(dirtyChannels & ((bitfield_channels_t)1 << md->destCh)))
continue;
// if this is the first calculation for the destination channel, initialize it with 0 (otherwise would be random)
if (i == 0 || md->destCh != (md-1)->destCh) {
if (i == 0 || md->destCh != (md-1)->destCh)
chans[md->destCh] = 0;
}
//========== FLIGHT MODE && SWITCH =====
bool mixCondition = (md->flightModes != 0 || md->swtch);
@@ -669,44 +669,43 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
//========== VALUE ===============
getvalue_t v = 0;
if (mode > e_perout_mode_inactive_flight_mode) {
if (!mixEnabled) {
continue;
}
else {
if (mixEnabled)
v = getValue(md->srcRaw);
}
else
continue;
}
else {
mixsrc_t srcRaw = MIXSRC_Rud + stickIndex;
v = getValue(srcRaw);
srcRaw -= MIXSRC_CH1;
if (srcRaw<=MIXSRC_LAST_CH-MIXSRC_CH1 && md->destCh != srcRaw) {
if (srcRaw <= MIXSRC_LAST_CH-MIXSRC_CH1 && md->destCh != srcRaw) {
if (dirtyChannels & ((bitfield_channels_t)1 << srcRaw) & (passDirtyChannels|~(((bitfield_channels_t) 1 << md->destCh)-1)))
passDirtyChannels |= (bitfield_channels_t) 1 << md->destCh;
if (srcRaw < md->destCh || pass > 0)
v = chans[srcRaw] >> 8;
}
if (!mixCondition) {
mixEnabled = v >> DELAY_POS_SHIFT;
mixEnabled = v;
}
}
bool apply_offset_and_curve = true;
bool applyOffsetAndCurve = true;
//========== DELAYS ===============
delayval_t _swOn = swOn[i].now;
delayval_t _swPrev = swOn[i].prev;
bool swTog = (mixEnabled > _swOn+DELAY_POS_MARGIN || mixEnabled < _swOn-DELAY_POS_MARGIN);
if (mode==e_perout_mode_normal && swTog) {
if (!swOn[i].delay) _swPrev = _swOn;
swOn[i].delay = (mixEnabled > _swOn ? md->delayUp : md->delayDown) * (100/DELAY_STEP);
if (mode == e_perout_mode_normal && swTog) {
if (!swOn[i].delay)
_swPrev = _swOn;
swOn[i].delay = (mixEnabled > _swOn ? md->delayUp : md->delayDown) * 10;
swOn[i].now = mixEnabled;
swOn[i].prev = _swPrev;
}
if (mode==e_perout_mode_normal && swOn[i].delay > 0) {
if (mode == e_perout_mode_normal && swOn[i].delay > 0) {
swOn[i].delay = max<int16_t>(0, (int16_t)swOn[i].delay - tick10ms);
if (!mixCondition)
v = _swPrev << DELAY_POS_SHIFT;
v = _swPrev;
else if (mixEnabled)
continue;
}
@@ -718,7 +717,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
if ((md->speedDown || md->speedUp) && md->mltpx!=MLTPX_REP) {
if (mixCondition) {
v = (md->mltpx == MLTPX_ADD ? 0 : RESX);
apply_offset_and_curve = false;
applyOffsetAndCurve = false;
}
}
else if (mixCondition) {
@@ -734,7 +733,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
#endif
}
if (apply_offset_and_curve) {
if (applyOffsetAndCurve) {
//========== TRIMS ================
if (!(mode & e_perout_mode_notrims)) {
@@ -757,7 +756,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
int16_t diff = v - (tact>>DEL_MULT_SHIFT);
if (diff) {
// open.20.fsguruh: speed is defined in % movement per second; In menu we specify the full movement (-100% to 100%) = 200% in total
// the unit of the stored value is the value from md->speedUp or md->speedDown divide SLOW_STEP seconds; e.g. value 4 means 4/SLOW_STEP = 2 seconds for CPU64
// the unit of the stored value is the value from md->speedUp or md->speedDown * 0.1s; e.g. value 4 means 0.4 seconds
// because we get a tick each 10msec, we need 100 ticks for one second
// the value in md->speedXXX gives the time it should take to do a full movement from -100 to 100 therefore 200%. This equals 2048 in recalculated internal range
if (tick10ms || !s_mixer_first_run_done) {
@@ -769,14 +768,14 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
if (diff > 0) {
if (s_mixer_first_run_done && md->speedUp > 0) {
// if a speed upwards is defined recalculate the new value according configured speed; the higher the speed the smaller the add value is
int32_t newValue = tact+rate/((int16_t)(100/SLOW_STEP)*md->speedUp);
int32_t newValue = tact+rate/((int16_t)10*md->speedUp);
if (newValue<currentValue) currentValue = newValue; // Endposition; prevent toggling around the destination
}
}
else { // if is <0 because ==0 is not possible
if (s_mixer_first_run_done && md->speedDown > 0) {
// see explanation in speedUp
int32_t newValue = tact-rate/((int16_t)(100/SLOW_STEP)*md->speedDown);
int32_t newValue = tact-rate/((int16_t)10*md->speedDown);
if (newValue>currentValue) currentValue = newValue; // Endposition; prevent toggling around the destination
}
}
@@ -788,7 +787,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
}
//========== CURVES ===============
if (apply_offset_and_curve && md->curve.type != CURVE_REF_DIFF && md->curve.value) {
if (applyOffsetAndCurve && md->curve.type != CURVE_REF_DIFF && md->curve.value) {
v = applyCurve(v, md->curve);
}
@@ -797,7 +796,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
dv = div_and_round(dv, 10);
//========== OFFSET / AFTER ===============
if (apply_offset_and_curve) {
if (applyOffsetAndCurve) {
int32_t offset = GET_GVAR_PREC1(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, mixerCurrentFlightMode);
if (offset) dv += div_and_round(calc100toRESX_16Bits(offset), 10) << 8;
}
@@ -912,7 +911,7 @@ void evalMixes(uint8_t tick10ms)
ACTIVE_PHASES_TYPE transitionMask = ((ACTIVE_PHASES_TYPE)1 << lastFlightMode) + ((ACTIVE_PHASES_TYPE)1 << fm);
if (fadeTime) {
flightModesFade |= transitionMask;
delta = (MAX_ACT / (100/SLOW_STEP)) / fadeTime;
delta = (MAX_ACT / 10) / fadeTime;
}
else {
flightModesFade &= ~transitionMask;
+2 -4
View File
@@ -147,10 +147,8 @@ enum CurveRefType {
#define GV1_LARGE 1024
#define GV_RANGE_WEIGHT 500
#define GV_RANGE_OFFSET 500
#define DELAY_STEP 10
#define SLOW_STEP 10
#define DELAY_MAX (25*DELAY_STEP) /* 25 seconds */
#define SLOW_MAX (25*SLOW_STEP) /* 25 seconds */
#define DELAY_MAX 250 /* 25 seconds */
#define SLOW_MAX 250 /* 25 seconds */
#define MD_WEIGHT(md) (md->weight)
#define MD_WEIGHT_TO_UNION(md, var) var.word = md->weight
+18 -32
View File
@@ -34,13 +34,9 @@ ModelData g_model;
Clipboard clipboard;
#endif
uint8_t unexpectedShutdown = 0;
uint16_t vbattRTC;
/* ARM: mixer duration in 0.5us */
uint16_t maxMixerDuration;
GlobalData globalData;
uint16_t maxMixerDuration; // step = 0.01ms
uint8_t heartbeat;
#if defined(OVERRIDE_CHANNEL_FUNCTION)
@@ -206,9 +202,7 @@ void per10ms()
}
#endif
if (!IS_DSM2_SERIAL_PROTOCOL(s_current_protocol[0])) {
telemetryInterrupt10ms();
}
telemetryInterrupt10ms();
// These moved here from evalFlightModeMixes() to improve beep trigger reliability.
#if defined(PWM_BACKLIGHT)
@@ -505,14 +499,9 @@ void modelDefault(uint8_t id)
}
#endif
#if defined(HARDWARE_INTERNAL_MODULE)
#if defined(FRSKY_RELEASE)
g_model.moduleData[INTERNAL_MODULE].type = IS_PXX2_INTERNAL_ENABLED() ? MODULE_TYPE_ISRM_PXX2 : MODULE_TYPE_XJT_PXX1;
g_model.moduleData[INTERNAL_MODULE].channelsCount = defaultModuleChannels_M8(INTERNAL_MODULE);
#elif defined(PCBSKY9X)
g_model.moduleData[EXTERNAL_MODULE].type = MODULE_TYPE_PPM;
#elif defined(RADIO_T12)
g_model.moduleData[EXTERNAL_MODULE].type = MODULE_TYPE_NONE;
g_model.moduleData[EXTERNAL_MODULE].type = MODULE_TYPE_MULTIMODULE;
#endif
#if defined(PCBXLITE)
@@ -683,11 +672,6 @@ getvalue_t convert16bitsTelemValue(source_t channel, ls_telemetry_value_t value)
return value;
}
ls_telemetry_value_t minTelemValue(source_t channel)
{
return 0;
}
ls_telemetry_value_t maxTelemValue(source_t channel)
{
return 30000;
@@ -942,6 +926,10 @@ void checkAll()
}
}
#if defined(EXTERNAL_ANTENNA) && defined(INTERNAL_MODULE_PXX1)
checkExternalAntenna();
#endif
START_SILENCE_PERIOD();
}
#endif // GUI
@@ -1866,8 +1854,7 @@ void opentxInit()
#endif
#if defined(EEPROM)
storageClearRadioSetting();
storageReadRadioSettings(false);
bool radioSettingsValid = storageReadRadioSettings(false);
#endif
BACKLIGHT_ENABLE(); // we start the backlight during the startup animation
@@ -1891,12 +1878,14 @@ void opentxInit()
// * radios without CPU controlled power can only use Reset status register (if available)
if (UNEXPECTED_SHUTDOWN()) {
TRACE("Unexpected Shutdown detected");
unexpectedShutdown = 1;
globalData.unexpectedShutdown = 1;
}
#if defined(SDCARD)
globalData.sdcardPresent = SD_CARD_PRESENT();
// SDCARD related stuff, only done if not unexpectedShutdown
if (!unexpectedShutdown) {
if (!globalData.unexpectedShutdown) {
sdInit();
#if defined(AUTOUPDATE)
@@ -1926,12 +1915,13 @@ void opentxInit()
#endif
#if defined(EEPROM)
storageReadRadioSettings(true);
if (!radioSettingsValid)
storageReadRadioSettings();
storageReadCurrentModel();
#endif
#if defined(COLORLCD)
if (!unexpectedShutdown) {
if (!globalData.unexpectedShutdown) {
// g_model.topbarData is still zero here (because it was not yet read from SDCARD),
// but we only remember the pointer to in in constructor.
// The storageReadAll() needs topbar object, so it must be created here
@@ -1947,7 +1937,7 @@ void opentxInit()
// handling of storage for radios that have no EEPROM
#if !defined(EEPROM)
#if defined(RAMBACKUP)
if (unexpectedShutdown) {
if (globalData.unexpectedShutdown) {
// SDCARD not available, try to restore last model from RAM
TRACE("rambackupRestore");
rambackupRestore();
@@ -1964,10 +1954,6 @@ void opentxInit()
auxSerialInit(g_eeGeneral.auxSerialMode, modelTelemetryProtocol());
#endif
#if defined(PCBTARANIS)
BACKLIGHT_ENABLE();
#endif
#if MENUS_LOCK == 1
getMovedSwitch();
if (TRIMS_PRESSED() && g_eeGeneral.switchUnlockStates==switches_states) {
@@ -2002,7 +1988,7 @@ void opentxInit()
backlightOn();
}
if (!unexpectedShutdown) {
if (!globalData.unexpectedShutdown) {
opentxStart();
}
+48 -30
View File
@@ -420,13 +420,13 @@ void watchdogSuspend(uint32_t timeout);
#define MAX_ALERT_TIME 60
struct t_inactivity
struct InactivityData
{
uint16_t counter;
uint8_t sum;
};
extern struct t_inactivity inactivity;
extern InactivityData inactivity;
#define LEN_STD_CHARS 40
@@ -583,9 +583,14 @@ extern uint8_t trimsDisplayMask;
void flightReset(uint8_t check=true);
extern uint8_t unexpectedShutdown;
PACK(struct GlobalData {
uint8_t unexpectedShutdown:1;
uint8_t sdcardPresent:1;
uint8_t externalAntennaEnabled: 1;
uint8_t spare:5;
});
extern uint16_t vbattRTC;
extern GlobalData globalData;
extern uint16_t maxMixerDuration;
@@ -875,16 +880,15 @@ void copySticksToOffset(uint8_t ch);
void moveTrimsToOffsets();
typedef uint16_t ACTIVE_PHASES_TYPE;
#define DELAY_POS_SHIFT 0
#define DELAY_POS_MARGIN 3
typedef int16_t delayval_t;
PACK(typedef struct {
uint16_t delay;
PACK(struct SwOn {
uint16_t delay:14; // max = 2550
uint8_t activeMix:1;
uint8_t activeExpo:1;
int16_t now; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
int16_t prev;
uint8_t activeMix;
uint8_t activeExpo;
}) SwOn;
});
extern SwOn swOn[MAX_MIXERS];
extern int32_t act[MAX_MIXERS];
@@ -1089,15 +1093,17 @@ constexpr uint8_t OPENTX_START_NO_CHECKS = 0x04;
// Re-useable byte array to save having multiple buffers
#if LCD_W <= 212
#define SD_SCREEN_FILE_LENGTH 32
constexpr uint8_t SD_SCREEN_FILE_LENGTH = 32;
#else
#define SD_SCREEN_FILE_LENGTH 64
constexpr uint8_t SD_SCREEN_FILE_LENGTH = 64;
#endif
#if defined(BLUETOOTH)
#include "bluetooth.h"
#endif
constexpr uint8_t TEXT_FILENAME_MAXLEN = 40;
union ReusableBuffer
{
struct {
@@ -1115,6 +1121,7 @@ union ReusableBuffer
struct {
char msg[64];
uint8_t r9mPower;
int8_t antennaMode;
BindInformation bindInformation;
struct {
union {
@@ -1181,7 +1188,7 @@ union ReusableBuffer
uint32_t updateTime;
ModuleSettings moduleSettings;
ReceiverSettings receiverSettings; // when dealing with receiver settings, we also need module settings
} hardwareAndSettings;
} hardwareAndSettings; // moduleOptions, receiverOptions, radioVersion
struct {
ModuleInformation modules[NUM_MODULES];
@@ -1189,6 +1196,10 @@ union ReusableBuffer
char msg[64];
} radioTools;
struct {
int8_t antennaMode;
} radioHardware;
struct {
uint8_t stickMode;
} generalSettings;
@@ -1221,13 +1232,29 @@ union ReusableBuffer
int8_t preset;
} curveEdit;
struct {
char filename[TEXT_FILENAME_MAXLEN];
char lines[NUM_BODY_LINES][LCD_COLS + 1];
int linesCount;
} viewText;
struct {
bool longNames;
bool secondPage;
bool mixersView;
} viewChannels;
struct {
uint8_t maxNameLen;
} modelFailsafe;
#if defined(STM32)
// Data for the USB mass storage driver. If USB mass storage runs no menu is not allowed to be displayed
uint8_t MSC_BOT_Data[MSC_MEDIA_PACKET];
#endif
};
extern union ReusableBuffer reusableBuffer;
extern ReusableBuffer reusableBuffer;
uint8_t zlen(const char *str, uint8_t size);
bool zexist(const char *str, uint8_t size);
@@ -1246,13 +1273,15 @@ char * strcat_zchar(char *dest, const char *name, uint8_t size, const char *defa
// Stick tolerance varies between transmitters, Higher is better
#define STICK_TOLERANCE 64
ls_telemetry_value_t minTelemValue(source_t channel);
ls_telemetry_value_t maxTelemValue(source_t channel);
ls_telemetry_value_t maxTelemValue(source_t channel);
getvalue_t convert16bitsTelemValue(source_t channel, ls_telemetry_value_t value);
getvalue_t convertLswTelemValue(LogicalSwitchData * cs);
#define convertTelemValue(channel, value) convert16bitsTelemValue(channel, value)
inline getvalue_t convertTelemValue(source_t channel, ls_telemetry_value_t value)
{
return convert16bitsTelemValue(channel, value);
}
inline int div_and_round(int num, int den)
{
@@ -1292,8 +1321,6 @@ extern uint8_t s_frsky_view;
constexpr uint32_t EARTH_RADIUS = 6371009;
void getGpsPilotPosition();
void getGpsDistance();
void varioWakeup();
#if defined(AUDIO) && defined(BUZZER)
@@ -1378,26 +1405,17 @@ enum JackMode {
#include "gyro.h"
#endif
inline bool isSimu()
{
#if defined(SIMU)
return true;
#else
return false;
#endif
}
#if defined(DEBUG_LATENCY)
extern uint8_t latencyToggleSwitch;
#endif
inline bool isAsteriskDisplayed()
{
#if defined(LOG_TELEMETRY) || defined(WATCHDOG_DISABLED) || defined(DEBUG_LATENCY)
#if defined(LOG_TELEMETRY) || !defined(WATCHDOG) || defined(DEBUG_LATENCY)
return true;
#endif
return unexpectedShutdown;
return globalData.unexpectedShutdown;
}
#include "module.h"
+34
View File
@@ -1,3 +1,26 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef _MODULES_CONSTANTS_H_
#define _MODULES_CONSTANTS_H_
enum ModuleType {
MODULE_TYPE_NONE = 0,
MODULE_TYPE_PPM,
@@ -165,3 +188,14 @@ enum FailsafeModes {
FAILSAFE_RECEIVER,
FAILSAFE_LAST = FAILSAFE_RECEIVER
};
enum AntennaModes {
ANTENNA_MODE_INTERNAL = -2,
ANTENNA_MODE_ASK = -1,
ANTENNA_MODE_PER_MODEL = 0,
ANTENNA_MODE_EXTERNAL = 1,
ANTENNA_MODE_FIRST = ANTENNA_MODE_INTERNAL,
ANTENNA_MODE_LAST = ANTENNA_MODE_EXTERNAL
};
#endif // _MODULES_CONSTANTS_H_
+43
View File
@@ -0,0 +1,43 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "opentx.h"
#if defined(EXTERNAL_ANTENNA)
bool isExternalAntennaEnabled()
{
switch (g_eeGeneral.antennaMode) {
case ANTENNA_MODE_INTERNAL:
return false;
case ANTENNA_MODE_EXTERNAL:
return true;
case ANTENNA_MODE_PER_MODEL:
switch (g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode) {
case ANTENNA_MODE_EXTERNAL:
case ANTENNA_MODE_ASK:
return globalData.externalAntennaEnabled;
default:
return false;
}
default:
return globalData.externalAntennaEnabled;
}
}
#endif
+2
View File
@@ -529,4 +529,6 @@ inline void setModuleType(uint8_t moduleIdx, uint8_t moduleType)
setDefaultPpmFrameLength(moduleIdx);
}
extern bool isExternalAntennaEnabled();
#endif // _MODULES_HELPERS_H_
+1 -7
View File
@@ -46,12 +46,6 @@
#define IS_DSM2_PROTOCOL(protocol) (0)
#endif
#if defined(DSM2_SERIAL)
#define IS_DSM2_SERIAL_PROTOCOL(protocol) (IS_DSM2_PROTOCOL(protocol))
#else
#define IS_DSM2_SERIAL_PROTOCOL(protocol) (0)
#endif
#if defined(MULTIMODULE)
#define IS_MULTIMODULE_PROTOCOL(protocol) (protocol==PROTOCOL_CHANNELS_MULTIMODULE)
#if !defined(DSM2)
@@ -146,7 +140,7 @@ class BindInformation {
class OtaUpdateInformation: public BindInformation {
public:
char filename[_MAX_LFN+1];
char filename[32+1];
uint32_t address;
};
+10 -10
View File
@@ -52,27 +52,27 @@ template <class PxxTransport>
void Pxx1Pulses<PxxTransport>::addExtraFlags(uint8_t module)
{
// Ext. flag (holds antenna selection on Horus internal module, 0x00 otherwise)
uint8_t extra_flags = 0;
uint8_t extraFlags = 0;
#if defined(PCBHORUS) || defined(PCBXLITE)
if (module == INTERNAL_MODULE) {
extra_flags |= (g_model.moduleData[module].pxx.external_antenna << 0);
#if defined(EXTERNAL_ANTENNA)
if (module == INTERNAL_MODULE && isExternalAntennaEnabled()) {
extraFlags |= (1 << 0);
}
#endif
extra_flags |= (g_model.moduleData[module].pxx.receiver_telem_off << 1);
extra_flags |= (g_model.moduleData[module].pxx.receiver_channel_9_16 << 2);
extraFlags |= (g_model.moduleData[module].pxx.receiverTelemetryOff << 1);
extraFlags |= (g_model.moduleData[module].pxx.receiverHigherChannels << 2);
if (isModuleR9MNonAccess(module)) {
extra_flags |= (min<uint8_t>(g_model.moduleData[module].pxx.power, isModuleR9M_FCC_VARIANT(module) ? (uint8_t)R9M_FCC_POWER_MAX : (uint8_t)R9M_LBT_POWER_MAX) << 3);
extraFlags |= (min<uint8_t>(g_model.moduleData[module].pxx.power, isModuleR9M_FCC_VARIANT(module) ? (uint8_t)R9M_FCC_POWER_MAX : (uint8_t)R9M_LBT_POWER_MAX) << 3);
if (isModuleR9M_EUPLUS(module))
extra_flags |= (1 << 6);
extraFlags |= (1 << 6);
}
// Disable S.PORT if internal module is active
if (module == EXTERNAL_MODULE && isSportLineUsedByInternalModule()) {
extra_flags |= (1 << 5);
extraFlags |= (1 << 5);
}
PxxTransport::addByte(extra_flags);
PxxTransport::addByte(extraFlags);
}
template <class PxxTransport>
+1 -1
View File
@@ -243,7 +243,7 @@ void Pxx2Pulses::setupAccstBindFrame(uint8_t module)
for (uint8_t i=0; i<PXX2_LEN_RX_NAME; i++) {
Pxx2Transport::addByte(0x00);
}
Pxx2Transport::addByte((g_model.moduleData[module].pxx.receiver_channel_9_16 << 7) + (g_model.moduleData[module].pxx.receiver_telem_off << 6));
Pxx2Transport::addByte((g_model.moduleData[module].pxx.receiverHigherChannels << 7) + (g_model.moduleData[module].pxx.receiverTelemetryOff << 6));
Pxx2Transport::addByte(g_model.header.modelId[module]);
}
+68
View File
@@ -410,6 +410,74 @@ bool sdListFiles(const char * path, const char * extension, const uint8_t maxlen
return popupMenuItemsCount;
}
constexpr uint32_t TEXT_FILE_MAXSIZE = 2048;
void sdReadTextFile(const char * filename, char lines[NUM_BODY_LINES][LCD_COLS + 1], int & lines_count)
{
FIL file;
int result;
char c;
unsigned int sz;
int line_length = 0;
uint8_t escape = 0;
char escape_chars[4] = {0};
int current_line = 0;
memclear(lines, NUM_BODY_LINES * (LCD_COLS + 1));
result = f_open(&file, filename, FA_OPEN_EXISTING | FA_READ);
if (result == FR_OK) {
for (unsigned 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 < sizeof(escape_chars)) {
escape_chars[escape - 1] = c;
if (escape == 2 && !strncmp(escape_chars, "up", 2)) {
c = '\300';
}
else if (escape == 2 && !strncmp(escape_chars, "dn", 2)) {
c = '\301';
}
else if (escape == 3) {
int val = atoi(escape_chars);
if (val >= 200 && val < 225) {
c = '\200' + val-200;
}
}
else {
escape++;
continue;
}
}
else if (c=='~') {
c = 'z'+1;
}
else if (c=='\t') {
c = 0x1D; //tab
}
escape = 0;
lines[current_line-menuVerticalOffset][line_length++] = c;
}
}
if (c != '\n') {
current_line += 1;
}
f_close(&file);
}
if (lines_count == 0) {
lines_count = current_line;
}
}
// returns true if current working dir is at the root level
bool isCwdAtRoot()
{
+2
View File
@@ -158,6 +158,8 @@ const char * sdCopyFile(const char * srcFilename, const char * srcDir, const cha
#define LIST_SD_FILE_EXT 2
bool sdListFiles(const char * path, const char * extension, const uint8_t maxlen, const char * selection, uint8_t flags=0);
void sdReadTextFile(const char * filename, char lines[NUM_BODY_LINES][LCD_COLS + 1], int & lines_count);
bool isCwdAtRoot();
FRESULT sdReadDir(DIR * dir, FILINFO * fno, bool & firstTime);
@@ -524,14 +524,14 @@ PACK(typedef struct {
ScriptData_v216 scriptsData[MAX_SCRIPTS]; \
char inputNames[MAX_INPUTS][LEN_INPUT_NAME]; \
uint8_t nPotsToWarn; \
int8_t potPosition[NUM_POTS+NUM_SLIDERS]; \
int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS]; \
uint8_t spare[2];
#elif defined(PCBSKY9X)
#define MODELDATA_EXTRA_216 \
uint8_t externalModule; \
ModuleData_v216 moduleData[NUM_MODULES+1]; \
uint8_t nPotsToWarn; \
int8_t potPosition[NUM_POTS+NUM_SLIDERS]; \
int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS]; \
uint8_t rxBattAlarms[2];
#endif
@@ -1070,7 +1070,7 @@ void convertModelData_216_to_217(ModelData &model)
#endif
newModel.potsWarnMode = oldModel.nPotsToWarn >> 6;
newModel.potsWarnEnabled = oldModel.nPotsToWarn & 0x1f;
memcpy(newModel.potsWarnPosition, oldModel.potPosition, sizeof(newModel.potsWarnPosition));
memcpy(newModel.potsWarnPosition, oldModel.potsWarnPosition, sizeof(newModel.potsWarnPosition));
}
void convertModelData_217_to_218(ModelData &model)
@@ -59,7 +59,7 @@ int convertSource_218_to_219(int source)
#endif
#if defined(PCBX10)
if ((source == MIXSRC_EXT1) || (source == MIXSRC_EXT2))
if (source == MIXSRC_EXT1 || source == MIXSRC_EXT2)
source += 2;
#endif
@@ -70,8 +70,8 @@ int convertSwitch_218_to_219(int swtch)
{
// on X7: 2 additional switches
// on X9D / X9D+: 1 additional switch
// on xlite : 2 more storage switches
// on XLite: 2 additional storage switches
// on X10: 2 additional pots => 12 multipos switches
#if defined(PCBX7) || defined(PCBHORUS) || defined(PCBX9D) || defined(PCBX9DP) || defined(PCBXLITE)
if (swtch < 0)
return -convertSwitch_218_to_219(-swtch);
@@ -95,6 +95,9 @@ int convertSwitch_218_to_219(int swtch)
#if defined(PCBHORUS)
if (swtch >= SWSRC_SI0)
swtch += 2 * 3;
#endif
#if defined(PCBX10)
if (swtch >= SWSRC_FIRST_MULTIPOS_SWITCH + 3 * XPOTS_MULTIPOS_COUNT)
swtch += 2 * XPOTS_MULTIPOS_COUNT;
#endif
@@ -120,6 +123,10 @@ void convertModelData_218_to_219(ModelData &model)
// 4 bytes more for the ModelHeader::bitmap
memclear(&newModel.header.bitmap[10], 4);
memcpy(newModel.timers, oldModel.timers, offsetof(ModelData_v218, mixData) - offsetof(ModelData_v218, timers));
// trainer battery compartment removed
if (newModel.trainerData.mode >= TRAINER_MODE_MASTER_BLUETOOTH)
newModel.trainerData.mode -= 1;
#endif
memclear(newModel.mixData, sizeof(ModelData_v219) - offsetof(ModelData_v219, mixData));
@@ -128,6 +135,14 @@ void convertModelData_218_to_219(ModelData &model)
zchar2str(name, oldModel.header.name, LEN_MODEL_NAME);
TRACE("Model %s conversion from v218 to v219", name);
for (uint8_t i=0; i<MAX_TIMERS_218; i++) {
TimerData & timer = newModel.timers[i];
if (timer.mode >= TMRMODE_COUNT)
timer.mode = TMRMODE_COUNT + convertSwitch_218_to_219(oldModel.timers[i].mode - TMRMODE_COUNT + 1) - 1;
else if (timer.mode < 0)
timer.mode = convertSwitch_218_to_219(oldModel.timers[i].mode);
}
for (uint8_t i=0; i<MAX_MIXERS_218; i++) {
memmove(&newModel.mixData[i], &oldModel.mixData[i], sizeof(MixData_v218));
newModel.mixData[i].srcRaw = convertSource_218_to_219(newModel.mixData[i].srcRaw); // from newModel to avoid overwrite
@@ -142,6 +157,10 @@ void convertModelData_218_to_219(ModelData &model)
memmove(&newModel.expoData[i], &oldModel.expoData[i], sizeof(ExpoData_v218));
newModel.expoData[i].srcRaw = convertSource_218_to_219(newModel.expoData[i].srcRaw); // from newModel to avoid overwrite
newModel.expoData[i].swtch = convertSwitch_218_to_219(newModel.expoData[i].swtch); // from newModel to avoid overwrite
#if LCD_W == 212
newModel.expoData[i].offset = oldModel.expoData[i].offset; // 212x64: expo name has been reduced to 6 chars instead of 8
newModel.expoData[i].curve = oldModel.expoData[i].curve; // 212x64: expo name has been reduced to 6 chars instead of 8
#endif
}
for (uint8_t i=0; i<MAX_CURVES_218; i++) {
@@ -166,8 +166,8 @@ PACK(typedef struct {
struct {
uint8_t power:2; // 0=10 mW, 1=100 mW, 2=500 mW, 3=1W
uint8_t spare1:2;
uint8_t receiver_telem_off:1; // false = receiver telem enabled
uint8_t receiver_channel_9_16:1; // false = pwm out 1-8, true 9-16
uint8_t receiverTelemetryOff:1; // false = receiver telem enabled
uint8_t receiverHigherChannels:1; // false = pwm out 1-8, true 9-16
uint8_t external_antenna:1; // false = internal antenna, true = external antenna
uint8_t fast:1;
uint8_t spare2;
+12 -8
View File
@@ -27,7 +27,6 @@
void eeLoadModel(uint8_t index)
{
if (index < MAX_MODELS) {
preModelLoad();
uint16_t size = eeLoadModelData(index);
@@ -86,17 +85,18 @@ void eeLoadModelHeaders()
}
}
void storageClearRadioSetting()
void storageClearRadioSettings()
{
memclear(&g_eeGeneral, sizeof(RadioData));
}
void storageReadRadioSettings(bool allowConversion)
bool storageReadRadioSettings(bool allowFixes)
{
if (g_eeGeneral.version != 0)
return;
if (!eepromOpen() || !eeLoadGeneral(allowConversion)) {
if (!eepromOpen() || !eeLoadGeneral(allowFixes)) {
if (!allowFixes) {
storageClearRadioSettings();
return false;
}
storageEraseAll(true);
}
else {
@@ -109,6 +109,10 @@ void storageReadRadioSettings(bool allowConversion)
currentLanguagePack = languagePacks[i];
}
}
postRadioSettingsLoad();
return true;
}
void storageReadCurrentModel()
@@ -118,7 +122,7 @@ void storageReadCurrentModel()
void storageReadAll()
{
storageReadRadioSettings(true);
storageReadRadioSettings();
storageReadCurrentModel();
}
+5 -5
View File
@@ -28,11 +28,11 @@ void eeLoadModel(uint8_t id);
uint8_t eeFindEmptyModel(uint8_t id, bool down);
void selectModel(uint8_t sub);
extern ModelHeader modelHeaders[MAX_MODELS];
void eeLoadModelHeader(uint8_t id, ModelHeader *header);
void eeLoadModelHeaders();
extern ModelHeader modelHeaders[MAX_MODELS];
void eeLoadModelHeader(uint8_t id, ModelHeader *header);
void eeLoadModelHeaders();
void storageClearRadioSetting();
void storageReadRadioSettings(bool allowConversion);
void storageClearRadioSettings();
bool storageReadRadioSettings(bool allowFixes = true);
void storageReadCurrentModel();
+4 -8
View File
@@ -256,21 +256,17 @@ void writeModel(int index)
writeFile(index+1, (uint8_t *)&g_model, sizeof(g_model));
}
bool eeLoadGeneral(bool allowConversion)
bool eeLoadGeneral(bool allowFixes)
{
eeLoadGeneralSettingsData();
if (g_eeGeneral.version != EEPROM_VER) {
TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER);
#if defined(PCBSKY9X)
if (!allowConversion) {
storageClearRadioSetting();
return true; // prevent eeprom from being wiped
}
if (!eeConvert()) {
if (!allowFixes)
return false; // prevent eeprom from being wiped
if (!eeConvert())
return false;
}
#else
return false;
#endif
+1 -1
View File
@@ -24,7 +24,7 @@
#include <inttypes.h>
#include <stdint.h>
bool eeLoadGeneral(bool allowConversion);
bool eeLoadGeneral(bool allowFixes);
void eeDeleteModel( uint8_t id );
bool eeCopyModel(uint8_t dst, uint8_t src);
void eeSwapModels(uint8_t id1, uint8_t id2);
+5 -7
View File
@@ -757,7 +757,7 @@ uint16_t eeLoadModelData(uint8_t index)
return theFile.readRlc((uint8_t*)&g_model, sizeof(g_model));
}
bool eeLoadGeneral(bool allowConversion)
bool eeLoadGeneral(bool allowFixes)
{
theFile.openRlc(FILE_GENERAL);
if (theFile.readRlc((uint8_t*)&g_eeGeneral, 3) == 3 && g_eeGeneral.version == EEPROM_VER) {
@@ -794,16 +794,14 @@ bool eeLoadGeneral(bool allowConversion)
return false;
}
#endif
#if defined(EEPROM_CONVERSIONS)
if (g_eeGeneral.version != EEPROM_VER) {
if (!allowConversion) {
storageClearRadioSetting();
return true; // prevent eeprom from being wiped
}
TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER);
if (!eeConvert()) {
if (!allowFixes)
return false; // prevent eeprom from being wiped
if (!eeConvert())
return false;
}
}
return true;
#else
+1 -2
View File
@@ -176,11 +176,10 @@ const char * eeRestoreModel(uint8_t i_fileDst, char *model_name);
// For conversions
void loadRadioSettings();
void loadModel(int index, bool alarms=true);
bool eepromOpen();
void eeLoadModelName(uint8_t id, char * name);
bool eeLoadGeneral(bool allowConversion);
bool eeLoadGeneral(bool allowFixes);
// For EEPROM backup/restore
inline bool isEepromStart(const void * buffer)
+2
View File
@@ -173,6 +173,8 @@ const char * loadRadioSettings(const char * path)
}
#endif
postRadioSettingsLoad();
return nullptr;
}
+2 -1
View File
@@ -49,9 +49,10 @@ void storageReadAll();
void storageDirty(uint8_t msk);
void storageCheck(bool immediately);
void storageFlushCurrentModel();
void postRadioSettingsLoad();
void preModelLoad();
void postModelLoad(bool alarms);
void checkExternalAntenna();
#if defined(EEPROM_RLC)
#include "eeprom_common.h"
+84 -8
View File
@@ -53,20 +53,92 @@ void preModelLoad()
pauseMixerCalculations();
}
#if defined(PCBFRSKY)
static void fixUpModel()
void postRadioSettingsLoad()
{
// Ensure that when rfProtocol is MODULE_SUBTYPE_PXX1_OFF the type of the module is MODULE_TYPE_NONE
if (g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_XJT_PXX1 && g_model.moduleData[INTERNAL_MODULE].rfProtocol == MODULE_SUBTYPE_PXX1_OFF)
g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_NONE;
#if defined(PXX2)
if (is_memclear(g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID)) {
setDefaultOwnerId();
}
#endif
}
#if defined(EXTERNAL_ANTENNA) && defined(INTERNAL_MODULE_PXX1)
void onAntennaSelection(const char * result)
{
if (result == STR_USE_INTERNAL_ANTENNA) {
globalData.externalAntennaEnabled = false;
}
else if (result == STR_USE_EXTERNAL_ANTENNA) {
globalData.externalAntennaEnabled = true;
}
else {
checkExternalAntenna();
}
}
void onAntennaSwitchConfirm(const char * result)
{
if (result == STR_OK) {
// Switch to external antenna confirmation
globalData.externalAntennaEnabled = true;
}
}
void checkExternalAntenna()
{
if (isModuleXJT(INTERNAL_MODULE)) {
if (g_eeGeneral.antennaMode == ANTENNA_MODE_EXTERNAL) {
globalData.externalAntennaEnabled = true;
}
else if (g_eeGeneral.antennaMode == ANTENNA_MODE_PER_MODEL && g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode == ANTENNA_MODE_EXTERNAL) {
if (!globalData.externalAntennaEnabled) {
#if defined(COLORLCD)
#warning "Antenna confirmation dialog needed"
#else
POPUP_CONFIRMATION(STR_ANTENNACONFIRM1, onAntennaSwitchConfirm);
SET_WARNING_INFO(STR_ANTENNACONFIRM2, sizeof(TR_ANTENNACONFIRM2), 0);
#endif
}
}
else if (g_eeGeneral.antennaMode == ANTENNA_MODE_ASK || (g_eeGeneral.antennaMode == ANTENNA_MODE_PER_MODEL && g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode == ANTENNA_MODE_ASK)) {
globalData.externalAntennaEnabled = false;
#if defined(COLORLCD)
#warning "Antenna confirmation dialog needed"
#else
POPUP_MENU_ADD_ITEM(STR_USE_INTERNAL_ANTENNA);
POPUP_MENU_ADD_ITEM(STR_USE_EXTERNAL_ANTENNA);
POPUP_MENU_START(onAntennaSelection);
#endif
}
else {
globalData.externalAntennaEnabled = false;
}
}
else {
globalData.externalAntennaEnabled = false;
}
}
#endif
void postModelLoad(bool alarms)
{
#if defined(PCBFRSKY)
fixUpModel();
#if defined(PXX2)
if (is_memclear(g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID)) {
memcpy(g_model.modelRegistrationID, g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID);
}
#endif
#if defined(HARDWARE_INTERNAL_MODULE)
if (!isInternalModuleAvailable(g_model.moduleData[INTERNAL_MODULE].type)) {
memclear(&g_model.moduleData[INTERNAL_MODULE], sizeof(ModuleData));
}
#endif
if (!isExternalModuleAvailable(g_model.moduleData[EXTERNAL_MODULE].type)) {
memclear(&g_model.moduleData[EXTERNAL_MODULE], sizeof(ModuleData));
}
AUDIO_FLUSH();
flightReset(false);
@@ -78,7 +150,10 @@ void postModelLoad(bool alarms)
TelemetrySensor & sensor = g_model.telemetrySensors[i];
if (sensor.type == TELEM_TYPE_CALCULATED && sensor.persistent) {
telemetryItems[i].value = sensor.persistentValue;
telemetryItems[i].lastReceived = TELEMETRY_VALUE_OLD; // #3595: make value visible even before the first new value is received)
telemetryItems[i].timeout = 0; // make value visible even before the first new value is received)
}
else {
telemetryItems[i].timeout = TELEMETRY_SENSOR_TIMEOUT_UNAVAILABLE;
}
}
@@ -105,6 +180,7 @@ void postModelLoad(bool alarms)
LOAD_MODEL_BITMAP();
LUA_LOAD_MODEL_SCRIPTS();
SEND_FAILSAFE_1S();
}
+1 -1
View File
@@ -328,7 +328,7 @@ char * getSwitchPositionName(char * dest, swsrc_t idx)
}
#else
#define IDX_TRIMS_IN_STR_VSWITCHES (1)
#define IDX_ON_IN_STR_VSWITCHES (IDX_TRIMS_IN_STR_VSWITCHES+SWSRC_LAST_TRIM-SWSRC_FIRST_TRIM+1)
#define IDX_ON_IN_STR_VSWITCHES (IDX_TRIMS_IN_STR_VSWITCHES + SWSRC_LAST_TRIM - SWSRC_FIRST_TRIM + 1)
if (idx <= SWSRC_LAST_SWITCH) {
div_t swinfo = switchInfo(idx);
s = getSwitchName(s, idx);
+4 -5
View File
@@ -40,22 +40,21 @@ enum LogicalSwitchContextState {
SWITCH_ENABLE
};
PACK(typedef struct {
PACK(struct LogicalSwitchContext {
uint8_t state:1;
uint8_t timerState:2;
uint8_t spare:5;
uint8_t timer;
int16_t lastValue;
}) LogicalSwitchContext;
});
PACK(typedef struct {
PACK(struct LogicalSwitchesFlightModeContext {
LogicalSwitchContext lsw[MAX_LOGICAL_SWITCHES];
}) LogicalSwitchesFlightModeContext;
});
LogicalSwitchesFlightModeContext lswFm[MAX_FLIGHT_MODES];
#define LS_LAST_VALUE(fm, idx) lswFm[fm].lsw[idx].lastValue
#if defined(PCBFRSKY) || defined(PCBFLYSKY)
#if defined(PCBX9E)
tmr10ms_t switchesMidposStart[16];
@@ -220,6 +220,7 @@ set(PULSES_SRC
${PULSES_SRC}
pulses.cpp
ppm.cpp
modules_helpers.cpp
)
if(DSM2)
@@ -206,4 +206,4 @@ extern "C" void AUX_SERIAL_USART_IRQHandler(void)
}
}
#endif
}
}
@@ -209,9 +209,8 @@ int main()
RCC_APB2PeriphClockCmd(LCD_RCC_APB2Periph | BACKLIGHT_RCC_APB2Periph | RCC_APB2Periph_SYSCFG, ENABLE);
keysInit();
pwrInit();
pwrOff();
keysInit();
#if defined(PCBHORUS)
// wait a bit for the inputs to stabilize...
@@ -234,7 +233,7 @@ int main()
delaysInit(); // needed for lcdInit()
#if defined(DEBUG)
#if defined(DEBUG) && defined(AUX_SERIAL)
auxSerialInit(UART_MODE_DEBUG, 0); // default serial mode (None if DEBUG not defined)
#endif
-1
View File
@@ -71,7 +71,6 @@ elseif (PCB STREQUAL X12S)
x12s_adc_driver.cpp
gps_driver.cpp
)
set(AUX_SERIAL_DRIVER ../common/arm/stm32/aux_serial_driver.cpp)
set(BITMAPS_TARGET x12s_bitmaps)
set(FONTS_TARGET x12s_fonts)
set(LCD_DRIVER lcd_driver.cpp)
-4
View File
@@ -128,10 +128,6 @@ void boardInit()
pwrOn();
delaysInit();
#if defined(DEBUG)
auxSerialInit(0, 0); // default serial mode (None if DEBUG not defined)
#endif
__enable_irq();
TRACE("\nHorus board started :)");
+6 -17
View File
@@ -317,12 +317,12 @@ void watchdogInit(unsigned int duration);
#define wdt_enable(x)
#define wdt_reset()
#else
#if defined(WATCHDOG_DISABLED)
#define wdt_enable(x)
#define wdt_reset()
#else
#if defined(WATCHDOG)
#define wdt_enable(x) watchdogInit(x)
#define wdt_reset() IWDG->KR = 0xAAAA
#else
#define wdt_enable(x)
#define wdt_reset()
#endif
#define WAS_RESET_BY_WATCHDOG() (RCC->CSR & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF))
#define WAS_RESET_BY_SOFTWARE() (RCC->CSR & RCC_CSR_SFTRSTF)
@@ -510,8 +510,8 @@ void backlightEnable(uint8_t dutyCycle = 0);
#else
#define BACKLIGHT_LEVEL_MIN 46
#endif
#define BACKLIGHT_ENABLE() backlightEnable(unexpectedShutdown ? BACKLIGHT_LEVEL_MAX : BACKLIGHT_LEVEL_MAX-g_eeGeneral.backlightBright)
#define BACKLIGHT_DISABLE() backlightEnable(unexpectedShutdown ? BACKLIGHT_LEVEL_MAX : ((g_eeGeneral.blOffBright == BACKLIGHT_LEVEL_MIN) && (g_eeGeneral.backlightMode != e_backlight_mode_off)) ? 0 : g_eeGeneral.blOffBright)
#define BACKLIGHT_ENABLE() backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX : BACKLIGHT_LEVEL_MAX - g_eeGeneral.backlightBright)
#define BACKLIGHT_DISABLE() backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX : ((g_eeGeneral.blOffBright == BACKLIGHT_LEVEL_MIN) && (g_eeGeneral.backlightMode != e_backlight_mode_off)) ? 0 : g_eeGeneral.blOffBright)
#define isBacklightEnabled() true
#if !defined(SIMU)
@@ -586,17 +586,6 @@ void gpsSendByte(uint8_t byte);
#define PILOTPOS_MIN_HDOP 500
#endif
// Second serial port driver
#if defined(PCBX12S)
#define AUX_SERIAL
#define DEBUG_BAUDRATE 115200
extern uint8_t auxSerialMode;
void auxSerialInit(unsigned int mode, unsigned int protocol);
void auxSerialPutc(char c);
#define auxSerialTelemetryInit(protocol) auxSerialInit(UART_MODE_TELEMETRY, protocol)
void auxSerialSbusInit();
void auxSerialStop();
#endif
#define USART_FLAG_ERRORS (USART_FLAG_ORE | USART_FLAG_NE | USART_FLAG_FE | USART_FLAG_PE)
// BT driver

Some files were not shown because too many files have changed in this diff Show More