diff --git a/companion/src/firmwares/opentx/opentxGruvin9xsimulator.cpp b/companion/src/firmwares/opentx/opentxGruvin9xsimulator.cpp index c27b48553..3edf3a2af 100644 --- a/companion/src/firmwares/opentx/opentxGruvin9xsimulator.cpp +++ b/companion/src/firmwares/opentx/opentxGruvin9xsimulator.cpp @@ -88,6 +88,11 @@ namespace Open9xGruvin9x { #include "radio/src/gui/menu_model_templates.cpp" #include "radio/src/gui/menu_general.cpp" #include "radio/src/gui/menu_general_setup.cpp" +#include "radio/src/gui/menu_general_trainer.cpp" +#include "radio/src/gui/menu_general_version.cpp" +#include "radio/src/gui/menu_general_diagkeys.cpp" +#include "radio/src/gui/menu_general_diaganas.cpp" +#include "radio/src/gui/menu_general_calib.cpp" #include "radio/src/gui/view_main.cpp" #include "radio/src/gui/view_statistics.cpp" #include "radio/src/gui/view_telemetry.cpp" diff --git a/companion/src/firmwares/opentx/opentxM128simulator.cpp b/companion/src/firmwares/opentx/opentxM128simulator.cpp index 093ec5e6f..6df8d70d2 100644 --- a/companion/src/firmwares/opentx/opentxM128simulator.cpp +++ b/companion/src/firmwares/opentx/opentxM128simulator.cpp @@ -89,6 +89,11 @@ namespace OpenTxM128 { #include "radio/src/gui/menu_model_templates.cpp" #include "radio/src/gui/menu_general.cpp" #include "radio/src/gui/menu_general_setup.cpp" +#include "radio/src/gui/menu_general_trainer.cpp" +#include "radio/src/gui/menu_general_version.cpp" +#include "radio/src/gui/menu_general_diagkeys.cpp" +#include "radio/src/gui/menu_general_diaganas.cpp" +#include "radio/src/gui/menu_general_calib.cpp" #include "radio/src/gui/view_main.cpp" #include "radio/src/gui/view_statistics.cpp" #include "radio/src/gui/view_telemetry.cpp" diff --git a/companion/src/firmwares/opentx/opentxM64simulator.cpp b/companion/src/firmwares/opentx/opentxM64simulator.cpp index c2f4a7e32..fe233e03c 100644 --- a/companion/src/firmwares/opentx/opentxM64simulator.cpp +++ b/companion/src/firmwares/opentx/opentxM64simulator.cpp @@ -94,6 +94,11 @@ namespace OpenTxM64 { #include "radio/src/gui/menu_model_templates.cpp" #include "radio/src/gui/menu_general.cpp" #include "radio/src/gui/menu_general_setup.cpp" +#include "radio/src/gui/menu_general_trainer.cpp" +#include "radio/src/gui/menu_general_version.cpp" +#include "radio/src/gui/menu_general_diagkeys.cpp" +#include "radio/src/gui/menu_general_diaganas.cpp" +#include "radio/src/gui/menu_general_calib.cpp" #include "radio/src/gui/view_main.cpp" #include "radio/src/gui/view_statistics.cpp" #include "radio/src/gui/view_telemetry.cpp" diff --git a/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp b/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp index ddadbc0ee..0c8d3fbd4 100644 --- a/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp +++ b/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp @@ -103,7 +103,13 @@ namespace Open9xSky9x { #include "radio/src/gui/menu_model_templates.cpp" #include "radio/src/gui/menu_general.cpp" #include "radio/src/gui/menu_general_setup.cpp" +#include "radio/src/gui/menu_general_sdmanager.cpp" +#include "radio/src/gui/menu_general_trainer.cpp" +#include "radio/src/gui/menu_general_version.cpp" +#include "radio/src/gui/menu_general_diagkeys.cpp" +#include "radio/src/gui/menu_general_diaganas.cpp" #include "radio/src/gui/menu_general_hardware.cpp" +#include "radio/src/gui/menu_general_calib.cpp" #include "radio/src/gui/view_main.cpp" #include "radio/src/gui/view_statistics.cpp" #include "radio/src/gui/view_telemetry.cpp" diff --git a/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp b/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp index ef0b51974..6a1e260d7 100644 --- a/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp +++ b/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp @@ -110,7 +110,13 @@ inline int geteepromsize() { #include "radio/src/gui/menu_model_telemetry.cpp" #include "radio/src/gui/menu_general.cpp" #include "radio/src/gui/menu_general_setup.cpp" +#include "radio/src/gui/menu_general_sdmanager.cpp" +#include "radio/src/gui/menu_general_trainer.cpp" +#include "radio/src/gui/menu_general_version.cpp" +#include "radio/src/gui/menu_general_diagkeys.cpp" +#include "radio/src/gui/menu_general_diaganas.cpp" #include "radio/src/gui/menu_general_hardware.cpp" +#include "radio/src/gui/menu_general_calib.cpp" #include "radio/src/gui/Taranis/view_main.cpp" #include "radio/src/gui/view_statistics.cpp" #include "radio/src/gui/view_channels.cpp" diff --git a/companion/src/firmwares/opentx/opentxTaranisX9ESimulator.cpp b/companion/src/firmwares/opentx/opentxTaranisX9ESimulator.cpp index 3ab3482cb..4de4f3cd7 100755 --- a/companion/src/firmwares/opentx/opentxTaranisX9ESimulator.cpp +++ b/companion/src/firmwares/opentx/opentxTaranisX9ESimulator.cpp @@ -112,7 +112,13 @@ inline int geteepromsize() { #include "radio/src/gui/menu_model_telemetry.cpp" #include "radio/src/gui/menu_general.cpp" #include "radio/src/gui/menu_general_setup.cpp" +#include "radio/src/gui/menu_general_sdmanager.cpp" +#include "radio/src/gui/menu_general_trainer.cpp" +#include "radio/src/gui/menu_general_version.cpp" +#include "radio/src/gui/menu_general_diagkeys.cpp" +#include "radio/src/gui/menu_general_diaganas.cpp" #include "radio/src/gui/menu_general_hardware.cpp" +#include "radio/src/gui/menu_general_calib.cpp" #include "radio/src/gui/Taranis/view_main.cpp" #include "radio/src/gui/view_statistics.cpp" #include "radio/src/gui/view_channels.cpp" diff --git a/radio/src/Makefile b/radio/src/Makefile index 829c1eae9..85150e3c4 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -366,7 +366,7 @@ M2561_VARIANT = +16384 EEPROM_VARIANT = 0 GUIMODELSRC = gui/menu_model.cpp gui/menu_model_select.cpp gui/menu_model_setup.cpp gui/menu_model_inputs_mixes.cpp gui/menu_model_limits.cpp gui/menu_model_logical_switches.cpp gui/menu_model_custom_functions.cpp gui/menu_model_telemetry.cpp -GUIGENERALSRC = gui/menu_general.cpp gui/menu_general_setup.cpp +GUIGENERALSRC = gui/menu_general.cpp gui/menu_general_setup.cpp gui/menu_general_trainer.cpp gui/menu_general_version.cpp gui/menu_general_diagkeys.cpp gui/menu_general_diaganas.cpp gui/menu_general_calib.cpp ifeq ($(PCB), $(filter $(PCB), STD 9X 9XR)) # 9x/9xr radio @@ -577,6 +577,7 @@ ifeq ($(PCB), GRUVIN9X) ifeq ($(SDCARD), YES) CPPDEFS += -DRTCLOCK CPPSRC += rtc.cpp targets/gruvin9x/rtc_driver.cpp + GUIGENERALSRC += gui/menu_general_sdmanager.cpp EXTRABOARDSRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c targets/gruvin9x/diskio.cpp endif @@ -618,6 +619,7 @@ ifeq ($(PCB), MEGA2560) ifeq ($(SDCARD), YES) EXTRABOARDSRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c targets/gruvin9x/diskio.cpp CPPDEFS += -DRTCLOCK + GUIGENERALSRC += gui/menu_general_sdmanager.cpp CPPSRC += rtc.cpp targets/gruvin9x/rtc_driver.cpp endif @@ -691,6 +693,7 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO)) ifeq ($(SDCARD), YES) CPPDEFS += -DVOICE INCDIRS += FatFs FatFs/option + GUIGENERALSRC += gui/menu_general_sdmanager.cpp EXTRABOARDSRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c targets/sky9x/diskio.cpp endif ifeq ($(BUZZER), YES) @@ -846,6 +849,7 @@ ifeq ($(PCB), TARANIS) endif ifeq ($(SDCARD), YES) EXTRABOARDSRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c targets/taranis/diskio.cpp + GUIGENERALSRC += gui/menu_general_sdmanager.cpp CPPDEFS += -DVOICE INCDIRS += FatFs FatFs/option endif diff --git a/radio/src/gui/menu_general.cpp b/radio/src/gui/menu_general.cpp index 7f0902ebb..40fa6d790 100644 --- a/radio/src/gui/menu_general.cpp +++ b/radio/src/gui/menu_general.cpp @@ -104,450 +104,6 @@ const MenuFuncP_PROGMEM menuTabGeneral[] PROGMEM = { menuGeneralCalib }; -#if defined(SDCARD) -void menuGeneralSdManagerInfo(uint8_t event) -{ - SIMPLE_SUBMENU(STR_SD_INFO_TITLE, 1); - - lcd_putsLeft(2*FH, STR_SD_TYPE); - lcd_puts(10*FW, 2*FH, SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD); - - lcd_putsLeft(3*FH, STR_SD_SIZE); - lcd_outdezAtt(10*FW, 3*FH, SD_GET_SIZE_MB(), LEFT); - lcd_putc(lcdLastPos, 3*FH, 'M'); - - lcd_putsLeft(4*FH, STR_SD_SECTORS); - lcd_outdezAtt(10*FW, 4*FH, SD_GET_BLOCKNR()/1000, LEFT); - lcd_putc(lcdLastPos, 4*FH, 'k'); - - lcd_putsLeft(5*FH, STR_SD_SPEED); - lcd_outdezAtt(10*FW, 5*FH, SD_GET_SPEED()/1000, LEFT); - lcd_puts(lcdLastPos, 5*FH, "kb/s"); -} - -inline bool isFilenameGreater(bool isfile, const char * fn, const char * line) -{ - return (isfile && !line[SD_SCREEN_FILE_LENGTH+1]) || (isfile==(bool)line[SD_SCREEN_FILE_LENGTH+1] && strcasecmp(fn, line) > 0); -} - -inline bool isFilenameLower(bool isfile, const char * fn, const char * line) -{ - return (!isfile && line[SD_SCREEN_FILE_LENGTH+1]) || (isfile==(bool)line[SD_SCREEN_FILE_LENGTH+1] && strcasecmp(fn, line) < 0); -} - -#if defined(PCBTARANIS) -void backupEeprom() -{ - char filename[60]; - uint8_t buffer[1024]; - FIL file; - - lcd_clear(); - lcd_putsLeft(4*FH, STR_WRITING); - lcd_rect(3, 6*FH+4, 204, 7); - lcdRefresh(); - - //reset unexpectedShutdown to prevent warning when user restores EEPROM backup - g_eeGeneral.unexpectedShutdown = 0; - eeDirty(EE_GENERAL); - eeCheck(true); - - // create the directory if needed... - DIR folder; - FRESULT result = f_opendir(&folder, EEPROMS_PATH); - if (result != FR_OK) { - if (result == FR_NO_PATH) - result = f_mkdir(EEPROMS_PATH); - if (result != FR_OK) { - POPUP_WARNING(SDCARD_ERROR(result)); - return; - } - } - - // prepare the filename... - char * tmp = strAppend(filename, EEPROMS_PATH "/eeprom"); - tmp = strAppendDate(tmp, true); - strAppend(tmp, EEPROM_EXT); - - // open the file for writing... - f_open(&file, filename, FA_WRITE | FA_CREATE_ALWAYS); - - for (int i=0; i 0) - s_editMode = 0; - - switch(_event) { - case EVT_ENTRY: - f_chdir(ROOT_PATH); - reusableBuffer.sdmanager.offset = 65535; - break; - -#if defined(PCBTARANIS) - case EVT_KEY_LONG(KEY_MENU): - if (!READ_ONLY()) { - killEvents(_event); - // MENU_ADD_ITEM(STR_SD_INFO); TODO: Implement - MENU_ADD_ITEM(STR_SD_FORMAT); - menuHandler = onSdManagerMenu; - } - break; -#endif - -#if defined(PCBTARANIS) - case EVT_KEY_BREAK(KEY_ENTER): -#else - CASE_EVT_ROTARY_BREAK - case EVT_KEY_FIRST(KEY_RIGHT): - case EVT_KEY_FIRST(KEY_ENTER): -#endif - { - if (m_posVert > 0) { - vertpos_t index = m_posVert-1-s_pgOfs; - if (!reusableBuffer.sdmanager.lines[index][SD_SCREEN_FILE_LENGTH+1]) { - f_chdir(reusableBuffer.sdmanager.lines[index]); - s_pgOfs = 0; - m_posVert = 1; - reusableBuffer.sdmanager.offset = 65535; - killEvents(_event); - break; - } - } - if (!IS_ROTARY_BREAK(_event) || m_posVert==0) - break; - // no break; - } - - case EVT_KEY_LONG(KEY_ENTER): - killEvents(_event); -#if !defined(PCBTARANIS) - if (m_posVert == 0) { - MENU_ADD_ITEM(STR_SD_INFO); - MENU_ADD_ITEM(STR_SD_FORMAT); - } - else -#endif - { -#if defined(CPUARM) - uint8_t index = m_posVert-1-s_pgOfs; - // TODO duplicated code for finding extension - char * ext = reusableBuffer.sdmanager.lines[index]; - int len = strlen(ext) - 4; - ext += len; - /* TODO if (!strcasecmp(ext, MODELS_EXT)) { - s_menu[s_menu_count++] = STR_LOAD_FILE; - } - else */ if (!strcasecmp(ext, SOUNDS_EXT)) { - MENU_ADD_ITEM(STR_PLAY_FILE); - } -#endif -#if defined(PCBTARANIS) - else if (!strcasecmp(ext, BITMAPS_EXT) && !READ_ONLY() && len <= (int)sizeof(g_model.header.bitmap)) { - MENU_ADD_ITEM(STR_ASSIGN_BITMAP); - } - else if (!strcasecmp(ext, TEXT_EXT)) { - MENU_ADD_ITEM(STR_VIEW_TEXT); - } - else if (!strcasecmp(ext, FIRMWARE_EXT) && !READ_ONLY()) { - MENU_ADD_ITEM(STR_FLASH_BOOTLOADER); - } -#endif -#if defined(LUA) - else if (!strcasecmp(ext, SCRIPTS_EXT)) { - MENU_ADD_ITEM(STR_EXECUTE_FILE); - } -#endif - if (!READ_ONLY()) { - MENU_ADD_ITEM(STR_DELETE_FILE); - // MENU_ADD_ITEM(STR_RENAME_FILE); TODO: Implement - // MENU_ADD_ITEM(STR_COPY_FILE); TODO: Implement - } - } - menuHandler = onSdManagerMenu; - break; - } - - if (reusableBuffer.sdmanager.offset != s_pgOfs) { - if (s_pgOfs == 0) { - reusableBuffer.sdmanager.offset = 0; - memset(reusableBuffer.sdmanager.lines, 0, sizeof(reusableBuffer.sdmanager.lines)); - } - else if (s_pgOfs == reusableBuffer.sdmanager.count-7) { - reusableBuffer.sdmanager.offset = s_pgOfs; - memset(reusableBuffer.sdmanager.lines, 0, sizeof(reusableBuffer.sdmanager.lines)); - } - else if (s_pgOfs > reusableBuffer.sdmanager.offset) { - memmove(reusableBuffer.sdmanager.lines[0], reusableBuffer.sdmanager.lines[1], 6*sizeof(reusableBuffer.sdmanager.lines[0])); - memset(reusableBuffer.sdmanager.lines[6], 0xff, SD_SCREEN_FILE_LENGTH); - reusableBuffer.sdmanager.lines[6][SD_SCREEN_FILE_LENGTH+1] = 1; - } - else { - memmove(reusableBuffer.sdmanager.lines[1], reusableBuffer.sdmanager.lines[0], 6*sizeof(reusableBuffer.sdmanager.lines[0])); - memset(reusableBuffer.sdmanager.lines[0], 0, sizeof(reusableBuffer.sdmanager.lines[0])); - } - - reusableBuffer.sdmanager.count = 0; - - FRESULT res = f_opendir(&dir, "."); /* Open the directory */ - if (res == FR_OK) { - for (;;) { - res = f_readdir(&dir, &fno); /* Read a directory item */ - if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */ - if (fno.fname[0] == '.' && fno.fname[1] == '\0') continue; /* Ignore dot entry */ -#if _USE_LFN - fn = *fno.lfname ? fno.lfname : fno.fname; -#else - fn = fno.fname; -#endif - if (strlen(fn) > SD_SCREEN_FILE_LENGTH) continue; - - reusableBuffer.sdmanager.count++; - - bool isfile = !(fno.fattrib & AM_DIR); - - if (s_pgOfs == 0) { - for (uint8_t i=0; i=0; i--) { - char *line = reusableBuffer.sdmanager.lines[i]; - if (line[0] == '\0' || isFilenameGreater(isfile, fn, line)) { - if (i > 0) memmove(reusableBuffer.sdmanager.lines[0], reusableBuffer.sdmanager.lines[1], sizeof(reusableBuffer.sdmanager.lines[0]) * i); - memset(line, 0, sizeof(reusableBuffer.sdmanager.lines[i])); - strcpy(line, fn); - line[SD_SCREEN_FILE_LENGTH+1] = isfile; - break; - } - } - } - else if (s_pgOfs > reusableBuffer.sdmanager.offset) { - if (isFilenameGreater(isfile, fn, reusableBuffer.sdmanager.lines[5]) && isFilenameLower(isfile, fn, reusableBuffer.sdmanager.lines[6])) { - memset(reusableBuffer.sdmanager.lines[6], 0, sizeof(reusableBuffer.sdmanager.lines[0])); - strcpy(reusableBuffer.sdmanager.lines[6], fn); - reusableBuffer.sdmanager.lines[6][SD_SCREEN_FILE_LENGTH+1] = isfile; - } - } - else { - if (isFilenameLower(isfile, fn, reusableBuffer.sdmanager.lines[1]) && isFilenameGreater(isfile, fn, reusableBuffer.sdmanager.lines[0])) { - memset(reusableBuffer.sdmanager.lines[0], 0, sizeof(reusableBuffer.sdmanager.lines[0])); - strcpy(reusableBuffer.sdmanager.lines[0], fn); - reusableBuffer.sdmanager.lines[0][SD_SCREEN_FILE_LENGTH+1] = isfile; - } - } - } - } - } - - reusableBuffer.sdmanager.offset = s_pgOfs; - - for (uint8_t i=0; i 0) { - char * ext = reusableBuffer.sdmanager.lines[index]; - ext += strlen(ext) - 4; - if (!strcasecmp(ext, BITMAPS_EXT)) { - if (sdBitmapIdx != m_posVert) { - sdBitmapIdx = m_posVert; - uint8_t *dest = sdBitmap; - if (bmpLoad(dest, reusableBuffer.sdmanager.lines[index], MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT)) { - memcpy(sdBitmap, logo_taranis, MODEL_BITMAP_SIZE); - } - } - lcd_bmp(22*FW+2, 2*FH+FH/2, sdBitmap); - } - } -#endif -} -#endif - #if defined(CPUARM) void menuGeneralCustomFunctions(uint8_t event) { @@ -555,407 +111,3 @@ void menuGeneralCustomFunctions(uint8_t event) return menuCustomFunctions(event, g_eeGeneral.customFn, globalFunctionsContext); } #endif - -#if LCD_W >= 212 - #define TRAINER_CALIB_POS 12 -#else - #define TRAINER_CALIB_POS 8 -#endif - -void menuGeneralTrainer(uint8_t event) -{ - uint8_t y; - bool slave = SLAVE_MODE(); - - MENU(STR_MENUTRAINER, menuTabGeneral, e_Trainer, (slave ? 1 : 7), {0, 2, 2, 2, 2, 0/*, 0*/}); - - if (slave) { - lcd_puts(7*FW, 4*FH, STR_SLAVE); - } - else { - uint8_t attr; - uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS); - - lcd_puts(3*FW, MENU_TITLE_HEIGHT+1, STR_MODESRC); - - y = MENU_TITLE_HEIGHT + 1 + FH; - - for (uint8_t i=1; i<=NUM_STICKS; i++) { - uint8_t chan = channel_order(i); - volatile TrainerMix *td = &g_eeGeneral.trainer.mix[chan-1]; - - putsMixerSource(0, y, MIXSRC_Rud-1+chan, (m_posVert==i && CURSOR_ON_LINE()) ? INVERS : 0); - - for (uint8_t j=0; j<3; j++) { - - attr = ((m_posVert==i && m_posHorz==j) ? blink : 0); - - switch(j) { - case 0: - lcd_putsiAtt(4*FW, y, STR_TRNMODE, td->mode, attr); - if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->mode, 0, 2); - break; - - case 1: - lcd_outdezAtt(11*FW, y, td->studWeight, attr); - if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->studWeight, -125, 125); - break; - - case 2: - lcd_putsiAtt(12*FW, y, STR_TRNCHN, td->srcChn, attr); - if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->srcChn, 0, 3); - break; - } - } - y += FH; - } - - attr = (m_posVert==5) ? blink : 0; - lcd_putsLeft(MENU_TITLE_HEIGHT+1+5*FH, STR_MULTIPLIER); - lcd_outdezAtt(LEN_MULTIPLIER*FW+3*FW, MENU_TITLE_HEIGHT+1+5*FH, g_eeGeneral.PPM_Multiplier+10, attr|PREC1); - if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.PPM_Multiplier, -10, 40); - - attr = (m_posVert==6) ? INVERS : 0; - if (attr) s_editMode = 0; - lcd_putsAtt(0*FW, MENU_TITLE_HEIGHT+1+6*FH, STR_CAL, attr); - for (uint8_t i=0; i<4; i++) { - uint8_t x = (i*TRAINER_CALIB_POS+16)*FW/2; -#if defined (PPM_UNIT_PERCENT_PREC1) - lcd_outdezAtt(x, MENU_TITLE_HEIGHT+1+6*FH, (g_ppmIns[i]-g_eeGeneral.trainer.calib[i])*2, PREC1); -#else - lcd_outdezAtt(x, MENU_TITLE_HEIGHT+1+6*FH, (g_ppmIns[i]-g_eeGeneral.trainer.calib[i])/5, 0); -#endif - } - - if (attr) { - if (event==EVT_KEY_LONG(KEY_ENTER)){ - memcpy(g_eeGeneral.trainer.calib, g_ppmIns, sizeof(g_eeGeneral.trainer.calib)); - eeDirty(EE_GENERAL); - AUDIO_WARNING1(); - } - } - } -} - -void menuGeneralVersion(uint8_t event) -{ - SIMPLE_MENU(STR_MENUVERSION, menuTabGeneral, e_Vers, 1); - - lcd_putsLeft(MENU_TITLE_HEIGHT+FH, vers_stamp); - -#if defined(COPROCESSOR) - if (Coproc_valid == 1) { - lcd_putsLeft(6*FH, PSTR("CoPr:")); - lcd_outdez8(10*FW, 6*FH, Coproc_read); - } - else { - lcd_putsLeft(6*FH, PSTR("CoPr: ---")); - } -#endif - -#if defined(PCBTARANIS) - lcd_putsLeft(MENU_TITLE_HEIGHT+6*FH, STR_EEBACKUP); - if (event == EVT_KEY_LONG(KEY_ENTER)) { - backupEeprom(); - } -#endif -} - -void displayKeyState(uint8_t x, uint8_t y, EnumKeys key) -{ - uint8_t t = switchState(key); - lcd_putcAtt(x, y, t+'0', t ? INVERS : 0); -} - -void menuGeneralDiagKeys(uint8_t event) -{ - SIMPLE_MENU(STR_MENUDIAG, menuTabGeneral, e_Keys, 1); - - lcd_puts(14*FW, MENU_TITLE_HEIGHT+2*FH, STR_VTRIM); - - for(uint8_t i=0; i<9; i++) { - coord_t y; - - if (i<8) { - y = MENU_TITLE_HEIGHT + FH*3 + FH*(i/2); - if (i&1) lcd_img(14*FW, y, sticks, i/2, 0); - displayKeyState(i&1? 20*FW : 18*FW, y, (EnumKeys)(TRM_BASE+i)); - } - - if (i<6) { - y = i*FH+MENU_TITLE_HEIGHT+FH; - lcd_putsiAtt(0, y, STR_VKEYS, (5-i), 0); - displayKeyState(5*FW+2, y, (EnumKeys)(KEY_MENU+(5-i))); - } - -#if !defined(PCBTARANIS) - if (i != SW_ID0-SW_BASE) { - y = MENU_TITLE_HEIGHT+i*FH-2*FH; - putsSwitches(8*FW, y, i+1, 0); //ohne off,on - displayKeyState(11*FW+2, y, (EnumKeys)(SW_BASE+i)); - } -#endif - } - -#if defined(ROTARY_ENCODERS) || defined(ROTARY_ENCODER_NAVIGATION) - for(uint8_t i=0; i>= 11; - batCalV += 2; // because of the diode - putsVolts(LEN_CALIB_FIELDS*FW+4*FW, MENU_TITLE_HEIGHT+1+5*FH, batCalV, (m_posVert==1 ? INVERS : 0)); -#elif defined(PCBSKY9X) - lcd_putsLeft(MENU_TITLE_HEIGHT+1+4*FH, STR_BATT_CALIB); - static int32_t adcBatt; - adcBatt = ((adcBatt * 7) + anaIn(TX_VOLTAGE)) / 8; - uint32_t batCalV = (adcBatt + adcBatt*(g_eeGeneral.vBatCalib)/128) * 4191; - batCalV /= 55296; - putsVolts(LEN_CALIB_FIELDS*FW+4*FW, MENU_TITLE_HEIGHT+1+4*FH, batCalV, (m_posVert==1 ? INVERS : 0)); -#elif defined(PCBGRUVIN9X) - lcd_putsLeft(6*FH-2, STR_BATT_CALIB); - // Gruvin wants 2 decimal places and instant update of volts calib field when button pressed - static uint16_t adcBatt; - adcBatt = ((adcBatt * 7) + anaIn(TX_VOLTAGE)) / 8; // running average, sourced directly (to avoid unending debate :P) - uint32_t batCalV = ((uint32_t)adcBatt*1390 + (10*(int32_t)adcBatt*g_eeGeneral.vBatCalib)/8) / BandGap; - lcd_outdezNAtt(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, batCalV, PREC2|(m_posVert==1 ? INVERS : 0)); -#else - lcd_putsLeft(6*FH-2, STR_BATT_CALIB); - putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, g_vbat100mV, (m_posVert==1 ? INVERS : 0)); -#endif - if (m_posVert==1) CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatCalib, -127, 127); - -#if defined(PCBSKY9X) && !defined(REVA) - lcd_putsLeft(6*FH+1, STR_CURRENT_CALIB); - putsValueWithUnit(LEN_CALIB_FIELDS*FW+4*FW, 6*FH+1, getCurrent(), UNIT_MILLIAMPS, (m_posVert==2 ? INVERS : 0)) ; - if (m_posVert==2) CHECK_INCDEC_GENVAR(event, g_eeGeneral.currentCalib, -49, 49); -#endif - -#if defined(PCBSKY9X) - lcd_putsLeft(7*FH+1, STR_TEMP_CALIB); - putsValueWithUnit(LEN_CALIB_FIELDS*FW+4*FW, 7*FH+1, getTemperature(), UNIT_TEMPERATURE, (m_posVert==3 ? INVERS : 0)) ; - if (m_posVert==3) CHECK_INCDEC_GENVAR(event, g_eeGeneral.temperatureCalib, -100, 100); -#endif -} - -#define XPOT_DELTA 10 -#define XPOT_DELAY 10 /* cycles */ - -void menuCommonCalib(uint8_t event) -{ - for (uint8_t i=0; i= POT1 && i <= POT_LAST) { - if (IS_POT_WITHOUT_DETENT(i)) { - reusableBuffer.calib.midVals[i] = (reusableBuffer.calib.hiVals[i] + reusableBuffer.calib.loVals[i]) / 2; - } -#if defined(PCBTARANIS) - uint8_t idx = i - POT1; - int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount; - if (IS_POT_MULTIPOS(i) && count <= XPOTS_MULTIPOS_COUNT) { - if (reusableBuffer.calib.xpotsCalib[idx].lastCount == 0 || vt < reusableBuffer.calib.xpotsCalib[idx].lastPosition - XPOT_DELTA || vt > reusableBuffer.calib.xpotsCalib[idx].lastPosition + XPOT_DELTA) { - reusableBuffer.calib.xpotsCalib[idx].lastPosition = vt; - reusableBuffer.calib.xpotsCalib[idx].lastCount = 1; - } - else { - if (reusableBuffer.calib.xpotsCalib[idx].lastCount < 255) reusableBuffer.calib.xpotsCalib[idx].lastCount++; - } - if (reusableBuffer.calib.xpotsCalib[idx].lastCount == XPOT_DELAY) { - int16_t position = reusableBuffer.calib.xpotsCalib[idx].lastPosition; - bool found = false; - for (int j=0; j= step-XPOT_DELTA && position <= step+XPOT_DELTA) { - found = true; - break; - } - } - if (!found) { - if (count < XPOTS_MULTIPOS_COUNT) { - reusableBuffer.calib.xpotsCalib[idx].steps[count] = position; - } - reusableBuffer.calib.xpotsCalib[idx].stepsCount += 1; - } - } - } -#endif - } - } - - calibrationState = reusableBuffer.calib.state; // make sure we don't scroll while calibrating - - switch (event) - { - case EVT_ENTRY: - reusableBuffer.calib.state = 0; - break; - - case EVT_KEY_BREAK(KEY_ENTER): - reusableBuffer.calib.state++; - break; - } - - switch (reusableBuffer.calib.state) { - case 0: - // START CALIBRATION - if (!READ_ONLY()) { - lcd_putsLeft(MENU_TITLE_HEIGHT+2*FH, STR_MENUTOSTART); - } - break; - - case 1: - // SET MIDPOINT - lcd_putsAtt(0*FW, MENU_TITLE_HEIGHT+FH, STR_SETMIDPOINT, INVERS); - lcd_putsLeft(MENU_TITLE_HEIGHT+2*FH, STR_MENUWHENDONE); - - for (uint8_t i=0; i 50) { - g_eeGeneral.calib[i].mid = reusableBuffer.calib.midVals[i]; - int16_t v = reusableBuffer.calib.midVals[i] - reusableBuffer.calib.loVals[i]; - g_eeGeneral.calib[i].spanNeg = v - v/STICK_TOLERANCE; - v = reusableBuffer.calib.hiVals[i] - reusableBuffer.calib.midVals[i]; - g_eeGeneral.calib[i].spanPos = v - v/STICK_TOLERANCE; - } - } - break; - - case 3: -#if defined(PCBTARANIS) - for (uint8_t i=POT1; i<=POT_LAST; i++) { - int idx = i - POT1; - int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount; - if (IS_POT_MULTIPOS(i)) { - if (count > 1 && count <= XPOTS_MULTIPOS_COUNT) { - for (int j=0; jcount = count - 1; - for (int j=0; jcount; j++) { - calib->steps[j] = (reusableBuffer.calib.xpotsCalib[idx].steps[j+1] + reusableBuffer.calib.xpotsCalib[idx].steps[j]) >> 5; - } - } - else { - g_eeGeneral.potsType &= ~(0x03<<(2*idx)); - } - } - } -#endif - g_eeGeneral.chkSum = evalChkSum(); - eeDirty(EE_GENERAL); - reusableBuffer.calib.state = 4; - break; - - default: - reusableBuffer.calib.state = 0; - break; - } - - doMainScreenGraphics(); - -#if defined(PCBTARANIS) - drawPotsBars(); - for (int i=POT1; i<=POT_LAST; i++) { - uint8_t steps = 0; - if (reusableBuffer.calib.state == 2) { - steps = reusableBuffer.calib.xpotsCalib[i-POT1].stepsCount; - } - else if (IS_POT_MULTIPOS(i)) { - StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[i]; - steps = calib->count + 1; - } - if (steps > 0 && steps <= XPOTS_MULTIPOS_COUNT) { - lcd_outdezAtt(LCD_W/2-2+(i-POT1)*5, LCD_H-6, steps, TINSIZE); - } - } -#endif -} - -void menuGeneralCalib(uint8_t event) -{ - check_simple(event, e_Calib, menuTabGeneral, DIM(menuTabGeneral), 0); - - if (menuEvent) { - calibrationState = 0; - } - - TITLE(STR_MENUCALIBRATION); - menuCommonCalib(READ_ONLY() ? 0 : event); -} - -void menuFirstCalib(uint8_t event) -{ - if (event == EVT_KEY_BREAK(KEY_EXIT) || reusableBuffer.calib.state == 4) { - calibrationState = 0; - chainMenu(menuMainView); - } - else { - lcd_putsCenter(0*FH, MENUCALIBRATION); - lcd_invert_line(0); - menuCommonCalib(event); - } -} diff --git a/radio/src/gui/menu_general_calib.cpp b/radio/src/gui/menu_general_calib.cpp new file mode 100755 index 000000000..82aa257be --- /dev/null +++ b/radio/src/gui/menu_general_calib.cpp @@ -0,0 +1,220 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * 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" + +#define XPOT_DELTA 10 +#define XPOT_DELAY 10 /* cycles */ + +void menuCommonCalib(uint8_t event) +{ + for (uint8_t i=0; i= POT1 && i <= POT_LAST) { + if (IS_POT_WITHOUT_DETENT(i)) { + reusableBuffer.calib.midVals[i] = (reusableBuffer.calib.hiVals[i] + reusableBuffer.calib.loVals[i]) / 2; + } +#if defined(PCBTARANIS) + uint8_t idx = i - POT1; + int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount; + if (IS_POT_MULTIPOS(i) && count <= XPOTS_MULTIPOS_COUNT) { + if (reusableBuffer.calib.xpotsCalib[idx].lastCount == 0 || vt < reusableBuffer.calib.xpotsCalib[idx].lastPosition - XPOT_DELTA || vt > reusableBuffer.calib.xpotsCalib[idx].lastPosition + XPOT_DELTA) { + reusableBuffer.calib.xpotsCalib[idx].lastPosition = vt; + reusableBuffer.calib.xpotsCalib[idx].lastCount = 1; + } + else { + if (reusableBuffer.calib.xpotsCalib[idx].lastCount < 255) reusableBuffer.calib.xpotsCalib[idx].lastCount++; + } + if (reusableBuffer.calib.xpotsCalib[idx].lastCount == XPOT_DELAY) { + int16_t position = reusableBuffer.calib.xpotsCalib[idx].lastPosition; + bool found = false; + for (int j=0; j= step-XPOT_DELTA && position <= step+XPOT_DELTA) { + found = true; + break; + } + } + if (!found) { + if (count < XPOTS_MULTIPOS_COUNT) { + reusableBuffer.calib.xpotsCalib[idx].steps[count] = position; + } + reusableBuffer.calib.xpotsCalib[idx].stepsCount += 1; + } + } + } +#endif + } + } + + calibrationState = reusableBuffer.calib.state; // make sure we don't scroll while calibrating + + switch (event) + { + case EVT_ENTRY: + reusableBuffer.calib.state = 0; + break; + + case EVT_KEY_BREAK(KEY_ENTER): + reusableBuffer.calib.state++; + break; + } + + switch (reusableBuffer.calib.state) { + case 0: + // START CALIBRATION + if (!READ_ONLY()) { + lcd_putsLeft(MENU_TITLE_HEIGHT+2*FH, STR_MENUTOSTART); + } + break; + + case 1: + // SET MIDPOINT + lcd_putsAtt(0*FW, MENU_TITLE_HEIGHT+FH, STR_SETMIDPOINT, INVERS); + lcd_putsLeft(MENU_TITLE_HEIGHT+2*FH, STR_MENUWHENDONE); + + for (uint8_t i=0; i 50) { + g_eeGeneral.calib[i].mid = reusableBuffer.calib.midVals[i]; + int16_t v = reusableBuffer.calib.midVals[i] - reusableBuffer.calib.loVals[i]; + g_eeGeneral.calib[i].spanNeg = v - v/STICK_TOLERANCE; + v = reusableBuffer.calib.hiVals[i] - reusableBuffer.calib.midVals[i]; + g_eeGeneral.calib[i].spanPos = v - v/STICK_TOLERANCE; + } + } + break; + + case 3: +#if defined(PCBTARANIS) + for (uint8_t i=POT1; i<=POT_LAST; i++) { + int idx = i - POT1; + int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount; + if (IS_POT_MULTIPOS(i)) { + if (count > 1 && count <= XPOTS_MULTIPOS_COUNT) { + for (int j=0; jcount = count - 1; + for (int j=0; jcount; j++) { + calib->steps[j] = (reusableBuffer.calib.xpotsCalib[idx].steps[j+1] + reusableBuffer.calib.xpotsCalib[idx].steps[j]) >> 5; + } + } + else { + g_eeGeneral.potsType &= ~(0x03<<(2*idx)); + } + } + } +#endif + g_eeGeneral.chkSum = evalChkSum(); + eeDirty(EE_GENERAL); + reusableBuffer.calib.state = 4; + break; + + default: + reusableBuffer.calib.state = 0; + break; + } + + doMainScreenGraphics(); + +#if defined(PCBTARANIS) + drawPotsBars(); + for (int i=POT1; i<=POT_LAST; i++) { + uint8_t steps = 0; + if (reusableBuffer.calib.state == 2) { + steps = reusableBuffer.calib.xpotsCalib[i-POT1].stepsCount; + } + else if (IS_POT_MULTIPOS(i)) { + StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[i]; + steps = calib->count + 1; + } + if (steps > 0 && steps <= XPOTS_MULTIPOS_COUNT) { + lcd_outdezAtt(LCD_W/2-2+(i-POT1)*5, LCD_H-6, steps, TINSIZE); + } + } +#endif +} + +void menuGeneralCalib(uint8_t event) +{ + check_simple(event, e_Calib, menuTabGeneral, DIM(menuTabGeneral), 0); + + if (menuEvent) { + calibrationState = 0; + } + + TITLE(STR_MENUCALIBRATION); + menuCommonCalib(READ_ONLY() ? 0 : event); +} + +void menuFirstCalib(uint8_t event) +{ + if (event == EVT_KEY_BREAK(KEY_EXIT) || reusableBuffer.calib.state == 4) { + calibrationState = 0; + chainMenu(menuMainView); + } + else { + lcd_putsCenter(0*FH, MENUCALIBRATION); + lcd_invert_line(0); + menuCommonCalib(event); + } +} diff --git a/radio/src/gui/menu_general_diaganas.cpp b/radio/src/gui/menu_general_diaganas.cpp new file mode 100755 index 000000000..2798f0702 --- /dev/null +++ b/radio/src/gui/menu_general_diaganas.cpp @@ -0,0 +1,107 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * 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" + +void menuGeneralDiagAna(uint8_t event) +{ +#if defined(PCBSKY9X) && !defined(REVA) + #define ANAS_ITEMS_COUNT 4 +#elif defined(PCBSKY9X) + #define ANAS_ITEMS_COUNT 3 +#else + #define ANAS_ITEMS_COUNT 2 +#endif + + SIMPLE_MENU(STR_MENUANA, menuTabGeneral, e_Ana, ANAS_ITEMS_COUNT); + + STICK_SCROLL_DISABLE(); + + for (uint8_t i=0; i>= 11; + batCalV += 2; // because of the diode + putsVolts(LEN_CALIB_FIELDS*FW+4*FW, MENU_TITLE_HEIGHT+1+5*FH, batCalV, (m_posVert==1 ? INVERS : 0)); +#elif defined(PCBSKY9X) + lcd_putsLeft(MENU_TITLE_HEIGHT+1+4*FH, STR_BATT_CALIB); + static int32_t adcBatt; + adcBatt = ((adcBatt * 7) + anaIn(TX_VOLTAGE)) / 8; + uint32_t batCalV = (adcBatt + adcBatt*(g_eeGeneral.vBatCalib)/128) * 4191; + batCalV /= 55296; + putsVolts(LEN_CALIB_FIELDS*FW+4*FW, MENU_TITLE_HEIGHT+1+4*FH, batCalV, (m_posVert==1 ? INVERS : 0)); +#elif defined(PCBGRUVIN9X) + lcd_putsLeft(6*FH-2, STR_BATT_CALIB); + // Gruvin wants 2 decimal places and instant update of volts calib field when button pressed + static uint16_t adcBatt; + adcBatt = ((adcBatt * 7) + anaIn(TX_VOLTAGE)) / 8; // running average, sourced directly (to avoid unending debate :P) + uint32_t batCalV = ((uint32_t)adcBatt*1390 + (10*(int32_t)adcBatt*g_eeGeneral.vBatCalib)/8) / BandGap; + lcd_outdezNAtt(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, batCalV, PREC2|(m_posVert==1 ? INVERS : 0)); +#else + lcd_putsLeft(6*FH-2, STR_BATT_CALIB); + putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, g_vbat100mV, (m_posVert==1 ? INVERS : 0)); +#endif + if (m_posVert==1) CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatCalib, -127, 127); + +#if defined(PCBSKY9X) && !defined(REVA) + lcd_putsLeft(6*FH+1, STR_CURRENT_CALIB); + putsValueWithUnit(LEN_CALIB_FIELDS*FW+4*FW, 6*FH+1, getCurrent(), UNIT_MILLIAMPS, (m_posVert==2 ? INVERS : 0)) ; + if (m_posVert==2) CHECK_INCDEC_GENVAR(event, g_eeGeneral.currentCalib, -49, 49); +#endif + +#if defined(PCBSKY9X) + lcd_putsLeft(7*FH+1, STR_TEMP_CALIB); + putsValueWithUnit(LEN_CALIB_FIELDS*FW+4*FW, 7*FH+1, getTemperature(), UNIT_TEMPERATURE, (m_posVert==3 ? INVERS : 0)) ; + if (m_posVert==3) CHECK_INCDEC_GENVAR(event, g_eeGeneral.temperatureCalib, -100, 100); +#endif +} diff --git a/radio/src/gui/menu_general_diagkeys.cpp b/radio/src/gui/menu_general_diagkeys.cpp new file mode 100755 index 000000000..2e6783f1a --- /dev/null +++ b/radio/src/gui/menu_general_diagkeys.cpp @@ -0,0 +1,83 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * 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" + +void displayKeyState(uint8_t x, uint8_t y, EnumKeys key) +{ + uint8_t t = switchState(key); + lcd_putcAtt(x, y, t+'0', t ? INVERS : 0); +} + +void menuGeneralDiagKeys(uint8_t event) +{ + SIMPLE_MENU(STR_MENUDIAG, menuTabGeneral, e_Keys, 1); + + lcd_puts(14*FW, MENU_TITLE_HEIGHT+2*FH, STR_VTRIM); + + for(uint8_t i=0; i<9; i++) { + coord_t y; + + if (i<8) { + y = MENU_TITLE_HEIGHT + FH*3 + FH*(i/2); + if (i&1) lcd_img(14*FW, y, sticks, i/2, 0); + displayKeyState(i&1? 20*FW : 18*FW, y, (EnumKeys)(TRM_BASE+i)); + } + + if (i<6) { + y = i*FH+MENU_TITLE_HEIGHT+FH; + lcd_putsiAtt(0, y, STR_VKEYS, (5-i), 0); + displayKeyState(5*FW+2, y, (EnumKeys)(KEY_MENU+(5-i))); + } + +#if !defined(PCBTARANIS) + if (i != SW_ID0-SW_BASE) { + y = MENU_TITLE_HEIGHT+i*FH-2*FH; + putsSwitches(8*FW, y, i+1, 0); //ohne off,on + displayKeyState(11*FW+2, y, (EnumKeys)(SW_BASE+i)); + } +#endif + } + +#if defined(ROTARY_ENCODERS) || defined(ROTARY_ENCODER_NAVIGATION) + for(uint8_t i=0; i + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * 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" + +void menuGeneralSdManagerInfo(uint8_t event) +{ + SIMPLE_SUBMENU(STR_SD_INFO_TITLE, 1); + + lcd_putsLeft(2*FH, STR_SD_TYPE); + lcd_puts(10*FW, 2*FH, SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD); + + lcd_putsLeft(3*FH, STR_SD_SIZE); + lcd_outdezAtt(10*FW, 3*FH, SD_GET_SIZE_MB(), LEFT); + lcd_putc(lcdLastPos, 3*FH, 'M'); + + lcd_putsLeft(4*FH, STR_SD_SECTORS); + lcd_outdezAtt(10*FW, 4*FH, SD_GET_BLOCKNR()/1000, LEFT); + lcd_putc(lcdLastPos, 4*FH, 'k'); + + lcd_putsLeft(5*FH, STR_SD_SPEED); + lcd_outdezAtt(10*FW, 5*FH, SD_GET_SPEED()/1000, LEFT); + lcd_puts(lcdLastPos, 5*FH, "kb/s"); +} + +inline bool isFilenameGreater(bool isfile, const char * fn, const char * line) +{ + return (isfile && !line[SD_SCREEN_FILE_LENGTH+1]) || (isfile==(bool)line[SD_SCREEN_FILE_LENGTH+1] && strcasecmp(fn, line) > 0); +} + +inline bool isFilenameLower(bool isfile, const char * fn, const char * line) +{ + return (!isfile && line[SD_SCREEN_FILE_LENGTH+1]) || (isfile==(bool)line[SD_SCREEN_FILE_LENGTH+1] && strcasecmp(fn, line) < 0); +} + +#if defined(PCBTARANIS) +void flashBootloader(const char * filename) +{ + FIL file; + f_open(&file, filename, FA_READ); + uint8_t buffer[1024]; + UINT count; + + lcd_clear(); + lcd_putsLeft(4*FH, STR_WRITING); + lcd_rect(3, 6*FH+4, 204, 7); + lcdRefresh(); + + static uint8_t unlocked = 0; + if (!unlocked) { + unlocked = 1; + unlockFlash(); + } + + for (int i=0; i 0) + s_editMode = 0; + + switch(_event) { + case EVT_ENTRY: + f_chdir(ROOT_PATH); + reusableBuffer.sdmanager.offset = 65535; + break; + +#if defined(PCBTARANIS) + case EVT_KEY_LONG(KEY_MENU): + if (!READ_ONLY()) { + killEvents(_event); + // MENU_ADD_ITEM(STR_SD_INFO); TODO: Implement + MENU_ADD_ITEM(STR_SD_FORMAT); + menuHandler = onSdManagerMenu; + } + break; +#endif + +#if defined(PCBTARANIS) + case EVT_KEY_BREAK(KEY_ENTER): +#else + CASE_EVT_ROTARY_BREAK + case EVT_KEY_FIRST(KEY_RIGHT): + case EVT_KEY_FIRST(KEY_ENTER): +#endif + { + if (m_posVert > 0) { + vertpos_t index = m_posVert-1-s_pgOfs; + if (!reusableBuffer.sdmanager.lines[index][SD_SCREEN_FILE_LENGTH+1]) { + f_chdir(reusableBuffer.sdmanager.lines[index]); + s_pgOfs = 0; + m_posVert = 1; + reusableBuffer.sdmanager.offset = 65535; + killEvents(_event); + break; + } + } + if (!IS_ROTARY_BREAK(_event) || m_posVert==0) + break; + // no break; + } + + case EVT_KEY_LONG(KEY_ENTER): + killEvents(_event); +#if !defined(PCBTARANIS) + if (m_posVert == 0) { + MENU_ADD_ITEM(STR_SD_INFO); + MENU_ADD_ITEM(STR_SD_FORMAT); + } + else +#endif + { +#if defined(CPUARM) + uint8_t index = m_posVert-1-s_pgOfs; + // TODO duplicated code for finding extension + char * ext = reusableBuffer.sdmanager.lines[index]; + int len = strlen(ext) - 4; + ext += len; + /* TODO if (!strcasecmp(ext, MODELS_EXT)) { + s_menu[s_menu_count++] = STR_LOAD_FILE; + } + else */ if (!strcasecmp(ext, SOUNDS_EXT)) { + MENU_ADD_ITEM(STR_PLAY_FILE); + } +#endif +#if defined(PCBTARANIS) + else if (!strcasecmp(ext, BITMAPS_EXT) && !READ_ONLY() && len <= (int)sizeof(g_model.header.bitmap)) { + MENU_ADD_ITEM(STR_ASSIGN_BITMAP); + } + else if (!strcasecmp(ext, TEXT_EXT)) { + MENU_ADD_ITEM(STR_VIEW_TEXT); + } + else if (!strcasecmp(ext, FIRMWARE_EXT) && !READ_ONLY()) { + MENU_ADD_ITEM(STR_FLASH_BOOTLOADER); + } +#endif +#if defined(LUA) + else if (!strcasecmp(ext, SCRIPTS_EXT)) { + MENU_ADD_ITEM(STR_EXECUTE_FILE); + } +#endif + if (!READ_ONLY()) { + MENU_ADD_ITEM(STR_DELETE_FILE); + // MENU_ADD_ITEM(STR_RENAME_FILE); TODO: Implement + // MENU_ADD_ITEM(STR_COPY_FILE); TODO: Implement + } + } + menuHandler = onSdManagerMenu; + break; + } + + if (reusableBuffer.sdmanager.offset != s_pgOfs) { + if (s_pgOfs == 0) { + reusableBuffer.sdmanager.offset = 0; + memset(reusableBuffer.sdmanager.lines, 0, sizeof(reusableBuffer.sdmanager.lines)); + } + else if (s_pgOfs == reusableBuffer.sdmanager.count-7) { + reusableBuffer.sdmanager.offset = s_pgOfs; + memset(reusableBuffer.sdmanager.lines, 0, sizeof(reusableBuffer.sdmanager.lines)); + } + else if (s_pgOfs > reusableBuffer.sdmanager.offset) { + memmove(reusableBuffer.sdmanager.lines[0], reusableBuffer.sdmanager.lines[1], 6*sizeof(reusableBuffer.sdmanager.lines[0])); + memset(reusableBuffer.sdmanager.lines[6], 0xff, SD_SCREEN_FILE_LENGTH); + reusableBuffer.sdmanager.lines[6][SD_SCREEN_FILE_LENGTH+1] = 1; + } + else { + memmove(reusableBuffer.sdmanager.lines[1], reusableBuffer.sdmanager.lines[0], 6*sizeof(reusableBuffer.sdmanager.lines[0])); + memset(reusableBuffer.sdmanager.lines[0], 0, sizeof(reusableBuffer.sdmanager.lines[0])); + } + + reusableBuffer.sdmanager.count = 0; + + FRESULT res = f_opendir(&dir, "."); /* Open the directory */ + if (res == FR_OK) { + for (;;) { + res = f_readdir(&dir, &fno); /* Read a directory item */ + if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */ + if (fno.fname[0] == '.' && fno.fname[1] == '\0') continue; /* Ignore dot entry */ +#if _USE_LFN + fn = *fno.lfname ? fno.lfname : fno.fname; +#else + fn = fno.fname; +#endif + if (strlen(fn) > SD_SCREEN_FILE_LENGTH) continue; + + reusableBuffer.sdmanager.count++; + + bool isfile = !(fno.fattrib & AM_DIR); + + if (s_pgOfs == 0) { + for (uint8_t i=0; i=0; i--) { + char *line = reusableBuffer.sdmanager.lines[i]; + if (line[0] == '\0' || isFilenameGreater(isfile, fn, line)) { + if (i > 0) memmove(reusableBuffer.sdmanager.lines[0], reusableBuffer.sdmanager.lines[1], sizeof(reusableBuffer.sdmanager.lines[0]) * i); + memset(line, 0, sizeof(reusableBuffer.sdmanager.lines[i])); + strcpy(line, fn); + line[SD_SCREEN_FILE_LENGTH+1] = isfile; + break; + } + } + } + else if (s_pgOfs > reusableBuffer.sdmanager.offset) { + if (isFilenameGreater(isfile, fn, reusableBuffer.sdmanager.lines[5]) && isFilenameLower(isfile, fn, reusableBuffer.sdmanager.lines[6])) { + memset(reusableBuffer.sdmanager.lines[6], 0, sizeof(reusableBuffer.sdmanager.lines[0])); + strcpy(reusableBuffer.sdmanager.lines[6], fn); + reusableBuffer.sdmanager.lines[6][SD_SCREEN_FILE_LENGTH+1] = isfile; + } + } + else { + if (isFilenameLower(isfile, fn, reusableBuffer.sdmanager.lines[1]) && isFilenameGreater(isfile, fn, reusableBuffer.sdmanager.lines[0])) { + memset(reusableBuffer.sdmanager.lines[0], 0, sizeof(reusableBuffer.sdmanager.lines[0])); + strcpy(reusableBuffer.sdmanager.lines[0], fn); + reusableBuffer.sdmanager.lines[0][SD_SCREEN_FILE_LENGTH+1] = isfile; + } + } + } + } + } + + reusableBuffer.sdmanager.offset = s_pgOfs; + + for (uint8_t i=0; i 0) { + char * ext = reusableBuffer.sdmanager.lines[index]; + ext += strlen(ext) - 4; + if (!strcasecmp(ext, BITMAPS_EXT)) { + if (sdBitmapIdx != m_posVert) { + sdBitmapIdx = m_posVert; + uint8_t *dest = sdBitmap; + if (bmpLoad(dest, reusableBuffer.sdmanager.lines[index], MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT)) { + memcpy(sdBitmap, logo_taranis, MODEL_BITMAP_SIZE); + } + } + lcd_bmp(22*FW+2, 2*FH+FH/2, sdBitmap); + } + } +#endif +} diff --git a/radio/src/gui/menu_general_trainer.cpp b/radio/src/gui/menu_general_trainer.cpp new file mode 100755 index 000000000..eb1d9ada4 --- /dev/null +++ b/radio/src/gui/menu_general_trainer.cpp @@ -0,0 +1,118 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * 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 LCD_W >= 212 + #define TRAINER_CALIB_POS 12 +#else + #define TRAINER_CALIB_POS 8 +#endif + +void menuGeneralTrainer(uint8_t event) +{ + uint8_t y; + bool slave = SLAVE_MODE(); + + MENU(STR_MENUTRAINER, menuTabGeneral, e_Trainer, (slave ? 1 : 7), {0, 2, 2, 2, 2, 0/*, 0*/}); + + if (slave) { + lcd_puts(7*FW, 4*FH, STR_SLAVE); + } + else { + uint8_t attr; + uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS); + + lcd_puts(3*FW, MENU_TITLE_HEIGHT+1, STR_MODESRC); + + y = MENU_TITLE_HEIGHT + 1 + FH; + + for (uint8_t i=1; i<=NUM_STICKS; i++) { + uint8_t chan = channel_order(i); + volatile TrainerMix *td = &g_eeGeneral.trainer.mix[chan-1]; + + putsMixerSource(0, y, MIXSRC_Rud-1+chan, (m_posVert==i && CURSOR_ON_LINE()) ? INVERS : 0); + + for (uint8_t j=0; j<3; j++) { + + attr = ((m_posVert==i && m_posHorz==j) ? blink : 0); + + switch(j) { + case 0: + lcd_putsiAtt(4*FW, y, STR_TRNMODE, td->mode, attr); + if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->mode, 0, 2); + break; + + case 1: + lcd_outdezAtt(11*FW, y, td->studWeight, attr); + if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->studWeight, -125, 125); + break; + + case 2: + lcd_putsiAtt(12*FW, y, STR_TRNCHN, td->srcChn, attr); + if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->srcChn, 0, 3); + break; + } + } + y += FH; + } + + attr = (m_posVert==5) ? blink : 0; + lcd_putsLeft(MENU_TITLE_HEIGHT+1+5*FH, STR_MULTIPLIER); + lcd_outdezAtt(LEN_MULTIPLIER*FW+3*FW, MENU_TITLE_HEIGHT+1+5*FH, g_eeGeneral.PPM_Multiplier+10, attr|PREC1); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.PPM_Multiplier, -10, 40); + + attr = (m_posVert==6) ? INVERS : 0; + if (attr) s_editMode = 0; + lcd_putsAtt(0*FW, MENU_TITLE_HEIGHT+1+6*FH, STR_CAL, attr); + for (uint8_t i=0; i<4; i++) { + uint8_t x = (i*TRAINER_CALIB_POS+16)*FW/2; +#if defined (PPM_UNIT_PERCENT_PREC1) + lcd_outdezAtt(x, MENU_TITLE_HEIGHT+1+6*FH, (g_ppmIns[i]-g_eeGeneral.trainer.calib[i])*2, PREC1); +#else + lcd_outdezAtt(x, MENU_TITLE_HEIGHT+1+6*FH, (g_ppmIns[i]-g_eeGeneral.trainer.calib[i])/5, 0); +#endif + } + + if (attr) { + if (event==EVT_KEY_LONG(KEY_ENTER)){ + memcpy(g_eeGeneral.trainer.calib, g_ppmIns, sizeof(g_eeGeneral.trainer.calib)); + eeDirty(EE_GENERAL); + AUDIO_WARNING1(); + } + } + } +} diff --git a/radio/src/gui/menu_general_version.cpp b/radio/src/gui/menu_general_version.cpp new file mode 100755 index 000000000..efdff1f94 --- /dev/null +++ b/radio/src/gui/menu_general_version.cpp @@ -0,0 +1,118 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * 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(PCBTARANIS) +void backupEeprom() +{ + char filename[60]; + uint8_t buffer[1024]; + FIL file; + + lcd_clear(); + lcd_putsLeft(4*FH, STR_WRITING); + lcd_rect(3, 6*FH+4, 204, 7); + lcdRefresh(); + + //reset unexpectedShutdown to prevent warning when user restores EEPROM backup + g_eeGeneral.unexpectedShutdown = 0; + eeDirty(EE_GENERAL); + eeCheck(true); + + // create the directory if needed... + DIR folder; + FRESULT result = f_opendir(&folder, EEPROMS_PATH); + if (result != FR_OK) { + if (result == FR_NO_PATH) + result = f_mkdir(EEPROMS_PATH); + if (result != FR_OK) { + POPUP_WARNING(SDCARD_ERROR(result)); + return; + } + } + + // prepare the filename... + char * tmp = strAppend(filename, EEPROMS_PATH "/eeprom"); + tmp = strAppendDate(tmp, true); + strAppend(tmp, EEPROM_EXT); + + // open the file for writing... + f_open(&file, filename, FA_WRITE | FA_CREATE_ALWAYS); + + for (int i=0; ichn]; } -void DrawFunction(FnFuncP fn, uint8_t offset=0) +void DrawFunction(FnFuncP fn, uint8_t offset) { lcd_vlineStip(X0-offset, 0, LCD_H, 0xee); lcd_hlineStip(X0-WCHART-offset, Y0, WCHART*2, 0xee); diff --git a/radio/src/gui/menus.h b/radio/src/gui/menus.h index 45ad25a8e..f7c4fb283 100644 --- a/radio/src/gui/menus.h +++ b/radio/src/gui/menus.h @@ -509,4 +509,7 @@ void displayWarning(uint8_t event); #define EDIT_MODE_INIT -1 #endif +typedef int16_t (*FnFuncP) (int16_t x); +void DrawFunction(FnFuncP fn, uint8_t offset=0); + #endif diff --git a/radio/src/gui/view_statistics.cpp b/radio/src/gui/view_statistics.cpp index e528d1ce0..30a8cf2a7 100644 --- a/radio/src/gui/view_statistics.cpp +++ b/radio/src/gui/view_statistics.cpp @@ -72,16 +72,16 @@ void menuStatisticsView(uint8_t event) #endif #if defined(THRTRACE) - uint8_t traceRd = (s_traceCnt < 0 ? s_traceWr : 0); - const uint8_t x=5; - const uint8_t y=60; - lcd_hline(x-3,y,MAXTRACE+3+3); - lcd_vline(x,y-32,32+3); + coord_t traceRd = (s_traceCnt < 0 ? s_traceWr : 0); + const coord_t x = 5; + const coord_t y = 60; + lcd_hline(x-3, y, MAXTRACE+3+3); + lcd_vline(x, y-32, 32+3); - for (uint8_t i=0; i=MAXTRACE) traceRd = 0; diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 553a675f8..148b705b3 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1618,8 +1618,13 @@ TimerState timersStates[MAX_TIMERS] = { { 0 }, { 0 } }; #if defined(THRTRACE) uint8_t s_traceBuf[MAXTRACE]; -uint8_t s_traceWr; -int s_traceCnt; +#if LCD_W >= 255 + int16_t s_traceWr; + int16_t s_traceCnt; +#else + uint8_t s_traceWr; + int16_t s_traceCnt; +#endif uint8_t s_cnt_10s; uint16_t s_cnt_samples_thr_10s; uint16_t s_sum_samples_thr_10s; diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 5782a93b6..a81d7892e 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -880,8 +880,13 @@ extern uint16_t lastMixerDuration; #if defined(THRTRACE) #define MAXTRACE (LCD_W - 8) extern uint8_t s_traceBuf[MAXTRACE]; - extern uint8_t s_traceWr; - extern int s_traceCnt; + #if LCD_W >= 255 + extern int16_t s_traceWr; + extern int16_t s_traceCnt; + #else + extern uint8_t s_traceWr; + extern int16_t s_traceCnt; + #endif extern uint8_t s_cnt_10s; extern uint16_t s_cnt_samples_thr_10s; extern uint16_t s_sum_samples_thr_10s;