Merge against latest 2.3
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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_
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user