New ML support - W25X20CL
language selection from menu is working
This commit is contained in:
parent
a9446cc6b3
commit
dcd58d002c
6 changed files with 35 additions and 55 deletions
|
@ -996,19 +996,6 @@ void erase_eeprom_section(uint16_t offset, uint16_t bytes)
|
|||
|
||||
#include "bootapp.h"
|
||||
|
||||
void __test(uint8_t lang)
|
||||
{
|
||||
uint8_t cnt = lang_get_count();
|
||||
printf_P(PSTR("cnt=%d lang=%d\n"), cnt, lang);
|
||||
if ((lang < 2) || (lang > cnt)) return;
|
||||
|
||||
cli();
|
||||
boot_app_magic = BOOT_APP_MAGIC;
|
||||
boot_app_flags = BOOT_APP_FLG_USER0;
|
||||
boot_reserved = lang << 4;
|
||||
wdt_enable(WDTO_15MS);
|
||||
while(1);
|
||||
}
|
||||
|
||||
#ifdef W25X20CL
|
||||
|
||||
|
@ -1026,17 +1013,15 @@ void upgrade_sec_lang_from_external_flash()
|
|||
uint32_t src_addr;
|
||||
if (lang_get_header(lang, &header, &src_addr))
|
||||
{
|
||||
fprintf_P(lcdout, PSTR(ESC_H(1,3) "lng=%1hhd sta=%1hhx %04x"), lang, state, header.size);
|
||||
fprintf_P(lcdout, PSTR(ESC_H(1,3) "l=%1hhd s=%1hhx %04x %04x"), lang, state, src_addr, header.size);
|
||||
delay(1000);
|
||||
boot_reserved = (state+1) | (lang << 4);
|
||||
if ((state * LANGBOOT_BLOCKSIZE) < 0x211c)
|
||||
boot_reserved = (state + 1) | (lang << 4);
|
||||
if ((state * LANGBOOT_BLOCKSIZE) < header.size)
|
||||
{
|
||||
cli();
|
||||
// for (uint16_t i = 0; i < LANGBOOT_BLOCKSIZE; i++)
|
||||
// ram_array[0x800 + i] = 0xee;
|
||||
uint16_t size = 0x211c - state * LANGBOOT_BLOCKSIZE;
|
||||
uint16_t size = header.size - state * LANGBOOT_BLOCKSIZE;
|
||||
if (size > LANGBOOT_BLOCKSIZE) size = LANGBOOT_BLOCKSIZE;
|
||||
w25x20cl_rd_data(0x25ba + state * LANGBOOT_BLOCKSIZE, (uint8_t*)LANGBOOT_RAMBUFFER, size);
|
||||
w25x20cl_rd_data(src_addr + state * LANGBOOT_BLOCKSIZE, (uint8_t*)LANGBOOT_RAMBUFFER, size);
|
||||
bootapp_ram2flash(LANGBOOT_RAMBUFFER, _SEC_LANG_TABLE + state * LANGBOOT_BLOCKSIZE, size);
|
||||
}
|
||||
}
|
||||
|
@ -1510,7 +1495,7 @@ void setup()
|
|||
//#ifdef DEBUG_SEC_LANG
|
||||
|
||||
uint16_t sec_lang_code = lang_get_code(1);
|
||||
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
|
||||
uint16_t ui = _SEC_LANG_TABLE; //table pointer
|
||||
printf_P(_n("lang_selected=%d\nlang_table=0x%04x\nSEC_LANG_CODE=0x%04x (%c%c)\n"), lang_selected, ui, sec_lang_code, sec_lang_code >> 8, sec_lang_code & 0xff);
|
||||
|
||||
// lang_print_sec_lang(uartout);
|
||||
|
|
|
@ -38,3 +38,13 @@ void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size)
|
|||
wdt_enable(WDTO_15MS);
|
||||
while(1);
|
||||
}
|
||||
|
||||
void bootapp_reboot_user0(uint8_t reserved)
|
||||
{
|
||||
cli();
|
||||
boot_app_magic = BOOT_APP_MAGIC;
|
||||
boot_app_flags = BOOT_APP_FLG_USER0;
|
||||
boot_reserved = reserved;
|
||||
wdt_enable(WDTO_15MS);
|
||||
while(1);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ extern "C" {
|
|||
|
||||
extern void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size);
|
||||
|
||||
extern void bootapp_reboot_user0(uint8_t reserved);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
|
|
@ -39,16 +39,6 @@ const char* lang_get_translation(const char* s)
|
|||
return (const char*)((char*)lang_table + ui); //return calculated pointer
|
||||
}
|
||||
|
||||
const char* lang_get_sec_lang_str(const char* s)
|
||||
{
|
||||
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
|
||||
lang_table_t* _lang_table = ui; //table pointer
|
||||
ui = pgm_read_word(((uint16_t*)s)); //read string id
|
||||
if (ui == 0xffff) return s + 2; //translation not found
|
||||
ui = pgm_read_word(((uint16_t*)(((char*)_lang_table + 16 + ui*2)))); //read relative offset
|
||||
return (const char*)((char*)_lang_table + ui); //return calculated pointer
|
||||
}
|
||||
|
||||
uint8_t lang_select(uint8_t lang)
|
||||
{
|
||||
if (lang == LANG_ID_PRI) //primary language
|
||||
|
@ -60,7 +50,7 @@ uint8_t lang_select(uint8_t lang)
|
|||
#ifdef W25X20CL
|
||||
if (lang == LANG_ID_SEC) //current secondary language
|
||||
{
|
||||
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
|
||||
uint16_t ui = _SEC_LANG_TABLE; //table pointer
|
||||
if (pgm_read_dword(((uint32_t*)(ui + 0))) != LANG_MAGIC) return 0; //magic not valid
|
||||
lang_table = ui; // set table pointer
|
||||
lang_selected = 1; // set language id
|
||||
|
@ -103,7 +93,7 @@ uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* off
|
|||
#ifdef W25X20CL
|
||||
if (lang == LANG_ID_SEC)
|
||||
{
|
||||
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
|
||||
uint16_t ui = _SEC_LANG_TABLE; //table pointer
|
||||
memcpy_P(header, ui, sizeof(lang_table_header_t)); //read table header from progmem
|
||||
if (offset) *offset = ui;
|
||||
return (header == LANG_MAGIC)?1:0; //return 1 if magic valid
|
||||
|
@ -130,7 +120,7 @@ uint16_t lang_get_code(uint8_t lang)
|
|||
#ifdef W25X20CL
|
||||
if (lang == LANG_ID_SEC)
|
||||
{
|
||||
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
|
||||
uint16_t ui = _SEC_LANG_TABLE; //table pointer
|
||||
if (pgm_read_dword(((uint32_t*)(ui + 0))) != LANG_MAGIC) return LANG_CODE_XX; //magic not valid
|
||||
return pgm_read_word(((uint32_t*)(ui + 10))); //return lang code from progmem
|
||||
}
|
||||
|
@ -149,7 +139,7 @@ uint16_t lang_get_code(uint8_t lang)
|
|||
|
||||
// if (lang == LANG_ID_SEC)
|
||||
// {
|
||||
// uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
|
||||
// uint16_t ui = _SEC_LANG_TABLE; //table pointer
|
||||
// if (pgm_read_dword(((uint32_t*)(ui + 0))) == LANG_MAGIC) //magic num is OK
|
||||
// return pgm_read_word(((uint16_t*)(ui + 10))); //read language code
|
||||
// }
|
||||
|
@ -168,22 +158,12 @@ const char* lang_get_name_by_code(uint16_t code)
|
|||
case LANG_CODE_PL: return _n("Polski");
|
||||
}
|
||||
return _n("??");
|
||||
|
||||
// if (lang == LANG_ID_UNDEFINED) lang = lang_selected;
|
||||
// if (lang == LANG_ID_PRI) return _T(MSG_LANGUAGE_NAME + 2);
|
||||
// if (lang == LANG_ID_SEC)
|
||||
// {
|
||||
// uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
|
||||
// if (pgm_read_dword(((uint32_t*)(ui + 0))) == LANG_MAGIC) //magic num is OK
|
||||
// return lang_get_sec_lang_str(MSG_LANGUAGE_NAME);
|
||||
// }
|
||||
// return 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_SEC_LANG
|
||||
const char* lang_get_sec_lang_str_by_id(uint16_t id)
|
||||
{
|
||||
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
|
||||
uint16_t ui = _SEC_LANG_TABLE; //table pointer
|
||||
return ui + pgm_read_word(((uint16_t*)(ui + 16 + id * 2))); //read relative offset and return calculated pointer
|
||||
}
|
||||
|
||||
|
@ -207,7 +187,7 @@ uint16_t lang_print_sec_lang(FILE* out)
|
|||
printf_P(_n(" _lt_resv1 = 0x%08lx\n"), _lt_resv1);
|
||||
if (_lt_magic != LANG_MAGIC) return 0;
|
||||
puts_P(_n(" strings:\n"));
|
||||
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
|
||||
uint16_t ui = _SEC_LANG_TABLE; //table pointer
|
||||
for (ui = 0; ui < _lt_count; ui++)
|
||||
fprintf_P(out, _n(" %3d %S\n"), ui, lang_get_sec_lang_str_by_id(ui));
|
||||
return _lt_count;
|
||||
|
@ -216,5 +196,10 @@ uint16_t lang_print_sec_lang(FILE* out)
|
|||
|
||||
#endif //(LANG_MODE == 0)
|
||||
|
||||
//const char MSG_LANGUAGE_NAME[] PROGMEM_I1 = ISTR("English"); ////c=0 r=0
|
||||
|
||||
void lang_boot_upgrade_start(uint8_t lang)
|
||||
{
|
||||
uint8_t cnt = lang_get_count();
|
||||
if ((lang < 2) || (lang > cnt)) return; //only languages from xflash can be selected
|
||||
bootapp_reboot_user0(lang << 4);
|
||||
}
|
||||
|
|
|
@ -100,7 +100,6 @@ extern uint8_t lang_selected;
|
|||
#if (LANG_MODE != 0)
|
||||
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);
|
||||
#define _SEC_LANG_TABLE ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00)
|
||||
#endif //(LANG_MODE != 0)
|
||||
|
||||
|
@ -118,6 +117,8 @@ extern const char* lang_get_sec_lang_str_by_id(uint16_t id);
|
|||
extern uint16_t lang_print_sec_lang(FILE* out);
|
||||
#endif //DEBUG_SEC_LANG
|
||||
|
||||
extern void lang_boot_upgrade_start(uint8_t lang);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif //defined(__cplusplus)
|
||||
|
@ -125,9 +126,6 @@ extern uint16_t lang_print_sec_lang(FILE* out);
|
|||
#define CAT2(_s1, _s2) _s1
|
||||
#define CAT4(_s1, _s2, _s3, _s4) _s1
|
||||
|
||||
//Localized language name
|
||||
//extern const char MSG_LANGUAGE_NAME[];
|
||||
|
||||
#include "messages.h"
|
||||
|
||||
|
||||
|
|
|
@ -3717,12 +3717,15 @@ static void lcd_crash_mode_set()
|
|||
static void lcd_set_lang(unsigned char lang)
|
||||
{
|
||||
if (lang > LANG_ID_SEC)
|
||||
{
|
||||
if (!lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Copy selected language from XFLASH?"), false, true))
|
||||
{
|
||||
lcd_return_to_status();
|
||||
lcd_update_enable(true);
|
||||
return;
|
||||
}
|
||||
lang_boot_upgrade_start(lang);
|
||||
}
|
||||
lang_select(lang);
|
||||
/*
|
||||
lang_selected = lang;
|
||||
|
@ -5657,11 +5660,9 @@ void lcd_confirm_print()
|
|||
|
||||
}
|
||||
|
||||
extern void __test(uint8_t lang);
|
||||
|
||||
static void lcd_test_menu()
|
||||
{
|
||||
__test(3);
|
||||
lang_boot_upgrade_start(3);
|
||||
lcd_update_enable(true);
|
||||
lcd_return_to_status();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue