[Taranis] A lot of new features, >100 hours work in one commit...
This commit is contained in:
+54
-27
@@ -491,7 +491,7 @@ void menuGeneralSetup(uint8_t event)
|
||||
case ITEM_SETUP_BRIGHTNESS:
|
||||
lcd_putsLeft(y, STR_BRIGHTNESS);
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, 100-g_eeGeneral.backlightBright, attr|LEFT) ;
|
||||
if(attr) {
|
||||
if (attr) {
|
||||
uint8_t b = 100 - g_eeGeneral.backlightBright;
|
||||
CHECK_INCDEC_GENVAR(event, b, 0, 100);
|
||||
g_eeGeneral.backlightBright = 100 - b;
|
||||
@@ -599,7 +599,7 @@ void menuGeneralSetup(uint8_t event)
|
||||
|
||||
case ITEM_SETUP_STICK_MODE:
|
||||
lcd_putcAtt(2*FW, y, '1'+g_eeGeneral.stickMode, attr);
|
||||
for (uint8_t i=0; i<4; i++) putsMixerSource((6+4*i)*FW, y, pgm_read_byte(modn12x3 + 4*g_eeGeneral.stickMode + i), 0);
|
||||
for (uint8_t i=0; i<4; i++) putsMixerSource((6+4*i)*FW, y, MIXSRC_Rud + pgm_read_byte(modn12x3 + 4*g_eeGeneral.stickMode + i), 0);
|
||||
if (attr && s_editMode>0) {
|
||||
CHECK_INCDEC_GENVAR(event, g_eeGeneral.stickMode, 0, 3);
|
||||
}
|
||||
@@ -651,7 +651,7 @@ inline bool isFilenameLower(bool isfile, const char * fn, const char * line)
|
||||
|
||||
void onSdManagerMenu(const char *result)
|
||||
{
|
||||
char lfn[SD_SCREEN_FILE_LENGTH];
|
||||
TCHAR lfn[_MAX_LFN + 1];
|
||||
|
||||
uint8_t index = m_posVert-1-s_pgOfs;
|
||||
if (result == STR_SD_INFO) {
|
||||
@@ -661,7 +661,7 @@ void onSdManagerMenu(const char *result)
|
||||
POPUP_CONFIRMATION(PSTR("Confirm Format?"));
|
||||
}
|
||||
else if (result == STR_DELETE_FILE) {
|
||||
f_getcwd(lfn, SD_SCREEN_FILE_LENGTH);
|
||||
f_getcwd(lfn, _MAX_LFN);
|
||||
strcat_P(lfn, PSTR("/"));
|
||||
strcat(lfn, reusableBuffer.sdmanager.lines[index]);
|
||||
f_unlink(lfn);
|
||||
@@ -673,13 +673,13 @@ void onSdManagerMenu(const char *result)
|
||||
}
|
||||
#if defined(CPUARM)
|
||||
/* TODO else if (result == STR_LOAD_FILE) {
|
||||
f_getcwd(lfn, SD_SCREEN_FILE_LENGTH);
|
||||
f_getcwd(lfn, _MAX_LFN);
|
||||
strcat(lfn, "/");
|
||||
strcat(lfn, reusableBuffer.sdmanager.lines[index]);
|
||||
POPUP_WARNING(eeLoadModelSD(lfn));
|
||||
} */
|
||||
else if (result == STR_PLAY_FILE) {
|
||||
f_getcwd(lfn, SD_SCREEN_FILE_LENGTH);
|
||||
f_getcwd(lfn, _MAX_LFN);
|
||||
strcat(lfn, "/");
|
||||
strcat(lfn, reusableBuffer.sdmanager.lines[index]);
|
||||
audioQueue.playFile(lfn, PLAY_BACKGROUND, 255);
|
||||
@@ -697,21 +697,31 @@ void onSdManagerMenu(const char *result)
|
||||
memcpy(modelHeaders[g_eeGeneral.currModel].bitmap, g_model.header.bitmap, sizeof(g_model.header.bitmap));
|
||||
eeDirty(EE_MODEL);
|
||||
}
|
||||
#if defined(LUA)
|
||||
else if (result == STR_EXECUTE_FILE) {
|
||||
f_getcwd(lfn, _MAX_LFN);
|
||||
strcat(lfn, "/");
|
||||
strcat(lfn, reusableBuffer.sdmanager.lines[index]);
|
||||
luaExec(lfn);
|
||||
}
|
||||
else if (result == STR_VIEW_TEXT) {
|
||||
f_getcwd(lfn, _MAX_LFN);
|
||||
strcat(lfn, "/");
|
||||
strcat(lfn, reusableBuffer.sdmanager.lines[index]);
|
||||
pushMenuTextView(lfn);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void menuGeneralSdManager(uint8_t event)
|
||||
void menuGeneralSdManager(uint8_t _event)
|
||||
{
|
||||
FILINFO fno;
|
||||
DIR dir;
|
||||
char *fn; /* This function is assuming non-Unicode cfg. */
|
||||
#if _USE_LFN
|
||||
TCHAR lfn[_MAX_LFN + 1];
|
||||
fno.lfname = lfn;
|
||||
fno.lfsize = sizeof(lfn);
|
||||
#else
|
||||
char lfn[SD_SCREEN_FILE_LENGTH];
|
||||
#endif
|
||||
|
||||
#if defined(SDCARD)
|
||||
if (s_warning_result) {
|
||||
@@ -734,12 +744,13 @@ void menuGeneralSdManager(uint8_t event)
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t event = ((READ_ONLY() && EVT_KEY_MASK(_event) == KEY_ENTER) ? 0 : _event);
|
||||
SIMPLE_MENU(SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD, menuTabDiag, e_Sd, 1+reusableBuffer.sdmanager.count);
|
||||
|
||||
if (s_editMode > 0)
|
||||
s_editMode = 0;
|
||||
|
||||
switch(event) {
|
||||
switch(_event) {
|
||||
case EVT_ENTRY:
|
||||
f_chdir(ROOT_PATH);
|
||||
reusableBuffer.sdmanager.offset = 65535;
|
||||
@@ -747,10 +758,12 @@ void menuGeneralSdManager(uint8_t event)
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
case EVT_KEY_LONG(KEY_MENU):
|
||||
killEvents(event);
|
||||
// MENU_ADD_ITEM(STR_SD_INFO); TODO: Implement
|
||||
MENU_ADD_ITEM(STR_SD_FORMAT);
|
||||
menuHandler = onSdManagerMenu;
|
||||
if (!READ_ONLY()) {
|
||||
killEvents(_event);
|
||||
// MENU_ADD_ITEM(STR_SD_INFO); TODO: Implement
|
||||
MENU_ADD_ITEM(STR_SD_FORMAT);
|
||||
menuHandler = onSdManagerMenu;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -772,13 +785,13 @@ void menuGeneralSdManager(uint8_t event)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!IS_ROTARY_BREAK(event) || m_posVert==0)
|
||||
if (!IS_ROTARY_BREAK(_event) || m_posVert==0)
|
||||
break;
|
||||
// no break;
|
||||
}
|
||||
|
||||
case EVT_KEY_LONG(KEY_ENTER):
|
||||
killEvents(event);
|
||||
killEvents(_event);
|
||||
#if !defined(PCBTARANIS)
|
||||
if (m_posVert == 0) {
|
||||
MENU_ADD_ITEM(STR_SD_INFO);
|
||||
@@ -799,14 +812,24 @@ void menuGeneralSdManager(uint8_t event)
|
||||
MENU_ADD_ITEM(STR_PLAY_FILE);
|
||||
}
|
||||
#if defined(PCBTARANIS)
|
||||
else if (!strcasecmp(ext, BITMAPS_EXT)) {
|
||||
else if (!strcasecmp(ext, BITMAPS_EXT) && !READ_ONLY()) {
|
||||
MENU_ADD_ITEM(STR_ASSIGN_BITMAP);
|
||||
}
|
||||
else if (!strcasecmp(ext, TEXT_EXT)) {
|
||||
MENU_ADD_ITEM(STR_VIEW_TEXT);
|
||||
}
|
||||
#endif
|
||||
#if defined(LUA)
|
||||
else if (!strcasecmp(ext, SCRIPTS_EXT)) {
|
||||
MENU_ADD_ITEM(STR_EXECUTE_FILE);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
MENU_ADD_ITEM(STR_DELETE_FILE);
|
||||
// MENU_ADD_ITEM(STR_RENAME_FILE); TODO: Implement
|
||||
// MENU_ADD_ITEM(STR_COPY_FILE); TODO: Implement
|
||||
if (!READ_ONLY()) {
|
||||
MENU_ADD_ITEM(STR_DELETE_FILE);
|
||||
// MENU_ADD_ITEM(STR_RENAME_FILE); TODO: Implement
|
||||
// MENU_ADD_ITEM(STR_COPY_FILE); TODO: Implement
|
||||
}
|
||||
}
|
||||
menuHandler = onSdManagerMenu;
|
||||
break;
|
||||
@@ -915,8 +938,10 @@ void menuGeneralSdManager(uint8_t event)
|
||||
if (!strcasecmp(ext, BITMAPS_EXT)) {
|
||||
if (sdBitmapIdx != m_posVert) {
|
||||
sdBitmapIdx = m_posVert;
|
||||
if (bmpLoad(sdBitmap, reusableBuffer.sdmanager.lines[index], MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT))
|
||||
uint8_t *dest = sdBitmap;
|
||||
if (bmpLoad(dest, reusableBuffer.sdmanager.lines[index], MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT)) {
|
||||
memcpy(sdBitmap, logo_taranis, MODEL_BITMAP_SIZE);
|
||||
}
|
||||
}
|
||||
lcd_bmp(22*FW+2, 2*FH+FH/2, sdBitmap);
|
||||
}
|
||||
@@ -953,7 +978,7 @@ void menuGeneralTrainer(uint8_t event)
|
||||
uint8_t chan = channel_order(i);
|
||||
volatile TrainerMix *td = &g_eeGeneral.trainer.mix[chan-1];
|
||||
|
||||
putsMixerSource(0, y, chan, (m_posVert==i && m_posHorz<0) ? INVERS : 0);
|
||||
putsMixerSource(0, y, MIXSRC_Rud-1+chan, (m_posVert==i && m_posHorz<0) ? INVERS : 0);
|
||||
|
||||
for (uint8_t j=0; j<3; j++) {
|
||||
|
||||
@@ -1088,7 +1113,7 @@ void menuGeneralDiagAna(uint8_t event)
|
||||
putsStrIdx(x, y, PSTR("A"), i+1);
|
||||
lcd_putc(x+2*FWNUM, y, ':');
|
||||
lcd_outhex4(x+3*FW-1, y, anaIn(i));
|
||||
lcd_outdez8(x+10*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i+1)-1]*25/256);
|
||||
lcd_outdez8(x+10*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256);
|
||||
}
|
||||
|
||||
#if !defined(CPUARM)
|
||||
@@ -1243,7 +1268,9 @@ void menuCommonCalib(uint8_t event)
|
||||
switch (reusableBuffer.calib.state) {
|
||||
case 0:
|
||||
// START CALIBRATION
|
||||
lcd_putsLeft(3*FH, STR_MENUTOSTART);
|
||||
if (!READ_ONLY()) {
|
||||
lcd_putsLeft(3*FH, STR_MENUTOSTART);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@@ -1296,7 +1323,7 @@ void menuGeneralCalib(uint8_t event)
|
||||
{
|
||||
SIMPLE_MENU(STR_MENUCALIBRATION, menuTabDiag, e_Calib, 1);
|
||||
|
||||
menuCommonCalib(event);
|
||||
menuCommonCalib(READ_ONLY() ? 0 : event);
|
||||
}
|
||||
|
||||
void menuFirstCalib(uint8_t event)
|
||||
|
||||
+842
-257
File diff suppressed because it is too large
Load Diff
+142
-32
@@ -58,10 +58,10 @@ void menu_lcd_onoff(uint8_t x, uint8_t y, uint8_t value, LcdFlags attr)
|
||||
|
||||
void displayScreenIndex(uint8_t index, uint8_t count, uint8_t attr)
|
||||
{
|
||||
lcd_outdezAtt(LCD_W,0,count,attr);
|
||||
lcd_outdezAtt(LCD_W, 0, count, attr);
|
||||
xcoord_t x = 1+LCD_W-FW*(count>9 ? 3 : 2);
|
||||
lcd_putcAtt(x,0,'/',attr);
|
||||
lcd_outdezAtt(x,0,index+1,attr);
|
||||
lcd_putcAtt(x, 0, '/', attr);
|
||||
lcd_outdezAtt(x, 0, index+1, attr);
|
||||
}
|
||||
|
||||
#if !defined(CPUM64)
|
||||
@@ -85,6 +85,25 @@ int16_t p1valdiff;
|
||||
int8_t p2valdiff;
|
||||
#endif
|
||||
|
||||
uint8_t switchToMix(uint8_t source)
|
||||
{
|
||||
#if defined(PCBTARANIS)
|
||||
if (source <= 5*3)
|
||||
return MIXSRC_FIRST_SWITCH + (source-1) / 3;
|
||||
else if (source <= 17)
|
||||
return MIXSRC_SF;
|
||||
else if (source <= 20)
|
||||
return MIXSRC_SG;
|
||||
else
|
||||
return MIXSRC_SH;
|
||||
#else
|
||||
if (source <= 3)
|
||||
return MIXSRC_3POS;
|
||||
else
|
||||
return MIXSRC_FIRST_SWITCH - 3 + source;
|
||||
#endif
|
||||
}
|
||||
|
||||
int8_t checkIncDec_Ret;
|
||||
|
||||
#if defined(CPUARM)
|
||||
@@ -167,7 +186,7 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui
|
||||
AUDIO_KEYPAD_DOWN();
|
||||
}
|
||||
|
||||
if (i_min==0 && i_max==1 && (event==EVT_KEY_BREAK(KEY_ENTER) || IS_ROTARY_BREAK(event))) {
|
||||
if (!READ_ONLY() && i_min==0 && i_max==1 && (event==EVT_KEY_BREAK(KEY_ENTER) || IS_ROTARY_BREAK(event))) {
|
||||
s_editMode = 0;
|
||||
newval = !val;
|
||||
}
|
||||
@@ -214,28 +233,16 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui
|
||||
#if defined(AUTOSOURCE)
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
if (s_editMode>0) {
|
||||
int8_t source = getMovedSource();
|
||||
int8_t source = GET_MOVED_SOURCE(i_min, i_max);
|
||||
if (source) {
|
||||
newval = MIXSRC_Rud - 1 + source;
|
||||
newval = source;
|
||||
}
|
||||
#if defined(AUTOSWITCH)
|
||||
source = abs(getMovedSwitch());
|
||||
if (source) {
|
||||
#if defined(PCBTARANIS)
|
||||
if (source <= 5*3)
|
||||
newval = MIXSRC_FIRST_SWITCH + (source-1) / 3;
|
||||
else if (source <= 17)
|
||||
newval = MIXSRC_SF;
|
||||
else if (source <= 20)
|
||||
newval = MIXSRC_SG;
|
||||
else
|
||||
newval = MIXSRC_SH;
|
||||
#else
|
||||
if (source <= 3)
|
||||
newval = MIXSRC_3POS;
|
||||
else
|
||||
newval = MIXSRC_FIRST_SWITCH - 3 + source;
|
||||
#endif
|
||||
else {
|
||||
uint8_t swtch = abs(getMovedSwitch());
|
||||
if (swtch) {
|
||||
newval = switchToMix(swtch);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -321,6 +328,35 @@ void title(const pm_char * s)
|
||||
uint8_t scrollbar_X = LCD_W-1;
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
bool modelHasNotes()
|
||||
{
|
||||
FILINFO info;
|
||||
TCHAR lfn[_MAX_LFN + 1];
|
||||
info.lfname = lfn;
|
||||
info.lfsize = sizeof(lfn);
|
||||
|
||||
char filename[sizeof(MODELS_PATH)+1+sizeof(g_model.header.name)+sizeof(TEXT_EXT)] = MODELS_PATH "/";
|
||||
char *buf = strcat_modelname(&filename[sizeof(MODELS_PATH)], g_eeGeneral.currModel);
|
||||
strcpy(buf, TEXT_EXT);
|
||||
|
||||
return (f_stat(filename, &info) == FR_OK);
|
||||
}
|
||||
|
||||
void onLongMenuPress(const char *result)
|
||||
{
|
||||
if (result == STR_VIEW_CHANNELS) {
|
||||
pushMenu(menuChannelsView);
|
||||
}
|
||||
else if (result == STR_VIEW_NOTES) {
|
||||
char filename[sizeof(MODELS_PATH)+1+sizeof(g_model.header.name)+sizeof(TEXT_EXT)] = MODELS_PATH "/";
|
||||
char *buf = strcat_modelname(&filename[sizeof(MODELS_PATH)], g_eeGeneral.currModel);
|
||||
strcpy(buf, TEXT_EXT);
|
||||
pushMenuTextView(filename);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
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)
|
||||
{
|
||||
vertpos_t l_posVert = m_posVert;
|
||||
@@ -366,9 +402,16 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
switch(event) {
|
||||
case EVT_KEY_LONG(KEY_MENU):
|
||||
if (menuTab == menuTabModel) {
|
||||
pushMenu(menuChannelsView);
|
||||
killEvents(event);
|
||||
return false;
|
||||
if (modelHasNotes()) {
|
||||
MENU_ADD_SD_ITEM(STR_VIEW_CHANNELS);
|
||||
MENU_ADD_ITEM(STR_VIEW_NOTES);
|
||||
menuHandler = onLongMenuPress;
|
||||
}
|
||||
else {
|
||||
pushMenu(menuChannelsView);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -501,7 +544,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
|
||||
case EVT_ROTARY_BREAK:
|
||||
if (s_editMode > 1) break;
|
||||
if (m_posHorz < 0 && maxcol > 0) {
|
||||
if (m_posHorz < 0 && maxcol > 0 && READ_ONLY_UNLOCKED()) {
|
||||
l_posHorz = 0;
|
||||
break;
|
||||
}
|
||||
@@ -518,8 +561,11 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
#if !defined(PCBTARANIS)
|
||||
case EVT_KEY_FIRST(KEY_ENTER):
|
||||
#endif
|
||||
if (!menuTab || l_posVert>0)
|
||||
s_editMode = (s_editMode<=0);
|
||||
if (!menuTab || l_posVert>0) {
|
||||
if (READ_ONLY_UNLOCKED()) {
|
||||
s_editMode = (s_editMode<=0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
@@ -757,7 +803,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
|
||||
#if LCD_W >= 212
|
||||
if (maxrow > LCD_LINES-1 && scrollbar_X)
|
||||
displayScrollbar(scrollbar_X, FH, LCD_H-FH, s_pgOfs, maxrow, LCD_LINES-1);
|
||||
displayScrollbar(scrollbar_X, FH, LCD_H-FH, s_pgOfs, menuTab ? maxrow : maxrow+1, LCD_LINES-1);
|
||||
#endif
|
||||
|
||||
#else
|
||||
@@ -844,7 +890,11 @@ void displayBox()
|
||||
{
|
||||
lcd_filled_rect(10, 16, LCD_W-20, 40, SOLID, ERASE);
|
||||
lcd_rect(10, 16, LCD_W-20, 40);
|
||||
#if defined(CPUARM)
|
||||
lcd_putsn(WARNING_LINE_X, WARNING_LINE_Y, s_warning, WARNING_LINE_LEN);
|
||||
#else
|
||||
lcd_puts(WARNING_LINE_X, WARNING_LINE_Y, s_warning);
|
||||
#endif
|
||||
// could be a place for a s_warning_info
|
||||
}
|
||||
|
||||
@@ -891,7 +941,7 @@ void displayWarning(uint8_t event)
|
||||
}
|
||||
}
|
||||
|
||||
int8_t selectMenuItem(uint8_t x, uint8_t y, const pm_char *label, const pm_char *values, int8_t value, int8_t min, int8_t max, LcdFlags attr, uint8_t event)
|
||||
select_menu_value_t selectMenuItem(uint8_t x, uint8_t y, const pm_char *label, const pm_char *values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, uint8_t event)
|
||||
{
|
||||
lcd_putsColumnLeft(x, y, label);
|
||||
if (values) lcd_putsiAtt(x, y, values, value-min, attr);
|
||||
@@ -924,7 +974,14 @@ int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t m
|
||||
bool invers = (attr & INVERS);
|
||||
if (invers && event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
s_editMode = !s_editMode;
|
||||
#if defined(CPUARM)
|
||||
if (attr & PREC1)
|
||||
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, s_perout_flight_phase)*10 : delta);
|
||||
else
|
||||
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, s_perout_flight_phase) : delta);
|
||||
#else
|
||||
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, s_perout_flight_phase) : delta);
|
||||
#endif
|
||||
eeDirty(EE_MODEL);
|
||||
}
|
||||
if (GV_IS_GV_VALUE(value, min, max)) {
|
||||
@@ -933,6 +990,10 @@ int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t m
|
||||
else
|
||||
x -= 2*FW+FWNUM;
|
||||
|
||||
#if defined(CPUARM)
|
||||
attr &= ~PREC1;
|
||||
#endif
|
||||
|
||||
int8_t idx = (int16_t) GV_INDEX_CALC_DELTA(value, delta);
|
||||
if (invers) {
|
||||
CHECK_INCDEC_MODELVAR(event, idx, -MAX_GVARS, MAX_GVARS-1);
|
||||
@@ -1107,6 +1168,22 @@ void drawStatusLine()
|
||||
#if defined(CPUARM)
|
||||
bool isSourceAvailable(int16_t source)
|
||||
{
|
||||
#if defined(PCBTARANIS)
|
||||
if (source>=MIXSRC_FIRST_INPUT && source<=MIXSRC_LAST_INPUT) {
|
||||
return ZEXIST(g_model.inputNames[source-MIXSRC_FIRST_INPUT]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
if (source>=MIXSRC_FIRST_LUA && source<=MIXSRC_LAST_LUA) {
|
||||
div_t qr = div(source-MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS);
|
||||
return (scriptInternalData[qr.quot].state==SCRIPT_OK && qr.rem<scriptInternalData[qr.quot].outputsCount);
|
||||
}
|
||||
#elif defined(PCBTARANIS)
|
||||
if (source>=MIXSRC_FIRST_LUA && source<=MIXSRC_LAST_LUA)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if !defined(HELI)
|
||||
if (source>=MIXSRC_CYC1 && source<=MIXSRC_CYC3)
|
||||
return false;
|
||||
@@ -1135,8 +1212,41 @@ bool isSourceAvailable(int16_t source)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isSourceP1Available(int16_t source)
|
||||
bool isInputSourceAvailable(int16_t source)
|
||||
{
|
||||
return isSourceAvailable(source+1);
|
||||
if (source>=MIXSRC_Rud && source<=MIXSRC_MAX)
|
||||
return true;
|
||||
|
||||
if (source>=MIXSRC_TrimRud && source<MIXSRC_SW1)
|
||||
return true;
|
||||
|
||||
if (source>=MIXSRC_FIRST_CH && source<=MIXSRC_LAST_CH)
|
||||
return true;
|
||||
|
||||
if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isSwitchAvailable(int16_t swtch)
|
||||
{
|
||||
if (swtch < 0) {
|
||||
if (swtch <= -SWSRC_ON)
|
||||
return false;
|
||||
#if defined(PCBTARANIS)
|
||||
else if (swtch == -SWSRC_SF0 || swtch == -SWSRC_SF2 || swtch == -SWSRC_SH0 || swtch == -SWSRC_SH2)
|
||||
return false;
|
||||
#endif
|
||||
else
|
||||
swtch = -swtch;
|
||||
}
|
||||
|
||||
if (swtch>=SWSRC_FIRST_CSW && swtch<=SWSRC_LAST_CSW) {
|
||||
CustomSwData * cs = cswAddress(swtch-SWSRC_FIRST_CSW);
|
||||
return (cs->func != CS_OFF);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
+24
-5
@@ -188,7 +188,12 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
|
||||
#define CHECK_INCDEC_MODELVAR_ZERO(event, var, max) \
|
||||
var = checkIncDecModelZero(event,var,max)
|
||||
|
||||
#if defined(AUTOSWITCH)
|
||||
#if defined(CPUARM)
|
||||
bool isSwitchAvailable(int16_t swtch);
|
||||
#define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER))
|
||||
#define CHECK_INCDEC_MODELSWITCH(event, var, min, max) \
|
||||
var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SWITCH|NO_INCDEC_MARKS, isSwitchAvailable)
|
||||
#elif defined(AUTOSWITCH)
|
||||
#define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER))
|
||||
#define CHECK_INCDEC_MODELSWITCH(event, var, min, max) \
|
||||
var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SWITCH)
|
||||
@@ -199,7 +204,7 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
|
||||
|
||||
#if defined(CPUARM)
|
||||
bool isSourceAvailable(int16_t source);
|
||||
bool isSourceP1Available(int16_t source);
|
||||
bool isInputSourceAvailable(int16_t source);
|
||||
#define CHECK_INCDEC_MODELSOURCE(event, var, min, max) \
|
||||
var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SOURCE|NO_INCDEC_MARKS, isSourceAvailable)
|
||||
#elif defined(AUTOSOURCE)
|
||||
@@ -246,11 +251,11 @@ void title(const pm_char * s);
|
||||
TITLE(title)
|
||||
|
||||
#define SUBMENU_NOTITLE(lines_count, ...) { \
|
||||
static const pm_uint8_t mstate_tab[] PROGMEM = __VA_ARGS__; \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
if (!check(event,0,NULL,0,mstate_tab,DIM(mstate_tab)-1,(lines_count)-1)) return; }
|
||||
|
||||
#define SUBMENU(title, lines_count, ...) \
|
||||
static const pm_uint8_t mstate_tab[] PROGMEM = __VA_ARGS__; \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
if (!check(event,0,NULL,0,mstate_tab,DIM(mstate_tab)-1,(lines_count)-1)) return; \
|
||||
TITLE(title)
|
||||
|
||||
@@ -261,7 +266,13 @@ void title(const pm_char * s);
|
||||
SIMPLE_SUBMENU_NOTITLE(lines_count); \
|
||||
TITLE(title)
|
||||
|
||||
int8_t selectMenuItem(uint8_t x, uint8_t y, const pm_char *label, const pm_char *values, int8_t value, int8_t min, int8_t max, LcdFlags attr, uint8_t event);
|
||||
#if defined(CPUARM)
|
||||
typedef int select_menu_value_t;
|
||||
#else
|
||||
typedef int8_t select_menu_value_t;
|
||||
#endif
|
||||
|
||||
select_menu_value_t selectMenuItem(uint8_t x, uint8_t y, const pm_char *label, const pm_char *values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, uint8_t event);
|
||||
uint8_t onoffMenuItem(uint8_t value, uint8_t x, uint8_t y, const pm_char *label, LcdFlags attr, uint8_t event );
|
||||
int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t event);
|
||||
|
||||
@@ -287,6 +298,11 @@ extern const pm_char * s_global_warning;
|
||||
|
||||
#define WARNING_LINE_X 16
|
||||
#define WARNING_LINE_Y 3*FH
|
||||
#if LCD_W >= 212
|
||||
#define WARNING_LINE_LEN 30
|
||||
#else
|
||||
#define WARNING_LINE_LEN 20
|
||||
#endif
|
||||
|
||||
void displayBox();
|
||||
void displayPopup(const pm_char * pstr);
|
||||
@@ -339,7 +355,10 @@ void displayWarning(uint8_t event);
|
||||
#define drawStatusLine()
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
void menuChannelsView(uint8_t event);
|
||||
void pushMenuTextView(const char *filename);
|
||||
#endif
|
||||
|
||||
#define LABEL(...) (uint8_t)-1
|
||||
|
||||
|
||||
+65
-29
@@ -114,6 +114,7 @@
|
||||
#define ICON_TRAINEE 71, 11
|
||||
#define ICON_USB 81, 11
|
||||
#define ICON_REBOOT 91, 11
|
||||
#define ICON_ALTITUDE 102, 9
|
||||
#endif
|
||||
|
||||
void drawPotsBars()
|
||||
@@ -135,15 +136,15 @@ void drawStick(uint8_t centrex, int16_t xval, int16_t yval)
|
||||
|
||||
void doMainScreenGraphics()
|
||||
{
|
||||
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1+1)-1];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(1+1)-1 == THR_STICK)
|
||||
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(LBOX_CENTERX, calibratedStick[CONVERT_MODE(0+1)-1], calibStickVert);
|
||||
drawStick(LBOX_CENTERX, calibratedStick[CONVERT_MODE(0)], calibStickVert);
|
||||
|
||||
calibStickVert = calibratedStick[CONVERT_MODE(2+1)-1];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(2+1)-1 == THR_STICK)
|
||||
calibStickVert = calibratedStick[CONVERT_MODE(2)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(RBOX_CENTERX, calibratedStick[CONVERT_MODE(3+1)-1], calibStickVert);
|
||||
drawStick(RBOX_CENTERX, calibratedStick[CONVERT_MODE(3)], calibStickVert);
|
||||
|
||||
#if !defined(PCBTARANIS)
|
||||
drawPotsBars();
|
||||
@@ -156,7 +157,7 @@ void displayTrims(uint8_t phase)
|
||||
static xcoord_t x[4] = {TRIM_LH_X, TRIM_LV_X, TRIM_RV_X, TRIM_RH_X};
|
||||
static uint8_t vert[4] = {0,1,1,0};
|
||||
uint8_t xm, ym;
|
||||
xm = x[CONVERT_MODE(i+1)-1];
|
||||
xm = x[CONVERT_MODE(i)];
|
||||
|
||||
uint8_t att = ROUND;
|
||||
int16_t val = getTrimValue(phase, i);
|
||||
@@ -210,9 +211,6 @@ void displaySliders()
|
||||
#define BAR_Y 1
|
||||
#define BAR_W 184
|
||||
#define BAR_H 9
|
||||
#define BAR_BATT_X BAR_X+18
|
||||
#define BAR_RSSI_X BAR_X+42
|
||||
#define BAR_A1_X BAR_X+69
|
||||
#define BAR_NOTIFS_X BAR_X+133
|
||||
#define BAR_VOLUME_X BAR_X+147
|
||||
#define BAR_TIME_X BAR_X+168
|
||||
@@ -232,15 +230,19 @@ void displayTopBarGauge(xcoord_t x, int count, bool blinking=false)
|
||||
|
||||
void displayTopBar()
|
||||
{
|
||||
uint8_t batt_icon_x;
|
||||
uint8_t altitude_icon_x;
|
||||
|
||||
/* Tx voltage */
|
||||
putsVBat(BAR_BATT_X, BAR_Y+1, 0);
|
||||
lcd_rect(BAR_BATT_X+FW, BAR_Y+1, 13, 7);
|
||||
lcd_vline(BAR_BATT_X+FW+13, BAR_Y+2, 5);
|
||||
putsVBat(BAR_X+2, BAR_Y+1, LEFT);
|
||||
batt_icon_x = lcdLastPos;
|
||||
lcd_rect(batt_icon_x+FW, BAR_Y+1, 13, 7);
|
||||
lcd_vline(batt_icon_x+FW+13, BAR_Y+2, 5);
|
||||
|
||||
if (frskyData.rssi[0].value > 0) {
|
||||
/* RSSI */
|
||||
LCD_ICON(BAR_RSSI_X, BAR_Y, ICON_RSSI);
|
||||
lcd_rect(BAR_RSSI_X+10, BAR_Y+1, 13, 7);
|
||||
LCD_ICON(batt_icon_x+3*FW+3, BAR_Y, ICON_RSSI);
|
||||
lcd_rect(batt_icon_x+5*FW, BAR_Y+1, 13, 7);
|
||||
|
||||
/* Rx voltage */
|
||||
lcdint_t voltage = 0;
|
||||
@@ -258,7 +260,17 @@ void displayTopBar()
|
||||
voltage = frskyData.hub.cellsSum;
|
||||
}
|
||||
if (voltage > 0) {
|
||||
putsTelemetryChannel(BAR_A1_X, BAR_Y+1, channel, voltage, LEFT);
|
||||
putsTelemetryChannel(batt_icon_x+7*FW+2, BAR_Y+1, channel, voltage, LEFT);
|
||||
altitude_icon_x = lcdLastPos+1;
|
||||
}
|
||||
else {
|
||||
altitude_icon_x = batt_icon_x+7*FW+3;
|
||||
}
|
||||
|
||||
/* Altitude */
|
||||
if (g_model.frsky.altitudeDisplayed && frskyData.hub.baroAltitudeOffset) {
|
||||
LCD_ICON(altitude_icon_x, BAR_Y, ICON_ALTITUDE);
|
||||
putsTelemetryValue(altitude_icon_x+2*FW-1, BAR_Y+1, TELEMETRY_ALT_BP, UNIT_METERS, LEFT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,9 +300,10 @@ void displayTopBar()
|
||||
x -= 12;
|
||||
}
|
||||
|
||||
/* SD ICON, not really needed
|
||||
if (sdMounted()) {
|
||||
LCD_NOTIF_ICON(x, ICON_SD);
|
||||
}
|
||||
} */
|
||||
|
||||
/* Audio volume */
|
||||
if (requiredSpeakerVolume == 0)
|
||||
@@ -314,11 +327,11 @@ void displayTopBar()
|
||||
|
||||
/* The inside of the Batt gauge */
|
||||
int count = 10 * (g_vbat100mV - g_eeGeneral.vBatMin - 90) / (30 + g_eeGeneral.vBatMax - g_eeGeneral.vBatMin);
|
||||
displayTopBarGauge(BAR_BATT_X+FW, count, g_vbat100mV <= g_eeGeneral.vBatWarn);
|
||||
displayTopBarGauge(batt_icon_x+FW, count, g_vbat100mV <= g_eeGeneral.vBatWarn);
|
||||
|
||||
/* The inside of the RSSI gauge */
|
||||
if (frskyData.rssi[0].value > 0) {
|
||||
displayTopBarGauge(BAR_RSSI_X+10, frskyData.rssi[0].value / 10, frskyData.rssi[0].value < getRssiAlarmValue(0));
|
||||
displayTopBarGauge(batt_icon_x+5*FW, frskyData.rssi[0].value / 10, frskyData.rssi[0].value < getRssiAlarmValue(0));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -358,7 +371,7 @@ void displayTimers()
|
||||
// Main timer
|
||||
if (g_model.timers[0].mode) {
|
||||
TimerState & timerState = timersStates[0];
|
||||
uint8_t att = DBLSIZE | (timerState.state==TMR_BEEPING ? BLINK|INVERS : 0);
|
||||
uint8_t att = DBLSIZE | (timerState.val<0 ? BLINK|INVERS : 0);
|
||||
putsTime(12*FW+2+10*FWNUM-4, FH*2, timerState.val, att, att);
|
||||
putsTmrMode(timerState.val >= 0 ? 9*FW-FW/2+3 : 9*FW-FW/2-4, FH*3, g_model.timers[0].mode, STRCONDENSED);
|
||||
}
|
||||
@@ -525,7 +538,7 @@ void menuMainView(uint8_t event)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(READONLY)
|
||||
#if MENUS_LOCK != 2/*no menus*/
|
||||
#if !defined(PCBTARANIS)
|
||||
case EVT_KEY_LONG(KEY_MENU):// go to last menu
|
||||
pushMenu(lastPopMenu());
|
||||
@@ -594,12 +607,14 @@ void menuMainView(uint8_t event)
|
||||
return;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
if (timersStates[0].state==TMR_BEEPING) {
|
||||
timersStates[0].state = TMR_STOPPED;
|
||||
}
|
||||
else if (s_global_warning) {
|
||||
if (s_global_warning) {
|
||||
s_global_warning = NULL;
|
||||
}
|
||||
#if defined(GVARS) && !defined(PCBSTD)
|
||||
else if (s_gvar_timer > 0) {
|
||||
s_gvar_timer = 0;
|
||||
}
|
||||
#endif
|
||||
#if !defined(PCBTARANIS)
|
||||
else if (view == VIEW_TIMER2) {
|
||||
resetTimer(1);
|
||||
@@ -652,18 +667,18 @@ void menuMainView(uint8_t event)
|
||||
// TODO simplify this + reuse code in checkSwitches() + Menu MODELSETUP
|
||||
switch(i) {
|
||||
case 5:
|
||||
sw = getValue(MIXSRC_SF-1) > 0 ? 3*i+2 : 3*i+1;
|
||||
sw = getValue(MIXSRC_SF) > 0 ? 3*i+2 : 3*i+1;
|
||||
break;
|
||||
case 6:
|
||||
val = getValue(MIXSRC_SG-1);
|
||||
val = getValue(MIXSRC_SG);
|
||||
sw = ((val < 0) ? 3*i : ((val == 0) ? 3*i+1 : 3*i+2));
|
||||
break;
|
||||
case 7:
|
||||
sw = getValue(MIXSRC_SH-1) > 0 ? 3*i+1 : 3*i;
|
||||
sw = getValue(MIXSRC_SH) > 0 ? 3*i+1 : 3*i;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
val = getValue(MIXSRC_SA+i-1);
|
||||
val = getValue(MIXSRC_SA+i);
|
||||
sw = ((val < 0) ? 3*i+1 : ((val == 0) ? 3*i+2 : 3*i+3));
|
||||
break;
|
||||
}
|
||||
@@ -822,6 +837,27 @@ void menuMainView(uint8_t event)
|
||||
s_warning = NULL;
|
||||
}
|
||||
|
||||
#if defined(GVARS) && !defined(PCBSTD)
|
||||
else if (s_gvar_timer > 0) {
|
||||
s_gvar_timer--;
|
||||
#if LCD_W >= 212
|
||||
lcd_filled_rect(BITMAP_X, BITMAP_Y, 64, 32, SOLID, ERASE);
|
||||
lcd_rect(BITMAP_X, BITMAP_Y, 64, 32);
|
||||
putsStrIdx(BITMAP_X+FW, BITMAP_Y+FH-1, STR_GV, s_gvar_last+1);
|
||||
lcd_putsnAtt(BITMAP_X+4*FW+FW/2, BITMAP_Y+FH-1, g_model.gvars[s_gvar_last].name, LEN_GVAR_NAME, ZCHAR);
|
||||
lcd_putsAtt(BITMAP_X+FW, BITMAP_Y+2*FH+3, PSTR("[\010]"), BOLD);
|
||||
lcd_outdezAtt(BITMAP_X+5*FW+FW/2, BITMAP_Y+2*FH+3, GVAR_VALUE(s_gvar_last, s_perout_flight_phase), BOLD);
|
||||
#else
|
||||
s_warning = STR_GLOBAL_VAR;
|
||||
displayBox();
|
||||
lcd_putsnAtt(16, 5*FH, g_model.gvars[s_gvar_last].name, LEN_GVAR_NAME, ZCHAR);
|
||||
lcd_putsAtt(16+7*FW, 5*FH, PSTR("[\010]"), BOLD);
|
||||
lcd_outdezAtt(16+7*FW+4*FW+FW/2, 5*FH, GVAR_VALUE(s_gvar_last, s_perout_flight_phase), BOLD);
|
||||
s_warning = NULL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(DSM2)
|
||||
if (dsm2Flag == DSM2_BIND_FLAG) // Issue 98
|
||||
lcd_putsAtt(15*FW, 0, PSTR("BIND"), 0);
|
||||
|
||||
@@ -84,9 +84,9 @@ void menuStatisticsView(uint8_t event)
|
||||
}
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define MENU_DEBUG_COL_OFS (13*FW)
|
||||
#define MENU_DEBUG_COL_OFS (11*FW-2)
|
||||
#else
|
||||
#define MENU_DEBUG_COL_OFS (14*FW)
|
||||
#define MENU_DEBUG_COL_OFS (14*FW)
|
||||
#endif
|
||||
|
||||
void menuStatisticsDebug(uint8_t event)
|
||||
@@ -167,18 +167,22 @@ void menuStatisticsDebug(uint8_t event)
|
||||
putsTelemetryValue(MENU_DEBUG_COL_OFS, 4*FH, Coproc_temp, UNIT_DEGREES, 0);
|
||||
putsTelemetryValue(20*FW+2, 4*FH, Coproc_maxtemp, UNIT_DEGREES, 0);
|
||||
}
|
||||
#elif defined(PCBTARANIS) && !defined(SIMU)
|
||||
lcd_putsLeft(4*FH, "Free Mem");
|
||||
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 4*FH, 0x20020000 - (unsigned int)heap, LEFT);
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
lcd_putsLeft(5*FH, STR_TMIXMAXMS);
|
||||
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 5*FH, (maxMixerDuration)/20, PREC2);
|
||||
|
||||
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 5*FH, (maxMixerDuration)/20, PREC2|LEFT);
|
||||
lcd_puts(lcdLastPos, 5*FH, "ms");
|
||||
lcd_putsLeft(6*FH, STR_FREESTACKMINB);
|
||||
lcd_outdezAtt(13*FW, 6*FH, stack_free(0), UNSIGN);
|
||||
lcd_putc(13*FW, 6*FH, '/');
|
||||
lcd_outdezAtt(13*FW+FWNUM, 6*FH, stack_free(1), UNSIGN|LEFT);
|
||||
lcd_putc(lcdLastPos, 6*FH, '/');
|
||||
lcd_outdezAtt(lcdLastPos+FWNUM, 6*FH, stack_free(2), UNSIGN|LEFT);
|
||||
lcd_putsAtt(MENU_DEBUG_COL_OFS-1, 6*FH+1, "[Main]", SMLSIZE);
|
||||
lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(0), UNSIGN|LEFT);
|
||||
lcd_putsAtt(lcdLastPos+2, 6*FH+1, "[Mix]", SMLSIZE);
|
||||
lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(1), UNSIGN|LEFT);
|
||||
lcd_putsAtt(lcdLastPos+2, 6*FH+1, "[Audio]", SMLSIZE);
|
||||
lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(2), UNSIGN|LEFT);
|
||||
#else
|
||||
lcd_putsLeft(1*FH, STR_TMR1LATMAXUS);
|
||||
lcd_outdez8(MENU_DEBUG_COL_OFS , 1*FH, g_tmr1Latency_max/2 );
|
||||
|
||||
@@ -113,7 +113,7 @@ void displayGpsCoord(uint8_t y, char direction, int16_t bp, int16_t ap)
|
||||
if (!direction) direction = '-';
|
||||
lcd_outdezAtt(TELEM_2ND_COLUMN, y, bp / 100, LEFT); // ddd before '.'
|
||||
lcd_putc(lcdLastPos, y, '@');
|
||||
uint8_t mn = bp % 100;
|
||||
uint8_t mn = bp % 100; // TODO div_t
|
||||
if (g_eeGeneral.gpsFormat == 0) {
|
||||
lcd_putc(lcdLastPos+FWNUM, y, direction);
|
||||
lcd_outdezNAtt(lcdLastPos+FW+FW+1, y, mn, LEFT|LEADING0, 2); // mm before '.'
|
||||
@@ -220,7 +220,7 @@ void menuTelemetryFrsky(uint8_t event)
|
||||
uint8_t y = barHeight+6+i*(barHeight+6);
|
||||
lcd_putsiAtt(0, y+barHeight-5, STR_VTELEMCHNS, source, 0);
|
||||
lcd_rect(25, y, BAR_WIDTH+1, barHeight+2);
|
||||
getvalue_t value = getValue(MIXSRC_FIRST_TELEM+source-2);
|
||||
getvalue_t value = getValue(MIXSRC_FIRST_TELEM+source-1);
|
||||
#if LCD_W >= 212
|
||||
putsTelemetryChannel(27+BAR_WIDTH, y+barHeight-6, source-1, value, LEFT);
|
||||
#endif
|
||||
@@ -305,7 +305,7 @@ void menuTelemetryFrsky(uint8_t event)
|
||||
}
|
||||
if (field) {
|
||||
fields_count++;
|
||||
getvalue_t value = getValue(MIXSRC_FIRST_TELEM+field-2);
|
||||
getvalue_t value = getValue(MIXSRC_FIRST_TELEM+field-1);
|
||||
uint8_t att = (i==3 ? NO_UNIT : DBLSIZE|NO_UNIT);
|
||||
#if LCD_W >= 212
|
||||
xcoord_t pos[] = {0, 71, 143, 214};
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../opentx.h"
|
||||
|
||||
#define TEXT_FILENAME_MAXLEN 40
|
||||
#define TEXT_FILE_MAXSIZE 1000
|
||||
|
||||
char s_text_file[TEXT_FILENAME_MAXLEN];
|
||||
char s_text_screen[LCD_LINES-1][LCD_COLS+1];
|
||||
|
||||
void readTextFile(int & lines_count)
|
||||
{
|
||||
FIL file;
|
||||
int result;
|
||||
char c;
|
||||
unsigned int sz;
|
||||
int line_length = 0;
|
||||
int escape = 0;
|
||||
char escape_chars[2];
|
||||
int current_line = 0;
|
||||
|
||||
memset(s_text_screen, 0, sizeof(s_text_screen));
|
||||
|
||||
result = f_open(&file, s_text_file, FA_OPEN_EXISTING | FA_READ);
|
||||
if (result == FR_OK) {
|
||||
for (int i=0; i<TEXT_FILE_MAXSIZE && f_read(&file, &c, 1, &sz)==FR_OK && sz==1 && (lines_count==0 || current_line-s_pgOfs<LCD_LINES-1); 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) {
|
||||
if (c=='\\' && escape==0) {
|
||||
escape = 1;
|
||||
continue;
|
||||
}
|
||||
else if (c!='\\' && escape>0 && escape<3) {
|
||||
escape_chars[escape-1] = c;
|
||||
if (escape == 2 && !strncmp(escape_chars, "up", 2)) {
|
||||
c = '\300';
|
||||
}
|
||||
else if (escape == 2 && !strncmp(escape_chars, "dn", 2)) {
|
||||
c = '\301';
|
||||
}
|
||||
else {
|
||||
escape++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
escape = 0;
|
||||
s_text_screen[current_line-s_pgOfs][line_length++] = c;
|
||||
}
|
||||
}
|
||||
f_close(&file);
|
||||
}
|
||||
|
||||
if (lines_count == 0) {
|
||||
lines_count = current_line;
|
||||
}
|
||||
}
|
||||
|
||||
void menuTextView(uint8_t event)
|
||||
{
|
||||
static int lines_count;
|
||||
|
||||
switch (event) {
|
||||
case EVT_ENTRY:
|
||||
s_pgOfs = 0;
|
||||
lines_count = 0;
|
||||
readTextFile(lines_count);
|
||||
break;
|
||||
|
||||
case EVT_KEY_BREAK(KEY_UP):
|
||||
if (s_pgOfs == 0)
|
||||
break;
|
||||
else
|
||||
s_pgOfs--;
|
||||
// no break;
|
||||
|
||||
case EVT_KEY_BREAK(KEY_DOWN):
|
||||
if (event == EVT_KEY_BREAK(KEY_DOWN)) {
|
||||
if (s_pgOfs+LCD_LINES-1 >= lines_count)
|
||||
break;
|
||||
else
|
||||
++s_pgOfs;
|
||||
}
|
||||
readTextFile(lines_count);
|
||||
break;
|
||||
|
||||
case EVT_KEY_BREAK(KEY_EXIT):
|
||||
popMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i=0; i<LCD_LINES-1; i++) {
|
||||
lcd_puts(0, i*FH+FH+1, s_text_screen[i]);
|
||||
}
|
||||
|
||||
char *title = s_text_file;
|
||||
#if defined(SIMU)
|
||||
if (!strncmp(title, "./", 2)) title += 2;
|
||||
#else
|
||||
// TODO?
|
||||
#endif
|
||||
lcd_puts(LCD_W/2-strlen(title)*FW/2, 0, title);
|
||||
lcd_invert_line(0);
|
||||
|
||||
if (lines_count > LCD_LINES-1) {
|
||||
displayScrollbar(LCD_W-1, FH, LCD_H-FH, s_pgOfs, lines_count, LCD_LINES-1);
|
||||
}
|
||||
}
|
||||
|
||||
void pushMenuTextView(const char *filename)
|
||||
{
|
||||
if (strlen(filename) < TEXT_FILENAME_MAXLEN) {
|
||||
strcpy(s_text_file, filename);
|
||||
pushMenu(menuTextView);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user