New ML support - language menu
This commit is contained in:
parent
baa66a0887
commit
b3f4e1f6e4
|
|
@ -76,6 +76,16 @@ const char* lang_select(unsigned char lang)
|
||||||
#endif //(LANG_MODE == 0)
|
#endif //(LANG_MODE == 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char lang_get_count()
|
||||||
|
{
|
||||||
|
uint16_t ui = (uint16_t)&_SEC_LANG; //pointer to _SEC_LANG reserved space
|
||||||
|
ui += 0x00ff; //add 1 page
|
||||||
|
ui &= 0xff00; //align to page
|
||||||
|
lang_table_t* _lang_table = ui; //table pointer
|
||||||
|
if (pgm_read_dword(((uint32_t*)(_lang_table + 0))) == 0x4bb45aa5) return 2;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
const char* lang_get_name(unsigned char lang)
|
const char* lang_get_name(unsigned char lang)
|
||||||
{
|
{
|
||||||
if (lang == 0) return MSG_LANGUAGE_NAME + 2;
|
if (lang == 0) return MSG_LANGUAGE_NAME + 2;
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ extern const char _SEC_LANG[LANG_SIZE_RESERVED];
|
||||||
extern const char* lang_get_translation(const char* s);
|
extern const char* lang_get_translation(const char* s);
|
||||||
extern const char* lang_get_sec_lang_str(const char* s);
|
extern const char* lang_get_sec_lang_str(const char* s);
|
||||||
extern const char* lang_select(unsigned char lang);
|
extern const char* lang_select(unsigned char lang);
|
||||||
|
extern unsigned char lang_get_count();
|
||||||
extern const char* lang_get_name(unsigned char lang);
|
extern const char* lang_get_name(unsigned char lang);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|
@ -81,7 +82,6 @@ extern const char* lang_get_name(unsigned char lang);
|
||||||
|
|
||||||
#define CAT2(_s1, _s2) _s1
|
#define CAT2(_s1, _s2) _s1
|
||||||
#define CAT4(_s1, _s2, _s3, _s4) _s1
|
#define CAT4(_s1, _s2, _s3, _s4) _s1
|
||||||
#define MSG_LANGUAGE_NAME_EXPLICIT(i) lang_get_name(i)
|
|
||||||
|
|
||||||
extern const char MSG_LANGUAGE_NAME[];
|
extern const char MSG_LANGUAGE_NAME[];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3759,14 +3759,12 @@ void lcd_force_language_selection() {
|
||||||
static void lcd_language_menu()
|
static void lcd_language_menu()
|
||||||
{
|
{
|
||||||
START_MENU();
|
START_MENU();
|
||||||
if (langsel == LANGSEL_OFF) {
|
if (langsel == LANGSEL_OFF)
|
||||||
MENU_ITEM(back, _T(MSG_SETTINGS), 0);
|
MENU_ITEM(back, _T(MSG_SETTINGS), 0);
|
||||||
} else if (langsel == LANGSEL_ACTIVE) {
|
else if (langsel == LANGSEL_ACTIVE)
|
||||||
MENU_ITEM(back, _T(MSG_WATCH), 0);
|
MENU_ITEM(back, _T(MSG_WATCH), 0);
|
||||||
}
|
for (int i=0; i < lang_get_count(); i++)
|
||||||
for (int i=0;i<LANG_NUM;i++){
|
MENU_ITEM(setlang, lang_get_name(i), i);
|
||||||
MENU_ITEM(setlang, MSG_LANGUAGE_NAME_EXPLICIT(i), i);
|
|
||||||
}
|
|
||||||
END_MENU();
|
END_MENU();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4594,50 +4592,52 @@ void lcd_mylang_drawmenu(int cursor) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void lcd_mylang_drawmenu(int cursor) {
|
void lcd_mylang_drawmenu(int cursor)
|
||||||
|
{
|
||||||
|
unsigned char lang_cnt = lang_get_count();
|
||||||
int first = 0;
|
int first = 0;
|
||||||
if (cursor>3) first = cursor-3;
|
if (cursor>3) first = cursor-3;
|
||||||
if (cursor==LANG_NUM && LANG_NUM>4) first = LANG_NUM-4;
|
if (cursor==lang_cnt && lang_cnt>4) first = lang_cnt-4;
|
||||||
if (cursor==LANG_NUM && LANG_NUM==4) first = LANG_NUM-4;
|
if (cursor==lang_cnt && lang_cnt==4) first = lang_cnt-4;
|
||||||
|
|
||||||
|
|
||||||
lcd.setCursor(0, 0);
|
lcd.setCursor(0, 0);
|
||||||
lcd.print(" ");
|
lcd.print(" ");
|
||||||
lcd.setCursor(1, 0);
|
lcd.setCursor(1, 0);
|
||||||
lcd_printPGM(MSG_LANGUAGE_NAME_EXPLICIT(first+0));
|
lcd_printPGM(lang_get_name(first+0));
|
||||||
|
|
||||||
lcd.setCursor(0, 1);
|
lcd.setCursor(0, 1);
|
||||||
lcd.print(" ");
|
lcd.print(" ");
|
||||||
lcd.setCursor(1, 1);
|
lcd.setCursor(1, 1);
|
||||||
lcd_printPGM(MSG_LANGUAGE_NAME_EXPLICIT(first+1));
|
lcd_printPGM(lang_get_name(first+1));
|
||||||
|
|
||||||
lcd.setCursor(0, 2);
|
lcd.setCursor(0, 2);
|
||||||
lcd.print(" ");
|
lcd.print(" ");
|
||||||
|
|
||||||
if (LANG_NUM > 2){
|
if (lang_cnt > 2){
|
||||||
lcd.setCursor(1, 2);
|
lcd.setCursor(1, 2);
|
||||||
lcd_printPGM(MSG_LANGUAGE_NAME_EXPLICIT(first+2));
|
lcd_printPGM(lang_get_name(first+2));
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd.setCursor(0, 3);
|
lcd.setCursor(0, 3);
|
||||||
lcd.print(" ");
|
lcd.print(" ");
|
||||||
if (LANG_NUM>3) {
|
if (lang_cnt>3) {
|
||||||
lcd.setCursor(1, 3);
|
lcd.setCursor(1, 3);
|
||||||
lcd_printPGM(MSG_LANGUAGE_NAME_EXPLICIT(first+3));
|
lcd_printPGM(lang_get_name(first+3));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursor==1) lcd.setCursor(0, 0);
|
if (cursor==1) lcd.setCursor(0, 0);
|
||||||
if (cursor==2) lcd.setCursor(0, 1);
|
if (cursor==2) lcd.setCursor(0, 1);
|
||||||
if (cursor>2) lcd.setCursor(0, 2);
|
if (cursor>2) lcd.setCursor(0, 2);
|
||||||
if (cursor==LANG_NUM && LANG_NUM>3) lcd.setCursor(0, 3);
|
if (cursor==lang_cnt && lang_cnt>3) lcd.setCursor(0, 3);
|
||||||
|
|
||||||
lcd.print(">");
|
lcd.print(">");
|
||||||
|
|
||||||
if (cursor<LANG_NUM-1 && LANG_NUM>4) {
|
if (cursor<lang_cnt-1 && lang_cnt>4) {
|
||||||
lcd.setCursor(19,3);
|
lcd.setCursor(19,3);
|
||||||
lcd.print("\x01");
|
lcd.print("\x01");
|
||||||
}
|
}
|
||||||
if (cursor>3 && LANG_NUM>4) {
|
if (cursor>3 && lang_cnt>4) {
|
||||||
lcd.setCursor(19,0);
|
lcd.setCursor(19,0);
|
||||||
lcd.print("^");
|
lcd.print("^");
|
||||||
}
|
}
|
||||||
|
|
@ -4645,20 +4645,23 @@ void lcd_mylang_drawmenu(int cursor) {
|
||||||
|
|
||||||
void lcd_mylang_drawcursor(int cursor) {
|
void lcd_mylang_drawcursor(int cursor) {
|
||||||
|
|
||||||
|
unsigned char lang_cnt = lang_get_count();
|
||||||
if (cursor==1) lcd.setCursor(0, 1);
|
if (cursor==1) lcd.setCursor(0, 1);
|
||||||
if (cursor>1 && cursor<LANG_NUM) lcd.setCursor(0, 2);
|
if (cursor>1 && cursor<lang_cnt) lcd.setCursor(0, 2);
|
||||||
if (cursor==LANG_NUM) lcd.setCursor(0, 3);
|
if (cursor==lang_cnt) lcd.setCursor(0, 3);
|
||||||
|
|
||||||
lcd.print(">");
|
lcd.print(">");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_mylang() {
|
void lcd_mylang()
|
||||||
|
{
|
||||||
int enc_dif = 0;
|
int enc_dif = 0;
|
||||||
int cursor_pos = 1;
|
int cursor_pos = 1;
|
||||||
lang_selected=255;
|
lang_selected=255;
|
||||||
int hlaska=1;
|
int hlaska=1;
|
||||||
int counter=0;
|
int counter=0;
|
||||||
|
unsigned char lang_cnt = lang_get_count();
|
||||||
lcd_set_custom_characters_arrows();
|
lcd_set_custom_characters_arrows();
|
||||||
|
|
||||||
lcd_implementation_clear();
|
lcd_implementation_clear();
|
||||||
|
|
@ -4667,7 +4670,6 @@ void lcd_mylang() {
|
||||||
|
|
||||||
lcd_mylang_drawmenu(cursor_pos);
|
lcd_mylang_drawmenu(cursor_pos);
|
||||||
|
|
||||||
|
|
||||||
enc_dif = encoderDiff;
|
enc_dif = encoderDiff;
|
||||||
|
|
||||||
while ( (lang_selected == 255) ) {
|
while ( (lang_selected == 255) ) {
|
||||||
|
|
@ -4686,8 +4688,8 @@ void lcd_mylang() {
|
||||||
cursor_pos ++;
|
cursor_pos ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursor_pos > LANG_NUM) {
|
if (cursor_pos > lang_cnt) {
|
||||||
cursor_pos = LANG_NUM;
|
cursor_pos = lang_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursor_pos < 1) {
|
if (cursor_pos < 1) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue