New ML support - language select menu

+cond. translation for W25X20CL
This commit is contained in:
Robert Pelnar 2018-06-08 01:19:49 +02:00
parent bd1e410228
commit 59e65b7f47
2 changed files with 25 additions and 6 deletions

View File

@ -57,6 +57,7 @@ uint8_t lang_select(uint8_t lang)
lang_selected = 0;
return 1;
}
#ifdef W25X20CL
if (lang == LANG_ID_SEC) //current secondary language
{
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
@ -65,6 +66,8 @@ uint8_t lang_select(uint8_t lang)
lang_selected = 1; // set language id
return 1;
}
#else //W25X20CL
#endif //W25X20CL
/*
uint16_t ui = (uint16_t)&_SEC_LANG; //pointer to _SEC_LANG reserved space
ui += 0x00ff; //add 1 page
@ -77,8 +80,8 @@ uint8_t lang_select(uint8_t lang)
uint8_t lang_get_count()
{
//#ifdef W25X20CL
uint8_t count = 1; //count = 1+n (primary + all in xflash)
#ifdef W25X20CL
uint8_t count = 2; //count = 1+n (primary + secondary + all in xflash)
uint32_t addr = 0x00000; //start of xflash
lang_table_header_t header; //table header structure
while (1)
@ -89,10 +92,13 @@ uint8_t lang_get_count()
count++; //inc counter
}
return count;
#else //W25X20CL
#endif //W25X20CL
}
uint16_t lang_get_code(uint8_t lang)
{
#ifdef W25X20CL
if (lang == LANG_ID_PRI) return LANG_CODE_EN; //primary lang = EN
if (lang == LANG_ID_SEC)
{
@ -110,6 +116,8 @@ uint16_t lang_get_code(uint8_t lang)
if (--lang == 0) return header.code;
addr += header.size; //calc address of next table
}
#else //W25X20CL
#endif //W25X20CL
// if (lang == LANG_ID_SEC)
// {

View File

@ -3769,8 +3769,9 @@ static void lcd_language_menu()
else if (langsel == LANGSEL_ACTIVE)
MENU_ITEM(back, _T(MSG_WATCH), 0);
MENU_ITEM(setlang, lang_get_name_by_code(lang_get_code(0)), 0);
for (int i = 1; i < lang_get_count(); i++)
MENU_ITEM(setlang, lang_get_name_by_code(lang_get_code(i+1)), i);
// MENU_ITEM(setlang, lang_get_name_by_code(lang_get_code(1)), 1);
for (int i = 2; i < lang_get_count(); i++)
MENU_ITEM(setlang, lang_get_name_by_code(lang_get_code(i)), i);
END_MENU();
}
#endif //(LANG_MODE != 0)
@ -7349,9 +7350,19 @@ static void menu_action_submenu(menuFunc_t data) {
static void menu_action_gcode(const char* pgcode) {
enquecommand_P(pgcode);
}
static void menu_action_setlang(unsigned char lang) {
static void menu_action_setlang(unsigned char lang)
{
if (lang <= LANG_ID_SEC)
{
lcd_set_lang(lang);
return;
}
uint16_t code = lang_get_code(lang);
if (code == lang_get_code(1)) lcd_set_lang(1);
lcd_set_lang(lang);
}
static void menu_action_function(menuFunc_t data) {
(*data)();
}