mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 16:55:20 +03:00
[Horus] Next round of screen changes + refactoring
This commit is contained in:
parent
8f4c161dc0
commit
a556c50956
106 changed files with 1848 additions and 1195 deletions
|
@ -1,19 +1,19 @@
|
|||
PROJECT( companion )
|
||||
|
||||
SET(C9X_VERSION_MAJOR "2")
|
||||
SET(C9X_VERSION_MINOR "2")
|
||||
SET(C9X_VERSION_REVISION "0")
|
||||
SET(C9X_VERSION_SUFFIX $ENV{OPENTX_VERSION_SUFFIX})
|
||||
SET(VERSION_MAJOR "2")
|
||||
SET(VERSION_MINOR "2")
|
||||
SET(VERSION_REVISION "0")
|
||||
SET(VERSION_SUFFIX $ENV{OPENTX_VERSION_SUFFIX})
|
||||
|
||||
SET(C9X_VERSION ${C9X_VERSION_MAJOR}.${C9X_VERSION_MINOR}.${C9X_VERSION_REVISION}${C9X_VERSION_SUFFIX})
|
||||
MESSAGE(STATUS "OpenTX Companion ${C9X_VERSION}")
|
||||
SET(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}${VERSION_SUFFIX})
|
||||
MESSAGE(STATUS "OpenTX Companion ${VERSION}")
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 )
|
||||
|
||||
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
SET(C9X_NAME_SUFFIX ${C9X_VERSION_MAJOR}${C9X_VERSION_MINOR})
|
||||
SET(C9X_NAME_SUFFIX ${VERSION_MAJOR}${VERSION_MINOR})
|
||||
SET(COMPANION_NAME "companion${C9X_NAME_SUFFIX}")
|
||||
SET(SIMULATOR_NAME "simulator${C9X_NAME_SUFFIX}")
|
||||
SET( SIMULATOR_LIB_PATH ${CMAKE_INSTALL_PREFIX}/lib/companion${C9X_NAME_SUFFIX} )
|
||||
|
@ -454,18 +454,18 @@ if(DPKG_PROGRAM)
|
|||
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}_${C9X_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
|
||||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}_${VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
|
||||
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Bertrand Songis <bsongis-nosp@m-gmail.com>")
|
||||
SET(CPACK_DEBIAN_PACKAGE_VERSION ${C9X_VERSION})
|
||||
SET(CPACK_DEBIAN_PACKAGE_VERSION_MAJOR ${C9X_VERSION_MAJOR})
|
||||
SET(CPACK_DEBIAN_PACKAGE_VERSION_MINOR ${C9X_VERSION_MINOR})
|
||||
SET(CPACK_DEBIAN_PACKAGE_VERSION ${VERSION})
|
||||
SET(CPACK_DEBIAN_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
|
||||
SET(CPACK_DEBIAN_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
|
||||
SET(CPACK_DEBIAN_ARCHITECTURE $(CMAKE_SYSTEM_PROCESSOR))
|
||||
SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
||||
else(DPKG_PROGRAM)
|
||||
SET(CPACK_GENERATOR "RPM")
|
||||
SET(CPACK_RPM_PACKAGE_VERSION ${C9X_VERSION})
|
||||
SET(CPACK_RPM_PACKAGE_VERSION ${VERSION})
|
||||
SET(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
|
||||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}-${C9X_VERSION}-${CMAKE_SYSTEM_PROCESSOR}")
|
||||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}-${VERSION}-${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif(DPKG_PROGRAM)
|
||||
|
||||
INCLUDE(CPack)
|
||||
|
|
|
@ -80,9 +80,9 @@ for (int fm=0; fm<MAX_FLIGHT_MODES; fm++) {
|
|||
|
||||
#ifdef LCDCHANGED_IMPORT
|
||||
#undef LCDCHANGED_IMPORT
|
||||
if (lcd_refresh) {
|
||||
if (simuLcdRefresh) {
|
||||
lightEnable = isBacklightEnable();
|
||||
lcd_refresh = false;
|
||||
simuLcdRefresh = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -98,7 +98,7 @@ return true;
|
|||
|
||||
#ifdef GETLCD_IMPORT
|
||||
#undef GETLCD_IMPORT
|
||||
return (::uint8_t *)lcd_buf;
|
||||
return (::uint8_t *)simuLcdBuf;
|
||||
#endif
|
||||
|
||||
#ifdef GETERROR_IMPORT
|
||||
|
|
|
@ -1230,7 +1230,7 @@ ifeq ($(PCB), HORUS)
|
|||
PULSESSRC = pulses/pulses_arm.cpp pulses/ppm_arm.cpp pulses/pxx_arm.cpp
|
||||
CPPSRC += tasks_arm.cpp audio_arm.cpp sbus.cpp telemetry/telemetry.cpp
|
||||
CPPSRC += targets/Horus/pulses_driver.cpp targets/Horus/keys_driver.cpp targets/Horus/adc_driver.cpp targets/Horus/trainer_driver.cpp targets/Horus/audio_driver.cpp targets/Horus/serial2_driver.cpp targets/Horus/telemetry_driver.cpp
|
||||
CPPSRC += gui/$(GUIDIRECTORY)/bitmaps.cpp gui/$(GUIDIRECTORY)/view_channels.cpp gui/$(GUIDIRECTORY)/view_about.cpp gui/$(GUIDIRECTORY)/view_text.cpp debug.cpp
|
||||
CPPSRC += bmp.cpp gui/$(GUIDIRECTORY)/bitmaps.cpp gui/$(GUIDIRECTORY)/view_channels.cpp gui/$(GUIDIRECTORY)/view_about.cpp gui/$(GUIDIRECTORY)/view_text.cpp debug.cpp
|
||||
SRC += targets/Horus/system_stm32f4xx.c
|
||||
CPPSRC += storage/storage_common.cpp storage/sdcard_raw.cpp
|
||||
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/misc.c
|
||||
|
@ -1577,13 +1577,16 @@ ifeq ($(SIMU), YES)
|
|||
CPPDEFS += -DDEBUG
|
||||
CPPSRC += dump.cpp
|
||||
else ifeq ($(CLI), YES)
|
||||
CPPDEFS += -DCLI -DDEBUG
|
||||
CPPDEFS += -DCLI
|
||||
CPPSRC += cli.cpp dump.cpp
|
||||
else ifeq ($(DEBUG), YES)
|
||||
CPPDEFS += -DDEBUG
|
||||
CPPSRC += dump.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG), YES)
|
||||
CPPDEFS += -DDEBUG
|
||||
endif
|
||||
|
||||
ifeq ($(EEPROM_PROGRESS_BAR), YES)
|
||||
CPPDEFS += -DEEPROM_PROGRESS_BAR
|
||||
endif
|
||||
|
@ -1911,7 +1914,7 @@ bitmaps/Horus/mask_%.lbm: bitmaps/Horus/mask_%.png
|
|||
$(IMG2LBM) $^ $@ $(LCDSIZE) $(MASKFORMAT)
|
||||
|
||||
bitmaps/Horus/%.lbm: bitmaps/Horus/%.png
|
||||
$(IMG2LBM) $^ $@ $(LCDSIZE) 5/6/5
|
||||
$(IMG2LBM) $^ $@ $(LCDSIZE) 5/6/5/8
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
PARSER = avr-cpp
|
||||
|
|
|
@ -152,8 +152,8 @@ const char * const audioFilenames[] = {
|
|||
"bye",
|
||||
"thralert",
|
||||
"swalert",
|
||||
"eebad",
|
||||
"eeformat",
|
||||
"baddata",
|
||||
"format",
|
||||
"lowbatt",
|
||||
"inactiv",
|
||||
"a1_org",
|
||||
|
|
|
@ -36,7 +36,8 @@
|
|||
|
||||
#include "opentx.h"
|
||||
|
||||
const pm_char * bmpLoad(uint8_t *bmp, const char *filename, const unsigned int width, const unsigned int height)
|
||||
#if defined(PCBTARANIS)
|
||||
const char * bmpLoad(uint8_t * bmp, const char * filename, uint16_t width, uint16_t height)
|
||||
{
|
||||
FIL bmpFile;
|
||||
UINT read;
|
||||
|
@ -203,6 +204,177 @@ const pm_char * bmpLoad(uint8_t *bmp, const char *filename, const unsigned int w
|
|||
f_close(&bmpFile);
|
||||
return 0;
|
||||
}
|
||||
#elif defined(PCBHORUS)
|
||||
const char * bmpLoad(uint8_t * bmp, const char * filename, uint16_t width, uint16_t height)
|
||||
{
|
||||
FIL bmpFile;
|
||||
UINT read;
|
||||
uint8_t palette[16];
|
||||
uint8_t bmpBuf[LCD_W]; /* maximum with LCD_W */
|
||||
uint8_t *buf = &bmpBuf[0];
|
||||
|
||||
if (width > LCD_W) {
|
||||
return STR_INCOMPATIBLE;
|
||||
}
|
||||
|
||||
FRESULT result = f_open(&bmpFile, filename, FA_OPEN_EXISTING | FA_READ);
|
||||
if (result != FR_OK) {
|
||||
return SDCARD_ERROR(result);
|
||||
}
|
||||
|
||||
if (f_size(&bmpFile) < 14) {
|
||||
f_close(&bmpFile);
|
||||
return STR_INCOMPATIBLE;
|
||||
}
|
||||
|
||||
result = f_read(&bmpFile, buf, 14, &read);
|
||||
if (result != FR_OK || read != 14) {
|
||||
f_close(&bmpFile);
|
||||
return SDCARD_ERROR(result);
|
||||
}
|
||||
|
||||
if (buf[0] != 'B' || buf[1] != 'M') {
|
||||
f_close(&bmpFile);
|
||||
return STR_INCOMPATIBLE;
|
||||
}
|
||||
|
||||
uint32_t fsize = *((uint32_t *)&buf[2]);
|
||||
uint32_t hsize = *((uint32_t *)&buf[10]); /* header size */
|
||||
|
||||
uint32_t len = limit((uint32_t)4, (uint32_t)(hsize-14), (uint32_t)32);
|
||||
result = f_read(&bmpFile, buf, len, &read);
|
||||
if (result != FR_OK || read != len) {
|
||||
f_close(&bmpFile);
|
||||
return SDCARD_ERROR(result);
|
||||
}
|
||||
|
||||
uint32_t ihsize = *((uint32_t *)&buf[0]); /* more header size */
|
||||
|
||||
/* invalid header size */
|
||||
if (ihsize + 14 > hsize) {
|
||||
f_close(&bmpFile);
|
||||
return STR_INCOMPATIBLE;
|
||||
}
|
||||
|
||||
/* sometimes file size is set to some headers size, set a real size in that case */
|
||||
if (fsize == 14 || fsize == ihsize + 14)
|
||||
fsize = f_size(&bmpFile) - 2;
|
||||
|
||||
/* declared file size less than header size */
|
||||
if (fsize <= hsize) {
|
||||
f_close(&bmpFile);
|
||||
return STR_INCOMPATIBLE;
|
||||
}
|
||||
|
||||
uint32_t w, h;
|
||||
|
||||
switch (ihsize){
|
||||
case 40: // windib
|
||||
case 56: // windib v3
|
||||
case 64: // OS/2 v2
|
||||
case 108: // windib v4
|
||||
case 124: // windib v5
|
||||
w = *((uint32_t *)&buf[4]);
|
||||
h = *((uint32_t *)&buf[8]);
|
||||
buf += 12;
|
||||
break;
|
||||
case 12: // OS/2 v1
|
||||
w = *((uint16_t *)&buf[4]);
|
||||
h = *((uint16_t *)&buf[6]);
|
||||
buf += 8;
|
||||
break;
|
||||
default:
|
||||
f_close(&bmpFile);
|
||||
return STR_INCOMPATIBLE;
|
||||
}
|
||||
|
||||
if (*((uint16_t *)&buf[0]) != 1) { /* planes */
|
||||
f_close(&bmpFile);
|
||||
return STR_INCOMPATIBLE;
|
||||
}
|
||||
|
||||
if (w > width || h > height) {
|
||||
f_close(&bmpFile);
|
||||
return STR_INCOMPATIBLE;
|
||||
}
|
||||
|
||||
uint16_t depth = *((uint16_t *)&buf[2]);
|
||||
|
||||
buf = &bmpBuf[0];
|
||||
|
||||
if (depth == 4) {
|
||||
if (f_lseek(&bmpFile, hsize-64) != FR_OK || f_read(&bmpFile, buf, 64, &read) != FR_OK || read != 64) {
|
||||
f_close(&bmpFile);
|
||||
return SDCARD_ERROR(result);
|
||||
}
|
||||
for (uint8_t i=0; i<16; i++) {
|
||||
palette[i] = buf[4*i];
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (f_lseek(&bmpFile, hsize) != FR_OK) {
|
||||
f_close(&bmpFile);
|
||||
return SDCARD_ERROR(result);
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t * dest = (uint16_t *)bmp;
|
||||
|
||||
*dest++ = w;
|
||||
*dest++ = h;
|
||||
|
||||
memset(dest, 0, BITMAP_BUFFER_SIZE(w, h) - 4);
|
||||
|
||||
uint32_t rowSize;
|
||||
|
||||
switch (depth) {
|
||||
case 32:
|
||||
for (int i=h-1; i>=0; i--) {
|
||||
uint8_t * dst = ((uint8_t *)dest) + i*w*3;
|
||||
for (unsigned int j=0; j<w; j++) {
|
||||
uint32_t pixel;
|
||||
result = f_read(&bmpFile, (uint8_t *)&pixel, 4, &read);
|
||||
if (result != FR_OK || read != 4) {
|
||||
f_close(&bmpFile);
|
||||
return SDCARD_ERROR(result);
|
||||
}
|
||||
*((uint16_t *)dst) = RGB((pixel>>24) & 0xff, (pixel>>16) & 0xff, (pixel>>8) & 0xff);
|
||||
dst += 2;
|
||||
*dst++ = 0x0F;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
|
||||
case 4:
|
||||
rowSize = ((4*w+31)/32)*4;
|
||||
for (int32_t i=h-1; i>=0; i--) {
|
||||
result = f_read(&bmpFile, buf, rowSize, &read);
|
||||
if (result != FR_OK || read != rowSize) {
|
||||
f_close(&bmpFile);
|
||||
return SDCARD_ERROR(result);
|
||||
}
|
||||
uint8_t * dst = ((uint8_t *)dest) + i*w*3;
|
||||
for (uint32_t j=0; j<w; j++) {
|
||||
uint8_t index = (buf[j/2] >> ((j & 1) ? 0 : 4)) & 0x0F;
|
||||
uint8_t val = palette[index];
|
||||
*((uint16_t *)dst) = RGB(val, val, val);
|
||||
dst += 2;
|
||||
*dst++ = 0x0F;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
f_close(&bmpFile);
|
||||
return STR_INCOMPATIBLE;
|
||||
}
|
||||
|
||||
f_close(&bmpFile);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
const uint8_t bmpHeader[] = {
|
||||
0x42, 0x4d, 0xF8, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x28, 0x00,
|
||||
|
|
|
@ -160,39 +160,11 @@ int cliTrace(const char ** argv)
|
|||
|
||||
int cliStackInfo(const char ** argv)
|
||||
{
|
||||
int tid = 0;
|
||||
if (toInt(argv, 1, &tid) > 0) {
|
||||
int available = 0;
|
||||
int total = 0;
|
||||
switch(tid) {
|
||||
case MENU_TASK_INDEX:
|
||||
total = menusStack.size();
|
||||
available = menusStack.available();
|
||||
break;
|
||||
case MIXER_TASK_INDEX:
|
||||
total = mixerStack.size();
|
||||
available = mixerStack.available();
|
||||
break;
|
||||
case AUDIO_TASK_INDEX:
|
||||
total = audioStack.size();
|
||||
available = audioStack.available();
|
||||
break;
|
||||
case CLI_TASK_INDEX:
|
||||
total = cliStack.size();
|
||||
available = cliStack.available();
|
||||
break;
|
||||
case MAIN_TASK_INDEX:
|
||||
total = stackAvailable();
|
||||
available = stackSize();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
serialPrint("%d available (%d total)", available, total);
|
||||
}
|
||||
else {
|
||||
serialPrint("%s: Invalid argument \"%s\"", argv[0], argv[1]);
|
||||
}
|
||||
serialPrint("[MAIN] %d available / %d", stackAvailable(), stackSize());
|
||||
serialPrint("[MENUS] %d available / %d", menusStack.available(), menusStack.size());
|
||||
serialPrint("[MIXER] %d available / %d", mixerStack.available(), mixerStack.size());
|
||||
serialPrint("[AUDIO] %d available / %d", audioStack.available(), audioStack.size());
|
||||
serialPrint("[CLI] %d available / %d", cliStack.available(), cliStack.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -269,7 +241,7 @@ int cliDisplay(const char ** argv)
|
|||
name[len] = '\0';
|
||||
serialPrint("[%s] = %s", name, switchState(EnumKeys(i)) ? "on" : "off");
|
||||
}
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION) || defined(REV9E) || defined(PCBHORUS) || defined(PCBFLAMENCO)
|
||||
serialPrint("[Enc.] = %d", rotencValue / 2);
|
||||
#endif
|
||||
for (int i=TRM_BASE; i<=TRM_LAST; i++) {
|
||||
|
@ -342,6 +314,18 @@ int cliDisplay(const char ** argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cliDebugVars(const char ** argv)
|
||||
{
|
||||
extern unsigned int ioMutexReq, ioMutexRel;
|
||||
extern unsigned int sdReadRetries;
|
||||
|
||||
serialPrint("ioMutexReq=%d", ioMutexReq);
|
||||
serialPrint("ioMutexRel=%d", ioMutexRel);
|
||||
serialPrint("sdReadRetries=%d", sdReadRetries);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cliHelp(const char ** argv);
|
||||
|
||||
const CliCommand cliCommands[] = {
|
||||
|
@ -349,7 +333,7 @@ const CliCommand cliCommands[] = {
|
|||
{ "ls", cliLs, "<directory>" },
|
||||
{ "play", cliPlay, "<filename>" },
|
||||
{ "print", cliDisplay, "<address> [<size>] | <what>" },
|
||||
{ "stackinfo", cliStackInfo, "<tid>" },
|
||||
{ "stackinfo", cliStackInfo, "" },
|
||||
{ "trace", cliTrace, "on | off" },
|
||||
{ "volume", cliVolume, "<level>" },
|
||||
#if defined(PCBFLAMENCO)
|
||||
|
@ -357,6 +341,7 @@ const CliCommand cliCommands[] = {
|
|||
{ "write_bq24195", cliWriteBQ24195, "<register> <data>" },
|
||||
#endif
|
||||
{ "help", cliHelp, "[<command>]" },
|
||||
{ "debugvars", cliDebugVars, "" },
|
||||
{ NULL, NULL, NULL } /* sentinel */
|
||||
};
|
||||
|
||||
|
|
|
@ -268,14 +268,4 @@ void lcdRefresh();
|
|||
#define BLINK_ON_PHASE (g_blinkTmr10ms & (1<<6))
|
||||
#endif
|
||||
|
||||
#if defined(SIMU)
|
||||
extern bool lcd_refresh;
|
||||
extern display_t lcd_buf[DISPLAY_BUFFER_SIZE];
|
||||
#endif
|
||||
|
||||
char *strAppend(char * dest, const char * source, int len=0);
|
||||
char *strSetCursor(char *dest, int position);
|
||||
char *strAppendDate(char * str, bool time=false);
|
||||
char *strAppendFilename(char * dest, const char * filename, const int size);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -88,7 +88,7 @@ enum EnumTabDiag {
|
|||
e_Calib
|
||||
};
|
||||
|
||||
const MenuFuncP_PROGMEM menuTabGeneral[] PROGMEM = {
|
||||
const MenuFuncP menuTabGeneral[] PROGMEM = {
|
||||
menuGeneralSetup,
|
||||
CASE_SDCARD(menuGeneralSdManager)
|
||||
CASE_CPUARM(menuGeneralCustomFunctions)
|
||||
|
|
|
@ -99,7 +99,7 @@ uint8_t editDelay(const coord_t y, const uint8_t event, const uint8_t attr, cons
|
|||
}
|
||||
#define EDIT_DELAY(x, y, event, attr, str, delay) editDelay(y, event, attr, str, delay)
|
||||
|
||||
const MenuFuncP_PROGMEM menuTabModel[] PROGMEM = {
|
||||
const MenuFuncP menuTabModel[] PROGMEM = {
|
||||
menuModelSelect,
|
||||
menuModelSetup,
|
||||
CASE_HELI(menuModelHeli)
|
||||
|
|
|
@ -67,9 +67,8 @@ extern uint8_t calibrationState;
|
|||
void menu_lcd_onoff(coord_t x, coord_t y, uint8_t value, LcdFlags attr);
|
||||
|
||||
typedef void (*MenuFuncP)(uint8_t event);
|
||||
typedef void (*MenuFuncP_PROGMEM)(uint8_t event);
|
||||
extern const MenuFuncP_PROGMEM menuTabModel[];
|
||||
extern const MenuFuncP_PROGMEM menuTabGeneral[];
|
||||
extern const MenuFuncP menuTabModel[];
|
||||
extern const MenuFuncP menuTabGeneral[];
|
||||
|
||||
extern MenuFuncP g_menuStack[5];
|
||||
extern uint8_t g_menuPos[4];
|
||||
|
|
|
@ -83,7 +83,7 @@ enum mavlink_menu_ {
|
|||
};
|
||||
|
||||
//! \brief Pointer array to mavlink settings menus.
|
||||
const MenuFuncP_PROGMEM menuTabMav[] PROGMEM = {
|
||||
const MenuFuncP menuTabMav[] PROGMEM = {
|
||||
menuTelemetryMavlinkSetup
|
||||
};
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ const uint8_t LBM_CURRENT_DOT[] = {
|
|||
* Main view bitmaps
|
||||
*/
|
||||
|
||||
const uint16_t LBM_MAINVIEW_BACKGROUND[] = {
|
||||
const uint8_t LBM_MAINVIEW_BACKGROUND[] = {
|
||||
#include "../../bitmaps/Horus/background.lbm"
|
||||
};
|
||||
|
||||
|
@ -224,10 +224,30 @@ const uint8_t LBM_LIBRARY_SLOT[] = {
|
|||
#include "../../bitmaps/Horus/mask_library_slot.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_LIBRARY_CURSOR[] = {
|
||||
#include "../../bitmaps/Horus/mask_library_category_index.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_SCORE0[] = {
|
||||
#include "../../bitmaps/Horus/mask_library_score_0.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_SCORE1[] = {
|
||||
#include "../../bitmaps/Horus/mask_library_score_1.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_STAR0[] = {
|
||||
#include "../../bitmaps/Horus/mask_library_star_0.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_STAR1[] = {
|
||||
#include "../../bitmaps/Horus/mask_library_star_1.lbm"
|
||||
};
|
||||
|
||||
/*
|
||||
* Other
|
||||
*/
|
||||
|
||||
const uint16_t LBM_ASTERISK[] = {
|
||||
const uint8_t LBM_ASTERISK[] = {
|
||||
#include "../../bitmaps/Horus/asterisk.lbm"
|
||||
};
|
||||
|
|
|
@ -74,6 +74,8 @@ void drawFooter();
|
|||
#define drawStatusLine(...)
|
||||
void drawProgressBar(const char *label);
|
||||
void updateProgressBar(int num, int den);
|
||||
void drawTopmenuDatetime();
|
||||
|
||||
|
||||
// Header bitmaps
|
||||
extern const uint8_t LBM_TOPMENU_POLYGON[];
|
||||
|
@ -83,7 +85,7 @@ extern const uint8_t LBM_CURRENT_SHADOW[];
|
|||
extern const uint8_t LBM_CURRENT_DOT[];
|
||||
|
||||
// Main view icons
|
||||
extern const uint16_t LBM_MAINVIEW_BACKGROUND[];
|
||||
extern const uint8_t LBM_MAINVIEW_BACKGROUND[];
|
||||
extern const uint8_t LBM_TOPMENU_OPENTX[];
|
||||
extern const uint8_t LBM_TOPMENU_USB[];
|
||||
extern const uint8_t LBM_HTRIM_FRAME[];
|
||||
|
@ -101,7 +103,12 @@ extern const uint8_t * const LBM_MODEL_ICONS[];
|
|||
// Model selection icons
|
||||
extern const uint8_t LBM_LIBRARY_ICON[];
|
||||
extern const uint8_t LBM_LIBRARY_SLOT[];
|
||||
extern const uint8_t LBM_LIBRARY_CURSOR[];
|
||||
extern const uint8_t LBM_SCORE0[];
|
||||
extern const uint8_t LBM_SCORE1[];
|
||||
extern const uint8_t LBM_STAR0[];
|
||||
extern const uint8_t LBM_STAR1[];
|
||||
|
||||
// Other icons
|
||||
extern const uint16_t LBM_ASTERISK[];
|
||||
extern const uint8_t LBM_ASTERISK[];
|
||||
|
||||
|
|
|
@ -147,6 +147,27 @@ int getFontHeight(LcdFlags flags)
|
|||
return heightTable[FONTSIZE(flags) >> 8];
|
||||
}
|
||||
|
||||
int getBitmapScale(const uint8_t * bmp, int dstWidth, int dstHeight)
|
||||
{
|
||||
int widthScale, heightScale;
|
||||
|
||||
int bmpWidth = getBitmapWidth(bmp);
|
||||
int bmpHeight = getBitmapHeight(bmp);
|
||||
|
||||
if (bmpWidth == 0 || bmpHeight == 0)
|
||||
return 0;
|
||||
|
||||
if (bmpWidth > dstWidth)
|
||||
widthScale = -((bmpWidth+dstWidth-1) / dstWidth);
|
||||
else
|
||||
widthScale = (dstWidth / bmpWidth);
|
||||
if (bmpHeight > dstHeight)
|
||||
heightScale = -((bmpHeight+dstHeight-1) / dstHeight);
|
||||
else
|
||||
heightScale = (dstHeight / bmpHeight);
|
||||
return min(widthScale, heightScale);
|
||||
}
|
||||
|
||||
int getTextWidth(const pm_char * s, int len, LcdFlags flags)
|
||||
{
|
||||
const uint16_t * specs = fontspecsTable[FONTSIZE(flags) >> 8];
|
||||
|
@ -228,24 +249,14 @@ void lcdDrawTextWithLen(coord_t x, coord_t y, const pm_char * s, uint8_t len, Lc
|
|||
lcdNextPos = x;
|
||||
}
|
||||
|
||||
void lcd_putsn(coord_t x, coord_t y, const pm_char * s, uint8_t len)
|
||||
{
|
||||
lcdDrawTextWithLen(x, y, s, len, TEXT_COLOR);
|
||||
}
|
||||
|
||||
void lcdDrawText(coord_t x, coord_t y, const pm_char * s, LcdFlags flags)
|
||||
{
|
||||
lcdDrawTextWithLen(x, y, s, 255, flags);
|
||||
}
|
||||
|
||||
void lcd_puts(coord_t x, coord_t y, const pm_char * s)
|
||||
{
|
||||
lcdDrawText(x, y, s, 0);
|
||||
}
|
||||
|
||||
void lcd_putsLeft(coord_t y, const pm_char * s)
|
||||
{
|
||||
lcd_puts(MENUS_MARGIN_LEFT, y, s);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, s);
|
||||
}
|
||||
|
||||
void lcd_putsCenter(coord_t y, const pm_char * s, LcdFlags attr)
|
||||
|
@ -277,17 +288,7 @@ void lcd_outhex4(coord_t x, coord_t y, uint32_t val, LcdFlags flags)
|
|||
lcdDrawText(x, y, s, flags);
|
||||
}
|
||||
|
||||
void lcd_outdez8(coord_t x, coord_t y, int8_t val)
|
||||
{
|
||||
lcd_outdezAtt(x, y, val);
|
||||
}
|
||||
|
||||
void lcd_outdezAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, const char *suffix, const char *prefix)
|
||||
{
|
||||
lcd_outdezNAtt(x, y, val, flags, 0, suffix, prefix);
|
||||
}
|
||||
|
||||
void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, int len, const char *suffix, const char *prefix)
|
||||
void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags, uint8_t len, const char * prefix, const char * suffix)
|
||||
{
|
||||
char str[48+1]; // max=16 for the prefix, 16 chars for the number, 16 chars for the suffix
|
||||
char *s = str+32;
|
||||
|
@ -455,7 +456,7 @@ void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att)
|
|||
// TODO to be optimized with putsValueWithUnit
|
||||
void putsVolts(coord_t x, coord_t y, uint16_t volts, LcdFlags att)
|
||||
{
|
||||
lcd_outdezAtt(x, y, (int16_t)volts, (~NO_UNIT) & (att | ((att&PREC2)==PREC2 ? 0 : PREC1)), (~att & NO_UNIT) ? "v" : NULL);
|
||||
lcdDrawNumber(x, y, (int16_t)volts, (~NO_UNIT) & (att | ((att&PREC2)==PREC2 ? 0 : PREC1)), 0, NULL, (~att & NO_UNIT) ? "v" : NULL);
|
||||
}
|
||||
|
||||
void putsVBat(coord_t x, coord_t y, LcdFlags att)
|
||||
|
@ -477,7 +478,7 @@ void putsMixerSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
|
|||
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, 0, att); // TODO macro
|
||||
}
|
||||
else if (idx <= MIXSRC_LAST_INPUT) {
|
||||
char s[32] = "\323";
|
||||
char s[32] = "\314";
|
||||
if (ZEXIST(g_model.inputNames[idx-MIXSRC_FIRST_INPUT])) {
|
||||
zchar2str(s+1, g_model.inputNames[idx-MIXSRC_FIRST_INPUT], LEN_INPUT_NAME);
|
||||
s[1+LEN_INPUT_NAME] = '\0';
|
||||
|
@ -713,16 +714,16 @@ const pm_uint8_t bchunit_ar[] PROGMEM = {
|
|||
UNIT_DIST, // GPS Alt
|
||||
};
|
||||
|
||||
void putsValueWithUnit(coord_t x, coord_t y, lcdint_t val, uint8_t unit, LcdFlags att)
|
||||
void putsValueWithUnit(coord_t x, coord_t y, int32_t val, uint8_t unit, LcdFlags att)
|
||||
{
|
||||
// convertUnit(val, unit);
|
||||
if (!(att & NO_UNIT) && unit != UNIT_RAW) {
|
||||
char unitStr[8];
|
||||
strAppend(unitStr, STR_VTELEMUNIT+1+unit*STR_VTELEMUNIT[0], STR_VTELEMUNIT[0]);
|
||||
lcd_outdezAtt(x, y, val, att, unitStr);
|
||||
lcdDrawNumber(x, y, val, att, 0, NULL, unitStr);
|
||||
}
|
||||
else {
|
||||
lcd_outdezAtt(x, y, val, att);
|
||||
lcdDrawNumber(x, y, val, att);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -734,7 +735,7 @@ void displayGpsCoords(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFl
|
|||
{
|
||||
}
|
||||
|
||||
void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, lcdint_t value, LcdFlags att)
|
||||
void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, int32_t value, LcdFlags att)
|
||||
{
|
||||
TelemetryItem & telemetryItem = telemetryItems[channel];
|
||||
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[channel];
|
||||
|
@ -755,7 +756,7 @@ void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, lcdint_t v
|
|||
}
|
||||
}
|
||||
|
||||
void putsChannelValue(coord_t x, coord_t y, source_t channel, lcdint_t value, LcdFlags att)
|
||||
void putsChannelValue(coord_t x, coord_t y, source_t channel, int32_t value, LcdFlags att)
|
||||
{
|
||||
if (channel >= MIXSRC_FIRST_TELEM) {
|
||||
channel = (channel-MIXSRC_FIRST_TELEM) / 3;
|
||||
|
@ -765,20 +766,20 @@ void putsChannelValue(coord_t x, coord_t y, source_t channel, lcdint_t value, Lc
|
|||
putsTimer(x, y, value, att);
|
||||
}
|
||||
else if (channel == MIXSRC_TX_VOLTAGE) {
|
||||
lcd_outdezAtt(x, y, value, att|PREC1);
|
||||
lcdDrawNumber(x, y, value, att|PREC1);
|
||||
}
|
||||
else if (channel < MIXSRC_FIRST_CH) {
|
||||
lcd_outdezAtt(x, y, calcRESXto100(value), att);
|
||||
lcdDrawNumber(x, y, calcRESXto100(value), att);
|
||||
}
|
||||
else if (channel <= MIXSRC_LAST_CH) {
|
||||
#if defined(PPM_UNIT_PERCENT_PREC1)
|
||||
lcd_outdezAtt(x, y, calcRESXto1000(value), att|PREC1);
|
||||
lcdDrawNumber(x, y, calcRESXto1000(value), att|PREC1);
|
||||
#else
|
||||
lcd_outdezAtt(x, y, calcRESXto100(value), att);
|
||||
lcdDrawNumber(x, y, calcRESXto100(value), att);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
lcd_outdezAtt(x, y, value, att);
|
||||
lcdDrawNumber(x, y, value, att);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -883,11 +884,10 @@ void lcdDrawVerticalLine(coord_t x, coord_t y, coord_t h, uint8_t pat, LcdFlags
|
|||
}
|
||||
|
||||
#if !defined(BOOT)
|
||||
void lcdDrawBitmap(coord_t x, coord_t y, const uint16_t * img, coord_t offset, coord_t width)
|
||||
void lcdDrawBitmap(coord_t x, coord_t y, const uint8_t * bmp, coord_t offset, coord_t width, int scale)
|
||||
{
|
||||
const uint16_t * q = img;
|
||||
coord_t w = *q++;
|
||||
coord_t height = *q++;
|
||||
int w = getBitmapWidth(bmp);
|
||||
int height = getBitmapHeight(bmp);
|
||||
|
||||
if (!width || width > w) {
|
||||
width = w;
|
||||
|
@ -897,12 +897,33 @@ void lcdDrawBitmap(coord_t x, coord_t y, const uint16_t * img, coord_t offset, c
|
|||
width = LCD_W-x;
|
||||
}
|
||||
|
||||
if (scale == 0) {
|
||||
scale = -1;
|
||||
}
|
||||
|
||||
if (scale < 0) {
|
||||
for (coord_t i=0, row=0; row<height; i+=1, row-=scale) {
|
||||
display_t * p = &displayBuf[(y+i)*LCD_W + x];
|
||||
const uint8_t * q = bmp + 4 + (row*w + offset) * 3;
|
||||
for (coord_t col=0; col<width; col-=scale) {
|
||||
lcdDrawTransparentPixel(p, *(q+2), *((uint16_t *)q));
|
||||
p++; q-=3*scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (coord_t row=0; row<height; row++) {
|
||||
display_t * p = &displayBuf[(row+y)*LCD_W + x];
|
||||
q = img + 2 + row*w + offset;
|
||||
for (int i=0; i<scale; i++) {
|
||||
display_t * p = &displayBuf[(y+scale*row+i)*LCD_W + x];
|
||||
const uint8_t * q = bmp + 4 + (row*w + offset) * 3;
|
||||
for (coord_t col=0; col<width; col++) {
|
||||
lcdDrawPixel(p, *q);
|
||||
p++; q++;
|
||||
for (int j=0; j<scale; j++) {
|
||||
lcdDrawTransparentPixel(p, *(q+2), *((uint16_t *)q));
|
||||
p++;
|
||||
}
|
||||
q+=3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -910,7 +931,7 @@ void lcdDrawBitmap(coord_t x, coord_t y, const uint16_t * img, coord_t offset, c
|
|||
|
||||
void lcdDrawBlackOverlay()
|
||||
{
|
||||
// lcdDrawFilledRect(0, 0, LCD_W, LCD_H, SOLID, TEXT_COLOR | (8<<24));
|
||||
lcdDrawFilledRect(0, 0, LCD_W, LCD_H, SOLID, TEXT_COLOR | (8<<24));
|
||||
}
|
||||
|
||||
void lcdDrawCircle(int x0, int y0, int radius)
|
||||
|
|
|
@ -49,16 +49,11 @@
|
|||
#define CONTRAST_MAX 45
|
||||
|
||||
#define lcdint_t int32_t
|
||||
#define lcduint_t uint32_t
|
||||
|
||||
#define LCD_LINES 17 // TODO change this constant which has no sense here, the header uses more than one line
|
||||
#define LCD_COLS 30
|
||||
|
||||
#define BSS 0x00
|
||||
// #define ERASE 0x00
|
||||
// #define FORCE 0x00
|
||||
#define FIXEDWIDTH 0x00
|
||||
// #define FILLWHITE 0x00
|
||||
#define BOLD 0x00
|
||||
|
||||
/* lcd common flags */
|
||||
|
@ -194,15 +189,12 @@ extern coord_t lcdNextPos;
|
|||
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags attr=TEXT_COLOR);
|
||||
void lcdDrawText(coord_t x, coord_t y, const pm_char * s, LcdFlags attr=TEXT_COLOR);
|
||||
void lcdDrawTextAtIndex(coord_t x, coord_t y, const pm_char * s, uint8_t idx, LcdFlags attr=TEXT_COLOR);
|
||||
void lcdDrawTextWithLen(coord_t x, coord_t y, const pm_char * s, unsigned char len, LcdFlags attr=TEXT_COLOR);
|
||||
void lcd_puts(coord_t x, coord_t y, const pm_char * s);
|
||||
void lcd_putsn(coord_t x, coord_t y, const pm_char * s, unsigned char len);
|
||||
void lcdDrawTextWithLen(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags attr=TEXT_COLOR);
|
||||
void lcdDrawTextWithLen(coord_t x, coord_t y, const pm_char * s, unsigned char len);
|
||||
void lcd_putsLeft(coord_t y, const pm_char * s);
|
||||
void lcd_putsCenter(coord_t y, const pm_char * s, LcdFlags attr=0);
|
||||
void lcd_outhex4(coord_t x, coord_t y, uint32_t val, LcdFlags mode=0);
|
||||
void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, int len, const char *suffix=NULL, const char *prefix=NULL);
|
||||
void lcd_outdezAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags mode=0, const char *suffix=NULL, const char *prefix=NULL);
|
||||
void lcd_outdez8(coord_t x, coord_t y, int8_t val);
|
||||
void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags=0, uint8_t len=0, const char * prefix=NULL, const char * suffix=NULL);
|
||||
|
||||
void putsStrIdx(coord_t x, coord_t y, const pm_char *str, int idx, LcdFlags att=0, const char *prefix="");
|
||||
void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att);
|
||||
|
@ -220,9 +212,9 @@ void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags attr);
|
|||
void putsVolts(coord_t x, coord_t y, uint16_t volts, LcdFlags att);
|
||||
void putsVBat(coord_t x, coord_t y, LcdFlags att);
|
||||
|
||||
void putsChannelValue(coord_t x, coord_t y, source_t channel, lcdint_t val, LcdFlags att=0);
|
||||
void putsChannelValue(coord_t x, coord_t y, source_t channel, int32_t val, LcdFlags att=0);
|
||||
void putsChannel(coord_t x, coord_t y, source_t channel, LcdFlags att=0);
|
||||
void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, lcdint_t val, LcdFlags att=0);
|
||||
void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, int32_t val, LcdFlags att=0);
|
||||
|
||||
#define putstime_t int32_t
|
||||
|
||||
|
@ -286,17 +278,36 @@ inline void lcdDrawSquare(coord_t x, coord_t y, coord_t w, LcdFlags att=0)
|
|||
lcdDrawSolidRect(x, y, w, w, att);
|
||||
}
|
||||
|
||||
void lcd_img(coord_t x, coord_t y, const pm_uchar * img, uint8_t idx, LcdFlags att=0);
|
||||
inline int getBitmapWidth(const uint8_t * bmp)
|
||||
{
|
||||
return *((const uint16_t *)bmp);
|
||||
}
|
||||
|
||||
inline int getBitmapHeight(const uint8_t * bmp)
|
||||
{
|
||||
return *(((const uint16_t *)bmp)+1);
|
||||
}
|
||||
|
||||
inline int getBitmapScaledSize(int size, int scale)
|
||||
{
|
||||
if (scale >= -1 && scale <= 1)
|
||||
return size;
|
||||
else if (scale < 0)
|
||||
return -(size / scale);
|
||||
else
|
||||
return size * scale;
|
||||
}
|
||||
|
||||
int getBitmapScale(const uint8_t * bmp, int dstWidth, int dstHeight);
|
||||
int getTextWidth(const pm_char *s, int len=0, LcdFlags flags=0);
|
||||
void lcdDrawBitmap(coord_t x, coord_t y, const uint16_t * img, coord_t offset=0, coord_t width=0);
|
||||
void lcdDrawBitmap(coord_t x, coord_t y, const uint8_t * img, coord_t offset=0, coord_t width=0, int scale=0);
|
||||
void lcdDrawBitmapPattern(coord_t x, coord_t y, const uint8_t * img, LcdFlags flags=0, coord_t offset=0, coord_t width=0);
|
||||
|
||||
#define lcdSetRefVolt(...)
|
||||
void lcdSetContrast();
|
||||
#define lcdOff(...)
|
||||
|
||||
const pm_char * bmpLoad(uint8_t *dest, const char *filename, const unsigned int width, const unsigned int height);
|
||||
const char * bmpLoad(uint8_t * dest, const char * filename, uint16_t width, uint16_t height);
|
||||
|
||||
#if defined(BOOT)
|
||||
#define BLINK_ON_PHASE (0)
|
||||
|
@ -304,14 +315,4 @@ const pm_char * bmpLoad(uint8_t *dest, const char *filename, const unsigned int
|
|||
#define BLINK_ON_PHASE (g_blinkTmr10ms & (1<<6))
|
||||
#endif
|
||||
|
||||
#ifdef SIMU
|
||||
extern bool lcd_refresh;
|
||||
extern display_t lcd_buf[DISPLAY_BUFFER_SIZE];
|
||||
#endif
|
||||
|
||||
char *strAppend(char * dest, const char * source, int len=0);
|
||||
char *strSetCursor(char *dest, int position);
|
||||
char *strAppendDate(char * str, bool time=false);
|
||||
char *strAppendFilename(char * dest, const char * filename, const int size);
|
||||
|
||||
#endif // _LCD_H_
|
||||
|
|
|
@ -64,12 +64,12 @@ const LanguagePack * LP_CONST languagePacks[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
void menuGeneralSetup(evt_t event);
|
||||
void menuGeneralSdManager(evt_t event);
|
||||
void menuGeneralCustomFunctions(evt_t event);
|
||||
void menuGeneralTrainer(evt_t event);
|
||||
void menuGeneralVersion(evt_t event);
|
||||
void menuGeneralCalib(evt_t event);
|
||||
bool menuGeneralSetup(evt_t event);
|
||||
bool menuGeneralSdManager(evt_t event);
|
||||
bool menuGeneralCustomFunctions(evt_t event);
|
||||
bool menuGeneralTrainer(evt_t event);
|
||||
bool menuGeneralVersion(evt_t event);
|
||||
bool menuGeneralCalib(evt_t event);
|
||||
|
||||
enum EnumTabDiag {
|
||||
e_Setup,
|
||||
|
@ -80,7 +80,7 @@ enum EnumTabDiag {
|
|||
e_Vers,
|
||||
};
|
||||
|
||||
const MenuFuncP_PROGMEM menuTabGeneral[] PROGMEM = {
|
||||
const MenuFuncP menuTabGeneral[] PROGMEM = {
|
||||
menuGeneralSetup,
|
||||
menuGeneralSdManager,
|
||||
menuGeneralCustomFunctions,
|
||||
|
@ -89,7 +89,7 @@ const MenuFuncP_PROGMEM menuTabGeneral[] PROGMEM = {
|
|||
menuGeneralVersion,
|
||||
};
|
||||
|
||||
void menuGeneralCustomFunctions(evt_t event)
|
||||
bool menuGeneralCustomFunctions(evt_t event)
|
||||
{
|
||||
MENU(STR_MENUGLOBALFUNCS, menuTabGeneral, e_GeneralCustomFunctions, NUM_CFN, DEFAULT_SCROLLBAR_X, { NAVIGATION_LINE_BY_LINE|4/*repeated*/ });
|
||||
return menuCustomFunctions(event, g_eeGeneral.customFn, globalFunctionsContext);
|
||||
|
|
|
@ -69,7 +69,7 @@ void drawSticksPositions()
|
|||
drawStick(RBOX_CENTERX, calibratedStick[CONVERT_MODE(3)], calibStickVert);
|
||||
}
|
||||
|
||||
void menuCommonCalib(evt_t event)
|
||||
bool menuCommonCalib(evt_t event)
|
||||
{
|
||||
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) { // get low and high vals for sticks and trims
|
||||
int16_t vt = anaIn(i);
|
||||
|
@ -216,13 +216,15 @@ void menuCommonCalib(evt_t event)
|
|||
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);
|
||||
lcdDrawNumber(LCD_W/2-2+(i-POT1)*5, LCD_H-6, steps, TINSIZE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void menuGeneralCalib(evt_t event)
|
||||
bool menuGeneralCalib(evt_t event)
|
||||
{
|
||||
SIMPLE_MENU(STR_MENUCALIBRATION, menuTabGeneral, e_Calib, 0, DEFAULT_SCROLLBAR_X);
|
||||
|
||||
|
@ -232,17 +234,18 @@ void menuGeneralCalib(evt_t event)
|
|||
calibrationState = 0;
|
||||
}
|
||||
|
||||
menuCommonCalib(READ_ONLY() ? 0 : event);
|
||||
return menuCommonCalib(READ_ONLY() ? 0 : event);
|
||||
}
|
||||
|
||||
void menuFirstCalib(evt_t event)
|
||||
bool menuFirstCalib(evt_t event)
|
||||
{
|
||||
if (event == EVT_KEY_BREAK(KEY_EXIT) || reusableBuffer.calib.state == 4) {
|
||||
calibrationState = 0;
|
||||
chainMenu(menuMainView);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
drawMenuTemplate(STR_MENUCALIBRATION, event);
|
||||
menuCommonCalib(event);
|
||||
drawScreenTemplate(STR_MENUCALIBRATION);
|
||||
return menuCommonCalib(event);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,38 +36,52 @@
|
|||
|
||||
#include "../../opentx.h"
|
||||
|
||||
#define REFRESH_FILES() reusableBuffer.sdmanager.offset = 65535
|
||||
#define REFRESH_FILES() do { reusableBuffer.sdmanager.offset = 65535; lastBitmap = -1; } 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)))
|
||||
|
||||
void menuGeneralSdManagerInfo(evt_t event)
|
||||
int lastBitmap;
|
||||
|
||||
bool menuGeneralSdManagerInfo(evt_t event)
|
||||
{
|
||||
SIMPLE_SUBMENU(STR_SD_INFO_TITLE, 1, DEFAULT_SCROLLBAR_X);
|
||||
|
||||
lcd_putsLeft(2*FH, STR_SD_TYPE);
|
||||
lcd_puts(100, 2*FH, SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD);
|
||||
lcdDrawText(100, 2*FH, SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD);
|
||||
|
||||
lcd_putsLeft(3*FH, STR_SD_SIZE);
|
||||
lcd_outdezAtt(100, 3*FH, sdGetSize(), LEFT, "M");
|
||||
lcdDrawNumber(100, 3*FH, sdGetSize(), LEFT, 0, NULL, "M");
|
||||
|
||||
lcd_putsLeft(4*FH, STR_SD_SECTORS);
|
||||
#if defined(SD_GET_FREE_BLOCKNR)
|
||||
lcd_outdezAtt(100, 4*FH, SD_GET_FREE_BLOCKNR()/1000, LEFT, "/");
|
||||
lcd_outdezAtt(150, 4*FH, sdGetNoSectors()/1000, LEFT);
|
||||
lcdDrawNumber(100, 4*FH, SD_GET_FREE_BLOCKNR()/1000, LEFT, 0, NULL, "/");
|
||||
lcdDrawNumber(150, 4*FH, sdGetNoSectors()/1000, LEFT);
|
||||
#else
|
||||
lcd_outdezAtt(100, 4*FH, sdGetNoSectors()/1000, LEFT, "k");
|
||||
lcdDrawNumber(100, 4*FH, sdGetNoSectors()/1000, LEFT, 0, NULL, "k");
|
||||
#endif
|
||||
|
||||
lcd_putsLeft(5*FH, STR_SD_SPEED);
|
||||
lcd_outdezAtt(100, 5*FH, SD_GET_SPEED()/1000, LEFT, "kb/s");
|
||||
lcdDrawNumber(100, 5*FH, SD_GET_SPEED()/1000, LEFT, 0, NULL, "kb/s");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
return (isfile && IS_DIRECTORY(line)) || (isfile==IS_FILE(line) && 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);
|
||||
return (!isfile && IS_FILE(line)) || (isfile==IS_FILE(line) && strcasecmp(fn, line) < 0);
|
||||
}
|
||||
|
||||
void getSelectionFullPath(char *lfn)
|
||||
{
|
||||
f_getcwd(lfn, _MAX_LFN);
|
||||
strcat(lfn, PSTR("/"));
|
||||
strcat(lfn, reusableBuffer.sdmanager.lines[m_posVert - s_pgOfs]);
|
||||
}
|
||||
|
||||
void onSdManagerMenu(const char *result)
|
||||
|
@ -92,39 +106,39 @@ void onSdManagerMenu(const char *result)
|
|||
}
|
||||
else if (result == STR_PASTE) {
|
||||
f_getcwd(lfn, _MAX_LFN);
|
||||
POPUP_WARNING(sdCopyFile(clipboard.data.sd.filename, clipboard.data.sd.directory, lfn));
|
||||
// if destination is dir, copy into that dir
|
||||
if (IS_DIRECTORY(line)) {
|
||||
strcat(lfn, PSTR("/"));
|
||||
strcat(lfn, line);
|
||||
}
|
||||
if (strcmp(clipboard.data.sd.directory, lfn)) { // prevent copying to the same directory
|
||||
POPUP_WARNING(sdCopyFile(clipboard.data.sd.filename, clipboard.data.sd.directory, clipboard.data.sd.filename, lfn));
|
||||
REFRESH_FILES();
|
||||
}
|
||||
}
|
||||
else if (result == STR_RENAME_FILE) {
|
||||
memcpy(reusableBuffer.sdmanager.originalName, line, sizeof(reusableBuffer.sdmanager.originalName));
|
||||
char * ext = getFileExtension(line, SD_SCREEN_FILE_LENGTH+1);
|
||||
if (ext) {
|
||||
memcpy(reusableBuffer.sdmanager.originalName, line, sizeof(reusableBuffer.sdmanager.originalName));
|
||||
// write spaces to allow a longer filename
|
||||
memset(ext, ' ', SD_SCREEN_FILE_LENGTH-LEN_FILE_EXTENSION-(ext-line));
|
||||
line[SD_SCREEN_FILE_LENGTH-LEN_FILE_EXTENSION] = '\0';
|
||||
}
|
||||
else {
|
||||
int len = strlen(line);
|
||||
memset(line + strlen(line), ' ', SD_SCREEN_FILE_LENGTH - len);
|
||||
line[SD_SCREEN_FILE_LENGTH] = '\0';
|
||||
}
|
||||
s_editMode = EDIT_MODIFY_STRING;
|
||||
editNameCursorPos = 0;
|
||||
}
|
||||
}
|
||||
else if (result == STR_DELETE_FILE) {
|
||||
f_getcwd(lfn, _MAX_LFN);
|
||||
strcat(lfn, PSTR("/"));
|
||||
strcat(lfn, line);
|
||||
getSelectionFullPath(lfn);
|
||||
f_unlink(lfn);
|
||||
REFRESH_FILES();
|
||||
if (m_posVert == reusableBuffer.sdmanager.count-1)
|
||||
m_posVert--;
|
||||
}
|
||||
/* TODO else if (result == STR_LOAD_FILE) {
|
||||
f_getcwd(lfn, _MAX_LFN);
|
||||
strcat(lfn, "/");
|
||||
strcat(lfn, line);
|
||||
POPUP_WARNING(eeLoadModelSD(lfn));
|
||||
} */
|
||||
else if (result == STR_PLAY_FILE) {
|
||||
f_getcwd(lfn, _MAX_LFN);
|
||||
strcat(lfn, "/");
|
||||
strcat(lfn, line);
|
||||
getSelectionFullPath(lfn);
|
||||
audioQueue.stopAll();
|
||||
audioQueue.playFile(lfn, 0, ID_PLAY_FROM_SD_MANAGER);
|
||||
}
|
||||
|
@ -136,38 +150,25 @@ void onSdManagerMenu(const char *result)
|
|||
}
|
||||
#endif
|
||||
else if (result == STR_VIEW_TEXT) {
|
||||
f_getcwd(lfn, _MAX_LFN);
|
||||
strcat(lfn, "/");
|
||||
strcat(lfn, line);
|
||||
getSelectionFullPath(lfn);
|
||||
pushMenuTextView(lfn);
|
||||
}
|
||||
#if 0
|
||||
else if (result == STR_FLASH_BOOTLOADER) {
|
||||
f_getcwd(lfn, _MAX_LFN);
|
||||
strcat(lfn, "/");
|
||||
strcat(lfn, line);
|
||||
getSelectionFullPath(lfn);
|
||||
flashBootloader(lfn);
|
||||
}
|
||||
#endif
|
||||
#if defined(LUA)
|
||||
else if (result == STR_EXECUTE_FILE) {
|
||||
f_getcwd(lfn, _MAX_LFN);
|
||||
strcat(lfn, "/");
|
||||
strcat(lfn, line);
|
||||
getSelectionFullPath(lfn);
|
||||
luaExec(lfn);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void menuGeneralSdManager(evt_t _event)
|
||||
bool menuGeneralSdManager(evt_t _event)
|
||||
{
|
||||
FILINFO fno;
|
||||
DIR dir;
|
||||
char *fn; /* This function is assuming non-Unicode cfg. */
|
||||
TCHAR lfn[_MAX_LFN + 1];
|
||||
fno.lfname = lfn;
|
||||
fno.lfsize = sizeof(lfn);
|
||||
|
||||
if (s_warning_result) {
|
||||
s_warning_result = 0;
|
||||
displayPopup(STR_FORMATTING);
|
||||
|
@ -197,7 +198,7 @@ void menuGeneralSdManager(evt_t _event)
|
|||
case EVT_KEY_LONG(KEY_MENU):
|
||||
if (!READ_ONLY() && s_editMode == 0) {
|
||||
killEvents(_event);
|
||||
MENU_ADD_ITEM(STR_SD_INFO); TODO: Implement
|
||||
MENU_ADD_ITEM(STR_SD_INFO);
|
||||
MENU_ADD_ITEM(STR_SD_FORMAT);
|
||||
menuHandler = onSdManagerMenu;
|
||||
}
|
||||
|
@ -219,26 +220,26 @@ void menuGeneralSdManager(evt_t _event)
|
|||
break;
|
||||
}
|
||||
else {
|
||||
if (!reusableBuffer.sdmanager.lines[index][SD_SCREEN_FILE_LENGTH+1]) {
|
||||
if (IS_DIRECTORY(reusableBuffer.sdmanager.lines[index])) {
|
||||
f_chdir(reusableBuffer.sdmanager.lines[index]);
|
||||
s_pgOfs = 0;
|
||||
m_posVert = 1;
|
||||
index = 1;
|
||||
REFRESH_FILES();
|
||||
killEvents(_event);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// no break
|
||||
|
||||
case EVT_KEY_LONG(KEY_ENTER):
|
||||
killEvents(_event);
|
||||
if (m_posVert < 0) {
|
||||
break;
|
||||
}
|
||||
if (s_editMode == 0) {
|
||||
killEvents(_event);
|
||||
char * line = reusableBuffer.sdmanager.lines[index];
|
||||
char * ext = getFileExtension(line, SD_SCREEN_FILE_LENGTH+1);
|
||||
if (!strcmp(line, "..")) {
|
||||
break; // no menu for parent dir
|
||||
}
|
||||
if (ext) {
|
||||
if (!strcasecmp(ext, SOUNDS_EXT)) {
|
||||
MENU_ADD_ITEM(STR_PLAY_FILE);
|
||||
|
@ -246,9 +247,6 @@ void menuGeneralSdManager(evt_t _event)
|
|||
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);
|
||||
}
|
||||
#if defined(LUA)
|
||||
else if (!strcasecmp(ext, SCRIPTS_EXT)) {
|
||||
MENU_ADD_ITEM(STR_EXECUTE_FILE);
|
||||
|
@ -256,19 +254,27 @@ void menuGeneralSdManager(evt_t _event)
|
|||
#endif
|
||||
}
|
||||
if (!READ_ONLY()) {
|
||||
if (line[SD_SCREEN_FILE_LENGTH+1]) // it's a file
|
||||
if (IS_FILE(line))
|
||||
MENU_ADD_ITEM(STR_COPY_FILE);
|
||||
if (clipboard.type == CLIPBOARD_TYPE_SD_FILE)
|
||||
MENU_ADD_ITEM(STR_PASTE);
|
||||
// MENU_ADD_ITEM(STR_RENAME_FILE);
|
||||
MENU_ADD_ITEM(STR_RENAME_FILE);
|
||||
if (IS_FILE(line))
|
||||
MENU_ADD_ITEM(STR_DELETE_FILE);
|
||||
}
|
||||
}
|
||||
menuHandler = onSdManagerMenu;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (reusableBuffer.sdmanager.offset != s_pgOfs) {
|
||||
FILINFO fno;
|
||||
DIR dir;
|
||||
char *fn; /* This function is assuming non-Unicode cfg. */
|
||||
TCHAR lfn[_MAX_LFN + 1];
|
||||
fno.lfname = lfn;
|
||||
fno.lfsize = sizeof(lfn);
|
||||
|
||||
if (s_pgOfs == 0) {
|
||||
reusableBuffer.sdmanager.offset = 0;
|
||||
memset(reusableBuffer.sdmanager.lines, 0, sizeof(reusableBuffer.sdmanager.lines));
|
||||
|
@ -280,7 +286,7 @@ void menuGeneralSdManager(evt_t _event)
|
|||
else if (s_pgOfs > reusableBuffer.sdmanager.offset) {
|
||||
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);
|
||||
reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1][SD_SCREEN_FILE_LENGTH+1] = 1;
|
||||
NODE_TYPE(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1]) = 1;
|
||||
}
|
||||
else {
|
||||
memmove(reusableBuffer.sdmanager.lines[1], reusableBuffer.sdmanager.lines[0], (NUM_BODY_LINES-1)*sizeof(reusableBuffer.sdmanager.lines[0]));
|
||||
|
@ -311,9 +317,9 @@ void menuGeneralSdManager(evt_t _event)
|
|||
char *line = reusableBuffer.sdmanager.lines[i];
|
||||
if (line[0] == '\0' || isFilenameLower(isfile, fn, line)) {
|
||||
if (i < NUM_BODY_LINES-1) memmove(reusableBuffer.sdmanager.lines[i+1], line, sizeof(reusableBuffer.sdmanager.lines[i]) * (NUM_BODY_LINES-1-i));
|
||||
memset(line, 0, sizeof(reusableBuffer.sdmanager.lines[i]));
|
||||
memset(line, 0, sizeof(reusableBuffer.sdmanager.lines[0]));
|
||||
strcpy(line, fn);
|
||||
line[SD_SCREEN_FILE_LENGTH+1] = isfile;
|
||||
NODE_TYPE(line) = isfile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -323,9 +329,9 @@ void menuGeneralSdManager(evt_t _event)
|
|||
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]));
|
||||
memset(line, 0, sizeof(reusableBuffer.sdmanager.lines[0]));
|
||||
strcpy(line, fn);
|
||||
line[SD_SCREEN_FILE_LENGTH+1] = isfile;
|
||||
NODE_TYPE(line) = isfile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -334,14 +340,14 @@ void menuGeneralSdManager(evt_t _event)
|
|||
if (isFilenameGreater(isfile, fn, reusableBuffer.sdmanager.lines[NUM_BODY_LINES-2]) && isFilenameLower(isfile, fn, reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1])) {
|
||||
memset(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1], 0, sizeof(reusableBuffer.sdmanager.lines[0]));
|
||||
strcpy(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1], fn);
|
||||
reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1][SD_SCREEN_FILE_LENGTH+1] = isfile;
|
||||
NODE_TYPE(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-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;
|
||||
NODE_TYPE(reusableBuffer.sdmanager.lines[0]) = isfile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -354,8 +360,8 @@ void menuGeneralSdManager(evt_t _event)
|
|||
coord_t y = MENU_CONTENT_TOP + i*FH;
|
||||
LcdFlags attr = (index == i ? INVERS : 0);
|
||||
if (reusableBuffer.sdmanager.lines[i][0]) {
|
||||
if (!reusableBuffer.sdmanager.lines[i][SD_SCREEN_FILE_LENGTH+1]) {
|
||||
char s[SD_SCREEN_FILE_LENGTH+1+2];
|
||||
if (IS_DIRECTORY(reusableBuffer.sdmanager.lines[i])) {
|
||||
char s[sizeof(reusableBuffer.sdmanager.lines[0])+2];
|
||||
sprintf(s, "[%s]", reusableBuffer.sdmanager.lines[i]);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, s, attr);
|
||||
}
|
||||
|
@ -364,4 +370,17 @@ void menuGeneralSdManager(evt_t _event)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
char * ext = getFileExtension(reusableBuffer.sdmanager.lines[index], SD_SCREEN_FILE_LENGTH+1);
|
||||
if (ext && !strcasecmp(ext, BITMAPS_EXT)) {
|
||||
if (lastBitmap != m_posVert) {
|
||||
if (bmpLoad(modelBitmap, reusableBuffer.sdmanager.lines[index], MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT)) {
|
||||
((uint32_t *)modelBitmap)[0] = 0;
|
||||
lastBitmap = m_posVert;
|
||||
}
|
||||
}
|
||||
lcdDrawBitmap(LCD_W/2, (LCD_H-MODEL_BITMAP_HEIGHT)/2, modelBitmap);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ enum menuGeneralSetupItems {
|
|||
ITEM_SETUP_MAX
|
||||
};
|
||||
|
||||
void menuGeneralSetup(evt_t event)
|
||||
bool menuGeneralSetup(evt_t event)
|
||||
{
|
||||
#if defined(RTCLOCK)
|
||||
struct gtm t;
|
||||
|
@ -151,11 +151,11 @@ void menuGeneralSetup(evt_t event)
|
|||
uint8_t rowattr = (m_posHorz==j ? attr : 0);
|
||||
switch (j) {
|
||||
case 0:
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, t.tm_year+1900, LEFT|flags|rowattr);
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, t.tm_year+1900, LEFT|flags|rowattr);
|
||||
if (rowattr && s_editMode>0) t.tm_year = checkIncDec(event, t.tm_year, 112, 200, 0);
|
||||
break;
|
||||
case 1:
|
||||
lcd_outdezNAtt(RADIO_SETUP_2ND_COLUMN+MONTH_OFFSET, y, t.tm_mon+1, LEFT|flags|rowattr|LEADING0, 2);
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN+MONTH_OFFSET, y, t.tm_mon+1, LEFT|flags|rowattr|LEADING0, 2);
|
||||
if (rowattr && s_editMode>0) t.tm_mon = checkIncDec(event, t.tm_mon, 0, 11, 0);
|
||||
break;
|
||||
case 2:
|
||||
|
@ -164,7 +164,7 @@ void menuGeneralSetup(evt_t event)
|
|||
int8_t dlim = (((((year%4==0) && (year%100!=0)) || (year%400==0)) && (t.tm_mon==1)) ? 1 : 0);
|
||||
static const pm_uint8_t dmon[] PROGMEM = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
dlim += pgm_read_byte(&dmon[t.tm_mon]);
|
||||
lcd_outdezNAtt(RADIO_SETUP_2ND_COLUMN+DAY_OFFSET, y, t.tm_mday, LEFT|flags|rowattr|LEADING0, 2);
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN+DAY_OFFSET, y, t.tm_mday, LEFT|flags|rowattr|LEADING0, 2);
|
||||
if (rowattr && s_editMode>0) t.tm_mday = checkIncDec(event, t.tm_mday, 1, dlim, 0);
|
||||
break;
|
||||
}
|
||||
|
@ -191,15 +191,15 @@ void menuGeneralSetup(evt_t event)
|
|||
switch (j) {
|
||||
case 0:
|
||||
if (rowattr && s_editMode>0) t.tm_hour = checkIncDec(event, t.tm_hour, 0, 23, 0);
|
||||
lcd_outdezNAtt(RADIO_SETUP_2ND_COLUMN, y, t.tm_hour, flags|rowattr|LEFT|LEADING0, 2);
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, t.tm_hour, flags|rowattr|LEFT|LEADING0, 2);
|
||||
break;
|
||||
case 1:
|
||||
if (rowattr && s_editMode>0) t.tm_min = checkIncDec(event, t.tm_min, 0, 59, 0);
|
||||
lcd_outdezNAtt(RADIO_SETUP_2ND_COLUMN+MINUTE_OFFSET, y, t.tm_min, flags|rowattr|LEFT|LEADING0, 2);
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN+MINUTE_OFFSET, y, t.tm_min, flags|rowattr|LEFT|LEADING0, 2);
|
||||
break;
|
||||
case 2:
|
||||
if (rowattr && s_editMode>0) t.tm_sec = checkIncDec(event, t.tm_sec, 0, 59, 0);
|
||||
lcd_outdezNAtt(RADIO_SETUP_2ND_COLUMN+SECOND_OFFSET, y, t.tm_sec, flags|rowattr|LEFT|LEADING0, 2);
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN+SECOND_OFFSET, y, t.tm_sec, flags|rowattr|LEFT|LEADING0, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ void menuGeneralSetup(evt_t event)
|
|||
lcdDrawSolidFilledRect(RADIO_SETUP_2ND_COLUMN-INVERT_HORZ_MARGIN, y-INVERT_VERT_MARGIN, 90, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR);
|
||||
}
|
||||
putsVolts(RADIO_SETUP_2ND_COLUMN, y, 90+g_eeGeneral.vBatMin, color|(m_posHorz==0 ? attr : 0)|LEFT|NO_UNIT);
|
||||
lcd_puts(RADIO_SETUP_2ND_COLUMN+20, y, "-");
|
||||
lcdDrawText(RADIO_SETUP_2ND_COLUMN+20, y, "-");
|
||||
putsVolts(RADIO_SETUP_2ND_COLUMN+28, y, 120+g_eeGeneral.vBatMax, color|(m_posHorz>0 ? attr : 0)|LEFT|NO_UNIT);
|
||||
if (attr && s_editMode>0) {
|
||||
if (m_posHorz==0)
|
||||
|
@ -271,7 +271,7 @@ void menuGeneralSetup(evt_t event)
|
|||
|
||||
case ITEM_SETUP_SPEAKER_PITCH:
|
||||
lcd_putsLeft( y, STR_SPKRPITCH);
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.speakerPitch*15, attr|LEFT, "Hz", "+");
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.speakerPitch*15, attr|LEFT, 0, "+", "Hz");
|
||||
if (attr) {
|
||||
CHECK_INCDEC_GENVAR(event, g_eeGeneral.speakerPitch, 0, 20);
|
||||
}
|
||||
|
@ -286,17 +286,17 @@ void menuGeneralSetup(evt_t event)
|
|||
break;
|
||||
case ITEM_SETUP_VARIO_PITCH:
|
||||
lcd_putsLeft(y, STR_PITCH_AT_ZERO);
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, VARIO_FREQUENCY_ZERO+(g_eeGeneral.varioPitch*10), attr|LEFT, "Hz");
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, VARIO_FREQUENCY_ZERO+(g_eeGeneral.varioPitch*10), attr|LEFT, 0, NULL, "Hz");
|
||||
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioPitch, -40, 40);
|
||||
break;
|
||||
case ITEM_SETUP_VARIO_RANGE:
|
||||
lcd_putsLeft(y, STR_PITCH_AT_MAX);
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, VARIO_FREQUENCY_ZERO+(g_eeGeneral.varioPitch*10)+VARIO_FREQUENCY_RANGE+(g_eeGeneral.varioRange*10), attr|LEFT, "Hz");
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, VARIO_FREQUENCY_ZERO+(g_eeGeneral.varioPitch*10)+VARIO_FREQUENCY_RANGE+(g_eeGeneral.varioRange*10), attr|LEFT, 0, NULL, "Hz");
|
||||
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioRange, -80, 80);
|
||||
break;
|
||||
case ITEM_SETUP_VARIO_REPEAT:
|
||||
lcd_putsLeft(y, STR_REPEAT_AT_ZERO);
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, VARIO_REPEAT_ZERO+(g_eeGeneral.varioRepeat*10), attr|LEFT, STR_MS);
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, VARIO_REPEAT_ZERO+(g_eeGeneral.varioRepeat*10), attr|LEFT, 0, NULL, STR_MS);
|
||||
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioRepeat, -30, 50);
|
||||
break;
|
||||
#endif
|
||||
|
@ -322,7 +322,7 @@ void menuGeneralSetup(evt_t event)
|
|||
#if 0
|
||||
case ITEM_SETUP_CONTRAST:
|
||||
lcd_putsLeft(y, STR_CONTRAST);
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.contrast, attr|LEFT);
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.contrast, attr|LEFT);
|
||||
if (attr) {
|
||||
CHECK_INCDEC_GENVAR(event, g_eeGeneral.contrast, CONTRAST_MIN, CONTRAST_MAX);
|
||||
lcdSetContrast();
|
||||
|
@ -374,7 +374,7 @@ void menuGeneralSetup(evt_t event)
|
|||
|
||||
case ITEM_SETUP_INACTIVITY_ALARM:
|
||||
lcd_putsLeft( y,STR_INACTIVITYALARM);
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.inactivityTimer, attr|LEFT, "m");
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.inactivityTimer, attr|LEFT, 0, NULL, "m");
|
||||
if (attr) g_eeGeneral.inactivityTimer = checkIncDec(event, g_eeGeneral.inactivityTimer, 0, 250, EE_GENERAL); //0..250minutes
|
||||
break;
|
||||
|
||||
|
@ -393,13 +393,13 @@ void menuGeneralSetup(evt_t event)
|
|||
|
||||
case ITEM_SETUP_BACKLIGHT_DELAY:
|
||||
lcd_putsLeft(y, STR_BLDELAY);
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.lightAutoOff*5, attr|LEFT, "s");
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.lightAutoOff*5, attr|LEFT, 0, NULL, "s");
|
||||
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.lightAutoOff, 0, 600/5);
|
||||
break;
|
||||
|
||||
case ITEM_SETUP_BRIGHTNESS:
|
||||
lcd_putsLeft(y, STR_BRIGHTNESS);
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, 100-g_eeGeneral.backlightBright, attr|LEFT) ;
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, 100-g_eeGeneral.backlightBright, attr|LEFT) ;
|
||||
if (attr) {
|
||||
uint8_t b = 100 - g_eeGeneral.backlightBright;
|
||||
CHECK_INCDEC_GENVAR(event, b, 0, 100);
|
||||
|
@ -419,7 +419,7 @@ void menuGeneralSetup(evt_t event)
|
|||
{
|
||||
lcd_putsLeft(y, STR_SPLASHSCREEN);
|
||||
if (SPLASH_NEEDED()) {
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, SPLASH_TIMEOUT/100, attr|LEFT, "s");
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, SPLASH_TIMEOUT/100, attr|LEFT, 0, NULL, "s");
|
||||
}
|
||||
else {
|
||||
lcdDrawTextAtIndex(RADIO_SETUP_2ND_COLUMN, y, STR_MMMINV, 0, attr); // TODO define
|
||||
|
@ -431,7 +431,7 @@ void menuGeneralSetup(evt_t event)
|
|||
|
||||
case ITEM_SETUP_TIMEZONE:
|
||||
lcd_putsLeft(y, STR_TIMEZONE);
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.timezone, attr|LEFT);
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.timezone, attr|LEFT);
|
||||
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.timezone, -12, 12);
|
||||
break;
|
||||
|
||||
|
@ -479,7 +479,7 @@ void menuGeneralSetup(evt_t event)
|
|||
|
||||
case ITEM_SETUP_SWITCHES_DELAY:
|
||||
lcd_putsLeft(y, STR_SWITCHES_DELAY);
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, 10*SWITCHES_DELAY(), attr|LEFT, STR_MS);
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, 10*SWITCHES_DELAY(), attr|LEFT, 0, NULL, STR_MS);
|
||||
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.switchesDelay, -15, +15);
|
||||
break;
|
||||
|
||||
|
@ -519,4 +519,6 @@ void menuGeneralSetup(evt_t event)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#define TRAINER_CALIB_POS 12
|
||||
|
||||
void menuGeneralTrainer(evt_t event)
|
||||
bool menuGeneralTrainer(evt_t event)
|
||||
{
|
||||
uint8_t y;
|
||||
bool slave = SLAVE_MODE();
|
||||
|
@ -52,7 +52,7 @@ void menuGeneralTrainer(evt_t event)
|
|||
|
||||
if (slave) {
|
||||
lcd_putsCenter(5*FH, STR_SLAVE, TEXT_COLOR);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t attr;
|
||||
|
@ -83,7 +83,7 @@ void menuGeneralTrainer(evt_t event)
|
|||
break;
|
||||
|
||||
case 1:
|
||||
lcd_outdezAtt(TRAINER_COLUMN_2, y, td->studWeight, LEFT|attr, "%");
|
||||
lcdDrawNumber(TRAINER_COLUMN_2, y, td->studWeight, LEFT|attr, 0, NULL, "%");
|
||||
if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->studWeight, -125, 125);
|
||||
break;
|
||||
|
||||
|
@ -98,7 +98,7 @@ void menuGeneralTrainer(evt_t event)
|
|||
|
||||
attr = (sub==5) ? blink : 0;
|
||||
lcd_putsLeft(MENU_CONTENT_TOP + 5*FH, STR_MULTIPLIER);
|
||||
lcd_outdezAtt(TRAINER_COLUMN_1, MENU_CONTENT_TOP + 5*FH, g_eeGeneral.PPM_Multiplier+10, LEFT|attr|PREC1);
|
||||
lcdDrawNumber(TRAINER_COLUMN_1, MENU_CONTENT_TOP + 5*FH, g_eeGeneral.PPM_Multiplier+10, LEFT|attr|PREC1);
|
||||
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.PPM_Multiplier, -10, 40);
|
||||
|
||||
attr = (sub==6) ? INVERS : 0;
|
||||
|
@ -106,9 +106,9 @@ void menuGeneralTrainer(evt_t event)
|
|||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 6*FH, STR_CAL, attr);
|
||||
for (int i=0; i<4; i++) {
|
||||
#if defined (PPM_UNIT_PERCENT_PREC1)
|
||||
lcd_outdezAtt(TRAINER_COLUMN_1+i*TRAINER_COLUMN_WIDTH, MENU_CONTENT_TOP + 6*FH, (ppmInput[i]-g_eeGeneral.trainer.calib[i])*2, LEFT|PREC1);
|
||||
lcdDrawNumber(TRAINER_COLUMN_1+i*TRAINER_COLUMN_WIDTH, MENU_CONTENT_TOP + 6*FH, (ppmInput[i]-g_eeGeneral.trainer.calib[i])*2, LEFT|PREC1);
|
||||
#else
|
||||
lcd_outdezAtt(TRAINER_COLUMN_1+i*TRAINER_COLUMN_WIDTH, MENU_CONTENT_TOP + 6*FH, (ppmInput[i]-g_eeGeneral.trainer.calib[i])/5, LEFT);
|
||||
lcdDrawNumber(TRAINER_COLUMN_1+i*TRAINER_COLUMN_WIDTH, MENU_CONTENT_TOP + 6*FH, (ppmInput[i]-g_eeGeneral.trainer.calib[i])/5, LEFT);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -119,4 +119,6 @@ void menuGeneralTrainer(evt_t event)
|
|||
AUDIO_WARNING1();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include "../../opentx.h"
|
||||
|
||||
void menuGeneralVersion(evt_t event)
|
||||
bool menuGeneralVersion(evt_t event)
|
||||
{
|
||||
SIMPLE_MENU(STR_MENUVERSION, menuTabGeneral, e_Vers, 1, DEFAULT_SCROLLBAR_X);
|
||||
|
||||
|
@ -50,4 +50,6 @@ void menuGeneralVersion(evt_t event)
|
|||
// if (event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
// backupEeprom();
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -53,21 +53,21 @@ enum EnumTabModel {
|
|||
CASE_FRSKY(e_Telemetry)
|
||||
};
|
||||
|
||||
void menuModelSelect(evt_t event);
|
||||
void menuModelSetup(evt_t event);
|
||||
void menuModelHeli(evt_t event);
|
||||
void menuModelFlightModesAll(evt_t event);
|
||||
void menuModelExposAll(evt_t event);
|
||||
void menuModelMixAll(evt_t event);
|
||||
void menuModelLimits(evt_t event);
|
||||
void menuModelCurvesAll(evt_t event);
|
||||
void menuModelCurveOne(evt_t event);
|
||||
void menuModelGVars(evt_t event);
|
||||
void menuModelLogicalSwitches(evt_t event);
|
||||
void menuModelCustomFunctions(evt_t event);
|
||||
void menuModelCustomScripts(evt_t event);
|
||||
void menuModelTelemetry(evt_t event);
|
||||
void menuModelExpoOne(evt_t event);
|
||||
bool menuModelSelect(evt_t event);
|
||||
bool menuModelSetup(evt_t event);
|
||||
bool menuModelHeli(evt_t event);
|
||||
bool menuModelFlightModesAll(evt_t event);
|
||||
bool menuModelExposAll(evt_t event);
|
||||
bool menuModelMixAll(evt_t event);
|
||||
bool menuModelLimits(evt_t event);
|
||||
bool menuModelCurvesAll(evt_t event);
|
||||
bool menuModelCurveOne(evt_t event);
|
||||
bool menuModelGVars(evt_t event);
|
||||
bool menuModelLogicalSwitches(evt_t event);
|
||||
bool menuModelCustomFunctions(evt_t event);
|
||||
bool menuModelCustomScripts(evt_t event);
|
||||
bool menuModelTelemetry(evt_t event);
|
||||
bool menuModelExpoOne(evt_t event);
|
||||
|
||||
extern uint8_t s_curveChan;
|
||||
|
||||
|
@ -80,13 +80,13 @@ void editCurveRef(coord_t x, coord_t y, CurveRef & curve, evt_t event, uint8_t a
|
|||
uint8_t editDelay(const coord_t x, const coord_t y, const evt_t event, const uint8_t attr, const pm_char *str, uint8_t delay)
|
||||
{
|
||||
lcdDrawText(x+MENUS_MARGIN_LEFT, y, str, TEXT_COLOR);
|
||||
lcd_outdezAtt(x+MIXES_2ND_COLUMN, y, (10/DELAY_STEP)*delay, attr|PREC1|LEFT);
|
||||
lcdDrawNumber(x+MIXES_2ND_COLUMN, y, (10/DELAY_STEP)*delay, attr|PREC1|LEFT);
|
||||
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, delay, DELAY_MAX);
|
||||
return delay;
|
||||
}
|
||||
#define EDIT_DELAY(x, y, event, attr, str, delay) editDelay(x, y, event, attr, str, delay)
|
||||
|
||||
const MenuFuncP_PROGMEM menuTabModel[] PROGMEM = {
|
||||
const MenuFuncP menuTabModel[] = {
|
||||
// menuModelSelect,
|
||||
menuModelSetup,
|
||||
CASE_HELI(menuModelHeli)
|
||||
|
|
|
@ -97,7 +97,7 @@ bool moveCurve(uint8_t index, int8_t shift)
|
|||
void displayPresetChoice(evt_t event)
|
||||
{
|
||||
displayWarning(event);
|
||||
lcd_outdezAtt(WARNING_LINE_X, WARNING_INFOLINE_Y-10, 45*s_warning_input_value/4, LEFT|INVERS, "@");
|
||||
lcdDrawNumber(WARNING_LINE_X, WARNING_INFOLINE_Y-10, 45*s_warning_input_value/4, LEFT|INVERS, 0, NULL, "@");
|
||||
|
||||
if (s_warning_result) {
|
||||
s_warning_result = 0;
|
||||
|
@ -135,7 +135,7 @@ void onCurveOneMenu(const char *result)
|
|||
}
|
||||
}
|
||||
|
||||
void menuModelCurveOne(evt_t event)
|
||||
bool menuModelCurveOne(evt_t event)
|
||||
{
|
||||
static uint8_t pointsOfs = 0;
|
||||
CurveInfo & crv = g_model.curves[s_curveChan];
|
||||
|
@ -143,7 +143,7 @@ void menuModelCurveOne(evt_t event)
|
|||
|
||||
SIMPLE_SUBMENU(STR_MENUCURVE, 4 + 5+crv.points + (crv.type==CURVE_TYPE_CUSTOM ? 5+crv.points-2 : 0), 0);
|
||||
|
||||
lcd_outdezAtt(MENU_TITLE_NEXT_POS, MENU_TITLE_TOP+2, s_curveChan+1, LEFT|HEADER_COLOR);
|
||||
lcdDrawNumber(MENU_TITLE_NEXT_POS, MENU_TITLE_TOP+2, s_curveChan+1, LEFT|HEADER_COLOR);
|
||||
|
||||
lcd_putsLeft(MENU_CONTENT_TOP, STR_NAME);
|
||||
editName(MENUS_MARGIN_LEFT+INDENT_WIDTH, MENU_CONTENT_TOP + FH, g_model.curveNames[s_curveChan], sizeof(g_model.curveNames[s_curveChan]), event, m_posVert==0);
|
||||
|
@ -167,7 +167,7 @@ void menuModelCurveOne(evt_t event)
|
|||
|
||||
attr = (m_posVert==2 ? (s_editMode>0 ? INVERS|BLINK : INVERS) : 0);
|
||||
lcd_putsLeft(MENU_CONTENT_TOP + 4*FH, STR_COUNT);
|
||||
lcd_outdezAtt(MENUS_MARGIN_LEFT+INDENT_WIDTH, MENU_CONTENT_TOP + 5*FH, 5+crv.points, LEFT|attr, STR_PTS);
|
||||
lcdDrawNumber(MENUS_MARGIN_LEFT+INDENT_WIDTH, MENU_CONTENT_TOP + 5*FH, 5+crv.points, LEFT|attr, 0, NULL, STR_PTS);
|
||||
if (attr) {
|
||||
int count = checkIncDecModel(event, crv.points, -3, 12); // 2pts - 17pts
|
||||
if (checkIncDec_Ret) {
|
||||
|
@ -233,9 +233,9 @@ void menuModelCurveOne(evt_t event)
|
|||
if (i>=pointsOfs && i<pointsOfs+NUM_BODY_LINES) {
|
||||
int8_t x = -100 + 200*i/(5+crv.points-1);
|
||||
if (crv.type==CURVE_TYPE_CUSTOM && i>0 && i<5+crv.points-1) x = points[5+crv.points+i-1];
|
||||
lcd_outdezAtt(120, posY, i+1, LEFT|TEXT_DISABLE_COLOR);
|
||||
lcd_outdezAtt(150, posY, x, LEFT|(selectionMode==1?attr:0));
|
||||
lcd_outdezAtt(200, posY, points[i], LEFT|(selectionMode==2?attr:0));
|
||||
lcdDrawNumber(120, posY, i+1, LEFT|TEXT_DISABLE_COLOR);
|
||||
lcdDrawNumber(150, posY, x, LEFT|(selectionMode==1 ? attr : 0));
|
||||
lcdDrawNumber(200, posY, points[i], LEFT|(selectionMode==2 ? attr : 0));
|
||||
posY += FH;
|
||||
}
|
||||
|
||||
|
@ -255,9 +255,9 @@ void menuModelCurveOne(evt_t event)
|
|||
}
|
||||
}
|
||||
|
||||
if (5+crv.points > NUM_BODY_LINES) {
|
||||
drawScrollbar(250, DEFAULT_SCROLLBAR_Y, DEFAULT_SCROLLBAR_H, pointsOfs, 5+crv.points, NUM_BODY_LINES);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, evt_t event, uint8_t attr)
|
||||
|
@ -291,7 +291,7 @@ void editCurveRef(coord_t x, coord_t y, CurveRef & curve, evt_t event, uint8_t a
|
|||
}
|
||||
}
|
||||
|
||||
void menuModelCurvesAll(evt_t event)
|
||||
bool menuModelCurvesAll(evt_t event)
|
||||
{
|
||||
SIMPLE_MENU(STR_MENUCURVES, menuTabModel, e_CurvesAll, MAX_CURVES, DEFAULT_SCROLLBAR_X);
|
||||
|
||||
|
@ -314,7 +314,7 @@ void menuModelCurvesAll(evt_t event)
|
|||
putsStrIdx(MENUS_MARGIN_LEFT, y, STR_CV, k+1, attr);
|
||||
editName(50, y, g_model.curveNames[k], sizeof(g_model.curveNames[k]), 0, 0);
|
||||
CurveInfo & crv = g_model.curves[k];
|
||||
lcd_outdezAtt(100, y, 5+crv.points, LEFT, STR_PTS);
|
||||
lcdDrawNumber(100, y, 5+crv.points, LEFT, 0, NULL, STR_PTS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,4 +322,6 @@ void menuModelCurvesAll(evt_t event)
|
|||
s_curveChan = sub;
|
||||
DrawCurve(23);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ void onCustomFunctionsMenu(const char *result)
|
|||
}
|
||||
}
|
||||
|
||||
void menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunctionsContext & functionsContext)
|
||||
bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunctionsContext & functionsContext)
|
||||
{
|
||||
uint32_t sub = m_posVert;
|
||||
|
||||
|
@ -217,7 +217,7 @@ void menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc
|
|||
#if defined(OVERRIDE_CHANNEL_FUNCTION)
|
||||
else if (func == FUNC_OVERRIDE_CHANNEL) {
|
||||
val_min = -LIMIT_EXT_PERCENT; val_max = +LIMIT_EXT_PERCENT;
|
||||
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
|
||||
lcdDrawNumber(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
|
||||
}
|
||||
#endif
|
||||
#if defined(DANGEROUS_MODULE_FUNCTIONS)
|
||||
|
@ -237,7 +237,7 @@ void menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc
|
|||
#if defined(HAPTIC)
|
||||
else if (func == FUNC_HAPTIC) {
|
||||
val_max = 3;
|
||||
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
|
||||
lcdDrawNumber(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
|
||||
}
|
||||
#endif
|
||||
#if defined(SDCARD)
|
||||
|
@ -281,7 +281,7 @@ void menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc
|
|||
}
|
||||
else if (func == FUNC_LOGS) {
|
||||
if (val_displayed) {
|
||||
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|PREC1|LEFT, "s");
|
||||
lcdDrawNumber(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|PREC1|LEFT, 0, NULL, "s");
|
||||
}
|
||||
else {
|
||||
lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_MMMINV, 0, attr);
|
||||
|
@ -301,7 +301,7 @@ void menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc
|
|||
case FUNC_ADJUST_GVAR_CONSTANT:
|
||||
val_displayed = (int16_t)CFN_PARAM(cfn);
|
||||
val_min = -CFN_GVAR_CST_MAX; val_max = +CFN_GVAR_CST_MAX;
|
||||
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
|
||||
lcdDrawNumber(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
|
||||
break;
|
||||
case FUNC_ADJUST_GVAR_SOURCE:
|
||||
val_max = MIXSRC_LAST_CH;
|
||||
|
@ -353,7 +353,7 @@ void menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc
|
|||
lcdDrawText(MODEL_CUSTOM_FUNC_4TH_COLUMN-1, y, "!1x", attr);
|
||||
}
|
||||
else {
|
||||
lcd_outdezAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN+12, y, CFN_PLAY_REPEAT(cfn)*CFN_PLAY_REPEAT_MUL, attr, "s");
|
||||
lcdDrawNumber(MODEL_CUSTOM_FUNC_4TH_COLUMN+12, y, CFN_PLAY_REPEAT(cfn)*CFN_PLAY_REPEAT_MUL, attr, 0, NULL, "s");
|
||||
}
|
||||
}
|
||||
else if (attr) {
|
||||
|
@ -363,9 +363,11 @@ void menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void menuModelCustomFunctions(evt_t event)
|
||||
bool menuModelCustomFunctions(evt_t event)
|
||||
{
|
||||
MENU(STR_MENUCUSTOMFUNC, menuTabModel, e_CustomFunctions, NUM_CFN, DEFAULT_SCROLLBAR_X, { NAVIGATION_LINE_BY_LINE|4/*repeated*/ });
|
||||
return menuCustomFunctions(event, g_model.customFn, modelFunctionsContext);
|
||||
|
|
|
@ -60,7 +60,7 @@ bool isTrimModeAvailable(int mode)
|
|||
#define FLIGHT_MODES_FADEIN_COLUMN 400
|
||||
#define FLIGHT_MODES_FADEOUT_COLUMN 450
|
||||
|
||||
void menuModelFlightModesAll(evt_t event)
|
||||
bool menuModelFlightModesAll(evt_t event)
|
||||
{
|
||||
MENU(STR_MENUFLIGHTPHASES, menuTabModel, e_FlightModesAll, MAX_FLIGHT_MODES+1, DEFAULT_SCROLLBAR_X, { NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, 0});
|
||||
|
||||
|
@ -106,7 +106,7 @@ void menuModelFlightModesAll(evt_t event)
|
|||
char s[32];
|
||||
sprintf(s, "Check FM%d Trims", mixerCurrentFlightMode);
|
||||
lcd_putsCenter(y, s, attr);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
FlightModeData *p = flightModeAddress(k);
|
||||
|
@ -124,7 +124,7 @@ void menuModelFlightModesAll(evt_t event)
|
|||
case ITEM_FLIGHT_MODES_SWITCH:
|
||||
if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, SWSRC_FIRST_IN_MIXES, SWSRC_LAST_IN_MIXES, isSwitchAvailableInMixes);
|
||||
if (k == 0)
|
||||
lcd_puts(FLIGHT_MODES_SWITCH_COLUMN, y, "N/A");
|
||||
lcdDrawText(FLIGHT_MODES_SWITCH_COLUMN, y, "N/A");
|
||||
else
|
||||
putsSwitches(FLIGHT_MODES_SWITCH_COLUMN, y, p->swtch, attr);
|
||||
break;
|
||||
|
@ -145,15 +145,17 @@ void menuModelFlightModesAll(evt_t event)
|
|||
|
||||
case ITEM_FLIGHT_MODES_FADE_IN:
|
||||
if (active) p->fadeIn = checkIncDec(event, p->fadeIn, 0, DELAY_MAX, EE_MODEL|NO_INCDEC_MARKS);
|
||||
lcd_outdezAtt(FLIGHT_MODES_FADEIN_COLUMN, y, (10/DELAY_STEP)*p->fadeIn, attr|PREC1);
|
||||
lcdDrawNumber(FLIGHT_MODES_FADEIN_COLUMN, y, (10/DELAY_STEP)*p->fadeIn, attr|PREC1);
|
||||
break;
|
||||
|
||||
case ITEM_FLIGHT_MODES_FADE_OUT:
|
||||
if (active) p->fadeOut = checkIncDec(event, p->fadeOut, 0, DELAY_MAX, EE_MODEL|NO_INCDEC_MARKS);
|
||||
lcd_outdezAtt(FLIGHT_MODES_FADEOUT_COLUMN, y, (10/DELAY_STEP)*p->fadeOut, attr|PREC1);
|
||||
lcdDrawNumber(FLIGHT_MODES_FADEOUT_COLUMN, y, (10/DELAY_STEP)*p->fadeOut, attr|PREC1);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ void onGVARSMenu(const char *result)
|
|||
|
||||
#define GVARS_FM_COLUMN(p) (123 + (p)*24)
|
||||
|
||||
void menuModelGVars(evt_t event)
|
||||
bool menuModelGVars(evt_t event)
|
||||
{
|
||||
MENU(STR_MENUGLOBALVARS, menuTabModel, e_GVars/* TODO, first2seconds ? CHECK_FLAG_NO_SCREEN_INDEX : 0*/, MAX_GVARS, DEFAULT_SCROLLBAR_X, { NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES});
|
||||
|
||||
|
@ -66,7 +66,7 @@ void menuModelGVars(evt_t event)
|
|||
for (int l=0; l<NUM_BODY_LINES; l++) {
|
||||
int i = l+s_pgOfs;
|
||||
coord_t y = MENU_CONTENT_TOP + l*FH;
|
||||
if (g_model.gvars[i].popup) lcd_puts(MENUS_MARGIN_LEFT+25, y, "!");
|
||||
if (g_model.gvars[i].popup) lcdDrawText(MENUS_MARGIN_LEFT+25, y, "!");
|
||||
putsStrIdx(MENUS_MARGIN_LEFT, y, STR_GV, i+1, ((sub==i && m_posHorz<0) ? INVERS : 0));
|
||||
|
||||
for (int j=0; j<1+MAX_FLIGHT_MODES; j++) {
|
||||
|
@ -91,9 +91,9 @@ void menuModelGVars(evt_t event)
|
|||
}
|
||||
else {
|
||||
if (abs(v) >= 1000)
|
||||
lcd_outdezAtt(x, y+1, v, TINSIZE|attr);
|
||||
lcdDrawNumber(x, y+1, v, TINSIZE|attr);
|
||||
else
|
||||
lcd_outdezAtt(x, y, v, attr);
|
||||
lcdDrawNumber(x, y, v, attr);
|
||||
vmin = -GVAR_MAX; vmax = GVAR_MAX;
|
||||
}
|
||||
if (attr) {
|
||||
|
@ -120,4 +120,6 @@ void menuModelGVars(evt_t event)
|
|||
MENU_ADD_ITEM(STR_CLEAR);
|
||||
menuHandler = onGVARSMenu;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ enum menuModelHeliItems {
|
|||
|
||||
#define MODEL_HELI_2ND_COLUMN (230)
|
||||
|
||||
void menuModelHeli(evt_t event)
|
||||
bool menuModelHeli(evt_t event)
|
||||
{
|
||||
SIMPLE_MENU(STR_MENUHELISETUP, menuTabModel, e_Heli, ITEM_HELI_MAX, DEFAULT_SCROLLBAR_X);
|
||||
|
||||
|
@ -68,7 +68,7 @@ void menuModelHeli(evt_t event)
|
|||
|
||||
case ITEM_HELI_SWASHRING:
|
||||
lcd_putsLeft(y, STR_SWASHRING);
|
||||
lcd_outdezAtt(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.value, LEFT|attr);
|
||||
lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.value, LEFT|attr);
|
||||
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.swashR.value, 100);
|
||||
break;
|
||||
|
||||
|
@ -79,8 +79,8 @@ void menuModelHeli(evt_t event)
|
|||
break;
|
||||
|
||||
case ITEM_HELI_ELE_WEIGHT:
|
||||
lcd_puts(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, STR_WEIGHT);
|
||||
lcd_outdezAtt(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.elevatorWeight, LEFT|attr);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, STR_WEIGHT);
|
||||
lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.elevatorWeight, LEFT|attr);
|
||||
if (attr) CHECK_INCDEC_MODELVAR(event, g_model.swashR.elevatorWeight, -100, 100);
|
||||
break;
|
||||
|
||||
|
@ -91,8 +91,8 @@ void menuModelHeli(evt_t event)
|
|||
break;
|
||||
|
||||
case ITEM_HELI_AIL_WEIGHT:
|
||||
lcd_puts(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, STR_WEIGHT);
|
||||
lcd_outdezAtt(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.aileronWeight, LEFT|attr);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, STR_WEIGHT);
|
||||
lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.aileronWeight, LEFT|attr);
|
||||
if (attr) CHECK_INCDEC_MODELVAR(event, g_model.swashR.aileronWeight, -100, 100);
|
||||
break;
|
||||
|
||||
|
@ -103,11 +103,13 @@ void menuModelHeli(evt_t event)
|
|||
break;
|
||||
|
||||
case ITEM_HELI_COL_WEIGHT:
|
||||
lcd_puts(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, STR_WEIGHT);
|
||||
lcd_outdezAtt(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.collectiveWeight, LEFT|attr);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, STR_WEIGHT);
|
||||
lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.collectiveWeight, LEFT|attr);
|
||||
if (attr) CHECK_INCDEC_MODELVAR(event, g_model.swashR.collectiveWeight, -100, 100);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -338,7 +338,7 @@ enum ExposFields {
|
|||
|
||||
#define CURVE_ROWS 1
|
||||
|
||||
void menuModelExpoOne(evt_t event)
|
||||
bool menuModelExpoOne(evt_t event)
|
||||
{
|
||||
ExpoData *ed = expoAddress(s_currIdx);
|
||||
|
||||
|
@ -359,12 +359,12 @@ void menuModelExpoOne(evt_t event)
|
|||
if (ed->scale > 0) x = (x * 1024) / convertTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1, ed->scale);
|
||||
}
|
||||
else {
|
||||
lcd_outdezAtt(CURVE_CENTER_X+CURVE_SIDE_WIDTH, CURVE_CENTER_Y+CURVE_SIDE_WIDTH-FH+6, calcRESXto1000(x), PREC1);
|
||||
lcdDrawNumber(CURVE_CENTER_X+CURVE_SIDE_WIDTH, CURVE_CENTER_Y+CURVE_SIDE_WIDTH-FH+6, calcRESXto1000(x), PREC1);
|
||||
}
|
||||
|
||||
x = limit(-1024, x, 1024);
|
||||
int y = limit<int>(-1024, expoFn(x), 1024);
|
||||
lcd_outdezAtt(CURVE_CENTER_X-CURVE_SIDE_WIDTH, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, calcRESXto1000(y), LEFT|PREC1);
|
||||
lcdDrawNumber(CURVE_CENTER_X-CURVE_SIDE_WIDTH, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, calcRESXto1000(y), LEFT|PREC1);
|
||||
|
||||
x = divRound(x*CURVE_SIDE_WIDTH, RESX);
|
||||
y = getYCoord(expoFn, x);
|
||||
|
@ -444,6 +444,8 @@ void menuModelExpoOne(evt_t event)
|
|||
}
|
||||
y += FH;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
enum MixFields {
|
||||
|
@ -481,8 +483,8 @@ void drawOffsetBar(uint8_t x, uint8_t y, MixData * md)
|
|||
int barMin = offset - weight;
|
||||
int barMax = offset + weight;
|
||||
if (y > 15) {
|
||||
lcd_outdezAtt(x-((barMin >= 0) ? 2 : 3), y-6, barMin, TINSIZE|LEFT);
|
||||
lcd_outdezAtt(x+GAUGE_WIDTH+1, y-6, barMax, TINSIZE);
|
||||
lcdDrawNumber(x-((barMin >= 0) ? 2 : 3), y-6, barMin, TINSIZE|LEFT);
|
||||
lcdDrawNumber(x+GAUGE_WIDTH+1, y-6, barMax, TINSIZE);
|
||||
}
|
||||
if (barMin < -101)
|
||||
barMin = -101;
|
||||
|
@ -516,7 +518,7 @@ void drawOffsetBar(uint8_t x, uint8_t y, MixData * md)
|
|||
#undef GAUGE_WIDTH
|
||||
#undef GAUGE_HEIGHT
|
||||
|
||||
void menuModelMixOne(evt_t event)
|
||||
bool menuModelMixOne(evt_t event)
|
||||
{
|
||||
MixData *md2 = mixAddress(s_currIdx) ;
|
||||
|
||||
|
@ -594,7 +596,7 @@ void menuModelMixOne(evt_t event)
|
|||
case MIX_FIELD_WARNING:
|
||||
lcd_putsColumnLeft(x+MIXES_2ND_COLUMN, y, STR_MIXWARNING);
|
||||
if (md2->mixWarn)
|
||||
lcd_outdezAtt(x+MIXES_2ND_COLUMN, y, md2->mixWarn, attr|LEFT);
|
||||
lcdDrawNumber(x+MIXES_2ND_COLUMN, y, md2->mixWarn, attr|LEFT);
|
||||
else
|
||||
lcdDrawText(x+MIXES_2ND_COLUMN, y, STR_OFF, attr);
|
||||
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, md2->mixWarn, 3);
|
||||
|
@ -617,6 +619,8 @@ void menuModelMixOne(evt_t event)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static uint8_t s_copySrcIdx;
|
||||
|
@ -709,7 +713,7 @@ void displayExpoInfos(coord_t y, ExpoData *ed)
|
|||
putsSwitches(EXPO_LINE_SWITCH_POS, y, ed->swtch);
|
||||
}
|
||||
if (ed->mode != 3) {
|
||||
lcd_puts(EXPO_LINE_SIDE_POS, y, ed->mode == 2 ? "\176" : "\177");
|
||||
lcdDrawText(EXPO_LINE_SIDE_POS, y, ed->mode == 2 ? "\176" : "\177");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -725,7 +729,7 @@ void displayExpoLine(coord_t y, ExpoData *ed)
|
|||
}
|
||||
}
|
||||
|
||||
void menuModelExpoMix(uint8_t expo, evt_t event)
|
||||
bool menuModelExpoMix(uint8_t expo, evt_t event)
|
||||
{
|
||||
int sub = m_posVert;
|
||||
|
||||
|
@ -919,7 +923,7 @@ void menuModelExpoMix(uint8_t expo, evt_t event)
|
|||
cs[0] = 'S';
|
||||
if (md->delayUp || md->delayDown)
|
||||
cs[0] = (cs[0] =='S' ? '*' : 'D');
|
||||
lcd_puts(MIX_LINE_DELAY_POS, y, cs);
|
||||
lcdDrawText(MIX_LINE_DELAY_POS, y, cs);
|
||||
}
|
||||
if (s_copyMode) {
|
||||
if ((s_copyMode==COPY_MODE || s_copyTgtOfs == 0) && s_copySrcCh == ch && i == (s_copySrcIdx + (s_copyTgtOfs<0))) {
|
||||
|
@ -967,14 +971,16 @@ void menuModelExpoMix(uint8_t expo, evt_t event)
|
|||
}
|
||||
|
||||
if (sub >= linesCount-1) m_posVert = linesCount-1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void menuModelExposAll(evt_t event)
|
||||
bool menuModelExposAll(evt_t event)
|
||||
{
|
||||
return menuModelExpoMix(1, event);
|
||||
}
|
||||
|
||||
void menuModelMixAll(evt_t event)
|
||||
bool menuModelMixAll(evt_t event)
|
||||
{
|
||||
return menuModelExpoMix(0, event);
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ void onLimitsMenu(const char *result)
|
|||
}
|
||||
}
|
||||
|
||||
void menuModelLimits(evt_t event)
|
||||
bool menuModelLimits(evt_t event)
|
||||
{
|
||||
MENU(STR_MENULIMITS, menuTabModel, e_Limits, NUM_CHNOUT+1, DEFAULT_SCROLLBAR_X,
|
||||
{ NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW,
|
||||
|
@ -130,9 +130,9 @@ void menuModelLimits(evt_t event)
|
|||
|
||||
if (sub < NUM_CHNOUT) {
|
||||
#if defined(PPM_CENTER_ADJUSTABLE) || defined(PPM_UNIT_US)
|
||||
lcd_outdezAtt(100, MENU_FOOTER_TOP, PPM_CH_CENTER(sub)+channelOutputs[sub]/2, HEADER_COLOR, STR_US);
|
||||
lcdDrawNumber(100, MENU_FOOTER_TOP, PPM_CH_CENTER(sub)+channelOutputs[sub]/2, HEADER_COLOR, 0, NULL, STR_US);
|
||||
#else
|
||||
lcd_outdezAtt(100, MENU_FOOTER_TOP, calcRESXto1000(channelOutputs[sub]), HEADER_COLOR|PREC1);
|
||||
lcdDrawNumber(100, MENU_FOOTER_TOP, calcRESXto1000(channelOutputs[sub]), HEADER_COLOR|PREC1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ void menuModelLimits(evt_t event)
|
|||
moveTrimsToOffsets(); // if highlighted and menu pressed - move trims to offsets
|
||||
}
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
LimitData *ld = limitAddress(k);
|
||||
|
@ -173,7 +173,7 @@ void menuModelLimits(evt_t event)
|
|||
char swVal[2] = "-"; // '-', '<', '>'
|
||||
if ((channelOutputs[k] - v) > 50) swVal[0] = (ld->revert ? 127 : 126); // Switch to raw inputs? - remove trim!
|
||||
if ((channelOutputs[k] - v) < -50) swVal[0] = (ld->revert ? 126 : 127);
|
||||
lcd_puts(LIMITS_DIRECTION_POS, y, swVal);
|
||||
lcdDrawText(LIMITS_DIRECTION_POS, y, swVal);
|
||||
|
||||
int limit = (g_model.extendedLimits ? LIMIT_EXT_MAX : 1000);
|
||||
|
||||
|
@ -203,9 +203,9 @@ void menuModelLimits(evt_t event)
|
|||
}
|
||||
|
||||
#if defined(PPM_UNIT_US)
|
||||
lcd_outdezAtt(LIMITS_OFFSET_POS, y, ((int32_t)ld->offset*128) / 25, attr|PREC1);
|
||||
lcdDrawNumber(LIMITS_OFFSET_POS, y, ((int32_t)ld->offset*128) / 25, attr|PREC1);
|
||||
#else
|
||||
lcd_outdezAtt(LIMITS_OFFSET_POS, y, ld->offset, attr|PREC1);
|
||||
lcdDrawNumber(LIMITS_OFFSET_POS, y, ld->offset, attr|PREC1);
|
||||
#endif
|
||||
if (active) {
|
||||
ld->offset = checkIncDec(event, ld->offset, -1000, 1000, EE_MODEL, NULL, stops1000);
|
||||
|
@ -221,7 +221,7 @@ void menuModelLimits(evt_t event)
|
|||
ld->min = GVAR_MENU_ITEM(LIMITS_MIN_POS, y, ld->min, -LIMIT_EXT_MAX, LIMIT_EXT_MAX, attr|PREC1, 0, event);
|
||||
break;
|
||||
}
|
||||
lcd_outdezAtt(LIMITS_MIN_POS, y, MIN_MAX_DISPLAY(ld->min-LIMITS_MIN_MAX_OFFSET), attr|PREC1);
|
||||
lcdDrawNumber(LIMITS_MIN_POS, y, MIN_MAX_DISPLAY(ld->min-LIMITS_MIN_MAX_OFFSET), attr|PREC1);
|
||||
if (active) ld->min = LIMITS_MIN_MAX_OFFSET + checkIncDec(event, ld->min-LIMITS_MIN_MAX_OFFSET, -limit, 0, EE_MODEL, NULL, stops1000);
|
||||
break;
|
||||
|
||||
|
@ -230,7 +230,7 @@ void menuModelLimits(evt_t event)
|
|||
ld->max = GVAR_MENU_ITEM(LIMITS_MAX_POS, y, ld->max, -LIMIT_EXT_MAX, LIMIT_EXT_MAX, attr|PREC1, 0, event);
|
||||
break;
|
||||
}
|
||||
lcd_outdezAtt(LIMITS_MAX_POS, y, MIN_MAX_DISPLAY(ld->max+LIMITS_MIN_MAX_OFFSET), attr|PREC1);
|
||||
lcdDrawNumber(LIMITS_MAX_POS, y, MIN_MAX_DISPLAY(ld->max+LIMITS_MIN_MAX_OFFSET), attr|PREC1);
|
||||
if (active) ld->max = -LIMITS_MIN_MAX_OFFSET + checkIncDec(event, ld->max+LIMITS_MIN_MAX_OFFSET, 0, +limit, EE_MODEL, NULL, stops1000);
|
||||
break;
|
||||
|
||||
|
@ -269,7 +269,7 @@ void menuModelLimits(evt_t event)
|
|||
|
||||
#if defined(PPM_CENTER_ADJUSTABLE)
|
||||
case ITEM_LIMITS_PPM_CENTER:
|
||||
lcd_outdezAtt(LIMITS_PPM_CENTER_POS, y, PPM_CENTER+ld->ppmCenter, attr);
|
||||
lcdDrawNumber(LIMITS_PPM_CENTER_POS, y, PPM_CENTER+ld->ppmCenter, attr);
|
||||
if (active) {
|
||||
CHECK_INCDEC_MODELVAR(event, ld->ppmCenter, -PPM_CENTER_MAX, +PPM_CENTER_MAX);
|
||||
}
|
||||
|
@ -287,4 +287,6 @@ void menuModelLimits(evt_t event)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ void putsEdgeDelayParam(coord_t x, coord_t y, LogicalSwitchData *cs, uint8_t lat
|
|||
char sright[10];
|
||||
sprintf(sright, "%d.%d", right.quot, right.rem);
|
||||
sprintf(s, "[%s:%s]", sleft, sright);
|
||||
lcd_puts(x-4, y, s);
|
||||
lcdDrawText(x-4, y, s);
|
||||
/* if (cs->v3 < 0)
|
||||
lcdDrawText(lcdLastPos+3, y, "<<", rattr);
|
||||
else if (cs->v3 == 0)
|
||||
|
@ -95,7 +95,7 @@ void onLogicalSwitchesMenu(const char *result)
|
|||
}
|
||||
}
|
||||
|
||||
void menuModelLogicalSwitches(evt_t event)
|
||||
bool menuModelLogicalSwitches(evt_t event)
|
||||
{
|
||||
INCDEC_DECLARE_VARS(EE_MODEL);
|
||||
|
||||
|
@ -173,8 +173,8 @@ void menuModelLogicalSwitches(evt_t event)
|
|||
INCDEC_ENABLE_CHECK(isSourceAvailable);
|
||||
}
|
||||
else if (cstate == LS_FAMILY_TIMER) {
|
||||
lcd_outdezAtt(CSW_2ND_COLUMN, y, lswTimerValue(cs->v1), LEFT|PREC1|attr1);
|
||||
lcd_outdezAtt(CSW_3RD_COLUMN, y, lswTimerValue(cs->v2), LEFT|PREC1|attr2);
|
||||
lcdDrawNumber(CSW_2ND_COLUMN, y, lswTimerValue(cs->v1), LEFT|PREC1|attr1);
|
||||
lcdDrawNumber(CSW_3RD_COLUMN, y, lswTimerValue(cs->v2), LEFT|PREC1|attr2);
|
||||
v1_min = v2_min = -128;
|
||||
v1_max = v2_max = 122;
|
||||
INCDEC_SET_FLAG(EE_MODEL);
|
||||
|
@ -201,19 +201,19 @@ void menuModelLogicalSwitches(evt_t event)
|
|||
|
||||
// CSW duration
|
||||
if (cs->duration > 0)
|
||||
lcd_outdezAtt(CSW_5TH_COLUMN, y, cs->duration, (horz==LS_FIELD_DURATION ? attr : 0)|PREC1|LEFT);
|
||||
lcdDrawNumber(CSW_5TH_COLUMN, y, cs->duration, (horz==LS_FIELD_DURATION ? attr : 0)|PREC1|LEFT);
|
||||
else
|
||||
lcdDrawTextAtIndex(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DURATION ? attr : 0);
|
||||
|
||||
// CSW delay
|
||||
if (cstate == LS_FAMILY_EDGE) {
|
||||
lcd_puts(CSW_6TH_COLUMN, y, STR_NA);
|
||||
lcdDrawText(CSW_6TH_COLUMN, y, STR_NA);
|
||||
if (attr && horz == LS_FIELD_DELAY) {
|
||||
REPEAT_LAST_CURSOR_MOVE();
|
||||
}
|
||||
}
|
||||
else if (cs->delay > 0) {
|
||||
lcd_outdezAtt(CSW_6TH_COLUMN, y, cs->delay, (horz==LS_FIELD_DELAY ? attr : 0)|PREC1|LEFT);
|
||||
lcdDrawNumber(CSW_6TH_COLUMN, y, cs->delay, (horz==LS_FIELD_DELAY ? attr : 0)|PREC1|LEFT);
|
||||
}
|
||||
else {
|
||||
lcdDrawTextAtIndex(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DELAY ? attr : 0);
|
||||
|
@ -272,4 +272,6 @@ void menuModelLogicalSwitches(evt_t event)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -37,24 +37,145 @@
|
|||
|
||||
#define CATEGORIES_WIDTH 140
|
||||
|
||||
void drawModel(coord_t x, coord_t y, const char * name)
|
||||
#define MODELCELL_WIDTH 153
|
||||
#define MODELCELL_HEIGHT 61
|
||||
|
||||
enum ModelSelectMode {
|
||||
MODE_SELECT_CATEGORY,
|
||||
MODE_SELECT_MODEL,
|
||||
};
|
||||
|
||||
uint8_t selectMode;
|
||||
uint8_t currentCategory;
|
||||
char selectedFilename[LEN_MODEL_FILENAME+1];
|
||||
|
||||
void drawCategory(coord_t y, const char * name, bool selected)
|
||||
{
|
||||
lcdDrawSolidRect(x, y, 153, 61, LINE_COLOR);
|
||||
lcdDrawText(x+5, y+2, name, TEXT_COLOR);
|
||||
lcdDrawSolidHorizontalLine(x+5, y+19, 143, LINE_COLOR);
|
||||
lcdDrawBitmapPattern(x+5, y+23, LBM_LIBRARY_SLOT, TEXT_COLOR);
|
||||
if (selected) {
|
||||
lcdDrawSolidFilledRect(0, y-INVERT_VERT_MARGIN, CATEGORIES_WIDTH, INVERT_LINE_HEIGHT, HEADER_BGCOLOR);
|
||||
lcdDrawBitmapPattern(CATEGORIES_WIDTH-12, y, LBM_LIBRARY_CURSOR, MENU_TITLE_COLOR);
|
||||
if (selectMode == MODE_SELECT_CATEGORY) {
|
||||
drawShadow(0, y-INVERT_VERT_MARGIN, CATEGORIES_WIDTH, INVERT_LINE_HEIGHT);
|
||||
}
|
||||
}
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, name, MENU_TITLE_COLOR);
|
||||
}
|
||||
|
||||
void menuModelSelect(evt_t event)
|
||||
void drawModel(coord_t x, coord_t y, const char * name, bool selected)
|
||||
{
|
||||
ModelHeader header;
|
||||
const char * error = readModel(name, (uint8_t *)&header, sizeof(header));
|
||||
if (error) {
|
||||
lcdDrawText(x+5, y+2, "(Invalid Model)", TEXT_COLOR);
|
||||
lcdDrawBitmapPattern(x+5, y+23, LBM_LIBRARY_SLOT, TEXT_COLOR);
|
||||
}
|
||||
else {
|
||||
lcdDrawTextWithLen(x+5, y+2, header.name, LEN_MODEL_NAME, ZCHAR|TEXT_COLOR);
|
||||
putsTimer(x+104, y+41, 0, TEXT_COLOR|LEFT);
|
||||
for (int i=0; i<4; i++) {
|
||||
lcdDrawBitmapPattern(x+104+i*11, y+25, LBM_SCORE0, TITLE_BGCOLOR);
|
||||
}
|
||||
loadModelBitmap(header.bitmap, modelBitmap);
|
||||
lcdDrawBitmap(x+5, y+24, modelBitmap, 0, 0, getBitmapScale(modelBitmap, 64, 32));
|
||||
}
|
||||
lcdDrawSolidHorizontalLine(x+5, y+19, 143, LINE_COLOR);
|
||||
if (selectMode == MODE_SELECT_MODEL && selected) {
|
||||
lcdDrawSolidRect(x, y, MODELCELL_WIDTH, MODELCELL_HEIGHT, TITLE_BGCOLOR);
|
||||
drawShadow(x, y, MODELCELL_WIDTH, MODELCELL_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
void onModelSelectMenu(const char * result)
|
||||
{
|
||||
if (result == STR_SELECT_MODEL) {
|
||||
memcpy(g_eeGeneral.currModelFilename, selectedFilename, LEN_MODEL_FILENAME);
|
||||
storageDirty(EE_GENERAL);
|
||||
loadModel(g_eeGeneral.currModelFilename);
|
||||
chainMenu(menuMainView);
|
||||
}
|
||||
else if (result == STR_DELETE_MODEL) {
|
||||
POPUP_CONFIRMATION(STR_DELETEMODEL);
|
||||
SET_WARNING_INFO(selectedFilename, LEN_MODEL_FILENAME, 0);
|
||||
}
|
||||
else if (result == STR_DUPLICATE_MODEL) {
|
||||
char duplicatedFilename[LEN_MODEL_FILENAME+1];
|
||||
memcpy(duplicatedFilename, selectedFilename, sizeof(duplicatedFilename));
|
||||
if (findNextFileIndex(duplicatedFilename, MODELS_PATH)) {
|
||||
sdCopyFile(selectedFilename, MODELS_PATH, duplicatedFilename, MODELS_PATH);
|
||||
storageInsertModel(duplicatedFilename, currentCategory, -1);
|
||||
}
|
||||
else {
|
||||
POPUP_WARNING("Invalid Filename");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define MODEL_INDEX() (m_posVert*2+m_posHorz)
|
||||
|
||||
bool menuModelSelect(evt_t event)
|
||||
{
|
||||
if (s_warning_result) {
|
||||
s_warning_result = 0;
|
||||
int modelIndex = MODEL_INDEX();
|
||||
storageRemoveModel(currentCategory, modelIndex);
|
||||
s_copyMode = 0;
|
||||
event = EVT_REFRESH;
|
||||
if (modelIndex > 0) {
|
||||
modelIndex--;
|
||||
m_posVert = modelIndex / 2;
|
||||
m_posHorz = modelIndex & 1;
|
||||
}
|
||||
}
|
||||
|
||||
switch(event) {
|
||||
case 0:
|
||||
// no need to refresh the screen
|
||||
return;
|
||||
return false;
|
||||
|
||||
case EVT_ENTRY:
|
||||
selectMode = MODE_SELECT_CATEGORY;
|
||||
currentCategory = m_posVert = 0;
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
switch (selectMode) {
|
||||
case MODE_SELECT_CATEGORY:
|
||||
chainMenu(menuMainView);
|
||||
return;
|
||||
return false;
|
||||
case MODE_SELECT_MODEL:
|
||||
selectMode = MODE_SELECT_CATEGORY;
|
||||
m_posVert = currentCategory;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case EVT_KEY_BREAK(KEY_ENTER):
|
||||
case EVT_KEY_BREAK(KEY_RIGHT):
|
||||
switch (selectMode) {
|
||||
case MODE_SELECT_CATEGORY:
|
||||
selectMode = MODE_SELECT_MODEL;
|
||||
m_posVert = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case EVT_KEY_LONG(KEY_ENTER):
|
||||
killEvents(event);
|
||||
if (selectMode == MODE_SELECT_MODEL) {
|
||||
ModelHeader header;
|
||||
const char * error = readModel(selectedFilename, (uint8_t *)&header, sizeof(header));
|
||||
if (!error) {
|
||||
MENU_ADD_ITEM(STR_SELECT_MODEL);
|
||||
MENU_ADD_ITEM(STR_DUPLICATE_MODEL);
|
||||
}
|
||||
// MENU_ADD_SD_ITEM(STR_BACKUP_MODEL);
|
||||
// MENU_ADD_ITEM(STR_MOVE_MODEL);
|
||||
MENU_ADD_ITEM(STR_DELETE_MODEL);
|
||||
// MENU_ADD_ITEM(STR_CREATE_MODEL);
|
||||
// MENU_ADD_ITEM(STR_RESTORE_MODEL);
|
||||
menuHandler = onModelSelectMenu;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Header
|
||||
|
@ -63,51 +184,71 @@ void menuModelSelect(evt_t event)
|
|||
lcdDrawBitmapPattern(5, 7, LBM_LIBRARY_ICON, MENU_TITLE_COLOR);
|
||||
drawTopmenuDatetime();
|
||||
|
||||
// Categories
|
||||
// Body
|
||||
lcdDrawSolidFilledRect(0, MENU_HEADER_HEIGHT, CATEGORIES_WIDTH, LCD_H-MENU_HEADER_HEIGHT-MENU_FOOTER_HEIGHT, TITLE_BGCOLOR);
|
||||
lcdDrawSolidFilledRect(CATEGORIES_WIDTH, MENU_HEADER_HEIGHT, LCD_W-CATEGORIES_WIDTH, LCD_H-MENU_HEADER_HEIGHT-MENU_FOOTER_HEIGHT, TEXT_BGCOLOR);
|
||||
|
||||
// Footer
|
||||
lcdDrawSolidFilledRect(0, MENU_FOOTER_TOP, LCD_W, MENU_FOOTER_HEIGHT, HEADER_BGCOLOR);
|
||||
|
||||
// Categories
|
||||
StorageModelsList storage;
|
||||
const char * error = storageOpenModelsList(&storage);
|
||||
if (!error) {
|
||||
bool result = true;
|
||||
coord_t y = MENU_HEADER_HEIGHT+10;
|
||||
while (y < LCD_H) {
|
||||
char line[256];
|
||||
result = storageReadNextCategory(&storage, line, sizeof(line)-1);
|
||||
int index = 0;
|
||||
while (1) {
|
||||
char line[LEN_MODEL_FILENAME+1];
|
||||
result = storageReadNextCategory(&storage, line, LEN_MODEL_FILENAME);
|
||||
if (!result)
|
||||
break;
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, line, MENU_TITLE_COLOR);
|
||||
if (y < LCD_H) {
|
||||
drawCategory(y, line, currentCategory==index);
|
||||
}
|
||||
y += FH;
|
||||
index++;
|
||||
}
|
||||
if (selectMode == MODE_SELECT_CATEGORY) {
|
||||
if (navigate(event, index, 9)) {
|
||||
putEvent(EVT_REFRESH);
|
||||
currentCategory = m_posVert;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Models
|
||||
lcdDrawSolidFilledRect(CATEGORIES_WIDTH, MENU_HEADER_HEIGHT, LCD_W-CATEGORIES_WIDTH, LCD_H-MENU_HEADER_HEIGHT-MENU_FOOTER_HEIGHT, TEXT_BGCOLOR);
|
||||
if (!error) {
|
||||
bool result = storageSeekCategory(&storage, 0);
|
||||
bool result = storageSeekCategory(&storage, currentCategory);
|
||||
coord_t y = MENU_HEADER_HEIGHT+7;
|
||||
unsigned int i = 0;
|
||||
int index = 0;
|
||||
while (result) {
|
||||
char line[256];
|
||||
result = storageReadNextModel(&storage, line, sizeof(line)-1);
|
||||
char line[LEN_MODEL_FILENAME+1];
|
||||
result = storageReadNextModel(&storage, line, LEN_MODEL_FILENAME);
|
||||
if (!result)
|
||||
break;
|
||||
if (y < LCD_H) {
|
||||
coord_t x;
|
||||
if (i & 1) {
|
||||
drawModel(CATEGORIES_WIDTH+MENUS_MARGIN_LEFT+162, y, line);
|
||||
if (index >= s_pgOfs*2 && index < (s_pgOfs+3)*2) {
|
||||
bool selected = (m_posVert*2+m_posHorz==index);
|
||||
if (index & 1) {
|
||||
drawModel(CATEGORIES_WIDTH+MENUS_MARGIN_LEFT+162, y, line, selected);
|
||||
y += 66;
|
||||
}
|
||||
else {
|
||||
drawModel(CATEGORIES_WIDTH+MENUS_MARGIN_LEFT+1, y, line);
|
||||
drawModel(CATEGORIES_WIDTH+MENUS_MARGIN_LEFT+1, y, line, selected);
|
||||
}
|
||||
if (selected) {
|
||||
memcpy(selectedFilename, line, sizeof(selectedFilename));
|
||||
}
|
||||
}
|
||||
i++;
|
||||
index++;
|
||||
}
|
||||
if (selectMode == MODE_SELECT_MODEL) {
|
||||
if (navigate(event, index, 3, 2)) {
|
||||
putEvent(EVT_REFRESH);
|
||||
}
|
||||
}
|
||||
drawScrollbar(DEFAULT_SCROLLBAR_X, MENU_HEADER_HEIGHT+7, MENU_FOOTER_TOP-MENU_HEADER_HEIGHT-15, s_pgOfs, (index+1)/2, 3);
|
||||
}
|
||||
|
||||
drawScrollbar(DEFAULT_SCROLLBAR_X, MENU_HEADER_HEIGHT+7, MENU_FOOTER_TOP-MENU_HEADER_HEIGHT-15, 0, 4, 2);
|
||||
|
||||
// Footer
|
||||
lcdDrawSolidFilledRect(0, MENU_FOOTER_TOP, LCD_W, MENU_FOOTER_HEIGHT, HEADER_BGCOLOR);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "../../opentx.h"
|
||||
|
||||
uint8_t g_moduleIdx;
|
||||
void menuModelFailsafe(evt_t event);
|
||||
bool menuModelFailsafe(evt_t event);
|
||||
|
||||
enum menuModelSetupItems {
|
||||
ITEM_MODEL_NAME,
|
||||
|
@ -113,6 +113,7 @@ void onModelSetupBitmapMenu(const char *result)
|
|||
else {
|
||||
// The user choosed a bmp file in the list
|
||||
copySelection(g_model.header.bitmap, result, sizeof(g_model.header.bitmap));
|
||||
loadModelBitmap(g_model.header.bitmap, modelBitmap);
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +171,7 @@ int getSwitchWarningsCount()
|
|||
return count;
|
||||
}
|
||||
|
||||
void menuModelSetup(evt_t event)
|
||||
bool menuModelSetup(evt_t event)
|
||||
{
|
||||
horzpos_t l_posHorz = m_posHorz;
|
||||
#define IF_EXTERNAL_MODULE_ON(x) (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_NONE ? HIDDEN_ROW : (uint8_t)(x))
|
||||
|
@ -550,7 +551,7 @@ void menuModelSetup(evt_t event)
|
|||
lcd_putsLeft(y, STR_CHANNELRANGE);
|
||||
if ((int8_t)PORT_CHANNELS_ROWS(moduleIdx) >= 0) {
|
||||
putsStrIdx(MODEL_SETUP_2ND_COLUMN, y, STR_CH, moduleData.channelsStart+1, m_posHorz==0 ? attr : 0);
|
||||
lcd_puts(MODEL_SETUP_2ND_COLUMN+30, y, "-");
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN+30, y, "-");
|
||||
putsStrIdx(MODEL_SETUP_2ND_COLUMN+40, y, STR_CH, moduleData.channelsStart+NUM_CHANNELS(moduleIdx), m_posHorz==1 ? attr : 0);
|
||||
if (attr && s_editMode>0) {
|
||||
switch (m_posHorz) {
|
||||
|
@ -577,8 +578,8 @@ void menuModelSetup(evt_t event)
|
|||
ModuleData & moduleData = g_model.moduleData[moduleIdx];
|
||||
if (IS_MODULE_PPM(moduleIdx)) {
|
||||
lcd_putsLeft(y, STR_PPMFRAME);
|
||||
lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN, y, (int16_t)moduleData.ppmFrameLength*5 + 225, (m_posHorz<=0 ? attr : 0) | PREC1|LEFT, STR_MS);
|
||||
lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN+70, y, (moduleData.ppmDelay*50)+300, (CURSOR_ON_LINE() || m_posHorz==1) ? attr : 0, "us");
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, (int16_t)moduleData.ppmFrameLength*5 + 225, (m_posHorz<=0 ? attr : 0) | PREC1|LEFT, 0, NULL, STR_MS);
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN+70, y, (moduleData.ppmDelay*50)+300, (CURSOR_ON_LINE() || m_posHorz==1) ? attr : 0, 0, NULL, "us");
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN+90, y, moduleData.ppmPulsePol ? "+" : "-", (CURSOR_ON_LINE() || m_posHorz==2) ? attr : 0);
|
||||
|
||||
if (attr && s_editMode>0) {
|
||||
|
@ -607,7 +608,7 @@ void menuModelSetup(evt_t event)
|
|||
lcd_putsLeft(y, STR_RXNUM);
|
||||
}
|
||||
if (IS_MODULE_XJT(moduleIdx) || IS_MODULE_DSM2(moduleIdx)) {
|
||||
if (xOffsetBind) lcd_outdezNAtt(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId[moduleIdx], (l_posHorz==0 ? attr : 0) | LEADING0|LEFT, 2);
|
||||
if (xOffsetBind) lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId[moduleIdx], (l_posHorz==0 ? attr : 0) | LEADING0|LEFT, 2);
|
||||
if (attr && l_posHorz==0 && s_editMode>0) {
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId[moduleIdx], IS_MODULE_DSM2(moduleIdx) ? 20 : 63);
|
||||
}
|
||||
|
@ -663,11 +664,13 @@ void menuModelSetup(evt_t event)
|
|||
|
||||
if (IS_RANGECHECK_ENABLE()) {
|
||||
displayPopup("RSSI :");
|
||||
lcd_outdezAtt(WARNING_LINE_X, WARNING_INFOLINE_Y, TELEMETRY_RSSI(), DBLSIZE|LEFT);
|
||||
}
|
||||
lcdDrawNumber(WARNING_LINE_X, WARNING_INFOLINE_Y, TELEMETRY_RSSI(), DBLSIZE|LEFT);
|
||||
}
|
||||
|
||||
void menuModelFailsafe(evt_t event)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool menuModelFailsafe(evt_t event)
|
||||
{
|
||||
static bool longNames = false;
|
||||
bool newLongNames = false;
|
||||
|
@ -731,13 +734,13 @@ void menuModelFailsafe(evt_t event)
|
|||
}
|
||||
#if defined(PPM_UNIT_US)
|
||||
uint8_t wbar = (longNames ? SLIDER_W-10 : SLIDER_W);
|
||||
lcd_outdezAtt(x+COL_W-4-wbar-ofs, y, PPM_CH_CENTER(ch)+val/2, flags);
|
||||
lcdDrawNumber(x+COL_W-4-wbar-ofs, y, PPM_CH_CENTER(ch)+val/2, flags);
|
||||
#elif defined(PPM_UNIT_PERCENT_PREC1)
|
||||
uint8_t wbar = (longNames ? SLIDER_W-16 : SLIDER_W-6);
|
||||
lcd_outdezAtt(x+COL_W-4-wbar-ofs, y, calcRESXto1000(val), PREC1|flags);
|
||||
lcdDrawNumber(x+COL_W-4-wbar-ofs, y, calcRESXto1000(val), PREC1|flags);
|
||||
#else
|
||||
uint8_t wbar = (longNames ? SLIDER_W-10 : SLIDER_W);
|
||||
lcd_outdezAtt(x+COL_W-4-wbar-ofs, y, calcRESXto1000(val)/10, flags);
|
||||
lcdDrawNumber(x+COL_W-4-wbar-ofs, y, calcRESXto1000(val)/10, flags);
|
||||
#endif
|
||||
|
||||
// Gauge
|
||||
|
@ -751,4 +754,6 @@ void menuModelFailsafe(evt_t event)
|
|||
}
|
||||
|
||||
longNames = newLongNames;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -208,13 +208,13 @@ bool isSensorAvailable(int sensor)
|
|||
#define SENSOR_FILTER_ROWS (sensor->isConfigurable() ? (uint8_t)0 : HIDDEN_ROW)
|
||||
#define SENSOR_PERSISTENT_ROWS (sensor->isConfigurable() ? (uint8_t)0 : HIDDEN_ROW)
|
||||
|
||||
void menuModelSensor(evt_t event)
|
||||
bool menuModelSensor(evt_t event)
|
||||
{
|
||||
TelemetrySensor *sensor = &g_model.telemetrySensors[s_currIdx];
|
||||
|
||||
SUBMENU(STR_MENUSENSOR, SENSOR_FIELD_MAX, DEFAULT_SCROLLBAR_X, { 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, 0 });
|
||||
|
||||
lcd_outdezAtt(MENUS_MARGIN_LEFT+getTextWidth(TR_MENUSENSOR)+5, MENU_FOOTER_TOP, s_currIdx+1, HEADER_COLOR|LEFT);
|
||||
lcdDrawNumber(MENUS_MARGIN_LEFT+getTextWidth(TR_MENUSENSOR)+5, MENU_FOOTER_TOP, s_currIdx+1, HEADER_COLOR|LEFT);
|
||||
putsTelemetryChannelValue(SENSOR_2ND_COLUMN, MENU_FOOTER_TOP, s_currIdx, getValue(MIXSRC_FIRST_TELEM+3*s_currIdx), HEADER_COLOR|LEFT);
|
||||
|
||||
int sub = m_posVert;
|
||||
|
@ -252,7 +252,7 @@ void menuModelSensor(evt_t event)
|
|||
if (sensor->type == TELEM_TYPE_CUSTOM) {
|
||||
lcd_putsLeft(y, STR_ID);
|
||||
lcd_outhex4(SENSOR_2ND_COLUMN, y, sensor->id, LEFT|(m_posHorz==0 ? attr : 0));
|
||||
lcd_outdezAtt(SENSOR_3RD_COLUMN, y, sensor->instance, LEFT|(m_posHorz==1 ? attr : 0));
|
||||
lcdDrawNumber(SENSOR_3RD_COLUMN, y, sensor->instance, LEFT|(m_posHorz==1 ? attr : 0));
|
||||
if (attr) {
|
||||
switch (m_posHorz) {
|
||||
case 0:
|
||||
|
@ -337,7 +337,7 @@ void menuModelSensor(evt_t event)
|
|||
if (sensor->custom.ratio == 0)
|
||||
lcdDrawText(SENSOR_2ND_COLUMN, y, "-", attr);
|
||||
else
|
||||
lcd_outdezAtt(SENSOR_2ND_COLUMN, y, sensor->custom.ratio, LEFT|attr|PREC1);
|
||||
lcdDrawNumber(SENSOR_2ND_COLUMN, y, sensor->custom.ratio, LEFT|attr|PREC1);
|
||||
break;
|
||||
}
|
||||
// no break
|
||||
|
@ -361,7 +361,7 @@ void menuModelSensor(evt_t event)
|
|||
lcd_putsLeft(y, NO_INDENT(STR_OFFSET));
|
||||
if (attr) CHECK_INCDEC_MODELVAR(event, sensor->custom.offset, -30000, +30000);
|
||||
if (sensor->prec > 0) attr |= (sensor->prec == 2 ? PREC2 : PREC1);
|
||||
lcd_outdezAtt(SENSOR_2ND_COLUMN, y, sensor->custom.offset, LEFT|attr);
|
||||
lcdDrawNumber(SENSOR_2ND_COLUMN, y, sensor->custom.offset, LEFT|attr);
|
||||
break;
|
||||
}
|
||||
// no break
|
||||
|
@ -400,6 +400,8 @@ void menuModelSensor(evt_t event)
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void onSensorMenu(const char *result)
|
||||
|
@ -442,7 +444,7 @@ void onTelemetryScriptFileSelectionMenu(const char *result)
|
|||
}
|
||||
#endif
|
||||
|
||||
void menuModelTelemetry(evt_t event)
|
||||
bool menuModelTelemetry(evt_t event)
|
||||
{
|
||||
MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX, DEFAULT_SCROLLBAR_X, { TELEMETRY_TYPE_ROWS RSSI_ROWS SENSORS_ROWS USRDATA_ROWS CASE_VARIO(LABEL(Vario)) CASE_VARIO(0) CASE_VARIO(VARIO_RANGE_ROWS) LABEL(TopBar), 0, 0, TELEMETRY_SCREEN_ROWS(0), TELEMETRY_SCREEN_ROWS(1), TELEMETRY_SCREEN_ROWS(2), TELEMETRY_SCREEN_ROWS(3) });
|
||||
|
||||
|
@ -461,10 +463,10 @@ void menuModelTelemetry(evt_t event)
|
|||
|
||||
if (k>=ITEM_TELEMETRY_SENSOR1 && k<ITEM_TELEMETRY_SENSOR1+MAX_SENSORS) {
|
||||
int index = k-ITEM_TELEMETRY_SENSOR1;
|
||||
lcd_outdezAtt(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, index+1, LEFT|attr, ":");
|
||||
lcdDrawNumber(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, index+1, LEFT|attr, 0, NULL, ":");
|
||||
lcdDrawTextWithLen(60, y, g_model.telemetrySensors[index].label, TELEM_LABEL_LEN, ZCHAR);
|
||||
if (telemetryItems[index].isFresh()) {
|
||||
lcd_puts(100, y, "*");
|
||||
lcdDrawText(100, y, "*");
|
||||
}
|
||||
TelemetryItem & telemetryItem = telemetryItems[index];
|
||||
if (telemetryItem.isAvailable()) {
|
||||
|
@ -472,7 +474,7 @@ void menuModelTelemetry(evt_t event)
|
|||
putsTelemetryChannelValue(TELEM_COL2, y, index, getValue(MIXSRC_FIRST_TELEM+3*index), LEFT|color);
|
||||
}
|
||||
else {
|
||||
lcd_puts(TELEM_COL2, y, "---"); // TODO shortcut
|
||||
lcdDrawText(TELEM_COL2, y, "---"); // TODO shortcut
|
||||
}
|
||||
if (attr) {
|
||||
s_editMode = 0;
|
||||
|
@ -519,7 +521,7 @@ void menuModelTelemetry(evt_t event)
|
|||
case ITEM_TELEMETRY_RSSI_ALARM2: {
|
||||
uint8_t alarm = k-ITEM_TELEMETRY_RSSI_ALARM1;
|
||||
lcd_putsLeft(y, (alarm==0 ? STR_LOWALARM : STR_CRITICALALARM));
|
||||
lcd_outdezNAtt(TELEM_COL2, y, getRssiAlarmValue(alarm), LEFT|attr, 3);
|
||||
lcdDrawNumber(TELEM_COL2, y, getRssiAlarmValue(alarm), LEFT|attr, 3);
|
||||
if (attr && s_editMode>0) {
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.frsky.rssiAlarms[alarm].value, -30, 30);
|
||||
}
|
||||
|
@ -541,10 +543,10 @@ void menuModelTelemetry(evt_t event)
|
|||
|
||||
case ITEM_TELEMETRY_VARIO_RANGE:
|
||||
lcd_putsLeft(y, STR_LIMIT);
|
||||
lcd_outdezAtt(TELEM_COL2, y, -10+g_model.frsky.varioMin, (m_posHorz<=0 ? attr : 0)|LEFT);
|
||||
lcd_outdezAtt(TELEM_COL2+70, y, -5+g_model.frsky.varioCenterMin, ((CURSOR_ON_LINE() || m_posHorz==1) ? attr : 0)|PREC1);
|
||||
lcd_outdezAtt(TELEM_COL2+115, y, 5+g_model.frsky.varioCenterMax, ((CURSOR_ON_LINE() || m_posHorz==2) ? attr : 0)|PREC1);
|
||||
lcd_outdezAtt(TELEM_COL2+160, y, 10+g_model.frsky.varioMax, ((CURSOR_ON_LINE() || m_posHorz==3) ? attr : 0));
|
||||
lcdDrawNumber(TELEM_COL2, y, -10+g_model.frsky.varioMin, (m_posHorz<=0 ? attr : 0)|LEFT);
|
||||
lcdDrawNumber(TELEM_COL2+70, y, -5+g_model.frsky.varioCenterMin, ((CURSOR_ON_LINE() || m_posHorz==1) ? attr : 0)|PREC1);
|
||||
lcdDrawNumber(TELEM_COL2+115, y, 5+g_model.frsky.varioCenterMax, ((CURSOR_ON_LINE() || m_posHorz==2) ? attr : 0)|PREC1);
|
||||
lcdDrawNumber(TELEM_COL2+160, y, 10+g_model.frsky.varioMax, ((CURSOR_ON_LINE() || m_posHorz==3) ? attr : 0));
|
||||
if (attr && s_editMode>0) {
|
||||
switch (m_posHorz) {
|
||||
case 0:
|
||||
|
@ -725,4 +727,6 @@ void menuModelTelemetry(evt_t event)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ void pushMenu(MenuFuncP newMenu)
|
|||
menuEvent = EVT_ENTRY;
|
||||
}
|
||||
|
||||
void menuModelNotes(evt_t event)
|
||||
bool menuModelNotes(evt_t event)
|
||||
{
|
||||
if (event == EVT_ENTRY) {
|
||||
strcpy(s_text_file, MODELS_PATH "/");
|
||||
|
@ -84,7 +84,7 @@ void menuModelNotes(evt_t event)
|
|||
strcpy(buf, TEXT_EXT);
|
||||
}
|
||||
|
||||
menuTextView(event);
|
||||
return menuTextView(event);
|
||||
}
|
||||
|
||||
void pushModelNotes()
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
|
||||
#define MENU_COLUMN2_X 280
|
||||
|
||||
#define lcd_putsColumnLeft(x, y, str) lcd_puts((x > MENU_COLUMN2_X+MENUS_MARGIN_LEFT+68) ? MENU_COLUMN2_X+MENUS_MARGIN_LEFT : MENUS_MARGIN_LEFT, y, str)
|
||||
#define lcd_putsColumnLeft(x, y, str) lcdDrawText((x > MENU_COLUMN2_X+MENUS_MARGIN_LEFT+68) ? MENU_COLUMN2_X+MENUS_MARGIN_LEFT : MENUS_MARGIN_LEFT, y, str)
|
||||
|
||||
typedef int16_t vertpos_t;
|
||||
|
||||
|
@ -68,10 +68,9 @@ extern uint8_t calibrationState;
|
|||
|
||||
void drawCheckBox(coord_t x, coord_t y, uint8_t value, LcdFlags attr);
|
||||
|
||||
typedef void (*MenuFuncP)(evt_t event);
|
||||
typedef void (*MenuFuncP_PROGMEM)(evt_t event);
|
||||
extern const MenuFuncP_PROGMEM menuTabModel[];
|
||||
extern const MenuFuncP_PROGMEM menuTabGeneral[];
|
||||
typedef bool (*MenuFuncP)(evt_t event);
|
||||
extern const MenuFuncP menuTabModel[];
|
||||
extern const MenuFuncP menuTabGeneral[];
|
||||
|
||||
extern MenuFuncP g_menuStack[5];
|
||||
extern uint8_t g_menuPos[4];
|
||||
|
@ -85,33 +84,28 @@ void pushMenu(MenuFuncP newMenu);
|
|||
/// return to last menu in menustack
|
||||
void popMenu();
|
||||
|
||||
void menuFirstCalib(evt_t event);
|
||||
bool menuFirstCalib(evt_t event);
|
||||
|
||||
void onMainViewMenu(const char *result);
|
||||
void menuMainView(evt_t event);
|
||||
void menuGeneralDiagAna(evt_t event);
|
||||
|
||||
void menuTelemetryFrsky(evt_t event);
|
||||
void menuGeneralSetup(evt_t event);
|
||||
void menuGeneralCalib(evt_t event);
|
||||
void menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunctionsContext & functionsContext);
|
||||
|
||||
void menuModelSelect(evt_t event);
|
||||
void menuModelSetup(evt_t event);
|
||||
void menuModelCustomFunctions(evt_t event);
|
||||
void menuStatisticsView(evt_t event);
|
||||
void menuStatisticsDebug(evt_t event);
|
||||
void menuAboutView(evt_t event);
|
||||
bool menuMainView(evt_t event);
|
||||
bool menuGeneralDiagAna(evt_t event);
|
||||
bool menuGeneralSetup(evt_t event);
|
||||
bool menuGeneralCalib(evt_t event);
|
||||
bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunctionsContext & functionsContext);
|
||||
bool menuModelSelect(evt_t event);
|
||||
bool menuModelSetup(evt_t event);
|
||||
bool menuModelCustomFunctions(evt_t event);
|
||||
bool menuStatisticsView(evt_t event);
|
||||
bool menuStatisticsDebug(evt_t event);
|
||||
bool menuAboutView(evt_t event);
|
||||
bool menuMainViewChannelsMonitor(evt_t event);
|
||||
bool menuChannelsView(evt_t event);
|
||||
bool menuChannelsView(evt_t event);
|
||||
bool menuTextView(evt_t event);
|
||||
|
||||
#if defined(DEBUG_TRACE_BUFFER)
|
||||
void menuTraceBuffer(evt_t event);
|
||||
#endif
|
||||
|
||||
void drawSlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr);
|
||||
|
||||
void menuMainViewChannelsMonitor(evt_t event);
|
||||
void menuChannelsView(evt_t event);
|
||||
|
||||
extern int8_t checkIncDec_Ret; // global helper vars
|
||||
|
||||
#define EDIT_SELECT_MENU -1
|
||||
|
@ -200,36 +194,40 @@ int8_t checkIncDecMovedSwitch(int8_t val);
|
|||
#define CURSOR_ON_LINE() (m_posHorz<0)
|
||||
|
||||
#define CHECK_FLAG_NO_SCREEN_INDEX 1
|
||||
bool navigate(evt_t event, int count, int rows, int columns=1);
|
||||
bool check(check_event_t event, uint8_t curr, const MenuFuncP * menuTab, uint8_t menuTabSize, const pm_uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow, uint8_t flags=0);
|
||||
bool check_simple(check_event_t event, uint8_t curr, const MenuFuncP * menuTab, uint8_t menuTabSize, vertpos_t maxrow);
|
||||
bool check_submenu_simple(check_event_t event, uint8_t maxrow);
|
||||
|
||||
#define MENU_TAB(...) const uint8_t mstate_tab[] = __VA_ARGS__
|
||||
|
||||
void drawMenuTemplate(const char *title, evt_t event, uint16_t scrollbar_X=0);
|
||||
void drawShadow(coord_t x, coord_t y, coord_t w, coord_t h);
|
||||
void drawScreenTemplate(const char * title);
|
||||
void drawMenuTemplate(const char * title, uint16_t scrollbar_X=0);
|
||||
void drawSlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr);
|
||||
|
||||
#define MENU(title, tab, menu, lines_count, scrollbar_X, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) TRACE("Menu %s displayed ...", title); \
|
||||
if (!check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, lines_count)) return; \
|
||||
drawMenuTemplate(title, event, scrollbar_X); \
|
||||
if (!check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, lines_count)) return false; \
|
||||
drawMenuTemplate(title, scrollbar_X); \
|
||||
|
||||
#define SIMPLE_MENU(title, tab, menu, lines_count, scrollbar_X) \
|
||||
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) TRACE("Menu %s displayed ...", title); \
|
||||
if (!check_simple(event, menu, tab, DIM(tab), lines_count)) return; \
|
||||
drawMenuTemplate(title, event, scrollbar_X); \
|
||||
if (!check_simple(event, menu, tab, DIM(tab), lines_count)) return false; \
|
||||
drawMenuTemplate(title, scrollbar_X); \
|
||||
|
||||
#define SUBMENU(title, lines_count, scrollbar_X, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
if (!check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, lines_count)) return; \
|
||||
drawMenuTemplate(title, event, scrollbar_X);
|
||||
if (!check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, lines_count)) return false; \
|
||||
drawMenuTemplate(title, scrollbar_X);
|
||||
|
||||
#define SIMPLE_SUBMENU_NOTITLE(lines_count) \
|
||||
if (!check_submenu_simple(event, lines_count)) return
|
||||
if (!check_submenu_simple(event, lines_count)) return false
|
||||
|
||||
#define SIMPLE_SUBMENU(title, lines_count, scrollbar_X) \
|
||||
SIMPLE_SUBMENU_NOTITLE(lines_count); \
|
||||
drawMenuTemplate(title, event, scrollbar_X)
|
||||
drawMenuTemplate(title, scrollbar_X)
|
||||
|
||||
typedef int select_menu_value_t;
|
||||
|
||||
|
@ -250,7 +248,7 @@ int8_t switchMenuItem(coord_t x, coord_t y, int8_t value, LcdFlags attr, evt_t e
|
|||
#define displayGVar(x, y, v, min, max) GVAR_MENU_ITEM(x, y, v, min, max, 0, 0, 0)
|
||||
#else
|
||||
int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, evt_t event);
|
||||
#define displayGVar(x, y, v, min, max) lcd_outdez8(x, y, v)
|
||||
#define displayGVar(x, y, v, min, max) lcdDrawNumber(x, y, v)
|
||||
#endif
|
||||
|
||||
void editName(coord_t x, coord_t y, char *name, uint8_t size, evt_t event, uint8_t active);
|
||||
|
@ -272,9 +270,9 @@ extern uint8_t s_warning_type;
|
|||
#define POPUP_W 300
|
||||
#define POPUP_H 130
|
||||
#define WARNING_LINE_LEN 32
|
||||
#define WARNING_LINE_X (POPUP_X+86)
|
||||
#define WARNING_LINE_X (POPUP_X+76)
|
||||
#define WARNING_LINE_Y (POPUP_Y+9)
|
||||
#define WARNING_INFOLINE_Y (WARNING_LINE_Y+64)
|
||||
#define WARNING_INFOLINE_Y (WARNING_LINE_Y+68)
|
||||
|
||||
void displayBox();
|
||||
void displayPopup(const char *title);
|
||||
|
@ -308,12 +306,9 @@ extern void (*menuHandler)(const char *result);
|
|||
|
||||
#define TEXT_FILENAME_MAXLEN 40
|
||||
extern char s_text_file[TEXT_FILENAME_MAXLEN];
|
||||
void menuTextView(evt_t event);
|
||||
void pushMenuTextView(const char *filename);
|
||||
void pushModelNotes();
|
||||
|
||||
void menuChannelsView(evt_t event);
|
||||
|
||||
#define LABEL(...) (uint8_t)-1
|
||||
|
||||
#define CURSOR_MOVED_LEFT(event) (event==EVT_ROTARY_LEFT || EVT_KEY_MASK(event) == KEY_LEFT)
|
||||
|
|
|
@ -222,6 +222,73 @@ uint8_t menuPageIndex;
|
|||
uint8_t menuPageCount;
|
||||
uint16_t linesCount;
|
||||
|
||||
bool navigate(evt_t event, int count, int rows, int columns)
|
||||
{
|
||||
int prevPosHorz = m_posHorz;
|
||||
int prevPosVert = m_posVert;
|
||||
|
||||
int maxrow = ((count+columns-1) / columns) - 1;
|
||||
int maxlastcol = count-maxrow*columns-1;
|
||||
int maxcol = (m_posVert != maxrow ? columns-1 : maxlastcol);
|
||||
|
||||
switch (event) {
|
||||
case EVT_KEY_FIRST(KEY_RIGHT):
|
||||
case EVT_KEY_REPT(KEY_RIGHT):
|
||||
INC(m_posHorz, 0, maxcol);
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_LEFT):
|
||||
case EVT_KEY_REPT(KEY_LEFT):
|
||||
DEC(m_posHorz, 0, maxcol);
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_DOWN):
|
||||
case EVT_KEY_REPT(KEY_DOWN):
|
||||
INC(m_posVert, 0, maxrow);
|
||||
if (m_posVert == maxrow && m_posHorz > maxlastcol) {
|
||||
m_posHorz = maxlastcol;
|
||||
}
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
case EVT_KEY_REPT(KEY_UP):
|
||||
DEC(m_posVert, 0, maxrow);
|
||||
if (m_posVert == maxrow && m_posHorz > maxlastcol) {
|
||||
m_posHorz = maxlastcol;
|
||||
}
|
||||
break;
|
||||
|
||||
case EVT_ROTARY_LEFT:
|
||||
if (m_posHorz > 0) {
|
||||
m_posHorz--;
|
||||
}
|
||||
else {
|
||||
DEC(m_posVert, 0, maxrow);
|
||||
m_posHorz = (m_posVert != maxrow ? columns-1 : maxlastcol);
|
||||
}
|
||||
break;
|
||||
|
||||
case EVT_ROTARY_RIGHT:
|
||||
if (m_posHorz < maxcol) {
|
||||
m_posHorz++;
|
||||
}
|
||||
else {
|
||||
INC(m_posVert, 0, maxrow);
|
||||
m_posHorz = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (s_pgOfs > m_posVert) {
|
||||
s_pgOfs = m_posVert;
|
||||
}
|
||||
else if (s_pgOfs <= m_posVert - rows) {
|
||||
s_pgOfs = m_posVert - rows + 1;
|
||||
}
|
||||
|
||||
return (prevPosHorz != m_posHorz || prevPosVert != m_posVert);
|
||||
}
|
||||
|
||||
bool check(check_event_t event, uint8_t curr, const MenuFuncP * menuTab, uint8_t menuTabSize, const pm_uint8_t * horTab, uint8_t horTabMax, vertpos_t rowcount, uint8_t flags)
|
||||
{
|
||||
uint8_t maxcol = MAXCOL(m_posVert);
|
||||
|
|
|
@ -48,7 +48,7 @@ int16_t s_warning_input_max;
|
|||
|
||||
void displayAlertBox()
|
||||
{
|
||||
lcdDrawBlackOverlay();
|
||||
lcdClear();
|
||||
lcdDrawSolidFilledRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, TEXT_BGCOLOR);
|
||||
lcdDrawRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, SOLID, ALARM_COLOR);
|
||||
lcdDrawRect(POPUP_X+1, POPUP_Y+1, POPUP_W-2, POPUP_H-2, SOLID, ALARM_COLOR);
|
||||
|
@ -57,7 +57,7 @@ void displayAlertBox()
|
|||
|
||||
void displayWarningBox()
|
||||
{
|
||||
lcdDrawBlackOverlay();
|
||||
// lcdDrawBlackOverlay();
|
||||
lcdDrawSolidFilledRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, TEXT_BGCOLOR);
|
||||
lcdDrawRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, SOLID, ALARM_COLOR);
|
||||
lcdDrawRect(POPUP_X+1, POPUP_Y+1, POPUP_W-2, POPUP_H-2, SOLID, ALARM_COLOR);
|
||||
|
@ -66,7 +66,7 @@ void displayWarningBox()
|
|||
|
||||
void displayMessageBox()
|
||||
{
|
||||
lcdDrawBlackOverlay();
|
||||
// lcdDrawBlackOverlay();
|
||||
lcdDrawSolidFilledRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, TEXT_BGCOLOR);
|
||||
lcdDrawRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, SOLID, WARNING_COLOR);
|
||||
lcdDrawRect(POPUP_X+1, POPUP_Y+1, POPUP_W-2, POPUP_H-2, SOLID, WARNING_COLOR);
|
||||
|
@ -85,9 +85,9 @@ void message(const pm_char *title, const pm_char *t, const char *last MESSAGE_SO
|
|||
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+25, STR_WARNING, ALARM_COLOR|DBLSIZE);
|
||||
#endif
|
||||
|
||||
if (t) lcd_puts(WARNING_LINE_X, WARNING_INFOLINE_Y, t);
|
||||
if (t) lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y, t);
|
||||
if (last) {
|
||||
lcd_puts(WARNING_LINE_X, WARNING_INFOLINE_Y+12, last);
|
||||
lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y+16, last);
|
||||
AUDIO_ERROR_MESSAGE(sound);
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ void message(const pm_char *title, const pm_char *t, const char *last MESSAGE_SO
|
|||
|
||||
void displayPopup(const char *title)
|
||||
{
|
||||
displayMessageBox();
|
||||
// displayMessageBox();
|
||||
lcdDrawTextWithLen(WARNING_LINE_X, WARNING_LINE_Y, title, WARNING_LINE_LEN, DBLSIZE|WARNING_COLOR);
|
||||
lcdRefresh();
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ void displayWarning(evt_t event)
|
|||
if (s_warning_info) {
|
||||
lcdDrawTextWithLen(WARNING_LINE_X, WARNING_INFOLINE_Y, s_warning_info, s_warning_info_len, WARNING_INFO_FLAGS);
|
||||
}
|
||||
lcd_puts(WARNING_LINE_X, WARNING_INFOLINE_Y+12, s_warning_type == WARNING_TYPE_ASTERISK ? STR_EXIT : STR_POPUPS);
|
||||
lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y+20, s_warning_type == WARNING_TYPE_ASTERISK ? STR_EXIT : STR_POPUPS);
|
||||
switch (event) {
|
||||
case EVT_KEY_BREAK(KEY_ENTER):
|
||||
if (s_warning_type == WARNING_TYPE_ASTERISK)
|
||||
|
@ -146,25 +146,6 @@ const char * displayMenu(evt_t event)
|
|||
{
|
||||
const char * result = NULL;
|
||||
uint8_t display_count = min(s_menu_count, (uint16_t)MENU_MAX_LINES);
|
||||
int y = (LCD_H - (display_count*(FH+1))) / 2;
|
||||
|
||||
lcdDrawBlackOverlay();
|
||||
lcdDrawSolidFilledRect(MENU_X, y, MENU_W, display_count * (FH+1), TEXT_BGCOLOR);
|
||||
lcdDrawSolidRect(MENU_X, y, MENU_W, display_count * (FH+1) + 1, ALARM_COLOR);
|
||||
|
||||
for (uint8_t i=0; i<display_count; i++) {
|
||||
if (i == s_menu_item) {
|
||||
lcdDrawSolidFilledRect(MENU_X+1, i*(FH+1) + y + 1, MENU_W-2, FH+1, TEXT_INVERTED_BGCOLOR);
|
||||
lcdDrawText(MENU_X+6, i*(FH+1) + y + 5, s_menu[i], TEXT_INVERTED_COLOR|s_menu_flags);
|
||||
}
|
||||
else {
|
||||
lcdDrawText(MENU_X+6, i*(FH+1) + y + 5, s_menu[i], s_menu_flags);
|
||||
}
|
||||
}
|
||||
|
||||
if (s_menu_count > display_count) {
|
||||
drawScrollbar(MENU_X+MENU_W-1, y+1, MENU_MAX_LINES * (FH+1), s_menu_offset, s_menu_count, MENU_MAX_LINES);
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case EVT_ROTARY_LEFT:
|
||||
|
@ -215,5 +196,25 @@ const char * displayMenu(evt_t event)
|
|||
break;
|
||||
}
|
||||
|
||||
int y = (LCD_H - (display_count*(FH+1))) / 2;
|
||||
|
||||
// lcdDrawBlackOverlay();
|
||||
lcdDrawSolidFilledRect(MENU_X, y, MENU_W, display_count * (FH+1), TEXT_BGCOLOR);
|
||||
lcdDrawSolidRect(MENU_X, y, MENU_W, display_count * (FH+1) + 1, ALARM_COLOR);
|
||||
|
||||
for (uint8_t i=0; i<display_count; i++) {
|
||||
if (i == s_menu_item) {
|
||||
lcdDrawSolidFilledRect(MENU_X+1, i*(FH+1) + y + 1, MENU_W-2, FH+1, TEXT_INVERTED_BGCOLOR);
|
||||
lcdDrawText(MENU_X+6, i*(FH+1) + y + 5, s_menu[i], TEXT_INVERTED_COLOR|s_menu_flags);
|
||||
}
|
||||
else {
|
||||
lcdDrawText(MENU_X+6, i*(FH+1) + y + 5, s_menu[i], s_menu_flags);
|
||||
}
|
||||
}
|
||||
|
||||
if (s_menu_count > display_count) {
|
||||
drawScrollbar(MENU_X+MENU_W-1, y+1, MENU_MAX_LINES * (FH+1), s_menu_offset, s_menu_count, MENU_MAX_LINES);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include "../../opentx.h"
|
||||
|
||||
const uint16_t LBM_SPLASH[] = {
|
||||
const uint8_t LBM_SPLASH[] = {
|
||||
#include "../../bitmaps/Horus/splash.lbm"
|
||||
};
|
||||
|
||||
|
@ -50,7 +50,7 @@ void displaySplash()
|
|||
#if MENUS_LOCK == 1
|
||||
if (readonly == false) {
|
||||
lcdDrawSolidFilledRect((LCD_W-(sizeof(TR_UNLOCKED)-1)*FW)/2 - 9, 50, (sizeof(TR_UNLOCKED)-1)*FW+16, 11, SOLID, ERASE|ROUND);
|
||||
lcd_puts((LCD_W-(sizeof(TR_UNLOCKED)-1)*FW)/2 , 53, STR_UNLOCKED);
|
||||
lcdDrawText((LCD_W-(sizeof(TR_UNLOCKED)-1)*FW)/2 , 53, STR_UNLOCKED);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ enum AboutScreens {
|
|||
#define ABOUT_X 62
|
||||
#define ABOUT_INDENT 16
|
||||
|
||||
void menuAboutView(evt_t event)
|
||||
bool menuAboutView(evt_t event)
|
||||
{
|
||||
static uint8_t screenIndex = 0;
|
||||
static uint8_t greyIndex = 0;
|
||||
|
@ -78,74 +78,74 @@ void menuAboutView(evt_t event)
|
|||
break;
|
||||
}
|
||||
|
||||
drawMenuTemplate("About", event);
|
||||
drawScreenTemplate("About");
|
||||
|
||||
uint8_t screenDuration = 150;
|
||||
|
||||
switch (screenIndex) {
|
||||
case ABOUT_OPENTX:
|
||||
case ABOUT_END:
|
||||
lcd_puts(ABOUT_X, MENU_HEADER_HEIGHT+1, STR_ABOUT_OPENTX_1);
|
||||
lcd_puts(ABOUT_X, MENU_CONTENT_TOP + FH, STR_ABOUT_OPENTX_2);
|
||||
lcd_puts(ABOUT_X, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_OPENTX_3);
|
||||
lcd_puts(ABOUT_X, MENU_CONTENT_TOP + 3*FH, STR_ABOUT_OPENTX_4);
|
||||
lcd_puts(ABOUT_X, MENU_CONTENT_TOP + 4*FH, STR_ABOUT_OPENTX_5);
|
||||
lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_OPENTX_1);
|
||||
lcdDrawText(ABOUT_X, MENU_CONTENT_TOP + FH, STR_ABOUT_OPENTX_2);
|
||||
lcdDrawText(ABOUT_X, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_OPENTX_3);
|
||||
lcdDrawText(ABOUT_X, MENU_CONTENT_TOP + 3*FH, STR_ABOUT_OPENTX_4);
|
||||
lcdDrawText(ABOUT_X, MENU_CONTENT_TOP + 4*FH, STR_ABOUT_OPENTX_5);
|
||||
screenDuration = 255;
|
||||
break;
|
||||
|
||||
case ABOUT_BERTRAND:
|
||||
lcdDrawText(ABOUT_X, MENU_HEADER_HEIGHT+1, STR_ABOUT_BERTRAND_1, INVERS);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_BERTRAND_2);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_BERTRAND_3);
|
||||
lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_BERTRAND_1, INVERS);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_BERTRAND_2);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_BERTRAND_3);
|
||||
break;
|
||||
|
||||
case ABOUT_ANDRE:
|
||||
lcdDrawText(ABOUT_X, MENU_HEADER_HEIGHT+1, STR_ABOUT_ANDRE_1, INVERS);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_ANDRE_2);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_ANDRE_3);
|
||||
lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_ANDRE_1, INVERS);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_ANDRE_2);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_ANDRE_3);
|
||||
break;
|
||||
|
||||
case ABOUT_MIKE:
|
||||
lcdDrawText(ABOUT_X, MENU_HEADER_HEIGHT+1, STR_ABOUT_MIKE_1, INVERS);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_MIKE_2);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_MIKE_3);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 3*FH, STR_ABOUT_MIKE_4);
|
||||
lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_MIKE_1, INVERS);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_MIKE_2);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_MIKE_3);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 3*FH, STR_ABOUT_MIKE_4);
|
||||
break;
|
||||
|
||||
case ABOUT_KJELL:
|
||||
lcdDrawText(ABOUT_X, MENU_HEADER_HEIGHT+1, STR_ABOUT_KJELL_1, INVERS);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_KJELL_2);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_KJELL_3);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 3*FH, STR_ABOUT_KJELL_4);
|
||||
lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_KJELL_1, INVERS);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_KJELL_2);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_KJELL_3);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 3*FH, STR_ABOUT_KJELL_4);
|
||||
break;
|
||||
|
||||
case ABOUT_MARTIN:
|
||||
lcdDrawText(ABOUT_X, MENU_HEADER_HEIGHT+1, STR_ABOUT_MARTIN_1, INVERS);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_MARTIN_2);
|
||||
lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_MARTIN_1, INVERS);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_MARTIN_2);
|
||||
break;
|
||||
|
||||
case ABOUT_ROMOLO:
|
||||
lcdDrawText(ABOUT_X, MENU_HEADER_HEIGHT+1, STR_ABOUT_ROMOLO_1, INVERS);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_ROMOLO_2);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_ROMOLO_3);
|
||||
lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_ROMOLO_1, INVERS);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_ROMOLO_2);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_ROMOLO_3);
|
||||
break;
|
||||
|
||||
case ABOUT_ROB:
|
||||
lcdDrawText(ABOUT_X, MENU_HEADER_HEIGHT+1, STR_ABOUT_ROB_1, INVERS);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_ROB_2);
|
||||
lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_ROB_1, INVERS);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_ROB_2);
|
||||
break;
|
||||
|
||||
case ABOUT_HARDWARE:
|
||||
lcdDrawText(ABOUT_X, MENU_HEADER_HEIGHT+1, "FrSky", INVERS);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_HARDWARE_2);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_HARDWARE_3);
|
||||
lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, "FrSky", INVERS);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_HARDWARE_2);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_HARDWARE_3);
|
||||
break;
|
||||
|
||||
case ABOUT_PARENTS:
|
||||
lcdDrawText(ABOUT_X, MENU_HEADER_HEIGHT+1, STR_ABOUT_PARENTS_1, INVERS);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_PARENTS_2);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_PARENTS_3);
|
||||
lcd_puts(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 3*FH, STR_ABOUT_PARENTS_4);
|
||||
lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_PARENTS_1, INVERS);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_PARENTS_2);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_PARENTS_3);
|
||||
lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 3*FH, STR_ABOUT_PARENTS_4);
|
||||
screenDuration = 255;
|
||||
break;
|
||||
}
|
||||
|
@ -156,4 +156,6 @@ void menuAboutView(evt_t event)
|
|||
chainMenu(menuMainView);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
bool isChannelUsed(int channel);
|
||||
int getChannelsUsed();
|
||||
|
||||
void menuChannelsView(evt_t event)
|
||||
bool menuChannelsView(evt_t event)
|
||||
{
|
||||
const int CHANNEL_MARGIN = 16;
|
||||
const int CHANNEL_HEIGHT = 25;
|
||||
|
@ -110,13 +110,15 @@ void menuChannelsView(evt_t event)
|
|||
// Value
|
||||
#if defined(PPM_UNIT_US)
|
||||
uint8_t wbar = (longNames ? 54 : 64);
|
||||
lcd_outdezAtt(x+LCD_W/2-3-wbar-ofs, y+1, PPM_CH_CENTER(ch)+val/2, TINSIZE);
|
||||
lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, PPM_CH_CENTER(ch)+val/2, TINSIZE);
|
||||
#elif defined(PPM_UNIT_PERCENT_PREC1)
|
||||
uint8_t wbar = (longNames ? 48 : 58);
|
||||
lcd_outdezAtt(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val), PREC1|TINSIZE);
|
||||
lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val), PREC1|TINSIZE);
|
||||
#else
|
||||
uint8_t wbar = (longNames ? 54 : 64);
|
||||
lcd_outdezAtt(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val)/10, TINSIZE); // G: Don't like the decimal part*
|
||||
lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val)/10, TINSIZE); // G: Don't like the decimal part*
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,16 @@
|
|||
#define TRIM_H_Y 235
|
||||
#define TRIM_LEN 80
|
||||
|
||||
#define MODELPANEL_LEFT 240
|
||||
#define MODELPANEL_TOP 68
|
||||
#define MODELPANEL_WIDTH MODEL_BITMAP_WIDTH
|
||||
#define MODELPANEL_HEIGHT 135
|
||||
|
||||
#define TIMER1PANEL_LEFT 46
|
||||
#define TIMER1PANEL_TOP 55
|
||||
#define TIMER2PANEL_LEFT TIMER1PANEL_LEFT
|
||||
#define TIMER2PANEL_TOP 134
|
||||
|
||||
void drawTrimSquare(coord_t x, coord_t y)
|
||||
{
|
||||
lcdDrawSolidFilledRect(x-2, y, 15, 15, TITLE_BGCOLOR);
|
||||
|
@ -140,7 +150,7 @@ void drawTrims(uint8_t flightMode)
|
|||
drawVerticalTrimPosition(xm-1, ym-6, val);
|
||||
if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && trim != 0) {
|
||||
if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS || (trimsDisplayTimer > 0 && (trimsDisplayMask & (1<<i)))) {
|
||||
// TODO lcd_outdezAtt(trim>0 ? 100 : 200, xm-2, trim, TINSIZE|VERTICAL);
|
||||
// TODO lcdDrawNumber(trim>0 ? 100 : 200, xm-2, trim, TINSIZE|VERTICAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +161,7 @@ void drawTrims(uint8_t flightMode)
|
|||
drawHorizontalTrimPosition(xm-3, ym-2, val);
|
||||
if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && trim != 0) {
|
||||
if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS || (trimsDisplayTimer > 0 && (trimsDisplayMask & (1<<i)))) {
|
||||
lcd_outdezAtt((stickIndex==0 ? TRIM_LH_X : TRIM_RH_X)+(trim>0 ? -20 : 50), ym+2, trim, TINSIZE);
|
||||
lcdDrawNumber((stickIndex==0 ? TRIM_LH_X : TRIM_RH_X)+(trim>0 ? -20 : 50), ym+2, trim, TINSIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,11 +176,11 @@ void drawTimer(coord_t x, coord_t y, int index)
|
|||
if (timerData.start) {
|
||||
lcdDrawBitmapPatternPie(x+2, y+3, LBM_RSCALE, TITLE_BGCOLOR, 0, timerState.val <= 0 ? 360 : 360*(timerData.start-timerState.val)/timerData.start);
|
||||
}
|
||||
putsTimer(x+74, y+31, abs(timerState.val), TEXT_COLOR|DBLSIZE|LEFT);
|
||||
putsTimer(x+76, y+31, abs(timerState.val), TEXT_COLOR|DBLSIZE|LEFT);
|
||||
if (ZLEN(timerData.name) > 0) {
|
||||
lcdDrawTextWithLen(x+74, y+20, timerData.name, LEN_TIMER_NAME, ZCHAR|SMLSIZE|TEXT_COLOR);
|
||||
lcdDrawTextWithLen(x+78, y+20, timerData.name, LEN_TIMER_NAME, ZCHAR|SMLSIZE|TEXT_COLOR);
|
||||
}
|
||||
putsStrIdx(x+137, y+17, "TMR", 1, SMLSIZE|TEXT_COLOR);
|
||||
putsStrIdx(x+137, y+17, "TMR", index+1, SMLSIZE|TEXT_COLOR);
|
||||
}
|
||||
|
||||
|
||||
|
@ -280,16 +290,7 @@ void onMainViewMenu(const char *result)
|
|||
}
|
||||
}
|
||||
|
||||
const uint16_t LBM_MAINVIEW_FLAT[] = {
|
||||
#include "../../bitmaps/Horus/mainview_flat.lbm"
|
||||
};
|
||||
|
||||
const uint16_t LBM_CORSAIR[] = {
|
||||
#include "../../bitmaps/Horus/corsair.lbm"
|
||||
};
|
||||
|
||||
|
||||
void menuMainView(evt_t event)
|
||||
bool menuMainView(evt_t event)
|
||||
{
|
||||
switch (event) {
|
||||
case EVT_ENTRY:
|
||||
|
@ -298,6 +299,10 @@ void menuMainView(evt_t event)
|
|||
killEvents(KEY_DOWN);
|
||||
break;
|
||||
|
||||
case EVT_ENTRY_UP:
|
||||
LOAD_MODEL_BITMAP();
|
||||
break;
|
||||
|
||||
case EVT_KEY_LONG(KEY_ENTER):
|
||||
killEvents(event);
|
||||
MENU_ADD_ITEM(STR_MODEL_SELECT);
|
||||
|
@ -341,14 +346,13 @@ void menuMainView(evt_t event)
|
|||
}
|
||||
|
||||
lcdDrawBitmap(0, 0, LBM_MAINVIEW_BACKGROUND);
|
||||
// lcdDrawBitmap(0, 0, LBM_MAINVIEW_FLAT);
|
||||
|
||||
// Header
|
||||
lcdDrawSolidFilledRect(0, 0, LCD_W, MENU_HEADER_HEIGHT, HEADER_BGCOLOR);
|
||||
lcdDrawBitmapPattern(0, 0, LBM_TOPMENU_POLYGON, TITLE_BGCOLOR);
|
||||
lcdDrawBitmapPattern(4, 10, LBM_TOPMENU_OPENTX, MENU_TITLE_COLOR);
|
||||
drawTopmenuDatetime();
|
||||
if (1 || usbPlugged()) {
|
||||
if (usbPlugged()) {
|
||||
lcdDrawBitmapPattern(378, 8, LBM_TOPMENU_USB, MENU_TITLE_COLOR);
|
||||
}
|
||||
const uint8_t rssiBarsValue[] = { 30, 40, 50, 60, 80 };
|
||||
|
@ -358,7 +362,6 @@ void menuMainView(evt_t event)
|
|||
lcdDrawSolidFilledRect(390+i*6, 38-height, 4, height, TELEMETRY_RSSI() >= rssiBarsValue[i] ? MENU_TITLE_COLOR : MENU_TITLE_DISABLE_COLOR);
|
||||
}
|
||||
|
||||
|
||||
// Flight Mode Name
|
||||
int mode = mixerCurrentFlightMode;
|
||||
for (int i=0; i<MAX_FLIGHT_MODES; i++) {
|
||||
|
@ -375,15 +378,21 @@ void menuMainView(evt_t event)
|
|||
drawTrims(mode);
|
||||
|
||||
// Model panel
|
||||
lcdDrawFilledRect(248, 58, 188, 158, SOLID, TEXT_BGCOLOR | OPACITY(5));
|
||||
lcdDrawBitmapPattern(256, 62, LBM_MODEL_ICON, TITLE_BGCOLOR);
|
||||
lcdDrawTextWithLen(293, 68, g_model.header.name, LEN_MODEL_NAME, ZCHAR|SMLSIZE);
|
||||
lcdDrawSolidHorizontalLine(287, 85, 140, TITLE_BGCOLOR);
|
||||
lcdDrawBitmap(256, 104, LBM_CORSAIR);
|
||||
lcdDrawFilledRect(MODELPANEL_LEFT, MODELPANEL_TOP, MODELPANEL_WIDTH, MODELPANEL_HEIGHT, SOLID, TEXT_BGCOLOR | OPACITY(5));
|
||||
lcdDrawBitmapPattern(MODELPANEL_LEFT+6, MODELPANEL_TOP+4, LBM_MODEL_ICON, TITLE_BGCOLOR);
|
||||
lcdDrawTextWithLen(MODELPANEL_LEFT+45, MODELPANEL_TOP+10, g_model.header.name, LEN_MODEL_NAME, ZCHAR|SMLSIZE);
|
||||
lcdDrawSolidHorizontalLine(MODELPANEL_LEFT+39, MODELPANEL_TOP+27, MODELPANEL_WIDTH-48, TITLE_BGCOLOR);
|
||||
int scale = getBitmapScale(modelBitmap, MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT);
|
||||
int width = getBitmapScaledSize(getBitmapWidth(modelBitmap), scale);
|
||||
int height = getBitmapScaledSize(getBitmapHeight(modelBitmap), scale);
|
||||
lcdDrawBitmap(MODELPANEL_LEFT+(MODEL_BITMAP_WIDTH-width)/2, MODELPANEL_TOP+MODELPANEL_HEIGHT-MODEL_BITMAP_HEIGHT/2-height/2, modelBitmap, 0, 0, scale);
|
||||
|
||||
// Timer 1
|
||||
// Timers
|
||||
if (g_model.timers[0].mode) {
|
||||
drawTimer(50, 61, 0);
|
||||
drawTimer(TIMER1PANEL_LEFT, TIMER1PANEL_TOP, 0);
|
||||
}
|
||||
if (g_model.timers[1].mode) {
|
||||
drawTimer(TIMER2PANEL_LEFT, TIMER2PANEL_TOP, 1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -392,18 +401,20 @@ void menuMainView(evt_t event)
|
|||
displayMessageBox();
|
||||
putsStrIdx(WARNING_LINE_X, WARNING_LINE_Y, STR_GV, s_gvar_last+1, DBLSIZE|YELLOW);
|
||||
lcdDrawTextWithLen(WARNING_LINE_X+45, WARNING_LINE_Y, g_model.gvars[s_gvar_last].name, LEN_GVAR_NAME, DBLSIZE|YELLOW|ZCHAR);
|
||||
lcd_outdezAtt(WARNING_LINE_X, WARNING_INFOLINE_Y, GVAR_VALUE(s_gvar_last, getGVarFlightPhase(mixerCurrentFlightMode, s_gvar_last)), DBLSIZE|LEFT);
|
||||
lcdDrawNumber(WARNING_LINE_X, WARNING_INFOLINE_Y, GVAR_VALUE(s_gvar_last, getGVarFlightPhase(mixerCurrentFlightMode, s_gvar_last)), DBLSIZE|LEFT);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void menuMainViewChannelsMonitor(evt_t event)
|
||||
bool menuMainViewChannelsMonitor(evt_t event)
|
||||
{
|
||||
switch (event) {
|
||||
case EVT_KEY_BREAK(KEY_EXIT):
|
||||
chainMenu(menuMainView);
|
||||
event = 0;
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
|
||||
return menuChannelsView(event);
|
||||
|
|
|
@ -36,12 +36,12 @@
|
|||
|
||||
#include "../../opentx.h"
|
||||
|
||||
void menuStatisticsView(evt_t event)
|
||||
bool menuStatisticsView(evt_t event)
|
||||
{
|
||||
switch(event) {
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
chainMenu(menuStatisticsDebug);
|
||||
return;
|
||||
return false;
|
||||
|
||||
case EVT_KEY_LONG(KEY_MENU):
|
||||
g_eeGeneral.globalTimer = 0;
|
||||
|
@ -51,10 +51,10 @@ void menuStatisticsView(evt_t event)
|
|||
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
chainMenu(menuMainView);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
drawMenuTemplate("Statistics", event);
|
||||
drawScreenTemplate("Statistics");
|
||||
|
||||
lcdDrawText( 10, MENU_CONTENT_TOP + FH*0, "\037\145TOT:\037\317BATT:", HEADER_COLOR);
|
||||
lcdDrawText( 10, MENU_CONTENT_TOP + FH*1, "TM1:\037\145TM2:", HEADER_COLOR);
|
||||
|
@ -84,6 +84,8 @@ void menuStatisticsView(evt_t event)
|
|||
if (traceRd==s_traceWr) break;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define MENU_DEBUG_COL1_OFS (11*10-2)
|
||||
|
@ -93,10 +95,8 @@ void menuStatisticsView(evt_t event)
|
|||
#define MENU_DEBUG_Y_STACK (MENU_CONTENT_TOP + 5*FH)
|
||||
#define MENU_DEBUG_Y_RTOS (MENU_CONTENT_TOP + 6*FH)
|
||||
|
||||
void menuStatisticsDebug(evt_t event)
|
||||
bool menuStatisticsDebug(evt_t event)
|
||||
{
|
||||
drawMenuTemplate(STR_MENUDEBUG, event);
|
||||
|
||||
switch(event)
|
||||
{
|
||||
case EVT_KEY_LONG(KEY_ENTER):
|
||||
|
@ -107,6 +107,7 @@ void menuStatisticsDebug(evt_t event)
|
|||
killEvents(event);
|
||||
AUDIO_KEYPAD_UP();
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_ENTER):
|
||||
#if defined(LUA)
|
||||
maxLuaInterval = 0;
|
||||
|
@ -119,48 +120,52 @@ void menuStatisticsDebug(evt_t event)
|
|||
#if defined(DEBUG_TRACE_BUFFER)
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
pushMenu(menuTraceBuffer);
|
||||
return;
|
||||
return false;
|
||||
#endif
|
||||
|
||||
case EVT_KEY_FIRST(KEY_DOWN):
|
||||
chainMenu(menuStatisticsView);
|
||||
break;
|
||||
return false;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
chainMenu(menuMainView);
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
|
||||
drawScreenTemplate(STR_MENUDEBUG);
|
||||
|
||||
lcd_putsLeft(MENU_DEBUG_Y_FREE_RAM, "Free Mem");
|
||||
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_FREE_RAM, availableMemory(), LEFT, "b");
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_FREE_RAM, availableMemory(), LEFT, 0, NULL, "b");
|
||||
|
||||
#if defined(LUA)
|
||||
lcd_putsLeft(MENU_DEBUG_Y_LUA, "Lua scripts");
|
||||
lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_LUA+1, "[Duration]", HEADER_COLOR|SMLSIZE);
|
||||
lcd_outdezAtt(MENU_DEBUG_COL1_OFS+30, MENU_DEBUG_Y_LUA, 10*maxLuaDuration, LEFT);
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS+30, MENU_DEBUG_Y_LUA, 10*maxLuaDuration, LEFT);
|
||||
lcdDrawText(MENU_DEBUG_COL1_OFS+60, MENU_DEBUG_Y_LUA+1, "[Interval]", HEADER_COLOR|SMLSIZE);
|
||||
lcd_outdezAtt(MENU_DEBUG_COL1_OFS+90, MENU_DEBUG_Y_LUA, 10*maxLuaInterval, LEFT);
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS+90, MENU_DEBUG_Y_LUA, 10*maxLuaInterval, LEFT);
|
||||
#endif
|
||||
|
||||
lcd_putsLeft(MENU_DEBUG_Y_MIXMAX, STR_TMIXMAXMS);
|
||||
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MIXMAX, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT, "ms");
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MIXMAX, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT, 0, NULL, "ms");
|
||||
|
||||
lcd_putsLeft(MENU_DEBUG_Y_RTOS, STR_FREESTACKMINB);
|
||||
lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS+1, "[Menus]", HEADER_COLOR|SMLSIZE);
|
||||
lcd_outdezAtt(MENU_DEBUG_COL1_OFS+30, MENU_DEBUG_Y_RTOS, menusStack.available(), LEFT);
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS+30, MENU_DEBUG_Y_RTOS, menusStack.available(), LEFT);
|
||||
lcdDrawText(MENU_DEBUG_COL1_OFS+60, MENU_DEBUG_Y_RTOS+1, "[Mix]", HEADER_COLOR|SMLSIZE);
|
||||
lcd_outdezAtt(MENU_DEBUG_COL1_OFS+90, MENU_DEBUG_Y_RTOS, mixerStack.available(), LEFT);
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS+90, MENU_DEBUG_Y_RTOS, mixerStack.available(), LEFT);
|
||||
lcdDrawText(MENU_DEBUG_COL1_OFS+120, MENU_DEBUG_Y_RTOS+1, "[Audio]", HEADER_COLOR|SMLSIZE);
|
||||
lcd_outdezAtt(MENU_DEBUG_COL1_OFS+150, MENU_DEBUG_Y_RTOS, audioStack.available(), LEFT);
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS+150, MENU_DEBUG_Y_RTOS, audioStack.available(), LEFT);
|
||||
|
||||
lcd_putsCenter(7*FH+1, STR_MENUTORESET);
|
||||
// lcd_status_line();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(DEBUG_TRACE_BUFFER)
|
||||
#include "stamp-opentx.h"
|
||||
|
||||
void menuTraceBuffer(evt_t event)
|
||||
bool menuTraceBuffer(evt_t event)
|
||||
{
|
||||
switch(event)
|
||||
{
|
||||
|
@ -171,6 +176,7 @@ void menuTraceBuffer(evt_t event)
|
|||
}
|
||||
|
||||
SIMPLE_SUBMENU("Trace Buffer " VERS_STR, TRACE_BUFFER_LEN);
|
||||
|
||||
/* RTC time */
|
||||
struct gtm t;
|
||||
gettime(&t);
|
||||
|
@ -181,16 +187,16 @@ void menuTraceBuffer(evt_t event)
|
|||
int8_t sub = m_posVert;
|
||||
|
||||
lcdDrawChar(0, FH, '#', TEXT_COLOR);
|
||||
lcd_puts(4*10, FH, "Time");
|
||||
lcd_puts(14*10, FH, "Event");
|
||||
lcd_puts(20*10, FH, "Data");
|
||||
lcdDrawText(4*10, FH, "Time");
|
||||
lcdDrawText(14*10, FH, "Event");
|
||||
lcdDrawText(20*10, FH, "Data");
|
||||
|
||||
for (uint8_t i=0; i<LCD_LINES-2; i++) {
|
||||
for (uint8_t i=0; i<NUM_BODY_LINES; i++) {
|
||||
y = 1 + (i+2)*FH;
|
||||
k = i+s_pgOfs;
|
||||
|
||||
// item
|
||||
lcd_outdezAtt(0, y, k, LEFT | (sub==k ? INVERS : 0));
|
||||
lcdDrawNumber(0, y, k, LEFT | (sub==k ? INVERS : 0));
|
||||
|
||||
const struct TraceElement * te = getTraceElement(k);
|
||||
if (te) {
|
||||
|
@ -198,7 +204,7 @@ void menuTraceBuffer(evt_t event)
|
|||
putstime_t tme = te->time % SECS_PER_DAY;
|
||||
putsTimer(4*10, y, tme, TIMEHOUR|LEFT);
|
||||
//event
|
||||
lcd_outdezNAtt(14*10, y, te->event, LEADING0|LEFT, 3);
|
||||
lcdDrawNumber(14*10, y, te->event, LEADING0|LEFT, 3);
|
||||
//data
|
||||
lcd_putsn (20*10, y, "0x", 2);
|
||||
lcd_outhex4(22*10-2, y, (uint16_t)(te->data >> 16));
|
||||
|
@ -207,6 +213,6 @@ void menuTraceBuffer(evt_t event)
|
|||
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif //#if defined(DEBUG_TRACE_BUFFER)
|
||||
#endif // defined(DEBUG_TRACE_BUFFER)
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#define TEXT_FILE_MAXSIZE 2048
|
||||
|
||||
char s_text_file[TEXT_FILENAME_MAXLEN];
|
||||
char s_text_screen[LCD_LINES-1][LCD_COLS+1];
|
||||
char s_text_screen[NUM_BODY_LINES][LCD_COLS+1];
|
||||
|
||||
void readTextFile(int & lines_count)
|
||||
{
|
||||
|
@ -56,13 +56,13 @@ void readTextFile(int & lines_count)
|
|||
|
||||
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-s_pgOfs<LCD_LINES-1); i++) {
|
||||
for (int i=0; i<TEXT_FILE_MAXSIZE && f_read(&file, &c, 1, &sz)==FR_OK && sz==1 && (lines_count==0 || current_line-s_pgOfs<NUM_BODY_LINES); i++) {
|
||||
if (c == '\n') {
|
||||
++current_line;
|
||||
line_length = 0;
|
||||
escape = 0;
|
||||
}
|
||||
else if (c!='\r' && current_line>=s_pgOfs && current_line-s_pgOfs<LCD_LINES-1 && line_length<LCD_COLS) {
|
||||
else if (c!='\r' && current_line>=s_pgOfs && current_line-s_pgOfs<NUM_BODY_LINES && line_length<LCD_COLS) {
|
||||
if (c=='\\' && escape==0) {
|
||||
escape = 1;
|
||||
continue;
|
||||
|
@ -103,11 +103,11 @@ void readTextFile(int & lines_count)
|
|||
}
|
||||
}
|
||||
|
||||
void menuTextView(evt_t event)
|
||||
bool menuTextView(evt_t event)
|
||||
{
|
||||
static int lines_count;
|
||||
|
||||
drawMenuTemplate("TEXT VIEWER", event);
|
||||
drawMenuTemplate("TEXT VIEWER");
|
||||
|
||||
switch (event) {
|
||||
case EVT_ENTRY:
|
||||
|
@ -138,7 +138,7 @@ void menuTextView(evt_t event)
|
|||
}
|
||||
|
||||
for (int i=0; i<NUM_BODY_LINES; i++) {
|
||||
lcd_puts(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + i*FH, s_text_screen[i]);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + i*FH, s_text_screen[i]);
|
||||
}
|
||||
|
||||
char *title = s_text_file;
|
||||
|
@ -147,9 +147,9 @@ void menuTextView(evt_t event)
|
|||
#endif
|
||||
lcd_putsCenter(MENU_FOOTER_TOP, title, HEADER_COLOR);
|
||||
|
||||
if (lines_count > NUM_BODY_LINES) {
|
||||
drawScrollbar(LCD_W-5, 30, MENU_FOOTER_TOP-34, s_pgOfs, lines_count, NUM_BODY_LINES);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void pushMenuTextView(const char *filename)
|
||||
|
|
|
@ -106,6 +106,7 @@ void drawCheckBox(coord_t x, coord_t y, uint8_t value, LcdFlags attr)
|
|||
|
||||
void drawScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible)
|
||||
{
|
||||
if (visible < count) {
|
||||
lcdDrawSolidVerticalLine(x, y, h, LINE_COLOR);
|
||||
coord_t yofs = (h*offset + count/2) / count;
|
||||
coord_t yhgt = (h*visible + count/2) / count;
|
||||
|
@ -113,6 +114,7 @@ void drawScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t co
|
|||
yhgt = h - yofs;
|
||||
lcdDrawSolidFilledRect(x-1, y + yofs, 3, yhgt, SCROLLBOX_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
void drawProgressBar(const char *label)
|
||||
{
|
||||
|
@ -130,9 +132,38 @@ void updateProgressBar(int num, int den)
|
|||
}
|
||||
}
|
||||
|
||||
void drawShadow(coord_t x, coord_t y, coord_t w, coord_t h)
|
||||
{
|
||||
lcdDrawSolidVerticalLine(x+w, y+1, h, TEXT_COLOR);
|
||||
lcdDrawSolidHorizontalLine(x+1, y+h, w, TEXT_COLOR);
|
||||
lcdDrawSolidVerticalLine(x+w+1, y+2, h, LINE_COLOR);
|
||||
lcdDrawSolidHorizontalLine(x+2, y+h+1, w, LINE_COLOR);
|
||||
}
|
||||
|
||||
void drawScreenTemplate(const char * title)
|
||||
{
|
||||
// Header
|
||||
lcdDrawSolidFilledRect(0, 0, LCD_W, MENU_HEADER_HEIGHT, HEADER_BGCOLOR);
|
||||
lcdDrawBitmapPattern(0, 0, LBM_TOPMENU_POLYGON, TITLE_BGCOLOR);
|
||||
drawTopmenuDatetime();
|
||||
|
||||
lcdDrawBitmapPattern(4, 10, LBM_TOPMENU_OPENTX, MENU_TITLE_COLOR);
|
||||
|
||||
if (title) {
|
||||
// must be done at the end so that we can write something at the right of the menu title
|
||||
lcdDrawText(50, 3, title, MENU_TITLE_COLOR|DBLSIZE);
|
||||
}
|
||||
|
||||
// Body
|
||||
lcdDrawSolidFilledRect(0, MENU_HEADER_HEIGHT, LCD_W, LCD_H-MENU_HEADER_HEIGHT-MENU_FOOTER_HEIGHT, TEXT_BGCOLOR);
|
||||
|
||||
// Footer
|
||||
lcdDrawSolidFilledRect(0, MENU_FOOTER_TOP, LCD_W, MENU_FOOTER_HEIGHT, HEADER_BGCOLOR);
|
||||
}
|
||||
|
||||
#define MENU_ICONS_SPACING 31
|
||||
|
||||
void drawMenuTemplate(const char * name, evt_t event, uint16_t scrollbar_X)
|
||||
void drawMenuTemplate(const char * name, uint16_t scrollbar_X)
|
||||
{
|
||||
// clear the screen
|
||||
lcdDrawSolidFilledRect(0, 0, LCD_W, MENU_HEADER_HEIGHT, HEADER_BGCOLOR);
|
||||
|
@ -257,7 +288,7 @@ int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t m
|
|||
}
|
||||
}
|
||||
else {
|
||||
lcd_outdezAtt(x, y, value, attr, "%");
|
||||
lcdDrawNumber(x, y, value, attr, 0, NULL, "%");
|
||||
if (invers) value = checkIncDec(event, value, min, max, EE_MODEL | editflags);
|
||||
}
|
||||
return value;
|
||||
|
@ -266,7 +297,7 @@ int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t m
|
|||
int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, evt_t event)
|
||||
{
|
||||
if (attr & INVERS) value = checkIncDec(event, value, min, max, EE_MODEL);
|
||||
lcd_outdezAtt(x, y, value, attr, "%");
|
||||
lcdDrawNumber(x, y, value, attr, 0, NULL, "%");
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -325,12 +325,12 @@ void lcd_outdez8(coord_t x, coord_t y, int8_t val)
|
|||
lcd_outdezAtt(x, y, val);
|
||||
}
|
||||
|
||||
void lcd_outdezAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags)
|
||||
void lcd_outdezAtt(coord_t x, coord_t y, int32_t val, LcdFlags flags)
|
||||
{
|
||||
lcd_outdezNAtt(x, y, val, flags);
|
||||
}
|
||||
|
||||
void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t len)
|
||||
void lcd_outdezNAtt(coord_t x, coord_t y, int32_t val, LcdFlags flags, uint8_t len)
|
||||
{
|
||||
uint8_t fw = FWNUM;
|
||||
int8_t mode = MODE(flags);
|
||||
|
@ -356,7 +356,7 @@ void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t
|
|||
|
||||
if (mode != MODE(LEADING0)) {
|
||||
len = 1;
|
||||
lcduint_t tmp = ((lcduint_t)val) / 10;
|
||||
int32_t tmp = val / 10;
|
||||
while (tmp) {
|
||||
len++;
|
||||
tmp /= 10;
|
||||
|
@ -400,7 +400,7 @@ void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t
|
|||
if (dblsize) x++;
|
||||
|
||||
for (uint8_t i=1; i<=len; i++) {
|
||||
div_t qr = div((lcduint_t)val, 10);
|
||||
div_t qr = div(val, 10);
|
||||
char c = qr.rem + '0';
|
||||
LcdFlags f = flags;
|
||||
lcdDrawChar(x, y, c, f);
|
||||
|
@ -875,7 +875,7 @@ const pm_uint8_t bchunit_ar[] PROGMEM = {
|
|||
UNIT_DIST, // GPS Alt
|
||||
};
|
||||
|
||||
void putsValueWithUnit(coord_t x, coord_t y, lcdint_t val, uint8_t unit, LcdFlags att)
|
||||
void putsValueWithUnit(coord_t x, coord_t y, int32_t val, uint8_t unit, LcdFlags att)
|
||||
{
|
||||
// convertUnit(val, unit);
|
||||
lcd_outdezAtt(x, y, val, att & (~NO_UNIT));
|
||||
|
@ -956,7 +956,7 @@ void displayGpsCoords(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFl
|
|||
}
|
||||
}
|
||||
|
||||
void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, lcdint_t value, LcdFlags att)
|
||||
void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, int32_t value, LcdFlags att)
|
||||
{
|
||||
TelemetryItem & telemetryItem = telemetryItems[channel];
|
||||
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[channel];
|
||||
|
@ -976,7 +976,7 @@ void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, lcdint_t v
|
|||
}
|
||||
}
|
||||
|
||||
void putsChannelValue(coord_t x, coord_t y, source_t channel, lcdint_t value, LcdFlags att)
|
||||
void putsChannelValue(coord_t x, coord_t y, source_t channel, int32_t value, LcdFlags att)
|
||||
{
|
||||
if (channel >= MIXSRC_FIRST_TELEM) {
|
||||
channel = (channel-MIXSRC_FIRST_TELEM) / 3;
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
#define CONTRAST_MAX 45
|
||||
|
||||
#define lcdint_t int32_t
|
||||
#define lcduint_t uint32_t
|
||||
|
||||
#define FW 6
|
||||
#define FWNUM 5
|
||||
|
@ -156,8 +155,8 @@ void lcd_putsLeft(coord_t y, const pm_char * s);
|
|||
|
||||
void lcd_outhex4(coord_t x, coord_t y, uint32_t val, LcdFlags mode=0);
|
||||
|
||||
void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags mode=0, uint8_t len=0);
|
||||
void lcd_outdezAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags mode=0);
|
||||
void lcd_outdezNAtt(coord_t x, coord_t y, int32_t val, LcdFlags mode=0, uint8_t len=0);
|
||||
void lcd_outdezAtt(coord_t x, coord_t y, int32_t val, LcdFlags mode=0);
|
||||
void lcd_outdez8(coord_t x, coord_t y, int8_t val);
|
||||
|
||||
void putsStrIdx(coord_t x, coord_t y, const pm_char *str, uint8_t idx, LcdFlags att=0);
|
||||
|
@ -180,9 +179,9 @@ void putsVolts(coord_t x, coord_t y, uint16_t volts, LcdFlags att);
|
|||
void putsVBat(coord_t x, coord_t y, LcdFlags att);
|
||||
|
||||
#if !defined(BOOT)
|
||||
void putsChannelValue(coord_t x, coord_t y, source_t channel, lcdint_t val, LcdFlags att=0);
|
||||
void putsChannelValue(coord_t x, coord_t y, source_t channel, int32_t val, LcdFlags att=0);
|
||||
void putsChannel(coord_t x, coord_t y, source_t channel, LcdFlags att=0);
|
||||
void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, lcdint_t val, LcdFlags att=0);
|
||||
void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, int32_t val, LcdFlags att=0);
|
||||
#endif
|
||||
|
||||
#define putstime_t int32_t
|
||||
|
@ -232,7 +231,7 @@ void lcdSetContrast();
|
|||
void lcdRefresh();
|
||||
#endif
|
||||
|
||||
const char *bmpLoad(uint8_t *dest, const char *filename, const unsigned int width, const unsigned int height);
|
||||
const char * bmpLoad(uint8_t * dest, const char * filename, uint16_t width, uint16_t height);
|
||||
const char * writeScreenshot();
|
||||
|
||||
#if defined(BOOT)
|
||||
|
@ -241,14 +240,4 @@ const char *writeScreenshot();
|
|||
#define BLINK_ON_PHASE (g_blinkTmr10ms & (1<<6))
|
||||
#endif
|
||||
|
||||
#if defined(SIMU)
|
||||
extern bool lcd_refresh;
|
||||
extern display_t lcd_buf[DISPLAY_BUFFER_SIZE];
|
||||
#endif
|
||||
|
||||
char *strAppend(char * dest, const char * source, int len=0);
|
||||
char *strSetCursor(char *dest, int position);
|
||||
char *strAppendDate(char * str, bool time=false);
|
||||
char *strAppendFilename(char * dest, const char * filename, const int size);
|
||||
|
||||
#endif // _LCD_H_
|
||||
|
|
|
@ -88,7 +88,7 @@ enum EnumTabDiag {
|
|||
e_Calib
|
||||
};
|
||||
|
||||
const MenuFuncP_PROGMEM menuTabGeneral[] PROGMEM = {
|
||||
const MenuFuncP menuTabGeneral[] = {
|
||||
menuGeneralSetup,
|
||||
menuGeneralSdManager,
|
||||
menuGeneralCustomFunctions,
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#define IS_DIRECTORY(fname) ((bool)(!NODE_TYPE(fname)))
|
||||
#define IS_FILE(fname) ((bool)(NODE_TYPE(fname)))
|
||||
|
||||
void menuGeneralSdManagerInfo(uint8_t event)
|
||||
void menuGeneralSdManagerInfo(evt_t event)
|
||||
{
|
||||
SIMPLE_SUBMENU(STR_SD_INFO_TITLE, 1);
|
||||
|
||||
|
@ -181,7 +181,7 @@ void onSdManagerMenu(const char *result)
|
|||
strcat(lfn, line);
|
||||
}
|
||||
if (strcmp(clipboard.data.sd.directory, lfn)) { // prevent copying to the same directory
|
||||
POPUP_WARNING(sdCopyFile(clipboard.data.sd.filename, clipboard.data.sd.directory, lfn));
|
||||
POPUP_WARNING(sdCopyFile(clipboard.data.sd.filename, clipboard.data.sd.directory, clipboard.data.sd.filename, lfn));
|
||||
REFRESH_FILES();
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ void onSdManagerMenu(const char *result)
|
|||
#endif
|
||||
}
|
||||
|
||||
void menuGeneralSdManager(uint8_t _event)
|
||||
void menuGeneralSdManager(evt_t _event)
|
||||
{
|
||||
if (s_warning_result) {
|
||||
s_warning_result = 0;
|
||||
|
@ -261,7 +261,7 @@ void menuGeneralSdManager(uint8_t _event)
|
|||
|
||||
int lastPos = m_posVert;
|
||||
|
||||
uint8_t event = (EVT_KEY_MASK(_event) == KEY_ENTER ? 0 : _event);
|
||||
evt_t event = (EVT_KEY_MASK(_event) == KEY_ENTER ? 0 : _event);
|
||||
SIMPLE_MENU(SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD, menuTabGeneral, e_Sd, reusableBuffer.sdmanager.count);
|
||||
|
||||
int index = m_posVert-s_pgOfs;
|
||||
|
@ -341,7 +341,7 @@ void menuGeneralSdManager(uint8_t _event)
|
|||
}
|
||||
}
|
||||
if (!READ_ONLY()) {
|
||||
if (IS_FILE(line)) // it's a file
|
||||
if (IS_FILE(line))
|
||||
MENU_ADD_ITEM(STR_COPY_FILE);
|
||||
if (clipboard.type == CLIPBOARD_TYPE_SD_FILE)
|
||||
MENU_ADD_ITEM(STR_PASTE);
|
||||
|
@ -366,17 +366,17 @@ void menuGeneralSdManager(uint8_t _event)
|
|||
reusableBuffer.sdmanager.offset = 0;
|
||||
memset(reusableBuffer.sdmanager.lines, 0, sizeof(reusableBuffer.sdmanager.lines));
|
||||
}
|
||||
else if (s_pgOfs == reusableBuffer.sdmanager.count-7) {
|
||||
else if (s_pgOfs == reusableBuffer.sdmanager.count-NUM_BODY_LINES) {
|
||||
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);
|
||||
NODE_TYPE(reusableBuffer.sdmanager.lines[6]) = 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 {
|
||||
memmove(reusableBuffer.sdmanager.lines[1], reusableBuffer.sdmanager.lines[0], 6*sizeof(reusableBuffer.sdmanager.lines[0]));
|
||||
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]));
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,7 @@ void menuGeneralSdManager(uint8_t _event)
|
|||
for (int i=0; i<NUM_BODY_LINES; i++) {
|
||||
char *line = reusableBuffer.sdmanager.lines[i];
|
||||
if (line[0] == '\0' || isFilenameLower(isfile, fn, line)) {
|
||||
if (i < 6) memmove(reusableBuffer.sdmanager.lines[i+1], line, sizeof(reusableBuffer.sdmanager.lines[i]) * (6-i));
|
||||
if (i < NUM_BODY_LINES-1) memmove(reusableBuffer.sdmanager.lines[i+1], line, sizeof(reusableBuffer.sdmanager.lines[i]) * (NUM_BODY_LINES-1-i));
|
||||
memset(line, 0, sizeof(reusableBuffer.sdmanager.lines[0]));
|
||||
strcpy(line, fn);
|
||||
NODE_TYPE(line) = isfile;
|
||||
|
@ -412,7 +412,7 @@ void menuGeneralSdManager(uint8_t _event)
|
|||
}
|
||||
}
|
||||
else if (reusableBuffer.sdmanager.offset == s_pgOfs) {
|
||||
for (int8_t i=6; i>=0; i--) {
|
||||
for (int8_t i=NUM_BODY_LINES-1; 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);
|
||||
|
@ -424,10 +424,10 @@ void menuGeneralSdManager(uint8_t _event)
|
|||
}
|
||||
}
|
||||
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);
|
||||
NODE_TYPE(reusableBuffer.sdmanager.lines[6]) = isfile;
|
||||
if (isFilenameGreater(isfile, fn, reusableBuffer.sdmanager.lines[NUM_BODY_LINES-2]) && isFilenameLower(isfile, fn, reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1])) {
|
||||
memset(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1], 0, sizeof(reusableBuffer.sdmanager.lines[0]));
|
||||
strcpy(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1], fn);
|
||||
NODE_TYPE(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1]) = isfile;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -85,7 +85,7 @@ void menuGeneralVersion(uint8_t event)
|
|||
{
|
||||
if (s_warning_result) {
|
||||
s_warning_result = 0;
|
||||
displayPopup(STR_EEPROMFORMATTING);
|
||||
displayPopup(STR_STORAGE_FORMAT);
|
||||
storageEraseAll(false);
|
||||
#if !defined(SIMU)
|
||||
NVIC_SystemReset();
|
||||
|
|
|
@ -108,7 +108,7 @@ uint8_t editDelay(const coord_t y, const uint8_t event, const uint8_t attr, cons
|
|||
#define EDIT_DELAY(x, y, event, attr, str, delay) editDelay(y, event, attr, str, delay)
|
||||
#endif
|
||||
|
||||
const MenuFuncP_PROGMEM menuTabModel[] PROGMEM = {
|
||||
const MenuFuncP menuTabModel[] = {
|
||||
menuModelSelect,
|
||||
menuModelSetup,
|
||||
CASE_HELI(menuModelHeli)
|
||||
|
|
|
@ -66,9 +66,8 @@ extern uint8_t calibrationState;
|
|||
void menu_lcd_onoff(coord_t x, coord_t y, uint8_t value, LcdFlags attr);
|
||||
|
||||
typedef void (*MenuFuncP)(uint8_t event);
|
||||
typedef void (*MenuFuncP_PROGMEM)(uint8_t event);
|
||||
extern const MenuFuncP_PROGMEM menuTabModel[];
|
||||
extern const MenuFuncP_PROGMEM menuTabGeneral[];
|
||||
extern const MenuFuncP menuTabModel[];
|
||||
extern const MenuFuncP menuTabGeneral[];
|
||||
|
||||
extern MenuFuncP g_menuStack[5];
|
||||
extern uint8_t g_menuPos[4];
|
||||
|
|
|
@ -51,4 +51,9 @@
|
|||
#include "9X/gui.h"
|
||||
#endif
|
||||
|
||||
#if defined(SIMU)
|
||||
extern bool simuLcdRefresh;
|
||||
extern display_t simuLcdBuf[DISPLAY_BUFFER_SIZE];
|
||||
#endif
|
||||
|
||||
#endif // _GUI_H_
|
||||
|
|
|
@ -190,7 +190,6 @@ enum EnumKeys {
|
|||
#define _MSK_KEY_FLAGS 0x0e00
|
||||
#define EVT_ENTRY 0x1000
|
||||
#define EVT_ENTRY_UP 0x2000
|
||||
#define EVT_MENU_UP 0x4000
|
||||
#else
|
||||
#define _MSK_KEY_BREAK 0x20
|
||||
#define _MSK_KEY_REPT 0x40
|
||||
|
@ -199,7 +198,6 @@ enum EnumKeys {
|
|||
#define _MSK_KEY_FLAGS 0xe0
|
||||
#define EVT_ENTRY 0xbf
|
||||
#define EVT_ENTRY_UP 0xbe
|
||||
#define EVT_MENU_UP 0xbd
|
||||
#endif
|
||||
|
||||
#define EVT_KEY_BREAK(key) ((key)|_MSK_KEY_BREAK)
|
||||
|
@ -227,6 +225,10 @@ enum EnumKeys {
|
|||
#define EVT_ROTARY_RIGHT 0xde
|
||||
#endif
|
||||
|
||||
#if defined(COLORLCD)
|
||||
#define EVT_REFRESH 0xDD00
|
||||
#endif
|
||||
|
||||
class Key
|
||||
{
|
||||
#define FILTERBITS 4
|
||||
|
|
|
@ -42,7 +42,7 @@ uint8_t requestScreenshot = false;
|
|||
|
||||
void handleUsbConnection()
|
||||
{
|
||||
#if defined(PCBTARANIS) && !defined(SIMU)
|
||||
#if defined(CPUSTM32) && !defined(SIMU)
|
||||
static bool usbStarted = false;
|
||||
|
||||
if (!usbStarted && usbPlugged()) {
|
||||
|
@ -78,7 +78,7 @@ void handleUsbConnection()
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif //#if defined(PCBTARANIS) && !defined(SIMU)
|
||||
#endif // defined(CPUSTM32) && !defined(SIMU)
|
||||
}
|
||||
|
||||
void checkSpeakerVolume()
|
||||
|
@ -107,7 +107,104 @@ void checkEeprom()
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(GUI)
|
||||
#if defined(GUI) && defined(COLORLCD)
|
||||
void guiMain(evt_t evt)
|
||||
{
|
||||
bool refreshNeeded = false;
|
||||
|
||||
#if defined(LUA)
|
||||
uint32_t t0 = get_tmr10ms();
|
||||
static uint32_t lastLuaTime = 0;
|
||||
uint16_t interval = (lastLuaTime == 0 ? 0 : (t0 - lastLuaTime));
|
||||
lastLuaTime = t0;
|
||||
if (interval > maxLuaInterval) {
|
||||
maxLuaInterval = interval;
|
||||
}
|
||||
|
||||
// run Lua scripts that don't use LCD (to use CPU time while LCD DMA is running)
|
||||
luaTask(0, RUN_MIX_SCRIPT | RUN_FUNC_SCRIPT | RUN_TELEM_BG_SCRIPT, false);
|
||||
|
||||
// wait for LCD DMA to finish before continuing, because code from this point
|
||||
// is allowed to change the contents of LCD buffer
|
||||
//
|
||||
// WARNING: make sure no code above this line does any change to the LCD display buffer!
|
||||
//
|
||||
lcdRefreshWait();
|
||||
|
||||
// draw LCD from menus or from Lua script
|
||||
// run Lua scripts that use LCD
|
||||
|
||||
bool standaloneScriptWasRun = luaTask(evt, RUN_STNDAL_SCRIPT, true);
|
||||
if (!standaloneScriptWasRun) {
|
||||
luaTask(evt, RUN_TELEM_FG_SCRIPT, true);
|
||||
refreshNeeded = true;
|
||||
}
|
||||
|
||||
t0 = get_tmr10ms() - t0;
|
||||
if (t0 > maxLuaDuration) {
|
||||
maxLuaDuration = t0;
|
||||
}
|
||||
#else
|
||||
lcdRefreshWait(); // WARNING: make sure no code above this line does any change to the LCD display buffer!
|
||||
const bool standaloneScriptWasRun = false;
|
||||
#endif
|
||||
|
||||
if (!standaloneScriptWasRun) {
|
||||
while (1) {
|
||||
// normal GUI from menus
|
||||
const char * warn = s_warning;
|
||||
uint8_t menu = s_menu_count;
|
||||
|
||||
static bool popupDisplayed = false;
|
||||
if (warn || menu) {
|
||||
if (popupDisplayed == false) {
|
||||
g_menuStack[g_menuStackPtr](EVT_REFRESH);
|
||||
lcdDrawBlackOverlay();
|
||||
lcdStoreBackupBuffer();
|
||||
}
|
||||
if (popupDisplayed == false || evt) {
|
||||
lcdRestoreBackupBuffer();
|
||||
if (warn) DISPLAY_WARNING(evt);
|
||||
if (menu) {
|
||||
const char * result = displayMenu(evt);
|
||||
if (result) {
|
||||
menuHandler(result);
|
||||
evt = EVT_REFRESH;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
refreshNeeded = true;
|
||||
popupDisplayed = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
popupDisplayed = false;
|
||||
refreshNeeded = g_menuStack[g_menuStackPtr](evt);
|
||||
}
|
||||
|
||||
if (menuEvent == EVT_ENTRY) {
|
||||
m_posVert = -1;
|
||||
m_posHorz = 0;
|
||||
evt = menuEvent;
|
||||
menuEvent = 0;
|
||||
}
|
||||
else if (menuEvent == EVT_ENTRY_UP) {
|
||||
m_posVert = g_menuPos[g_menuStackPtr];
|
||||
m_posHorz = 0;
|
||||
evt = menuEvent;
|
||||
menuEvent = 0;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (refreshNeeded) {
|
||||
lcdRefresh();
|
||||
}
|
||||
}
|
||||
#elif defined(GUI)
|
||||
void guiMain(evt_t evt)
|
||||
{
|
||||
#if defined(LUA)
|
||||
|
@ -147,39 +244,29 @@ void guiMain(evt_t evt)
|
|||
#endif
|
||||
|
||||
if (!standaloneScriptWasRun) {
|
||||
while (1) {
|
||||
#if !defined(COLORLCD)
|
||||
lcdClear();
|
||||
#endif
|
||||
|
||||
// normal GUI from menus
|
||||
const char * warn = s_warning;
|
||||
uint8_t menu = s_menu_count;
|
||||
if (menuEvent) {
|
||||
m_posVert = menuEvent == EVT_ENTRY_UP ? g_menuPos[g_menuStackPtr] : 0;
|
||||
m_posHorz = 0;
|
||||
evt = menuEvent;
|
||||
menuEvent = 0;
|
||||
AUDIO_MENUS();
|
||||
}
|
||||
|
||||
g_menuStack[g_menuStackPtr]((warn || menu) ? 0 : evt);
|
||||
if (warn) DISPLAY_WARNING(evt);
|
||||
if (menu) {
|
||||
const char * result = displayMenu(evt);
|
||||
if (result) {
|
||||
menuHandler(result);
|
||||
putEvent(EVT_MENU_UP);
|
||||
}
|
||||
}
|
||||
|
||||
drawStatusLine();
|
||||
if (menuEvent == EVT_ENTRY) {
|
||||
m_posVert = -1;
|
||||
m_posHorz = 0;
|
||||
evt = menuEvent;
|
||||
menuEvent = 0;
|
||||
}
|
||||
else if (menuEvent == EVT_ENTRY_UP) {
|
||||
m_posVert = g_menuPos[g_menuStackPtr];
|
||||
m_posHorz = 0;
|
||||
evt = menuEvent;
|
||||
menuEvent = 0;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lcdRefresh();
|
||||
|
|
|
@ -146,7 +146,6 @@ void perMain()
|
|||
const char * result = displayMenu(evt);
|
||||
if (result) {
|
||||
menuHandler(result);
|
||||
putEvent(EVT_MENU_UP);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -439,6 +439,7 @@ enum UartModes {
|
|||
#if defined(PCBHORUS)
|
||||
#define LEN_SWITCH_NAME 3
|
||||
#define LEN_ANA_NAME 3
|
||||
#define LEN_MODEL_FILENAME 16
|
||||
#define EXTRA_GENERAL_FIELDS \
|
||||
EXTRA_GENERAL_FIELDS_ARM \
|
||||
uint8_t serial2Mode:6; \
|
||||
|
@ -448,7 +449,7 @@ enum UartModes {
|
|||
uint8_t potsType; /*two bits for every pot*/\
|
||||
char switchNames[NUM_SWITCHES][LEN_SWITCH_NAME]; \
|
||||
char anaNames[NUM_STICKS+NUM_POTS][LEN_ANA_NAME]; \
|
||||
char currModelFilename[10];
|
||||
char currModelFilename[LEN_MODEL_FILENAME+1];
|
||||
#elif defined(PCBFLAMENCO)
|
||||
#define LEN_SWITCH_NAME 3
|
||||
#define LEN_ANA_NAME 3
|
||||
|
|
|
@ -55,7 +55,7 @@ ModelData g_model;
|
|||
Clipboard clipboard;
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS) && defined(SDCARD)
|
||||
#if (defined(PCBTARANIS) || defined(PCBHORUS)) && defined(SDCARD)
|
||||
uint8_t modelBitmap[MODEL_BITMAP_SIZE];
|
||||
void loadModelBitmap(char * name, uint8_t * bitmap)
|
||||
{
|
||||
|
@ -325,6 +325,10 @@ void generalDefault()
|
|||
memcpy(g_eeGeneral.bluetoothName, defaultName, sizeof(defaultName));
|
||||
#endif
|
||||
|
||||
#if !defined(EEPROM)
|
||||
strcpy(g_eeGeneral.currModelFilename, DEFAULT_MODEL_FILENAME);
|
||||
#endif
|
||||
|
||||
g_eeGeneral.chkSum = 0xFFFF;
|
||||
}
|
||||
|
||||
|
@ -417,17 +421,6 @@ void checkModelIdUnique(uint8_t index, uint8_t module)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(SDCARD)
|
||||
bool isFileAvailable(const char * filename)
|
||||
{
|
||||
FILINFO info;
|
||||
TCHAR lfn[_MAX_LFN + 1];
|
||||
info.lfname = lfn;
|
||||
info.lfsize = sizeof(lfn);
|
||||
return f_stat(filename, &info) == FR_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
void modelDefault(uint8_t id)
|
||||
{
|
||||
memset(&g_model, 0, sizeof(g_model));
|
||||
|
@ -466,6 +459,10 @@ void modelDefault(uint8_t id)
|
|||
g_model.mavlink.rc_rssi_scale = 15;
|
||||
g_model.mavlink.pc_rssi_en = 1;
|
||||
#endif
|
||||
|
||||
#if !defined(EEPROM)
|
||||
strcpy(g_model.header.name, "\015\361\374\373\364\033\034");
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(VIRTUALINPUTS)
|
||||
|
@ -1172,7 +1169,7 @@ void checkLowEEPROM()
|
|||
{
|
||||
if (g_eeGeneral.disableMemoryWarning) return;
|
||||
if (EeFsGetFree() < 100) {
|
||||
ALERT(STR_EEPROMWARN, STR_EEPROMLOWMEM, AU_ERROR);
|
||||
ALERT(STR_STORAGE_WARNING, STR_EEPROMLOWMEM, AU_ERROR);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -257,14 +257,12 @@
|
|||
#endif
|
||||
#define CONVERT_PTR_UINT(x) ((uint32_t)(uint64_t)(x))
|
||||
#define CONVERT_UINT_PTR(x) ((uint32_t*)(uint64_t)(x))
|
||||
char *convertSimuPath(const char *path);
|
||||
#else
|
||||
#define FORCEINLINE inline __attribute__ ((always_inline))
|
||||
#define NOINLINE __attribute__ ((noinline))
|
||||
#define SIMU_SLEEP(x)
|
||||
#define CONVERT_PTR_UINT(x) ((uint32_t)(x))
|
||||
#define CONVERT_UINT_PTR(x) ((uint32_t *)(x))
|
||||
#define convertSimuPath(x) (x)
|
||||
#endif
|
||||
|
||||
#if !defined(CPUM64) && !defined(ACCURAT_THROTTLE_TIMER)
|
||||
|
@ -458,8 +456,16 @@
|
|||
#include "storage/storage.h"
|
||||
#include "pulses/pulses.h"
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define BITMAP_BUFFER_SIZE(width, height) (2 + width * ((height+7)/8)*4)
|
||||
#if defined(PCBHORUS)
|
||||
#define BITMAP_BUFFER_SIZE(width, height) (4 + (width)*(height)*3)
|
||||
#define MODEL_BITMAP_WIDTH (3*64) // 171
|
||||
#define MODEL_BITMAP_HEIGHT (3*32) // 101
|
||||
#define MODEL_BITMAP_SIZE BITMAP_BUFFER_SIZE(MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT)
|
||||
extern uint8_t modelBitmap[MODEL_BITMAP_SIZE];
|
||||
void loadModelBitmap(char * name, uint8_t * bitmap);
|
||||
#define LOAD_MODEL_BITMAP() loadModelBitmap(g_model.header.bitmap, modelBitmap)
|
||||
#elif defined(PCBTARANIS)
|
||||
#define BITMAP_BUFFER_SIZE(width, height) (2 + (width) * (((height)+7)/8)*4)
|
||||
#define MODEL_BITMAP_WIDTH 64
|
||||
#define MODEL_BITMAP_HEIGHT 32
|
||||
#define MODEL_BITMAP_SIZE BITMAP_BUFFER_SIZE(MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT)
|
||||
|
@ -556,6 +562,7 @@ typedef struct {
|
|||
}
|
||||
} CustomFunctionsContext;
|
||||
|
||||
#include "strhelpers.h"
|
||||
#include "gui/gui.h"
|
||||
|
||||
#if defined(TEMPLATES)
|
||||
|
@ -597,7 +604,7 @@ enum BaseCurves {
|
|||
|
||||
#define THRCHK_DEADBAND 16
|
||||
|
||||
#if defined(PCBFLAMENCO)
|
||||
#if defined(COLORLCD)
|
||||
#define SPLASH_NEEDED() (true)
|
||||
#elif defined(PCBTARANIS)
|
||||
#define SPLASH_NEEDED() (g_eeGeneral.splashMode != 3)
|
||||
|
@ -1095,7 +1102,6 @@ void generalDefault();
|
|||
void modelDefault(uint8_t id);
|
||||
|
||||
#if defined(CPUARM)
|
||||
bool isFileAvailable(const char * filename);
|
||||
void checkModelIdUnique(uint8_t index, uint8_t module);
|
||||
#endif
|
||||
|
||||
|
@ -1410,8 +1416,8 @@ enum AUDIO_SOUNDS {
|
|||
#if defined(VOICE)
|
||||
AU_THROTTLE_ALERT,
|
||||
AU_SWITCH_ALERT,
|
||||
AU_BAD_EEPROM,
|
||||
AU_EEPROM_FORMATTING,
|
||||
AU_BAD_RADIODATA,
|
||||
AU_STORAGE_FORMAT,
|
||||
#endif
|
||||
AU_TX_BATTERY_LOW,
|
||||
AU_INACTIVITY,
|
||||
|
@ -1544,13 +1550,13 @@ extern void opentxClose();
|
|||
extern void opentxInit();
|
||||
|
||||
// Re-useable byte array to save having multiple buffers
|
||||
#define SD_SCREEN_FILE_LENGTH (32)
|
||||
#define SD_SCREEN_FILE_LENGTH (64)
|
||||
union ReusableBuffer
|
||||
{
|
||||
// 275 bytes
|
||||
struct
|
||||
{
|
||||
char listnames[LCD_LINES-1][LEN_MODEL_NAME];
|
||||
char listnames[NUM_BODY_LINES][LEN_MODEL_NAME];
|
||||
#if !defined(CPUARM)
|
||||
uint16_t eepromfree;
|
||||
#endif
|
||||
|
@ -1584,7 +1590,7 @@ union ReusableBuffer
|
|||
// 274 bytes
|
||||
struct
|
||||
{
|
||||
char lines[LCD_LINES-1][SD_SCREEN_FILE_LENGTH+1+1]; // the last char is used to store the flags (directory) of the line
|
||||
char lines[NUM_BODY_LINES][SD_SCREEN_FILE_LENGTH+1+1]; // the last char is used to store the flags (directory) of the line
|
||||
uint32_t available;
|
||||
uint16_t offset;
|
||||
uint16_t count;
|
||||
|
@ -1598,7 +1604,7 @@ extern union ReusableBuffer reusableBuffer;
|
|||
void checkFlashOnBeep();
|
||||
|
||||
#if defined(CPUARM)
|
||||
void putsValueWithUnit(coord_t x, coord_t y, lcdint_t val, uint8_t unit, LcdFlags att);
|
||||
void putsValueWithUnit(coord_t x, coord_t y, int32_t val, uint8_t unit, LcdFlags att);
|
||||
#elif defined(FRSKY)
|
||||
void convertUnit(getvalue_t & val, uint8_t & unit); // TODO check FORCEINLINE on stock
|
||||
#else
|
||||
|
|
|
@ -58,6 +58,74 @@ const char * sdCheckAndCreateDirectory(const char * path)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool isFileAvailable(const char * path)
|
||||
{
|
||||
FILINFO info;
|
||||
TCHAR lfn[_MAX_LFN + 1];
|
||||
info.lfname = lfn;
|
||||
info.lfsize = sizeof(lfn);
|
||||
return f_stat(path, &info) == FR_OK;
|
||||
}
|
||||
|
||||
bool isFileAvailable(const char * filename, const char * directory)
|
||||
{
|
||||
char path[256];
|
||||
char * pos = strAppend(path, directory);
|
||||
*pos = '/';
|
||||
strAppend(pos+1, filename);
|
||||
return isFileAvailable(path);
|
||||
}
|
||||
|
||||
#define LEN_FILE_EXTENSION 4
|
||||
char * getFileExtension(char * filename, int size=0)
|
||||
{
|
||||
int len = strlen(filename);
|
||||
if (size != 0 && size < len) {
|
||||
len = size;
|
||||
}
|
||||
for (int i=len; i>=len-LEN_FILE_EXTENSION; --i) {
|
||||
if (filename[i] == '.') {
|
||||
return &filename[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char * getFileIndex(char * filename, unsigned int & value)
|
||||
{
|
||||
value = 0;
|
||||
char * pos = getFileExtension(filename);
|
||||
if (!pos || pos == filename)
|
||||
return NULL;
|
||||
while (pos > filename) {
|
||||
pos--;
|
||||
char c = *pos;
|
||||
if (c >= '0' && c <= '9') {
|
||||
value = (value * 10) + (c - '\0');
|
||||
}
|
||||
else {
|
||||
return pos+1;
|
||||
}
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
bool findNextFileIndex(char * filename, const char * directory)
|
||||
{
|
||||
unsigned int index;
|
||||
char * pos = getFileIndex(filename, index);
|
||||
char extension[LEN_FILE_EXTENSION+1];
|
||||
strncpy(extension, getFileExtension(filename), sizeof(extension));
|
||||
do {
|
||||
pos = strAppendNumber(pos, ++index);
|
||||
strAppend(pos, extension);
|
||||
if (!isFileAvailable(filename, directory)) {
|
||||
return true;
|
||||
}
|
||||
} while (index < 99);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool sdListFiles(const char *path, const char *extension, const uint8_t maxlen, const char *selection, uint8_t flags=0)
|
||||
{
|
||||
FILINFO fno;
|
||||
|
@ -207,29 +275,20 @@ bool sdListFiles(const char *path, const char *extension, const uint8_t maxlen,
|
|||
}
|
||||
|
||||
#if defined(CPUARM) && defined(SDCARD)
|
||||
const char * sdCopyFile(const char * filename, const char * srcDir, const char * destDir)
|
||||
const char * sdCopyFile(const char * srcPath, const char * destPath)
|
||||
{
|
||||
FIL srcFile;
|
||||
FIL dstFile;
|
||||
FIL destFile;
|
||||
char buf[256];
|
||||
UINT read = sizeof(buf);
|
||||
UINT written = sizeof(buf);
|
||||
|
||||
char path[2*CLIPBOARD_PATH_LEN+1];
|
||||
char *tmp = strAppend(path, srcDir, CLIPBOARD_PATH_LEN);
|
||||
*tmp++ = '/';
|
||||
strAppend(tmp, filename, CLIPBOARD_PATH_LEN);
|
||||
|
||||
FRESULT result = f_open(&srcFile, path, FA_OPEN_EXISTING | FA_READ);
|
||||
FRESULT result = f_open(&srcFile, srcPath, FA_OPEN_EXISTING | FA_READ);
|
||||
if (result != FR_OK) {
|
||||
return SDCARD_ERROR(result);
|
||||
}
|
||||
|
||||
tmp = strAppend(path, destDir, CLIPBOARD_PATH_LEN);
|
||||
*tmp++ = '/';
|
||||
strAppend(tmp, filename, CLIPBOARD_PATH_LEN);
|
||||
|
||||
result = f_open(&dstFile, path, FA_CREATE_ALWAYS | FA_WRITE);
|
||||
result = f_open(&destFile, destPath, FA_CREATE_ALWAYS | FA_WRITE);
|
||||
if (result != FR_OK) {
|
||||
f_close(&srcFile);
|
||||
return SDCARD_ERROR(result);
|
||||
|
@ -238,11 +297,11 @@ const char * sdCopyFile(const char * filename, const char * srcDir, const char *
|
|||
while (result==FR_OK && read==sizeof(buf) && written==sizeof(buf)) {
|
||||
result = f_read(&srcFile, buf, sizeof(buf), &read);
|
||||
if (result == FR_OK) {
|
||||
result = f_write(&dstFile, buf, read, &written);
|
||||
result = f_write(&destFile, buf, read, &written);
|
||||
}
|
||||
}
|
||||
|
||||
f_close(&dstFile);
|
||||
f_close(&destFile);
|
||||
f_close(&srcFile);
|
||||
|
||||
if (result != FR_OK) {
|
||||
|
@ -251,7 +310,22 @@ const char * sdCopyFile(const char * filename, const char * srcDir, const char *
|
|||
|
||||
return NULL;
|
||||
}
|
||||
#endif // #if defined(PCBTARANIS)
|
||||
|
||||
const char * sdCopyFile(const char * srcFilename, const char * srcDir, const char * destFilename, const char * destDir)
|
||||
{
|
||||
char srcPath[2*CLIPBOARD_PATH_LEN+1];
|
||||
char * tmp = strAppend(srcPath, srcDir, CLIPBOARD_PATH_LEN);
|
||||
*tmp++ = '/';
|
||||
strAppend(tmp, srcFilename, CLIPBOARD_PATH_LEN);
|
||||
|
||||
char destPath[2*CLIPBOARD_PATH_LEN+1];
|
||||
tmp = strAppend(destPath, destDir, CLIPBOARD_PATH_LEN);
|
||||
*tmp++ = '/';
|
||||
strAppend(tmp, destFilename, CLIPBOARD_PATH_LEN);
|
||||
|
||||
return sdCopyFile(srcPath, destPath);
|
||||
}
|
||||
#endif // defined(CPUARM) && defined(SDCARD)
|
||||
|
||||
|
||||
#if !defined(SIMU) || defined(SIMU_DISKIO)
|
||||
|
|
|
@ -100,6 +100,10 @@ inline const pm_char * SDCARD_ERROR(FRESULT result)
|
|||
#define O9X_FOURCC 0x3178396F // o9x for gruvin9x/MEGA2560
|
||||
#endif
|
||||
|
||||
bool isFileAvailable(const char * filename);
|
||||
bool findNextFileIndex(char * filename, const char * directory);
|
||||
|
||||
const char * sdCopyFile(const char * src, const char * dest);
|
||||
const char * sdCopyFile(const char * filename, const char * srcDir, const char * destDir);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -53,10 +53,11 @@ void serialPutc(char c)
|
|||
void serialPrintf(const char * format, ...)
|
||||
{
|
||||
va_list arglist;
|
||||
char tmp[PRINTF_BUFFER_SIZE];
|
||||
char tmp[PRINTF_BUFFER_SIZE+1];
|
||||
|
||||
va_start(arglist, format);
|
||||
vsnprintf(tmp, PRINTF_BUFFER_SIZE, format, arglist);
|
||||
tmp[PRINTF_BUFFER_SIZE] = '\0';
|
||||
va_end(arglist);
|
||||
|
||||
const char *t = tmp;
|
||||
|
|
|
@ -454,8 +454,8 @@ void Open9xSim::setPixel(int x, int y, FXColor color)
|
|||
|
||||
void Open9xSim::refreshDisplay()
|
||||
{
|
||||
if (lcd_refresh) {
|
||||
lcd_refresh = false;
|
||||
if (simuLcdRefresh) {
|
||||
simuLcdRefresh = false;
|
||||
FXColor offColor = isBacklightEnable() ? BL_COLOR : FXRGB(200, 200, 200);
|
||||
#if LCD_W == 128
|
||||
FXColor onColor = FXRGB(0, 0, 0);
|
||||
|
@ -463,19 +463,19 @@ void Open9xSim::refreshDisplay()
|
|||
for (int x=0; x<LCD_W; x++) {
|
||||
for (int y=0; y<LCD_H; y++) {
|
||||
#if defined(PCBHORUS)
|
||||
display_t z = lcd_buf[y * LCD_W + x];
|
||||
display_t z = simuLcdBuf[y * LCD_W + x];
|
||||
if (1) {
|
||||
FXColor color = FXRGB(255*((z&0xF800)>>11)/0x1f, 255*((z&0x07E0)>>5)/0x3F, 255*(z&0x001F)/0x01F);
|
||||
setPixel(x, y, color);
|
||||
}
|
||||
#elif defined(PCBFLAMENCO)
|
||||
display_t z = lcd_buf[y * LCD_W + x];
|
||||
display_t z = simuLcdBuf[y * LCD_W + x];
|
||||
if (1) {
|
||||
FXColor color = FXRGB(255*((z&0xF00)>>8)/0x0f, 255*((z&0x0F0)>>4)/0x0f, 255*(z&0x00F)/0x0f);
|
||||
setPixel(x, y, color);
|
||||
}
|
||||
#elif defined(PCBTARANIS)
|
||||
display_t * p = &lcd_buf[y / 2 * LCD_W + x];
|
||||
display_t * p = &simuLcdBuf[y / 2 * LCD_W + x];
|
||||
uint8_t z = (y & 1) ? (*p >> 4) : (*p & 0x0F);
|
||||
if (z) {
|
||||
FXColor color;
|
||||
|
@ -486,7 +486,7 @@ void Open9xSim::refreshDisplay()
|
|||
setPixel(x, y, color);
|
||||
}
|
||||
#else
|
||||
if (lcd_buf[x+(y/8)*LCD_W] & (1<<(y%8))) {
|
||||
if (simuLcdBuf[x+(y/8)*LCD_W] & (1<<(y%8))) {
|
||||
setPixel(x, y, onColor);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1401,10 +1401,10 @@ bool eeConvert()
|
|||
g_eeGeneral.backlightMode = e_backlight_mode_on;
|
||||
g_eeGeneral.backlightBright = 0;
|
||||
g_eeGeneral.contrast = 25;
|
||||
ALERT(STR_EEPROMWARN, msg, AU_BAD_EEPROM);
|
||||
ALERT(STR_STORAGE_WARNING, msg, AU_BAD_RADIODATA);
|
||||
|
||||
// Message
|
||||
MESSAGE(STR_EEPROMWARN, STR_EEPROM_CONVERTING, NULL, AU_EEPROM_FORMATTING); // TODO translations
|
||||
MESSAGE(STR_STORAGE_WARNING, STR_EEPROM_CONVERTING, NULL, AU_STORAGE_FORMAT); // TODO translations
|
||||
|
||||
// General Settings conversion
|
||||
eeLoadGeneralSettingsData();
|
||||
|
|
|
@ -116,16 +116,25 @@ const char * loadFile(const char * filename, uint8_t * data, uint16_t maxsize)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const char * loadModel(const char * filename)
|
||||
void getModelPath(char * path, const char * filename)
|
||||
{
|
||||
char path[256];
|
||||
strcpy(path, STR_MODELS_PATH);
|
||||
path[sizeof(MODELS_PATH)-1] = '/';
|
||||
strcpy(&path[sizeof(MODELS_PATH)], filename);
|
||||
}
|
||||
|
||||
const char * readModel(const char * filename, uint8_t * buffer, uint32_t size)
|
||||
{
|
||||
char path[256];
|
||||
getModelPath(path, filename);
|
||||
return loadFile(path, buffer, size);
|
||||
}
|
||||
|
||||
const char * loadModel(const char * filename)
|
||||
{
|
||||
preModelLoad();
|
||||
|
||||
const char * error = loadFile(path, (uint8_t *)&g_model, sizeof(g_model));
|
||||
const char * error = readModel(filename, (uint8_t *)&g_model, sizeof(g_model));
|
||||
if (error) {
|
||||
TRACE("loadModel error=%s", error);
|
||||
}
|
||||
|
@ -194,7 +203,6 @@ void storageReadAll()
|
|||
|
||||
if (loadGeneralSettings() != NULL) {
|
||||
storageEraseAll(true);
|
||||
strcpy(g_eeGeneral.currModelFilename, "model.bin");
|
||||
}
|
||||
|
||||
stickMode = g_eeGeneral.stickMode;
|
||||
|
@ -211,10 +219,22 @@ void storageReadAll()
|
|||
loadModel(g_eeGeneral.currModelFilename);
|
||||
}
|
||||
|
||||
void storageCreateModelsList()
|
||||
{
|
||||
FIL file;
|
||||
|
||||
FRESULT result = f_open(&file, RADIO_MODELSLIST_PATH, FA_CREATE_ALWAYS | FA_WRITE);
|
||||
if (result == FR_OK) {
|
||||
f_puts("[" DEFAULT_CATEGORY "]\n" DEFAULT_MODEL_FILENAME "\n", &file);
|
||||
f_close(&file);
|
||||
}
|
||||
}
|
||||
|
||||
void storageFormat()
|
||||
{
|
||||
sdCheckAndCreateDirectory(RADIO_PATH);
|
||||
sdCheckAndCreateDirectory(MODELS_PATH);
|
||||
storageCreateModelsList();
|
||||
}
|
||||
|
||||
struct StorageModelsList {
|
||||
|
@ -357,6 +377,10 @@ const char * storageModifyModel(unsigned int operation, int category, int positi
|
|||
f_putc('\n', &file);
|
||||
continue;
|
||||
}
|
||||
else if (operation == STORAGE_REMOVE) {
|
||||
TRACE("skip %s", line);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -370,6 +394,8 @@ const char * storageModifyModel(unsigned int operation, int category, int positi
|
|||
}
|
||||
|
||||
f_close(&file);
|
||||
f_unlink(RADIO_PATH "/models.old");
|
||||
f_rename(RADIO_MODELSLIST_PATH, RADIO_PATH "/models.old");
|
||||
f_rename(RADIO_PATH "/models.tmp", RADIO_MODELSLIST_PATH);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define DEFAULT_CATEGORY "Models"
|
||||
#define DEFAULT_MODEL_FILENAME "model01.bin"
|
||||
|
||||
const char * readModel(const char * filename, uint8_t * buffer, uint32_t size);
|
||||
const char * loadModel(const char * filename);
|
||||
|
||||
|
||||
|
|
|
@ -117,10 +117,10 @@ void storageEraseAll(bool warn)
|
|||
modelDefault(0);
|
||||
|
||||
if (warn) {
|
||||
ALERT(STR_EEPROMWARN, STR_BADEEPROMDATA, AU_BAD_EEPROM);
|
||||
ALERT(STR_STORAGE_WARNING, STR_BAD_RADIO_DATA, AU_BAD_RADIODATA);
|
||||
}
|
||||
|
||||
MESSAGE(STR_EEPROMWARN, STR_EEPROMFORMATTING, NULL, AU_EEPROM_FORMATTING);
|
||||
MESSAGE(STR_STORAGE_WARNING, STR_STORAGE_FORMAT, NULL, AU_STORAGE_FORMAT);
|
||||
|
||||
storageFormat();
|
||||
storageDirty(EE_GENERAL);
|
||||
|
|
|
@ -161,8 +161,7 @@ char *strcat_zchar(char * dest, const char * name, uint8_t size, const char *def
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(COLORLCD)
|
||||
char *strAppendDigits(char *dest, int value)
|
||||
char * strAppendNumber(char * dest, unsigned int value)
|
||||
{
|
||||
div_t qr = div(value, 10);
|
||||
*dest++ = '0' + qr.quot;
|
||||
|
@ -170,7 +169,6 @@ char *strAppendDigits(char *dest, int value)
|
|||
*dest = '\0';
|
||||
return dest;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM) || defined(SDCARD)
|
||||
char * strAppend(char * dest, const char * source, int len)
|
||||
|
@ -204,18 +202,6 @@ char *strAppendFilename(char *dest, const char *filename, const int size)
|
|||
return dest;
|
||||
}
|
||||
|
||||
#define LEN_FILE_EXTENSION 4
|
||||
char *getFileExtension(char *filename, int size)
|
||||
{
|
||||
int len = min<int>(size, strlen(filename));
|
||||
for (int i=len; i>=len-LEN_FILE_EXTENSION; --i) {
|
||||
if (filename[i] == '.') {
|
||||
return &filename[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(RTCLOCK)
|
||||
#include "rtc.h"
|
||||
|
||||
|
|
41
radio/src/strhelpers.h
Normal file
41
radio/src/strhelpers.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - 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.
|
||||
*
|
||||
*/
|
||||
|
||||
char * strAppend(char * dest, const char * source, int len=0);
|
||||
char * strAppendNumber(char * dest, unsigned int number);
|
||||
char * strSetCursor(char * dest, int position);
|
||||
char * strAppendDate(char * str, bool time=false);
|
||||
char * strAppendFilename(char * dest, const char * filename, const int size);
|
|
@ -63,6 +63,8 @@ const int8_t ana_direction[NUMBER_ANALOG] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
|||
|
||||
void adcInit()
|
||||
{
|
||||
return ;
|
||||
|
||||
// Enable clocks
|
||||
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN;
|
||||
RCC->AHB1ENR |= ADC_RCC_AHB1Periph_GPIO | RCC_AHB1ENR_DMA2EN;
|
||||
|
@ -93,6 +95,8 @@ void adcInit()
|
|||
|
||||
void adcRead()
|
||||
{
|
||||
return ;
|
||||
|
||||
DMA2_Stream0->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
ADC1->SR &= ~(uint32_t) ( ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR ) ;
|
||||
DMA2->LIFCR = DMA_LIFCR_CTCIF0 | DMA_LIFCR_CHTIF0 |DMA_LIFCR_CTEIF0 | DMA_LIFCR_CDMEIF0 | DMA_LIFCR_CFEIF0 ; // Write ones to clear bits
|
||||
|
|
|
@ -72,7 +72,7 @@ void init5msTimer()
|
|||
{
|
||||
// Timer14
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM14EN ; // Enable clock
|
||||
TIM14->ARR = 4999 ; // 5mS
|
||||
TIM14->ARR = 999 ; // 5mS
|
||||
TIM14->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 1000000 - 1 ; // 1uS from 30MHz
|
||||
TIM14->CCER = 0 ;
|
||||
TIM14->CCMR1 = 0 ;
|
||||
|
@ -95,13 +95,18 @@ void interrupt5ms()
|
|||
{
|
||||
static uint32_t pre_scale ; // Used to get 10 Hz counter
|
||||
|
||||
++pre_scale;
|
||||
|
||||
if (pre_scale == 5 || pre_scale == 10) {
|
||||
AUDIO_HEARTBEAT();
|
||||
|
||||
#if defined(HAPTIC)
|
||||
HAPTIC_HEARTBEAT();
|
||||
#endif
|
||||
|
||||
if ( ++pre_scale >= 2 ) {
|
||||
}
|
||||
|
||||
if ( pre_scale >= 10 ) {
|
||||
pre_scale = 0 ;
|
||||
per10ms();
|
||||
}
|
||||
|
@ -244,13 +249,3 @@ void checkTrainerSettings()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
bool eeCopyModel(uint8_t dst, uint8_t src) { }
|
||||
void eeSwapModels(uint8_t id1, uint8_t id2) { }
|
||||
void eeDeleteModel(uint8_t idx) { }
|
||||
uint8_t eeFindEmptyModel(uint8_t id, bool down) { return 0; };
|
||||
bool eeModelExists(uint8_t id) { return true; }
|
||||
const pm_char * eeBackupModel(uint8_t i_fileSrc) { return NULL; }
|
||||
const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name) { return NULL; }
|
||||
void selectModel(uint8_t sub) { }
|
||||
|
|
|
@ -104,15 +104,9 @@ extern "C" {
|
|||
#define PIN_PORTA 0x0000
|
||||
#define PIN_PORTB 0x0100
|
||||
#define PIN_PORTC 0x0200
|
||||
#define PIN_PORTD 0x0300
|
||||
#define PIN_PORTE 0x0400
|
||||
#define PIN_PORTF 0x0500
|
||||
#define PIN_PER_1 0x0010
|
||||
#define PIN_PER_2 0x0020
|
||||
#define PIN_PER_3 0x0030
|
||||
#define PIN_PER_5 0x0050
|
||||
#define PIN_PER_6 0x0060
|
||||
#define PIN_PER_8 0x0080
|
||||
#define PIN_OS25 0x2000
|
||||
#define PIN_OS50 0x4000
|
||||
#define PIN_OS100 0x6000
|
||||
|
@ -241,7 +235,7 @@ void pwrOn(void);
|
|||
void pwrOff(void);
|
||||
uint32_t pwrPressed(void);
|
||||
uint32_t pwrPressedDuration(void);
|
||||
#define UNEXPECTED_SHUTDOWN() (g_eeGeneral.unexpectedShutdown)
|
||||
#define UNEXPECTED_SHUTDOWN() (false) // (g_eeGeneral.unexpectedShutdown)
|
||||
|
||||
// Led driver
|
||||
void ledInit(void);
|
||||
|
@ -253,6 +247,8 @@ void ledBlue(void);
|
|||
void lcdInit(void);
|
||||
void lcdRefresh(void);
|
||||
void lcdDrawSolidFilledRectDMA(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
|
||||
void lcdStoreBackupBuffer(void);
|
||||
void lcdRestoreBackupBuffer(void);
|
||||
|
||||
// Backlight driver
|
||||
#define setBacklight(xx)
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
/*-----------------------------------------------------------------------*/
|
||||
#if !defined(BOOT)
|
||||
static OS_MutexID ioMutex;
|
||||
volatile int mutexCheck = 0;
|
||||
|
||||
unsigned int ioMutexReq = 0, ioMutexRel = 0;
|
||||
int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex)
|
||||
{
|
||||
*mutex = ioMutex;
|
||||
|
@ -27,11 +26,13 @@ int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex)
|
|||
|
||||
int ff_req_grant (_SYNC_t mutex)
|
||||
{
|
||||
ioMutexReq += 1;
|
||||
return CoEnterMutexSection(mutex) == E_OK;
|
||||
}
|
||||
|
||||
void ff_rel_grant (_SYNC_t mutex)
|
||||
{
|
||||
ioMutexRel += 1;
|
||||
CoLeaveMutexSection(mutex);
|
||||
}
|
||||
|
||||
|
@ -87,7 +88,7 @@ DSTATUS disk_status (
|
|||
return(stat);
|
||||
}
|
||||
|
||||
|
||||
unsigned int sdReadRetries = 0;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Read Sector(s) */
|
||||
|
@ -99,20 +100,23 @@ DRESULT disk_read (
|
|||
UINT count /* Number of sectors to read (1..255) */
|
||||
)
|
||||
{
|
||||
DRESULT res = RES_OK;
|
||||
SD_Error Status;
|
||||
|
||||
// TRACE("disk_read %d %p %10d %d\n",drv,buff,sector,count);
|
||||
// TRACE("disk_read %d %p %10d %d", drv, buff, sector, count);
|
||||
|
||||
if (SD_Detect() != SD_PRESENT)
|
||||
return(RES_NOTRDY);
|
||||
if (SD_Detect() != SD_PRESENT) {
|
||||
TRACE("SD_Detect() != SD_PRESENT");
|
||||
return RES_NOTRDY;
|
||||
}
|
||||
|
||||
if ((DWORD)buff & 3) // DMA Alignment failure, do single up to aligned buffer
|
||||
{
|
||||
DRESULT res = RES_OK;
|
||||
TRACE("DMA Alignment failure, align buffer");
|
||||
|
||||
DWORD scratch[BLOCK_SIZE / 4]; // Alignment assured, you'll need a sufficiently big stack
|
||||
|
||||
while(count--)
|
||||
{
|
||||
while(count--) {
|
||||
res = disk_read(drv, (BYTE *)scratch, sector++, 1);
|
||||
|
||||
if (res != RES_OK) {
|
||||
|
@ -125,30 +129,49 @@ DRESULT disk_read (
|
|||
buff += BLOCK_SIZE;
|
||||
}
|
||||
|
||||
return(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
Status = SD_ReadMultiBlocksFIXED(buff, sector, BLOCK_SIZE, count); // 4GB Compliant
|
||||
for (int retry=0; retry<3; retry++) {
|
||||
res = RES_OK;
|
||||
|
||||
if (Status == SD_OK)
|
||||
{
|
||||
if (count == 1) {
|
||||
Status = SD_ReadBlock(buff, sector, BLOCK_SIZE); // 4GB Compliant
|
||||
}
|
||||
else {
|
||||
Status = SD_ReadMultiBlocks(buff, sector, BLOCK_SIZE, count); // 4GB Compliant
|
||||
}
|
||||
|
||||
#if defined(SD_DMA_MODE)
|
||||
if (Status == SD_OK) {
|
||||
SDTransferState State;
|
||||
|
||||
Status = SD_WaitReadOperation(); // Check if the Transfer is finished
|
||||
|
||||
while ((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL)
|
||||
|
||||
if ((State == SD_TRANSFER_ERROR) || (Status != SD_OK)) {
|
||||
TRACE("SD_ReadMultiBlocksFIXED() wait error (State=%d Status=%d)", State, Status);
|
||||
return(RES_ERROR);
|
||||
if (State == SD_TRANSFER_ERROR) {
|
||||
TRACE("State=SD_TRANSFER_ERROR");
|
||||
res = RES_ERROR;
|
||||
}
|
||||
else if (Status != SD_OK) {
|
||||
TRACE("Status(WaitRead)=%d", Status);
|
||||
res = RES_ERROR;
|
||||
}
|
||||
else
|
||||
return(RES_OK);
|
||||
}
|
||||
else {
|
||||
TRACE("SD_ReadMultiBlocksFIXED() error (Status=%d)", Status);
|
||||
return(RES_ERROR);
|
||||
TRACE("Status(ReadBlock)=%d", Status);
|
||||
res = RES_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (res == RES_OK)
|
||||
break;
|
||||
|
||||
sdReadRetries += 1;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
@ -163,15 +186,15 @@ DRESULT disk_write (
|
|||
)
|
||||
{
|
||||
SD_Error Status;
|
||||
DRESULT res = RES_OK;
|
||||
|
||||
// TRACE("disk_write %d %p %10d %d\n",drv,buff,sector,count);
|
||||
// TRACE("disk_write %d %p %10d %d", drv, buff, sector, count);
|
||||
|
||||
if (SD_Detect() != SD_PRESENT)
|
||||
return(RES_NOTRDY);
|
||||
|
||||
if ((DWORD)buff & 3) // DMA Alignment failure, do single up to aligned buffer
|
||||
{
|
||||
DRESULT res = RES_OK;
|
||||
DWORD scratch[BLOCK_SIZE / 4]; // Alignment assured, you'll need a sufficiently big stack
|
||||
|
||||
while(count--)
|
||||
|
@ -189,7 +212,12 @@ DRESULT disk_write (
|
|||
return(res);
|
||||
}
|
||||
|
||||
Status = SD_WriteMultiBlocksFIXED((uint8_t *)buff, sector, BLOCK_SIZE, count); // 4GB Compliant
|
||||
if (count == 1) {
|
||||
Status = SD_WriteBlock((uint8_t *)buff, sector*BLOCK_SIZE, BLOCK_SIZE); // 4GB Compliant
|
||||
}
|
||||
else {
|
||||
Status = SD_WriteMultiBlocks((uint8_t *)buff, sector, BLOCK_SIZE, count); // 4GB Compliant
|
||||
}
|
||||
|
||||
if (Status == SD_OK)
|
||||
{
|
||||
|
@ -200,12 +228,14 @@ DRESULT disk_write (
|
|||
while((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL)
|
||||
|
||||
if ((State == SD_TRANSFER_ERROR) || (Status != SD_OK))
|
||||
return(RES_ERROR);
|
||||
else
|
||||
return(RES_OK);
|
||||
res = RES_ERROR;
|
||||
}
|
||||
else
|
||||
return(RES_ERROR);
|
||||
else {
|
||||
res = RES_ERROR;
|
||||
}
|
||||
|
||||
// TRACE("result=%d", res);
|
||||
return res;
|
||||
}
|
||||
#endif /* _READONLY */
|
||||
|
||||
|
@ -221,7 +251,25 @@ DRESULT disk_ioctl (
|
|||
void *buff /* Buffer to send/receive control data */
|
||||
)
|
||||
{
|
||||
return RES_OK;
|
||||
DRESULT res;
|
||||
|
||||
if (drv) return RES_PARERR;
|
||||
|
||||
res = RES_ERROR;
|
||||
|
||||
switch (ctrl) {
|
||||
case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
|
||||
*(DWORD*)buff = SDCardInfo.CardCapacity / BLOCK_SIZE;
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
case GET_SECTOR_SIZE : /* Get R/W sector size (WORD) */
|
||||
*(WORD*)buff = BLOCK_SIZE;
|
||||
res = RES_OK;
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// TODO everything here should not be in the driver layer ...
|
||||
|
@ -231,15 +279,6 @@ FATFS g_FATFS_Obj;
|
|||
FIL g_telemetryFile = {0};
|
||||
#endif
|
||||
|
||||
#if defined(BOOT)
|
||||
void sdInit(void)
|
||||
{
|
||||
if (f_mount(&g_FATFS_Obj, "", 1) == FR_OK) {
|
||||
f_chdir("/");
|
||||
}
|
||||
}
|
||||
#else
|
||||
// TODO shouldn't be there!
|
||||
void sdInit(void)
|
||||
{
|
||||
ioMutex = CoCreateMutex();
|
||||
|
@ -276,7 +315,6 @@ void sdDone()
|
|||
f_mount(NULL, "", 0); // unmount SD
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t sdMounted()
|
||||
{
|
||||
|
|
|
@ -54,22 +54,22 @@
|
|||
#define SWITCHES_GPIO_PIN_H GPIO_Pin_7 // PG.07
|
||||
|
||||
// Trims
|
||||
#define TRIMS_GPIO_REG_LHL GPIOC->IDR
|
||||
#define TRIMS_GPIO_PIN_LHL GPIO_Pin_0 // PC.00
|
||||
#define TRIMS_GPIO_REG_LHR GPIOI->IDR
|
||||
#define TRIMS_GPIO_PIN_LHR GPIO_Pin_4 // PI.04
|
||||
#define TRIMS_GPIO_REG_LVD GPIOG->IDR
|
||||
#define TRIMS_GPIO_PIN_LVD GPIO_Pin_12 // PG.12
|
||||
#define TRIMS_GPIO_REG_LVU GPIOJ->IDR
|
||||
#define TRIMS_GPIO_PIN_LVU GPIO_Pin_14 // PJ.14
|
||||
#define TRIMS_GPIO_REG_RVD GPIOJ->IDR
|
||||
#define TRIMS_GPIO_PIN_RVD GPIO_Pin_13 // PJ.13
|
||||
#define TRIMS_GPIO_REG_RHL GPIOD->IDR
|
||||
#define TRIMS_GPIO_PIN_RHL GPIO_Pin_3 // PD.03
|
||||
#define TRIMS_GPIO_REG_RHL GPIOC->IDR
|
||||
#define TRIMS_GPIO_PIN_RHL GPIO_Pin_0 // PC.00
|
||||
#define TRIMS_GPIO_REG_RHR GPIOI->IDR
|
||||
#define TRIMS_GPIO_PIN_RHR GPIO_Pin_4 // PI.04
|
||||
#define TRIMS_GPIO_REG_RVD GPIOG->IDR
|
||||
#define TRIMS_GPIO_PIN_RVD GPIO_Pin_12 // PG.12
|
||||
#define TRIMS_GPIO_REG_RVU GPIOJ->IDR
|
||||
#define TRIMS_GPIO_PIN_RVU GPIO_Pin_12 // PJ.12
|
||||
#define TRIMS_GPIO_REG_RHR GPIOD->IDR
|
||||
#define TRIMS_GPIO_PIN_RHR GPIO_Pin_7 // PD.07
|
||||
#define TRIMS_GPIO_PIN_RVU GPIO_Pin_14 // PJ.14
|
||||
#define TRIMS_GPIO_REG_LVD GPIOJ->IDR
|
||||
#define TRIMS_GPIO_PIN_LVD GPIO_Pin_13 // PJ.13
|
||||
#define TRIMS_GPIO_REG_LHL GPIOD->IDR
|
||||
#define TRIMS_GPIO_PIN_LHL GPIO_Pin_3 // PD.03
|
||||
#define TRIMS_GPIO_REG_LVU GPIOJ->IDR
|
||||
#define TRIMS_GPIO_PIN_LVU GPIO_Pin_12 // PJ.12
|
||||
#define TRIMS_GPIO_REG_LHR GPIOD->IDR
|
||||
#define TRIMS_GPIO_PIN_LHR GPIO_Pin_7 // PD.07
|
||||
#define TRIMS_GPIO_REG_RSD GPIOJ->IDR
|
||||
#define TRIMS_GPIO_PIN_RSD GPIO_Pin_8 // PJ.08
|
||||
#define TRIMS_GPIO_REG_RSU GPIOD->IDR
|
||||
|
@ -81,13 +81,13 @@
|
|||
|
||||
// Index of all keys
|
||||
#define KEYS_GPIOB_PINS (SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_C_H | TRIMS_GPIO_PIN_LSD | TRIMS_GPIO_PIN_LSU)
|
||||
#define KEYS_GPIOC_PINS (KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_ENTER | KEYS_GPIO_PIN_RIGHT | TRIMS_GPIO_PIN_LHL)
|
||||
#define KEYS_GPIOD_PINS (SWITCHES_GPIO_PIN_C_L | TRIMS_GPIO_PIN_RHL | TRIMS_GPIO_PIN_RHR | TRIMS_GPIO_PIN_RSU)
|
||||
#define KEYS_GPIOC_PINS (KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_ENTER | KEYS_GPIO_PIN_RIGHT | TRIMS_GPIO_PIN_RHL)
|
||||
#define KEYS_GPIOD_PINS (SWITCHES_GPIO_PIN_C_L | TRIMS_GPIO_PIN_LHL | TRIMS_GPIO_PIN_LHR | TRIMS_GPIO_PIN_RSU)
|
||||
#define KEYS_GPIOE_PINS (SWITCHES_GPIO_PIN_E_L)
|
||||
#define KEYS_GPIOG_PINS (KEYS_GPIO_PIN_UP | SWITCHES_GPIO_PIN_D_L | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L | SWITCHES_GPIO_PIN_H | TRIMS_GPIO_PIN_LVD)
|
||||
#define KEYS_GPIOG_PINS (KEYS_GPIO_PIN_UP | SWITCHES_GPIO_PIN_D_L | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L | SWITCHES_GPIO_PIN_H | TRIMS_GPIO_PIN_RVD)
|
||||
#define KEYS_GPIOH_PINS (SWITCHES_GPIO_PIN_A_L | SWITCHES_GPIO_PIN_B_H | SWITCHES_GPIO_PIN_E_H | SWITCHES_GPIO_PIN_F | ENC_GPIO_PIN_A | ENC_GPIO_PIN_B)
|
||||
#define KEYS_GPIOI_PINS (KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_LEFT | KEYS_GPIO_PIN_DOWN | SWITCHES_GPIO_PIN_A_H | TRIMS_GPIO_PIN_LHR)
|
||||
#define KEYS_GPIOJ_PINS (SWITCHES_GPIO_PIN_D_H | TRIMS_GPIO_PIN_LVU | TRIMS_GPIO_PIN_RVD | TRIMS_GPIO_PIN_RVU | TRIMS_GPIO_PIN_RSD)
|
||||
#define KEYS_GPIOI_PINS (KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_LEFT | KEYS_GPIO_PIN_DOWN | SWITCHES_GPIO_PIN_A_H | TRIMS_GPIO_PIN_RHR)
|
||||
#define KEYS_GPIOJ_PINS (SWITCHES_GPIO_PIN_D_H | TRIMS_GPIO_PIN_RVU | TRIMS_GPIO_PIN_LVD | TRIMS_GPIO_PIN_LVU | TRIMS_GPIO_PIN_RSD)
|
||||
|
||||
// ADC
|
||||
#define ADC_RCC_AHB1Periph_GPIO (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC)
|
||||
|
|
|
@ -9,22 +9,20 @@
|
|||
#define HFP 3
|
||||
#define VFP 2
|
||||
|
||||
#define LCD_PIXEL_WIDTH ((uint16_t)480)
|
||||
#define LCD_PIXEL_HEIGHT ((uint16_t)272)
|
||||
|
||||
#define LCD_DIR_HORIZONTAL 0x0000
|
||||
#define LCD_DIR_VERTICAL 0x0001
|
||||
|
||||
#define LCD_BACKGROUND_LAYER 0x0000
|
||||
#define LCD_FOREGROUND_LAYER 0x0001
|
||||
#define LCD_FIRST_LAYER 0
|
||||
#define LCD_SECOND_LAYER 1
|
||||
|
||||
#define LCD_BKLIGHT_PWM_FREQ 300
|
||||
|
||||
#define LCD_DEFAULT_FRAME_BUFFER SDRAM_BANK_ADDR
|
||||
#define FRAME_BUFFER_OFFSET ((uint32_t)0x100000)
|
||||
#define LCD_FIRST_FRAME_BUFFER SDRAM_BANK_ADDR
|
||||
#define LCD_SECOND_FRAME_BUFFER (SDRAM_BANK_ADDR + DISPLAY_BUFFER_SIZE)
|
||||
#define LCD_BACKUP_FRAME_BUFFER (SDRAM_BANK_ADDR + 2*DISPLAY_BUFFER_SIZE)
|
||||
|
||||
uint32_t CurrentFrameBuffer = LCD_DEFAULT_FRAME_BUFFER;
|
||||
uint32_t CurrentLayer = LCD_BACKGROUND_LAYER;
|
||||
uint32_t CurrentFrameBuffer = LCD_FIRST_FRAME_BUFFER;
|
||||
uint32_t CurrentLayer = LCD_FIRST_LAYER;
|
||||
|
||||
#define NRST_LOW() do { LCD_GPIO_NRST->BSRRH = LCD_GPIO_PIN_NRST; } while(0)
|
||||
#define NRST_HIGH() do { LCD_GPIO_NRST->BSRRL = LCD_GPIO_PIN_NRST; } while(0)
|
||||
|
@ -193,13 +191,13 @@ void LCD_Init_LTDC(void)
|
|||
/* Configure accumulated vertical back porch */
|
||||
LTDC_InitStruct.LTDC_AccumulatedVBP = VBP;
|
||||
/* Configure accumulated active width */
|
||||
LTDC_InitStruct.LTDC_AccumulatedActiveW = LCD_PIXEL_WIDTH + HBP;
|
||||
LTDC_InitStruct.LTDC_AccumulatedActiveW = LCD_W + HBP;
|
||||
/* Configure accumulated active height */
|
||||
LTDC_InitStruct.LTDC_AccumulatedActiveH = LCD_PIXEL_HEIGHT + VBP;
|
||||
LTDC_InitStruct.LTDC_AccumulatedActiveH = LCD_H + VBP;
|
||||
/* Configure total width */
|
||||
LTDC_InitStruct.LTDC_TotalWidth = LCD_PIXEL_WIDTH + HBP + HFP;
|
||||
LTDC_InitStruct.LTDC_TotalWidth = LCD_W + HBP + HFP;
|
||||
/* Configure total height */
|
||||
LTDC_InitStruct.LTDC_TotalHeigh = LCD_PIXEL_HEIGHT + VBP + VFP;
|
||||
LTDC_InitStruct.LTDC_TotalHeigh = LCD_H + VBP + VFP;
|
||||
|
||||
// init ltdc
|
||||
LTDC_Init(<DC_InitStruct);
|
||||
|
@ -240,9 +238,9 @@ void LCD_LayerInit()
|
|||
Vertical start = vertical synchronization + vertical back porch = 4
|
||||
Vertical stop = Vertical start + window height -1 = 4 + 320 -1 */
|
||||
LTDC_Layer_InitStruct.LTDC_HorizontalStart = HBP + 1;
|
||||
LTDC_Layer_InitStruct.LTDC_HorizontalStop = (LCD_PIXEL_WIDTH + HBP);
|
||||
LTDC_Layer_InitStruct.LTDC_HorizontalStop = (LCD_W + HBP);
|
||||
LTDC_Layer_InitStruct.LTDC_VerticalStart = VBP + 1;;
|
||||
LTDC_Layer_InitStruct.LTDC_VerticalStop = (LCD_PIXEL_HEIGHT + VBP);
|
||||
LTDC_Layer_InitStruct.LTDC_VerticalStop = (LCD_H + VBP);
|
||||
|
||||
/* Pixel Format configuration*/
|
||||
LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565;
|
||||
|
@ -260,20 +258,20 @@ void LCD_LayerInit()
|
|||
|
||||
/* the length of one line of pixels in bytes + 3 then :
|
||||
Line Lenth = Active high width x number of bytes per pixel + 3
|
||||
Active high width = LCD_PIXEL_WIDTH
|
||||
Active high width = LCD_W
|
||||
number of bytes per pixel = 2 (pixel_format : RGB565)
|
||||
*/
|
||||
LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((LCD_PIXEL_WIDTH * 2) + 3);
|
||||
LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((LCD_W * 2) + 3);
|
||||
/* the pitch is the increment from the start of one line of pixels to the
|
||||
start of the next line in bytes, then :
|
||||
Pitch = Active high width x number of bytes per pixel */
|
||||
LTDC_Layer_InitStruct.LTDC_CFBPitch = (LCD_PIXEL_WIDTH * 2);
|
||||
LTDC_Layer_InitStruct.LTDC_CFBPitch = (LCD_W * 2);
|
||||
|
||||
/* Configure the number of lines */
|
||||
LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCD_PIXEL_HEIGHT;
|
||||
LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCD_H;
|
||||
|
||||
/* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/ Offset */
|
||||
LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_DEFAULT_FRAME_BUFFER;
|
||||
LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FIRST_FRAME_BUFFER;
|
||||
|
||||
/* Initialize LTDC layer 1 */
|
||||
LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct);
|
||||
|
@ -283,7 +281,7 @@ void LCD_LayerInit()
|
|||
LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA;
|
||||
|
||||
/* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/ Offset */
|
||||
LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_DEFAULT_FRAME_BUFFER + FRAME_BUFFER_OFFSET;
|
||||
LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FIRST_FRAME_BUFFER + DISPLAY_BUFFER_SIZE;
|
||||
|
||||
/* Initialize LTDC layer 2 */
|
||||
LTDC_LayerInit(LTDC_Layer2, <DC_Layer_InitStruct);
|
||||
|
@ -377,25 +375,21 @@ void LCD_Init(void)
|
|||
*/
|
||||
void LCD_SetLayer(uint32_t Layerx)
|
||||
{
|
||||
if (Layerx == LCD_BACKGROUND_LAYER)
|
||||
if (Layerx == LCD_FIRST_LAYER)
|
||||
{
|
||||
CurrentFrameBuffer = LCD_DEFAULT_FRAME_BUFFER;
|
||||
CurrentLayer = LCD_BACKGROUND_LAYER;
|
||||
CurrentFrameBuffer = LCD_FIRST_FRAME_BUFFER;
|
||||
CurrentLayer = LCD_FIRST_LAYER;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentFrameBuffer = LCD_DEFAULT_FRAME_BUFFER + FRAME_BUFFER_OFFSET;
|
||||
CurrentLayer = LCD_FOREGROUND_LAYER;
|
||||
CurrentFrameBuffer = LCD_FIRST_FRAME_BUFFER + DISPLAY_BUFFER_SIZE;
|
||||
CurrentLayer = LCD_SECOND_LAYER;
|
||||
}
|
||||
}
|
||||
|
||||
void LCD_Clear(uint16_t Color)
|
||||
{
|
||||
uint16_t *index ;
|
||||
|
||||
/* erase memory */
|
||||
for (index = (uint16_t *)CurrentFrameBuffer; index < (uint16_t *)(CurrentFrameBuffer+(FRAME_BUFFER_OFFSET)); index++)
|
||||
{
|
||||
for (uint16_t * index = (uint16_t *)CurrentFrameBuffer; index < (uint16_t *)(CurrentFrameBuffer+DISPLAY_BUFFER_SIZE); index++) {
|
||||
*index = Color;
|
||||
}
|
||||
}
|
||||
|
@ -408,12 +402,10 @@ void LCD_Clear(uint16_t Color)
|
|||
*/
|
||||
void LCD_SetTransparency(uint8_t transparency)
|
||||
{
|
||||
if (CurrentLayer == LCD_BACKGROUND_LAYER)
|
||||
{
|
||||
if (CurrentLayer == LCD_FIRST_LAYER) {
|
||||
LTDC_LayerAlpha(LTDC_Layer1, transparency);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
LTDC_LayerAlpha(LTDC_Layer2, transparency);
|
||||
}
|
||||
LTDC_ReloadConfig(LTDC_IMReload);
|
||||
|
@ -429,19 +421,19 @@ void lcdInit(void)
|
|||
LTDC_Cmd(ENABLE);
|
||||
|
||||
/* Set Background layer */
|
||||
LCD_SetLayer(LCD_BACKGROUND_LAYER);
|
||||
LCD_SetLayer(LCD_FIRST_LAYER);
|
||||
LCD_Clear(0);
|
||||
LCD_SetTransparency(0);
|
||||
|
||||
/* Set Foreground layer */
|
||||
LCD_SetLayer(LCD_FOREGROUND_LAYER);
|
||||
LCD_SetLayer(LCD_SECOND_LAYER);
|
||||
LCD_Clear(0);
|
||||
LCD_SetTransparency(255);
|
||||
}
|
||||
|
||||
void lcdDrawSolidFilledRectDMA(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
|
||||
{
|
||||
uint32_t addr = CurrentFrameBuffer + 2*(LCD_PIXEL_WIDTH*y + x);
|
||||
uint32_t addr = CurrentFrameBuffer + 2*(LCD_W*y + x);
|
||||
uint16_t red = (0xF800 & color) >> 11;
|
||||
uint16_t blue = 0x001F & color;
|
||||
uint16_t green = (0x07E0 & color) >> 5;
|
||||
|
@ -456,7 +448,7 @@ void lcdDrawSolidFilledRectDMA(uint16_t x, uint16_t y, uint16_t w, uint16_t h, u
|
|||
DMA2D_InitStruct.DMA2D_OutputRed = red;
|
||||
DMA2D_InitStruct.DMA2D_OutputAlpha = 0x0F;
|
||||
DMA2D_InitStruct.DMA2D_OutputMemoryAdd = addr;
|
||||
DMA2D_InitStruct.DMA2D_OutputOffset = (LCD_PIXEL_WIDTH - w);
|
||||
DMA2D_InitStruct.DMA2D_OutputOffset = (LCD_W - w);
|
||||
DMA2D_InitStruct.DMA2D_NumberOfLine = h;
|
||||
DMA2D_InitStruct.DMA2D_PixelPerLine = w;
|
||||
DMA2D_Init(&DMA2D_InitStruct);
|
||||
|
@ -468,12 +460,26 @@ void lcdDrawSolidFilledRectDMA(uint16_t x, uint16_t y, uint16_t w, uint16_t h, u
|
|||
while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET);
|
||||
}
|
||||
|
||||
void lcdStoreBackupBuffer()
|
||||
{
|
||||
for (uint16_t * src = (uint16_t *)CurrentFrameBuffer, * dest = (uint16_t *)LCD_BACKUP_FRAME_BUFFER; src < (uint16_t *)(CurrentFrameBuffer+DISPLAY_BUFFER_SIZE); src++, dest++) {
|
||||
*dest = *src;
|
||||
}
|
||||
}
|
||||
|
||||
void lcdRestoreBackupBuffer()
|
||||
{
|
||||
for (uint16_t * dest = (uint16_t *)CurrentFrameBuffer, * src = (uint16_t *)LCD_BACKUP_FRAME_BUFFER; dest < (uint16_t *)(CurrentFrameBuffer+DISPLAY_BUFFER_SIZE); src++, dest++) {
|
||||
*dest = *src;
|
||||
}
|
||||
}
|
||||
|
||||
void lcdRefresh()
|
||||
{
|
||||
LCD_SetTransparency(255);
|
||||
if (CurrentLayer == LCD_BACKGROUND_LAYER)
|
||||
LCD_SetLayer(LCD_FOREGROUND_LAYER);
|
||||
if (CurrentLayer == LCD_FIRST_LAYER)
|
||||
LCD_SetLayer(LCD_SECOND_LAYER);
|
||||
else
|
||||
LCD_SetLayer(LCD_BACKGROUND_LAYER);
|
||||
LCD_SetLayer(LCD_FIRST_LAYER);
|
||||
LCD_SetTransparency(0);
|
||||
}
|
||||
|
|
|
@ -331,21 +331,6 @@
|
|||
*/
|
||||
#define SDIO_SEND_IF_COND ((uint32_t)0x00000008)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32F4_DISCOVERY_SDIO_SD_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32F4_DISCOVERY_SDIO_SD_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
static uint32_t CardType = SDIO_STD_CAPACITY_SD_CARD_V1_1;
|
||||
static uint32_t CSD_Tab[4], CID_Tab[4], RCA = 0;
|
||||
static uint8_t SDSTATUS_Tab[16];
|
||||
|
@ -357,14 +342,7 @@ SD_CardInfo SDCardInfo;
|
|||
SDIO_InitTypeDef SDIO_InitStructure;
|
||||
SDIO_CmdInitTypeDef SDIO_CmdInitStructure;
|
||||
SDIO_DataInitTypeDef SDIO_DataInitStructure;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup STM32F4_DISCOVERY_SDIO_SD_Private_Function_Prototypes
|
||||
* @{
|
||||
*/
|
||||
static SD_Error CmdError(void);
|
||||
static SD_Error CmdResp1Error(uint8_t cmd);
|
||||
static SD_Error CmdResp7Error(void);
|
||||
|
@ -440,7 +418,7 @@ void SD_LowLevel_Init(void)
|
|||
|
||||
/* Configure PC.08, PC.09, PC.10, PC.11 pins: D0, D1, D2, D3 pins */
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
|
@ -498,7 +476,7 @@ void SD_LowLevel_DMA_TxConfig(uint32_t *BufferSRC, uint32_t BufferSize)
|
|||
SDDMA_InitStructure.DMA_PeripheralBaseAddr = SD_SDIO_FIFO_ADDRESS;
|
||||
SDDMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)BufferSRC;
|
||||
SDDMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
|
||||
SDDMA_InitStructure.DMA_BufferSize = 0;
|
||||
SDDMA_InitStructure.DMA_BufferSize = 1;
|
||||
SDDMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||
SDDMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||
SDDMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
|
||||
|
@ -540,7 +518,7 @@ void SD_LowLevel_DMA_RxConfig(uint32_t *BufferDST, uint32_t BufferSize)
|
|||
SDDMA_InitStructure.DMA_PeripheralBaseAddr = SD_SDIO_FIFO_ADDRESS;
|
||||
SDDMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)BufferDST;
|
||||
SDDMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
|
||||
SDDMA_InitStructure.DMA_BufferSize = 0;
|
||||
SDDMA_InitStructure.DMA_BufferSize = 1;
|
||||
SDDMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||
SDDMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||
SDDMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
|
||||
|
@ -712,13 +690,17 @@ uint8_t SD_Detect(void)
|
|||
return status;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
//disable optimize
|
||||
#define OPTIMIZE(level) __attribute__((optimize(level)))
|
||||
|
||||
/**
|
||||
* @brief Enquires cards about their operating voltage and configures
|
||||
* clock controls.
|
||||
* @param None
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_PowerON(void)
|
||||
OPTIMIZE("O0") SD_Error SD_PowerON(void)
|
||||
{
|
||||
__IO SD_Error errorstatus = SD_OK;
|
||||
uint32_t response = 0, count = 0, validvoltage = 0;
|
||||
|
@ -865,7 +847,7 @@ SD_Error SD_PowerON(void)
|
|||
* @param None
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_PowerOFF(void)
|
||||
OPTIMIZE("O0") SD_Error SD_PowerOFF(void)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
|
||||
|
@ -881,7 +863,7 @@ SD_Error SD_PowerOFF(void)
|
|||
* @param None
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_InitializeCards(void)
|
||||
OPTIMIZE("O0") SD_Error SD_InitializeCards(void)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
uint16_t rca = 0x01;
|
||||
|
@ -970,7 +952,7 @@ SD_Error SD_InitializeCards(void)
|
|||
* information.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_GetCardInfo(SD_CardInfo *cardinfo)
|
||||
OPTIMIZE("O0") SD_Error SD_GetCardInfo(SD_CardInfo *cardinfo)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
uint8_t tmp = 0;
|
||||
|
@ -1061,7 +1043,7 @@ SD_Error SD_GetCardInfo(SD_CardInfo *cardinfo)
|
|||
/*!< Byte 10 */
|
||||
tmp = (uint8_t)((CSD_Tab[2] & 0x0000FF00) >> 8);
|
||||
|
||||
cardinfo->CardCapacity = (uint64_t)(cardinfo->SD_csd.DeviceSize + 1) * (uint64_t)(512 * 1024);
|
||||
cardinfo->CardCapacity = ((uint64_t)cardinfo->SD_csd.DeviceSize + 1) * 512 * 1024;
|
||||
cardinfo->CardBlockSize = 512;
|
||||
}
|
||||
|
||||
|
@ -1182,7 +1164,7 @@ SD_Error SD_GetCardInfo(SD_CardInfo *cardinfo)
|
|||
* @arg SDIO_BusWide_1b: 1-bit data transfer
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_GetCardStatus(SD_CardStatus *cardstatus)
|
||||
OPTIMIZE("O0") SD_Error SD_GetCardStatus(SD_CardStatus *cardstatus)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
uint8_t tmp = 0;
|
||||
|
@ -1267,7 +1249,7 @@ SD_Error SD_GetCardStatus(SD_CardStatus *cardstatus)
|
|||
* @arg SDIO_BusWide_1b: 1-bit data transfer
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_EnableWideBusOperation(uint32_t WideMode)
|
||||
OPTIMIZE("O0") SD_Error SD_EnableWideBusOperation(uint32_t WideMode)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
|
||||
|
@ -1326,7 +1308,7 @@ SD_Error SD_EnableWideBusOperation(uint32_t WideMode)
|
|||
* @param addr: Address of the Card to be selected.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_SelectDeselect(uint32_t addr)
|
||||
OPTIMIZE("O0") SD_Error SD_SelectDeselect(uint32_t addr)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
|
||||
|
@ -1357,7 +1339,7 @@ SD_Error SD_SelectDeselect(uint32_t addr)
|
|||
* @param BlockSize: the SD card Data block size. The Block size should be 512.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_ReadBlock(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize)
|
||||
OPTIMIZE("O0") SD_Error SD_ReadBlock(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
#if defined (SD_POLLING_MODE)
|
||||
|
@ -1367,13 +1349,21 @@ SD_Error SD_ReadBlock(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize)
|
|||
TransferError = SD_OK;
|
||||
TransferEnd = 0;
|
||||
StopCondition = 0;
|
||||
DMAEndOfTransfer = 0;
|
||||
|
||||
SDIO->DCTRL = 0x0;
|
||||
|
||||
if (CardType == SDIO_HIGH_CAPACITY_SD_CARD)
|
||||
{
|
||||
#if defined (SD_DMA_MODE)
|
||||
SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE);
|
||||
SDIO_DMACmd(ENABLE);
|
||||
SD_LowLevel_DMA_RxConfig((uint32_t *)readbuff, BlockSize);
|
||||
#endif
|
||||
|
||||
if (CardType == SDIO_HIGH_CAPACITY_SD_CARD) {
|
||||
BlockSize = 512;
|
||||
ReadAddr /= 512;
|
||||
}
|
||||
else {
|
||||
ReadAddr *= 512;
|
||||
}
|
||||
|
||||
/* Set Block Size for Card */
|
||||
|
@ -1464,10 +1454,6 @@ SD_Error SD_ReadBlock(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize)
|
|||
/*!< Clear all the static flags */
|
||||
SDIO_ClearFlag(SDIO_STATIC_FLAGS);
|
||||
|
||||
#elif defined (SD_DMA_MODE)
|
||||
SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE);
|
||||
SDIO_DMACmd(ENABLE);
|
||||
SD_LowLevel_DMA_RxConfig((uint32_t *)readbuff, BlockSize);
|
||||
#endif
|
||||
|
||||
return(errorstatus);
|
||||
|
@ -1488,19 +1474,25 @@ SD_Error SD_ReadBlock(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize)
|
|||
* @param NumberOfBlocks: number of blocks to be read.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_ReadMultiBlocks(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks)
|
||||
OPTIMIZE("O0") SD_Error SD_ReadMultiBlocks(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
TransferError = SD_OK;
|
||||
TransferEnd = 0;
|
||||
StopCondition = 1;
|
||||
DMAEndOfTransfer = 0;
|
||||
|
||||
SDIO->DCTRL = 0x0;
|
||||
|
||||
if (CardType == SDIO_HIGH_CAPACITY_SD_CARD)
|
||||
{
|
||||
SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE);
|
||||
SD_LowLevel_DMA_RxConfig((uint32_t *)readbuff, (NumberOfBlocks * BlockSize));
|
||||
SDIO_DMACmd(ENABLE);
|
||||
|
||||
if (CardType == SDIO_HIGH_CAPACITY_SD_CARD) {
|
||||
BlockSize = 512;
|
||||
ReadAddr /= 512;
|
||||
}
|
||||
else {
|
||||
ReadAddr *= 512;
|
||||
}
|
||||
|
||||
/*!< Set Block Size for Card */
|
||||
|
@ -1541,71 +1533,6 @@ SD_Error SD_ReadMultiBlocks(uint8_t *readbuff, uint32_t ReadAddr, uint16_t Block
|
|||
return(errorstatus);
|
||||
}
|
||||
|
||||
SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE);
|
||||
SDIO_DMACmd(ENABLE);
|
||||
SD_LowLevel_DMA_RxConfig((uint32_t *)readbuff, (NumberOfBlocks * BlockSize));
|
||||
|
||||
return(errorstatus);
|
||||
}
|
||||
|
||||
// FIXED Version where ReadAddr is in BLOCKS NOT BYTES, permits SDHC media >4GB
|
||||
|
||||
SD_Error SD_ReadMultiBlocksFIXED(uint8_t *readbuff, uint32_t ReadAddr, uint32_t BlockSize, uint32_t NumberOfBlocks)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
TransferError = SD_OK;
|
||||
TransferEnd = 0;
|
||||
StopCondition = 1;
|
||||
|
||||
SDIO->DCTRL = 0x0;
|
||||
|
||||
if (CardType == SDIO_HIGH_CAPACITY_SD_CARD)
|
||||
BlockSize = 512;
|
||||
else
|
||||
ReadAddr *= BlockSize; // Convert to Bytes for NON SDHC
|
||||
|
||||
/*!< Set Block Size for Card */
|
||||
SDIO_CmdInitStructure.SDIO_Argument = (uint32_t) BlockSize;
|
||||
SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_SET_BLOCKLEN;
|
||||
SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
|
||||
SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
|
||||
SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
|
||||
SDIO_SendCommand(&SDIO_CmdInitStructure);
|
||||
|
||||
errorstatus = CmdResp1Error(SD_CMD_SET_BLOCKLEN);
|
||||
|
||||
if (SD_OK != errorstatus)
|
||||
{
|
||||
return(errorstatus);
|
||||
}
|
||||
|
||||
SDIO_DataInitStructure.SDIO_DataTimeOut = SD_DATATIMEOUT;
|
||||
SDIO_DataInitStructure.SDIO_DataLength = NumberOfBlocks * BlockSize;
|
||||
SDIO_DataInitStructure.SDIO_DataBlockSize = (uint32_t) 9 << 4;
|
||||
SDIO_DataInitStructure.SDIO_TransferDir = SDIO_TransferDir_ToSDIO;
|
||||
SDIO_DataInitStructure.SDIO_TransferMode = SDIO_TransferMode_Block;
|
||||
SDIO_DataInitStructure.SDIO_DPSM = SDIO_DPSM_Enable;
|
||||
SDIO_DataConfig(&SDIO_DataInitStructure);
|
||||
|
||||
/*!< Send CMD18 READ_MULT_BLOCK with argument data address */
|
||||
SDIO_CmdInitStructure.SDIO_Argument = (uint32_t)ReadAddr;
|
||||
SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_READ_MULT_BLOCK;
|
||||
SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
|
||||
SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
|
||||
SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
|
||||
SDIO_SendCommand(&SDIO_CmdInitStructure);
|
||||
|
||||
errorstatus = CmdResp1Error(SD_CMD_READ_MULT_BLOCK);
|
||||
|
||||
if (errorstatus != SD_OK)
|
||||
{
|
||||
return(errorstatus);
|
||||
}
|
||||
|
||||
SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE);
|
||||
SDIO_DMACmd(ENABLE);
|
||||
SD_LowLevel_DMA_RxConfig((uint32_t *)readbuff, (NumberOfBlocks * BlockSize));
|
||||
|
||||
return(errorstatus);
|
||||
}
|
||||
|
||||
|
@ -1617,7 +1544,7 @@ SD_Error SD_ReadMultiBlocksFIXED(uint8_t *readbuff, uint32_t ReadAddr, uint32_t
|
|||
* @param None.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_WaitReadOperation(void)
|
||||
OPTIMIZE("O0") SD_Error SD_WaitReadOperation(void)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
uint32_t timeout;
|
||||
|
@ -1641,6 +1568,7 @@ SD_Error SD_WaitReadOperation(void)
|
|||
if (StopCondition == 1)
|
||||
{
|
||||
errorstatus = SD_StopTransfer();
|
||||
StopCondition = 0;
|
||||
}
|
||||
|
||||
if ((timeout == 0) && (errorstatus == SD_OK))
|
||||
|
@ -1675,7 +1603,7 @@ SD_Error SD_WaitReadOperation(void)
|
|||
* @param BlockSize: the SD card Data block size. The Block size should be 512.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_WriteBlock(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSize)
|
||||
OPTIMIZE("O0") SD_Error SD_WriteBlock(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSize)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
|
||||
|
@ -1690,6 +1618,11 @@ SD_Error SD_WriteBlock(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSiz
|
|||
|
||||
SDIO->DCTRL = 0x0;
|
||||
|
||||
#if defined (SD_DMA_MODE)
|
||||
SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE);
|
||||
SD_LowLevel_DMA_TxConfig((uint32_t *)writebuff, BlockSize);
|
||||
SDIO_DMACmd(ENABLE);
|
||||
#endif
|
||||
|
||||
if (CardType == SDIO_HIGH_CAPACITY_SD_CARD)
|
||||
{
|
||||
|
@ -1784,10 +1717,6 @@ SD_Error SD_WriteBlock(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSiz
|
|||
errorstatus = SD_START_BIT_ERR;
|
||||
return(errorstatus);
|
||||
}
|
||||
#elif defined (SD_DMA_MODE)
|
||||
SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE);
|
||||
SD_LowLevel_DMA_TxConfig((uint32_t *)writebuff, BlockSize);
|
||||
SDIO_DMACmd(ENABLE);
|
||||
#endif
|
||||
|
||||
return(errorstatus);
|
||||
|
@ -1808,7 +1737,7 @@ SD_Error SD_WriteBlock(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSiz
|
|||
* @param NumberOfBlocks: number of blocks to be written.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_WriteMultiBlocks(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSize, uint32_t NumberOfBlocks)
|
||||
OPTIMIZE("O0") SD_Error SD_WriteMultiBlocks(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSize, uint32_t NumberOfBlocks)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
|
||||
|
@ -1818,6 +1747,10 @@ SD_Error SD_WriteMultiBlocks(uint8_t *writebuff, uint32_t WriteAddr, uint16_t Bl
|
|||
|
||||
SDIO->DCTRL = 0x0;
|
||||
|
||||
SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_TXUNDERR | SDIO_IT_STBITERR, ENABLE);
|
||||
SD_LowLevel_DMA_TxConfig((uint32_t *)writebuff, (NumberOfBlocks * BlockSize));
|
||||
SDIO_DMACmd(ENABLE);
|
||||
|
||||
if (CardType == SDIO_HIGH_CAPACITY_SD_CARD)
|
||||
{
|
||||
BlockSize = 512;
|
||||
|
@ -1893,105 +1826,9 @@ SD_Error SD_WriteMultiBlocks(uint8_t *writebuff, uint32_t WriteAddr, uint16_t Bl
|
|||
SDIO_DataInitStructure.SDIO_DPSM = SDIO_DPSM_Enable;
|
||||
SDIO_DataConfig(&SDIO_DataInitStructure);
|
||||
|
||||
SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE);
|
||||
SDIO_DMACmd(ENABLE);
|
||||
SD_LowLevel_DMA_TxConfig((uint32_t *)writebuff, (NumberOfBlocks * BlockSize));
|
||||
|
||||
return(errorstatus);
|
||||
}
|
||||
|
||||
// FIXED Version where WriteAddr is in BLOCKS NOT BYTES, permits SDHC media >4GB
|
||||
|
||||
SD_Error SD_WriteMultiBlocksFIXED(uint8_t *writebuff, uint32_t WriteAddr, uint32_t BlockSize, uint32_t NumberOfBlocks)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
|
||||
TransferError = SD_OK;
|
||||
TransferEnd = 0;
|
||||
StopCondition = 1;
|
||||
|
||||
SDIO->DCTRL = 0x0;
|
||||
|
||||
if (CardType == SDIO_HIGH_CAPACITY_SD_CARD)
|
||||
BlockSize = 512;
|
||||
else
|
||||
WriteAddr *= BlockSize; // Convert to Bytes for NON SDHC
|
||||
|
||||
/* Set Block Size for Card */
|
||||
SDIO_CmdInitStructure.SDIO_Argument = (uint32_t) BlockSize;
|
||||
SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_SET_BLOCKLEN;
|
||||
SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
|
||||
SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
|
||||
SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
|
||||
SDIO_SendCommand(&SDIO_CmdInitStructure);
|
||||
|
||||
errorstatus = CmdResp1Error(SD_CMD_SET_BLOCKLEN);
|
||||
|
||||
if (SD_OK != errorstatus)
|
||||
{
|
||||
return(errorstatus);
|
||||
}
|
||||
|
||||
/*!< To improve performance */
|
||||
SDIO_CmdInitStructure.SDIO_Argument = (uint32_t) (RCA << 16);
|
||||
SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_APP_CMD;
|
||||
SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
|
||||
SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
|
||||
SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
|
||||
SDIO_SendCommand(&SDIO_CmdInitStructure);
|
||||
|
||||
|
||||
errorstatus = CmdResp1Error(SD_CMD_APP_CMD);
|
||||
|
||||
if (errorstatus != SD_OK)
|
||||
{
|
||||
return(errorstatus);
|
||||
}
|
||||
/*!< To improve performance */
|
||||
SDIO_CmdInitStructure.SDIO_Argument = (uint32_t)NumberOfBlocks;
|
||||
SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_SET_BLOCK_COUNT;
|
||||
SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
|
||||
SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
|
||||
SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
|
||||
SDIO_SendCommand(&SDIO_CmdInitStructure);
|
||||
|
||||
errorstatus = CmdResp1Error(SD_CMD_SET_BLOCK_COUNT);
|
||||
|
||||
if (errorstatus != SD_OK)
|
||||
{
|
||||
return(errorstatus);
|
||||
}
|
||||
|
||||
|
||||
/*!< Send CMD25 WRITE_MULT_BLOCK with argument data address */
|
||||
SDIO_CmdInitStructure.SDIO_Argument = (uint32_t)WriteAddr;
|
||||
SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_WRITE_MULT_BLOCK;
|
||||
SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
|
||||
SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
|
||||
SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
|
||||
SDIO_SendCommand(&SDIO_CmdInitStructure);
|
||||
|
||||
errorstatus = CmdResp1Error(SD_CMD_WRITE_MULT_BLOCK);
|
||||
|
||||
if (SD_OK != errorstatus)
|
||||
{
|
||||
return(errorstatus);
|
||||
}
|
||||
|
||||
SDIO_DataInitStructure.SDIO_DataTimeOut = SD_DATATIMEOUT;
|
||||
SDIO_DataInitStructure.SDIO_DataLength = NumberOfBlocks * BlockSize;
|
||||
SDIO_DataInitStructure.SDIO_DataBlockSize = (uint32_t) 9 << 4;
|
||||
SDIO_DataInitStructure.SDIO_TransferDir = SDIO_TransferDir_ToCard;
|
||||
SDIO_DataInitStructure.SDIO_TransferMode = SDIO_TransferMode_Block;
|
||||
SDIO_DataInitStructure.SDIO_DPSM = SDIO_DPSM_Enable;
|
||||
SDIO_DataConfig(&SDIO_DataInitStructure);
|
||||
|
||||
SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE);
|
||||
SDIO_DMACmd(ENABLE);
|
||||
SD_LowLevel_DMA_TxConfig((uint32_t *)writebuff, (NumberOfBlocks * BlockSize));
|
||||
|
||||
return(errorstatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function waits until the SDIO DMA data transfer is finished.
|
||||
|
@ -2001,7 +1838,7 @@ SD_Error SD_WriteMultiBlocksFIXED(uint8_t *writebuff, uint32_t WriteAddr, uint32
|
|||
* @param None.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_WaitWriteOperation(void)
|
||||
OPTIMIZE("O0") SD_Error SD_WaitWriteOperation(void)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
uint32_t timeout;
|
||||
|
@ -2025,6 +1862,7 @@ SD_Error SD_WaitWriteOperation(void)
|
|||
if (StopCondition == 1)
|
||||
{
|
||||
errorstatus = SD_StopTransfer();
|
||||
StopCondition = 0;
|
||||
}
|
||||
|
||||
if ((timeout == 0) && (errorstatus == SD_OK))
|
||||
|
@ -2053,7 +1891,7 @@ SD_Error SD_WaitWriteOperation(void)
|
|||
* - SD_TRANSFER_OK: No data transfer is acting
|
||||
* - SD_TRANSFER_BUSY: Data transfer is acting
|
||||
*/
|
||||
SDTransferState SD_GetTransferState(void)
|
||||
OPTIMIZE("O0") SDTransferState SD_GetTransferState(void)
|
||||
{
|
||||
if (SDIO->STA & (SDIO_FLAG_TXACT | SDIO_FLAG_RXACT))
|
||||
{
|
||||
|
@ -2070,7 +1908,7 @@ SDTransferState SD_GetTransferState(void)
|
|||
* @param None
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_StopTransfer(void)
|
||||
OPTIMIZE("O0") SD_Error SD_StopTransfer(void)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
|
||||
|
@ -2093,7 +1931,7 @@ SD_Error SD_StopTransfer(void)
|
|||
* @param endaddr: the end address.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_Erase(uint32_t startaddr, uint32_t endaddr)
|
||||
OPTIMIZE("O0") SD_Error SD_Erase(uint32_t startaddr, uint32_t endaddr)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
uint32_t delay = 0;
|
||||
|
@ -2189,7 +2027,7 @@ SD_Error SD_Erase(uint32_t startaddr, uint32_t endaddr)
|
|||
* status (Card Status register).
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_SendStatus(uint32_t *pcardstatus)
|
||||
OPTIMIZE("O0") SD_Error SD_SendStatus(uint32_t *pcardstatus)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
|
||||
|
@ -2224,7 +2062,7 @@ SD_Error SD_SendStatus(uint32_t *pcardstatus)
|
|||
* (SD Status register).
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_SendSDStatus(uint32_t *psdstatus)
|
||||
OPTIMIZE("O0") SD_Error SD_SendSDStatus(uint32_t *psdstatus)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
uint32_t count = 0;
|
||||
|
@ -2341,7 +2179,7 @@ SD_Error SD_SendSDStatus(uint32_t *psdstatus)
|
|||
* @param None
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
SD_Error SD_ProcessIRQ(void)
|
||||
OPTIMIZE("O0") SD_Error SD_ProcessIRQ(void)
|
||||
{
|
||||
if (SDIO_GetITStatus(SDIO_IT_DATAEND) != RESET)
|
||||
{
|
||||
|
@ -2386,7 +2224,7 @@ SD_Error SD_ProcessIRQ(void)
|
|||
* @param None.
|
||||
* @retval None.
|
||||
*/
|
||||
void SD_ProcessDMAIRQ(void)
|
||||
OPTIMIZE("O0") void SD_ProcessDMAIRQ(void)
|
||||
{
|
||||
if(DMA2->LISR & SD_SDIO_DMA_FLAG_TCIF)
|
||||
{
|
||||
|
@ -2400,7 +2238,7 @@ void SD_ProcessDMAIRQ(void)
|
|||
* @param None
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
static SD_Error CmdError(void)
|
||||
OPTIMIZE("O0") static SD_Error CmdError(void)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
uint32_t timeout;
|
||||
|
@ -2429,7 +2267,7 @@ static SD_Error CmdError(void)
|
|||
* @param None
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
static SD_Error CmdResp7Error(void)
|
||||
OPTIMIZE("O0") static SD_Error CmdResp7Error(void)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
uint32_t status;
|
||||
|
@ -2466,7 +2304,7 @@ static SD_Error CmdResp7Error(void)
|
|||
* @param cmd: The sent command index.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
static SD_Error CmdResp1Error(uint8_t cmd)
|
||||
OPTIMIZE("O0") static SD_Error CmdResp1Error(uint8_t cmd)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
uint32_t status;
|
||||
|
@ -2612,7 +2450,7 @@ static SD_Error CmdResp1Error(uint8_t cmd)
|
|||
* @param None
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
static SD_Error CmdResp3Error(void)
|
||||
OPTIMIZE("O0") static SD_Error CmdResp3Error(void)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
uint32_t status;
|
||||
|
@ -2640,7 +2478,7 @@ static SD_Error CmdResp3Error(void)
|
|||
* @param None
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
static SD_Error CmdResp2Error(void)
|
||||
OPTIMIZE("O0") static SD_Error CmdResp2Error(void)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
uint32_t status;
|
||||
|
@ -2678,7 +2516,7 @@ static SD_Error CmdResp2Error(void)
|
|||
* address RCA.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
static SD_Error CmdResp6Error(uint8_t cmd, uint16_t *prca)
|
||||
OPTIMIZE("O0") static SD_Error CmdResp6Error(uint8_t cmd, uint16_t *prca)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
uint32_t status;
|
||||
|
@ -2747,7 +2585,7 @@ static SD_Error CmdResp6Error(uint8_t cmd, uint16_t *prca)
|
|||
* This parameter can be: ENABLE or DISABLE.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
static SD_Error SDEnWideBus(FunctionalState NewState)
|
||||
OPTIMIZE("O0") static SD_Error SDEnWideBus(FunctionalState NewState)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
|
||||
|
@ -2861,7 +2699,7 @@ static SD_Error SDEnWideBus(FunctionalState NewState)
|
|||
* @param pstatus: pointer to the variable that will contain the SD card state.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
static SD_Error IsCardProgramming(uint8_t *pstatus)
|
||||
OPTIMIZE("O0") static SD_Error IsCardProgramming(uint8_t *pstatus)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
__IO uint32_t respR1 = 0, status = 0;
|
||||
|
@ -3020,7 +2858,7 @@ static SD_Error IsCardProgramming(uint8_t *pstatus)
|
|||
* @param pscr: pointer to the buffer that will contain the SCR value.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
static SD_Error FindSCR(uint16_t rca, uint32_t *pscr)
|
||||
OPTIMIZE("O0") static SD_Error FindSCR(uint16_t rca, uint32_t *pscr)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
SD_Error errorstatus = SD_OK;
|
||||
|
@ -3129,7 +2967,7 @@ static SD_Error FindSCR(uint16_t rca, uint32_t *pscr)
|
|||
* @param NumberOfBytes: number of bytes.
|
||||
* @retval None
|
||||
*/
|
||||
uint8_t convert_from_bytes_to_power_of_two(uint16_t NumberOfBytes)
|
||||
OPTIMIZE("O0") uint8_t convert_from_bytes_to_power_of_two(uint16_t NumberOfBytes)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
|
||||
|
|
|
@ -386,6 +386,8 @@ SD_Error SD_WaitWriteOperation(void);
|
|||
}
|
||||
#endif
|
||||
|
||||
extern SD_CardInfo SDCardInfo;
|
||||
|
||||
#endif /* __STM32F4_DISCOVERY_SDIO_SD_H */
|
||||
/**
|
||||
* @}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
* when FS core is used.
|
||||
*******************************************************************************/
|
||||
#ifndef USE_USB_OTG_FS
|
||||
#define USE_USB_OTG_FS
|
||||
#define USE_USB_OTG_FS // USB2.0 Full Speed == 12 Mbit
|
||||
#endif /* USE_USB_OTG_FS */
|
||||
|
||||
#ifdef USE_USB_OTG_FS
|
||||
|
|
|
@ -65,22 +65,22 @@
|
|||
|
||||
#if defined(BOOT)
|
||||
#define USBD_PID 0x5720
|
||||
#define USBD_PRODUCT_FS_STRING "FrSky Taranis Bootloader"
|
||||
#define USBD_PRODUCT_FS_STRING "FrSky Horus Bootloader"
|
||||
#define USBD_CONFIGURATION_FS_STRING "MSC Config"
|
||||
#define USBD_INTERFACE_FS_STRING "MSC Interface"
|
||||
#elif defined(USB_JOYSTICK)
|
||||
#define USBD_PID 0x5710
|
||||
#define USBD_PRODUCT_FS_STRING "FrSky Taranis Joystick"
|
||||
#define USBD_PRODUCT_FS_STRING "FrSky Horus Joystick"
|
||||
#define USBD_CONFIGURATION_FS_STRING "HID Config"
|
||||
#define USBD_INTERFACE_FS_STRING "HID Interface"
|
||||
#elif defined(USB_SERIAL)
|
||||
#define USBD_PID 0x5740 // do not change, this ID is used by the ST USB driver for Windows
|
||||
#define USBD_PRODUCT_FS_STRING "FrSky Taranis Serial Port"
|
||||
#define USBD_PRODUCT_FS_STRING "FrSky Horus Serial Port"
|
||||
#define USBD_CONFIGURATION_FS_STRING "VSP Config"
|
||||
#define USBD_INTERFACE_FS_STRING "VSP Interface"
|
||||
#elif defined(USB_MASS_STORAGE)
|
||||
#define USBD_PID 0x5720
|
||||
#define USBD_PRODUCT_FS_STRING "FrSky Taranis Mass Storage"
|
||||
#define USBD_PRODUCT_FS_STRING "FrSky Horus Mass Storage"
|
||||
#define USBD_CONFIGURATION_FS_STRING "MSC Config"
|
||||
#define USBD_INTERFACE_FS_STRING "MSC Interface"
|
||||
#endif
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
#define __USB_DESC_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_def.h"
|
||||
#include "usb_core.h"
|
||||
#include "usbd_def.h"
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
|
|
|
@ -191,8 +191,10 @@ int8_t STORAGE_Read (uint8_t lun,
|
|||
uint32_t blk_addr,
|
||||
uint16_t blk_len)
|
||||
{
|
||||
if (SD_ReadMultiBlocksFIXED(buf, blk_addr, BLOCKSIZE, blk_len) != 0) {
|
||||
return -1;
|
||||
|
||||
for (int retry=0; retry<3; retry++) {
|
||||
if (SD_ReadMultiBlocks(buf, blk_addr, BLOCKSIZE, blk_len) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SDTransferState State;
|
||||
|
@ -201,11 +203,12 @@ int8_t STORAGE_Read (uint8_t lun,
|
|||
|
||||
while((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL)
|
||||
|
||||
if ((State == SD_TRANSFER_ERROR) || (Status != SD_OK))
|
||||
return -1;
|
||||
|
||||
if ((State == SD_TRANSFER_OK) && (Status == SD_OK)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
/**
|
||||
* @brief Write data to the medium
|
||||
* @param lun : logical unit number
|
||||
|
@ -220,7 +223,7 @@ int8_t STORAGE_Write (uint8_t lun,
|
|||
uint32_t blk_addr,
|
||||
uint16_t blk_len)
|
||||
{
|
||||
if (SD_WriteMultiBlocksFIXED(buf, blk_addr, BLOCKSIZE, blk_len) != 0)
|
||||
if (SD_WriteMultiBlocks(buf, blk_addr, BLOCKSIZE, blk_len) != 0)
|
||||
return -1;
|
||||
|
||||
SDTransferState State;
|
||||
|
|
|
@ -81,7 +81,6 @@
|
|||
/*-----------------------------------------------------------------------*/
|
||||
#if !defined(BOOT)
|
||||
static OS_MutexID ioMutex;
|
||||
volatile int mutexCheck = 0;
|
||||
|
||||
int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex)
|
||||
{
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
|
||||
#include "usb_bsp.h"
|
||||
|
||||
#include "../Taranis/board_taranis.h"
|
||||
#include "../Taranis/usbd_conf.h"
|
||||
#include "board_taranis.h"
|
||||
#include "usbd_conf.h"
|
||||
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "../Taranis/board_taranis.h"
|
||||
#include "board_taranis.h"
|
||||
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd_int.h"
|
||||
|
||||
int usbPlugged(void)
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
extern "C" {
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "../Taranis/usb_conf.h"
|
||||
#include "usb_conf.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#define __USBD_CONF__H__
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "../Taranis/usb_conf.h"
|
||||
#include "usb_conf.h"
|
||||
|
||||
#define USBD_CFG_MAX_NUM 1
|
||||
#define USBD_ITF_MAX_NUM 1
|
||||
|
|
|
@ -27,12 +27,12 @@
|
|||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <string.h>
|
||||
#include "usbd_desc.h"
|
||||
#include "board_taranis.h"
|
||||
#include "usbd_conf.h"
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_desc.h"
|
||||
#include "usbd_req.h"
|
||||
#include "usbd_conf.h"
|
||||
#include "usb_regs.h"
|
||||
#include "board_taranis.h"
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
|
|
|
@ -47,9 +47,9 @@
|
|||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "../Taranis/usbd_desc.h"
|
||||
#include "usbd_hid_core.h"
|
||||
#include "usbd_req.h"
|
||||
#include "usbd_desc.h"
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
|
|
|
@ -28,14 +28,14 @@
|
|||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "../../opentx.h"
|
||||
#include "../../thirdparty/FatFs/diskio.h"
|
||||
#include "../Taranis/board_taranis.h"
|
||||
#include "board_taranis.h"
|
||||
|
||||
#if defined(__cplusplus) && !defined(SIMU)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "usbd_msc_mem.h"
|
||||
#include "../Taranis/usb_conf.h"
|
||||
#include "usb_conf.h"
|
||||
|
||||
#if defined(BOOT)
|
||||
#define STORAGE_LUN_NBR 2
|
||||
|
|
|
@ -975,11 +975,15 @@ FRESULT f_unlink (const TCHAR * name)
|
|||
|
||||
FRESULT f_rename(const TCHAR *oldname, const TCHAR *newname)
|
||||
{
|
||||
if (rename(oldname, newname) < 0) {
|
||||
TRACE("f_rename(%s, %s) = error %d (%s)", oldname, newname, errno, strerror(errno));
|
||||
char old[1024];
|
||||
strcpy(old, convertSimuPath(oldname));
|
||||
char * path = convertSimuPath(newname);
|
||||
|
||||
if (rename(old, path) < 0) {
|
||||
TRACE("f_rename(%s, %s) = error %d (%s)", old, path, errno, strerror(errno));
|
||||
return FR_INVALID_NAME;
|
||||
}
|
||||
TRACE("f_rename(%s, %s) = OK", oldname, newname);
|
||||
TRACE("f_rename(%s, %s) = OK", old, path);
|
||||
return FR_OK;
|
||||
}
|
||||
|
||||
|
@ -1226,8 +1230,8 @@ uint32_t sdGetSpeed()
|
|||
|
||||
#endif // #if defined(SIMU_DISKIO)
|
||||
|
||||
bool lcd_refresh = true;
|
||||
display_t lcd_buf[DISPLAY_BUFFER_SIZE];
|
||||
bool simuLcdRefresh = true;
|
||||
display_t simuLcdBuf[DISPLAY_BUFFER_SIZE];
|
||||
|
||||
#if !defined(PCBFLAMENCO) && !defined(PCBHORUS)
|
||||
void lcdSetRefVolt(uint8_t val)
|
||||
|
@ -1251,8 +1255,19 @@ void lcdRefresh()
|
|||
TW8823_SendScreen();
|
||||
#endif
|
||||
|
||||
memcpy(lcd_buf, displayBuf, sizeof(lcd_buf));
|
||||
lcd_refresh = true;
|
||||
memcpy(simuLcdBuf, displayBuf, sizeof(simuLcdBuf));
|
||||
simuLcdRefresh = true;
|
||||
}
|
||||
|
||||
display_t simuLcdBackupBuf[DISPLAY_BUFFER_SIZE];
|
||||
void lcdStoreBackupBuffer()
|
||||
{
|
||||
memcpy(simuLcdBackupBuf, displayBuf, sizeof(simuLcdBackupBuf));
|
||||
}
|
||||
|
||||
void lcdRestoreBackupBuffer()
|
||||
{
|
||||
memcpy(displayBuf, simuLcdBackupBuf, sizeof(displayBuf));
|
||||
}
|
||||
|
||||
#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS)
|
||||
|
|
|
@ -52,7 +52,7 @@ OS_TID menusTaskId;
|
|||
TaskStack<MENUS_STACK_SIZE> _ALIGNED(8) menusStack;
|
||||
|
||||
OS_TID mixerTaskId;
|
||||
TaskStack<MENUS_STACK_SIZE> mixerStack;
|
||||
TaskStack<MIXER_STACK_SIZE> mixerStack;
|
||||
|
||||
OS_TID audioTaskId;
|
||||
TaskStack<AUDIO_STACK_SIZE> audioStack;
|
||||
|
@ -235,4 +235,4 @@ void tasksStart()
|
|||
CoStartOS();
|
||||
}
|
||||
|
||||
#endif // #if !defined(SIMU)
|
||||
#endif // !defined(SIMU)
|
||||
|
|
|
@ -72,11 +72,11 @@ void doPaint(QPainter & p)
|
|||
#endif
|
||||
for (int x=0; x<LCD_W; x++, idx++) {
|
||||
#if !defined(PCBTARANIS)
|
||||
if (lcd_buf[idx] & mask) {
|
||||
if (simuLcdBuf[idx] & mask) {
|
||||
p.drawPoint(x, y);
|
||||
}
|
||||
#else
|
||||
unsigned int z = (y & 1) ? (lcd_buf[idx] >> 4) : (lcd_buf[idx] & 0x0F);
|
||||
unsigned int z = (y & 1) ? (simuLcdBuf[idx] >> 4) : (simuLcdBuf[idx] & 0x0F);
|
||||
if (z) {
|
||||
if (z != previousDepth) {
|
||||
previousDepth = z;
|
||||
|
|
|
@ -298,18 +298,27 @@ const pm_char STR_CH[] PROGMEM = TR_CH;
|
|||
const pm_char STR_MODEL[] PROGMEM = TR_MODEL;
|
||||
const pm_char STR_FP[] PROGMEM = TR_FP;
|
||||
const pm_char STR_MIX[] PROGMEM = TR_MIX;
|
||||
const pm_char STR_EEPROMLOWMEM[] PROGMEM = TR_EEPROMLOWMEM;
|
||||
const pm_char STR_ALERT[] PROGMEM = TR_ALERT;
|
||||
const pm_char STR_PRESSANYKEYTOSKIP[] PROGMEM = TR_PRESSANYKEYTOSKIP;
|
||||
const pm_char STR_THROTTLENOTIDLE[] PROGMEM = TR_THROTTLENOTIDLE;
|
||||
const pm_char STR_ALARMSDISABLED[] PROGMEM = TR_ALARMSDISABLED;
|
||||
const pm_char STR_PRESSANYKEY[] PROGMEM = TR_PRESSANYKEY;
|
||||
const pm_char STR_BADEEPROMDATA[] PROGMEM = TR_BADEEPROMDATA;
|
||||
const pm_char STR_EEPROMFORMATTING[] PROGMEM = TR_EEPROMFORMATTING;
|
||||
const pm_char STR_EEPROMOVERFLOW[] PROGMEM = TR_EEPROMOVERFLOW;
|
||||
const pm_char STR_TRIMS2OFFSETS[] PROGMEM = TR_TRIMS2OFFSETS;
|
||||
const pm_char STR_MENURADIOSETUP[] PROGMEM = TR_MENURADIOSETUP;
|
||||
|
||||
#if defined(EEPROM)
|
||||
const pm_char STR_BAD_RADIO_DATA[] PROGMEM = TR_BADEEPROMDATA;
|
||||
const pm_char STR_STORAGE_FORMAT[] PROGMEM = TR_EEPROMFORMATTING;
|
||||
const pm_char STR_STORAGE_WARNING[] PROGMEM = TR_EEPROMWARN;
|
||||
const pm_char STR_EEPROM_CONVERTING[] PROGMEM = TR_EEPROM_CONVERTING;
|
||||
const pm_char STR_EEPROMLOWMEM[] PROGMEM = TR_EEPROMLOWMEM;
|
||||
const pm_char STR_EEPROMOVERFLOW[] PROGMEM = TR_EEPROMOVERFLOW;
|
||||
#else
|
||||
const pm_char STR_BAD_RADIO_DATA[] PROGMEM = TR_BAD_RADIO_DATA;
|
||||
const pm_char STR_STORAGE_WARNING[] PROGMEM = TR_STORAGE_WARNING;
|
||||
const pm_char STR_STORAGE_FORMAT[] PROGMEM = TR_STORAGE_FORMAT;
|
||||
#endif
|
||||
|
||||
#if defined(FAS_OFFSET) || !defined(CPUM64)
|
||||
const pm_char STR_FAS_OFFSET[] PROGMEM = TR_FAS_OFFSET;
|
||||
#endif
|
||||
|
@ -416,6 +425,7 @@ const pm_char STR_PERSISTENT_MAH[] PROGMEM = TR_PERSISTENT_MAH;
|
|||
#if defined(NAVIGATION_MENUS)
|
||||
const pm_char STR_SELECT_MODEL[] PROGMEM = TR_SELECT_MODEL;
|
||||
const pm_char STR_CREATE_MODEL[] PROGMEM = TR_CREATE_MODEL;
|
||||
const pm_char STR_DUPLICATE_MODEL[] PROGMEM = TR_DUPLICATE_MODEL;
|
||||
const pm_char STR_COPY_MODEL[] PROGMEM = TR_COPY_MODEL;
|
||||
const pm_char STR_MOVE_MODEL[] PROGMEM = TR_MOVE_MODEL;
|
||||
const pm_char STR_DELETE_MODEL[] PROGMEM = TR_DELETE_MODEL;
|
||||
|
@ -452,8 +462,6 @@ const pm_char STR_MODELS_EXT[] PROGMEM = MODELS_EXT;
|
|||
#endif
|
||||
|
||||
const pm_char STR_WARNING[] PROGMEM = TR_WARNING;
|
||||
const pm_char STR_EEPROMWARN[] PROGMEM = TR_EEPROMWARN;
|
||||
const pm_char STR_EEPROM_CONVERTING[] PROGMEM = TR_EEPROM_CONVERTING;
|
||||
const pm_char STR_THROTTLEWARN[] PROGMEM = TR_THROTTLEWARN;
|
||||
const pm_char STR_ALARMSWARN[] PROGMEM = TR_ALARMSWARN;
|
||||
const pm_char STR_SWITCHWARN[] PROGMEM = TR_SWITCHWARN;
|
||||
|
|
|
@ -500,8 +500,8 @@ extern const pm_char STR_THROTTLENOTIDLE[];
|
|||
extern const pm_char STR_ALARMSDISABLED[];
|
||||
extern const pm_char STR_PRESSANYKEY[];
|
||||
#define LEN_PRESSANYKEY PSIZE(TR_PRESSANYKEY)
|
||||
extern const pm_char STR_BADEEPROMDATA[];
|
||||
extern const pm_char STR_EEPROMFORMATTING[];
|
||||
extern const pm_char STR_BAD_RADIO_DATA[];
|
||||
extern const pm_char STR_STORAGE_FORMAT[];
|
||||
extern const pm_char STR_EEPROMOVERFLOW[];
|
||||
extern const pm_char STR_TRIMS2OFFSETS[];
|
||||
extern const pm_char STR_MENURADIOSETUP[];
|
||||
|
@ -598,6 +598,7 @@ extern const pm_char STR_CURRENT[];
|
|||
#if defined(NAVIGATION_MENUS)
|
||||
extern const pm_char STR_SELECT_MODEL[];
|
||||
extern const pm_char STR_CREATE_MODEL[];
|
||||
extern const pm_char STR_DUPLICATE_MODEL[];
|
||||
extern const pm_char STR_COPY_MODEL[];
|
||||
extern const pm_char STR_MOVE_MODEL[];
|
||||
extern const pm_char STR_DELETE_MODEL[];
|
||||
|
@ -635,7 +636,7 @@ extern const pm_char STR_RESET_BTN[];
|
|||
#endif
|
||||
|
||||
extern const pm_char STR_WARNING[];
|
||||
extern const pm_char STR_EEPROMWARN[];
|
||||
extern const pm_char STR_STORAGE_WARNING[];
|
||||
extern const pm_char STR_EEPROM_CONVERTING[];
|
||||
extern const pm_char STR_THROTTLEWARN[];
|
||||
extern const pm_char STR_ALARMSWARN[];
|
||||
|
|
|
@ -806,6 +806,7 @@
|
|||
#define TR_CURRENT INDENT"Proud"
|
||||
#define TR_SELECT_MODEL "Vyber model"
|
||||
#define TR_CREATE_MODEL "Nový model"
|
||||
#define TR_DUPLICATE_MODEL "Duplicate Model"
|
||||
#define TR_COPY_MODEL "Kopírovat"
|
||||
#define TR_MOVE_MODEL "Přesunout"
|
||||
#define TR_BACKUP_MODEL "Zálohovat na SD"
|
||||
|
|
|
@ -810,6 +810,7 @@
|
|||
#define TR_CURRENT TR(INDENT "Strom", INDENT "Stromquelle")
|
||||
#define TR_SELECT_MODEL "Modell Wählen"
|
||||
#define TR_CREATE_MODEL "Neues Modell"
|
||||
#define TR_DUPLICATE_MODEL "Duplicate Model"
|
||||
#define TR_COPY_MODEL "Kopiere Modell"
|
||||
#define TR_MOVE_MODEL "Verschiebe Modell"
|
||||
#define TR_BACKUP_MODEL "Modell auf SD-Karte" //9XR-Pro
|
||||
|
|
|
@ -760,7 +760,9 @@
|
|||
#define TR_ALARMSDISABLED "Alarms Disabled"
|
||||
#define TR_PRESSANYKEY TR("\010Press any Key", "Press any Key")
|
||||
#define TR_BADEEPROMDATA "Bad EEprom Data"
|
||||
#define TR_BAD_RADIO_DATA "Bad Radio Data"
|
||||
#define TR_EEPROMFORMATTING "Formatting EEPROM"
|
||||
#define TR_STORAGE_FORMAT "Storage Preparation"
|
||||
#define TR_EEPROMOVERFLOW "EEPROM overflow"
|
||||
#define TR_MENURADIOSETUP "RADIO SETUP"
|
||||
#define TR_MENUDATEANDTIME "DATE AND TIME"
|
||||
|
@ -824,6 +826,7 @@
|
|||
#define TR_CURRENT TR(INDENT "Current",INDENT "Current Source")
|
||||
#define TR_SELECT_MODEL "Select Model"
|
||||
#define TR_CREATE_MODEL "Create Model"
|
||||
#define TR_DUPLICATE_MODEL "Duplicate Model"
|
||||
#define TR_COPY_MODEL "Copy Model"
|
||||
#define TR_MOVE_MODEL "Move Model"
|
||||
#define TR_BACKUP_MODEL "Backup Model"
|
||||
|
@ -835,6 +838,7 @@
|
|||
#define TR_INCOMPATIBLE "Incompatible"
|
||||
#define TR_WARNING "WARNING"
|
||||
#define TR_EEPROMWARN "EEPROM"
|
||||
#define TR_STORAGE_WARNING "STORAGE"
|
||||
#define TR_EEPROM_CONVERTING "Converting EEPROM"
|
||||
#define TR_THROTTLEWARN "THROTTLE"
|
||||
#define TR_ALARMSWARN "ALARMS"
|
||||
|
|
|
@ -760,6 +760,7 @@
|
|||
#define TR_CURRENT INDENT"Actual"
|
||||
#define TR_SELECT_MODEL "Selec Modelo"
|
||||
#define TR_CREATE_MODEL "Crear Modelo"
|
||||
#define TR_DUPLICATE_MODEL "Duplicate Model"
|
||||
#define TR_COPY_MODEL "Copiar Modelo"
|
||||
#define TR_MOVE_MODEL "Mover Modelo"
|
||||
#define TR_BACKUP_MODEL "Copia Sgdad Mod."
|
||||
|
|
|
@ -760,6 +760,7 @@
|
|||
#define TR_CURRENT INDENT"Current"
|
||||
#define TR_SELECT_MODEL "Select Model"
|
||||
#define TR_CREATE_MODEL "Create Model"
|
||||
#define TR_DUPLICATE_MODEL "Duplicate Model"
|
||||
#define TR_COPY_MODEL "Copy Model"
|
||||
#define TR_MOVE_MODEL "Move Model"
|
||||
#define TR_BACKUP_MODEL "Backup Model"
|
||||
|
|
|
@ -797,6 +797,7 @@
|
|||
#define TR_CURRENT TR(INDENT "Courant",INDENT "Source Courant")
|
||||
#define TR_SELECT_MODEL "Sélect. Modèle"
|
||||
#define TR_CREATE_MODEL "Créer Modèle"
|
||||
#define TR_DUPLICATE_MODEL "Duplicate Model"
|
||||
#define TR_COPY_MODEL "Copier Modèle"
|
||||
#define TR_MOVE_MODEL "Déplacer Modèle"
|
||||
#define TR_BACKUP_MODEL "Archiver Modèle"
|
||||
|
|
|
@ -808,6 +808,7 @@
|
|||
#define TR_CURRENT TR(INDENT "Corrente",INDENT "Corrente")
|
||||
#define TR_SELECT_MODEL "Scegli Memo."
|
||||
#define TR_CREATE_MODEL "Crea Modello"
|
||||
#define TR_DUPLICATE_MODEL "Duplicate Model"
|
||||
#define TR_COPY_MODEL "Copia Modello"
|
||||
#define TR_MOVE_MODEL "Sposta Modello"
|
||||
#define TR_BACKUP_MODEL "Salva Modello"
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue