diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 1229e10a..0f79a78d 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1271,11 +1271,13 @@ void setup() // If they differ, an update procedure may need to be performed. At the end of this block, the current firmware version // is being written into the EEPROM, so the update procedure will be triggered only once. -/// lang_selected = eeprom_read_byte((uint8_t*)EEPROM_LANG); -/// if (lang_selected >= LANG_NUM){ -/// lcd_mylang(); -/// } - lang_select(1); + lang_selected = eeprom_read_byte((uint8_t*)EEPROM_LANG); + if (lang_selected >= LANG_NUM) + { + lcd_mylang(); + } + lang_select(lang_selected); + puts_P(_n("\nNew ML support")); printf_P(_n(" lang_selected = %d\n"), lang_selected); printf_P(_n(" &_SEC_LANG = 0x%04x\n"), &_SEC_LANG); diff --git a/Firmware/language.c b/Firmware/language.c index 67b80f68..c51fc60e 100644 --- a/Firmware/language.c +++ b/Firmware/language.c @@ -74,4 +74,22 @@ const char* lang_select(unsigned char lang) ui = pgm_read_word(((uint16_t*)(((char*)lang_table + 16)))); //read relative offset of first string (language name) return (const char*)((char*)lang_table + ui); //return calculated pointer #endif //(LANG_MODE == 0) -} \ No newline at end of file +} + +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) +{ + if (lang == 0) return MSG_LANGUAGE_NAME + 2; + return lang_get_sec_lang_str(MSG_LANGUAGE_NAME); +} + +const char MSG_LANGUAGE_NAME[] PROGMEM_I1 = ISTR("English"); ////c=0 r=0 diff --git a/Firmware/language.h b/Firmware/language.h index 193fcda2..ec641334 100644 --- a/Firmware/language.h +++ b/Firmware/language.h @@ -44,15 +44,16 @@ // Language indices into their particular symbol tables. -#define LANG_ID_EN 0 -#define LANG_ID_CZ 1 +#define LANG_ID_PRI 0 +#define LANG_ID_SEC 1 + // Language is not defined and it shall be selected from the menu. #define LANG_ID_FORCE_SELECTION 254 // Language is not defined on a virgin RAMBo board. #define LANG_ID_UNDEFINED 255 // Default language ID, if no language is selected. -#define LANG_ID_DEFAULT LANG_ID_CZ +#define LANG_ID_DEFAULT LANG_ID_PRI // Number of languages available in the language table. #define LANG_NUM 2 @@ -72,6 +73,8 @@ extern const char _SEC_LANG[LANG_SIZE_RESERVED]; extern const char* lang_get_translation(const char* s); extern const char* lang_get_sec_lang_str(const char* s); extern const char* lang_select(unsigned char lang); +extern unsigned char lang_get_count(); +extern const char* lang_get_name(unsigned char lang); #if defined(__cplusplus) } @@ -79,9 +82,11 @@ extern const char* lang_select(unsigned char lang); #define CAT2(_s1, _s2) _s1 #define CAT4(_s1, _s2, _s3, _s4) _s1 -#define MSG_LANGUAGE_NAME_EXPLICIT(i) ((i==0)?PSTR("ENG"):PSTR("CZE")) + +extern const char MSG_LANGUAGE_NAME[]; #include "messages.h" + #endif //__LANGUAGE_H diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index ae5ef9c2..e940e488 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3759,14 +3759,12 @@ void lcd_force_language_selection() { static void lcd_language_menu() { START_MENU(); - if (langsel == LANGSEL_OFF) { + if (langsel == LANGSEL_OFF) MENU_ITEM(back, _T(MSG_SETTINGS), 0); - } else if (langsel == LANGSEL_ACTIVE) { + else if (langsel == LANGSEL_ACTIVE) MENU_ITEM(back, _T(MSG_WATCH), 0); - } - for (int i=0;i3) first = cursor-3; - if (cursor==LANG_NUM && LANG_NUM>4) first = LANG_NUM-4; - 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_cnt && lang_cnt==4) first = lang_cnt-4; lcd.setCursor(0, 0); lcd.print(" "); lcd.setCursor(1, 0); - lcd_printPGM(MSG_LANGUAGE_NAME_EXPLICIT(first+0)); + lcd_printPGM(lang_get_name(first+0)); lcd.setCursor(0, 1); lcd.print(" "); lcd.setCursor(1, 1); - lcd_printPGM(MSG_LANGUAGE_NAME_EXPLICIT(first+1)); + lcd_printPGM(lang_get_name(first+1)); lcd.setCursor(0, 2); lcd.print(" "); - if (LANG_NUM > 2){ + if (lang_cnt > 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.print(" "); - if (LANG_NUM>3) { + if (lang_cnt>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==2) lcd.setCursor(0, 1); 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(">"); - if (cursor4) { + if (cursor4) { lcd.setCursor(19,3); lcd.print("\x01"); } - if (cursor>3 && LANG_NUM>4) { + if (cursor>3 && lang_cnt>4) { lcd.setCursor(19,0); lcd.print("^"); - } + } } void lcd_mylang_drawcursor(int cursor) { + unsigned char lang_cnt = lang_get_count(); if (cursor==1) lcd.setCursor(0, 1); - if (cursor>1 && cursor1 && cursor"); } -void lcd_mylang() { +void lcd_mylang() +{ int enc_dif = 0; int cursor_pos = 1; lang_selected=255; int hlaska=1; int counter=0; + unsigned char lang_cnt = lang_get_count(); lcd_set_custom_characters_arrows(); lcd_implementation_clear(); @@ -4667,7 +4670,6 @@ void lcd_mylang() { lcd_mylang_drawmenu(cursor_pos); - enc_dif = encoderDiff; while ( (lang_selected == 255) ) { @@ -4686,8 +4688,8 @@ void lcd_mylang() { cursor_pos ++; } - if (cursor_pos > LANG_NUM) { - cursor_pos = LANG_NUM; + if (cursor_pos > lang_cnt) { + cursor_pos = lang_cnt; } if (cursor_pos < 1) { diff --git a/lang/lang_en.txt b/lang/lang_en.txt index 170eb8ea..caf1ef8b 100644 --- a/lang/lang_en.txt +++ b/lang/lang_en.txt @@ -217,6 +217,9 @@ #MSG_SELFTEST_ENDSTOPS c=0 r=0 "Endstops" +#MSG_LANGUAGE_NAME c=0 r=0 +"English" + #MSG_Enqueing c=0 r=0 "enqueing \x22" diff --git a/lang/lang_en_cz.txt b/lang/lang_en_cz.txt index f7d8989d..19eba930 100644 --- a/lang/lang_en_cz.txt +++ b/lang/lang_en_cz.txt @@ -290,6 +290,10 @@ "Endstops" "Endstops" +#MSG_LANGUAGE_NAME c=0 r=0 +"English" +"Cestina" + #MSG_Enqueing c=0 r=0 "enqueing \x22" "enqueing \x22" diff --git a/lang/postbuild.sh b/lang/postbuild.sh index b24bc67d..70a4a314 100644 --- a/lang/postbuild.sh +++ b/lang/postbuild.sh @@ -26,7 +26,9 @@ OBJCOPY=C:/arduino-1.6.8/hardware/tools/avr/bin/avr-objcopy.exe # Selected language: LANG=$1 #if [ -z "$LANG" ]; then LANG='cz'; fi - +# +# Params: +IGNORE_MISSING_TEXT=1 function finish { @@ -67,8 +69,16 @@ echo "OK" >&2 #check for messages declared in progmem1, but not found in lang_en.txt echo -n " checking textaddr.txt..." >&2 -if cat textaddr.txt | grep "^ADDR NF"; then echo "NG! - some strings not found in lang_en.txt!"; finish 1; fi -echo "OK" >&2 +if cat textaddr.txt | grep "^ADDR NF" >/dev/null; then + echo "NG! - some texts not found in lang_en.txt!" + if [ $(("0$IGNORE_MISSING_TEXT")) -eq 0 ]; then + finish 1 + else + echo " missing text ignored!" >&2 + fi +else + echo "OK" >&2 +fi #update progmem1 id entries in binary file echo -n " extracting binary..." >&2