New ML support - czech version is working!!!
postbuild.sh, make_lang.sh - fixed (id and offset calculation) language.c, language.h - fixed (==||==) config.h - reserved space for _SEC_LANG changed Marlin_main.cpp - debug output + hardcoded lang_select(1) //means cz
This commit is contained in:
parent
fba9003223
commit
55157640c5
@ -1263,13 +1263,25 @@ void setup()
|
||||
/// if (lang_selected >= LANG_NUM){
|
||||
/// lcd_mylang();
|
||||
/// }
|
||||
lang_select(0);
|
||||
lang_select(1);
|
||||
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);
|
||||
printf_P(_n(" sizeof(_SEC_LANG) = 0x%04x\n"), sizeof(_SEC_LANG));
|
||||
uint16_t ptr_lang_table0 = ((uint16_t)(&_SEC_LANG) + 0xff) & 0xff00;
|
||||
printf_P(_n(" &_lang_table0 = 0x%04x\n"), ptr_lang_table0);
|
||||
uint32_t _lt_magic = pgm_read_dword(((uint32_t*)(ptr_lang_table0 + 0)));
|
||||
uint16_t _lt_size = pgm_read_word(((uint16_t*)(ptr_lang_table0 + 4)));
|
||||
uint16_t _lt_count = pgm_read_word(((uint16_t*)(ptr_lang_table0 + 6)));
|
||||
uint16_t _lt_chsum = pgm_read_word(((uint16_t*)(ptr_lang_table0 + 8)));
|
||||
uint16_t _lt_resv0 = pgm_read_word(((uint16_t*)(ptr_lang_table0 + 10)));
|
||||
uint32_t _lt_resv1 = pgm_read_dword(((uint32_t*)(ptr_lang_table0 + 12)));
|
||||
printf_P(_n(" _lt_magic = 0x%08lx %S\n"), _lt_magic, (_lt_magic==0x4bb45aa5)?_n("OK"):_n("NA"));
|
||||
printf_P(_n(" _lt_size = 0x%04x (%d)\n"), _lt_size, _lt_size);
|
||||
printf_P(_n(" _lt_count = 0x%04x (%d)\n"), _lt_count, _lt_count);
|
||||
printf_P(_n(" _lt_chsum = 0x%04x\n"), _lt_chsum);
|
||||
printf_P(_n(" _lt_resv0 = 0x%04x\n"), _lt_resv0);
|
||||
printf_P(_n(" _lt_resv1 = 0x%08lx\n"), _lt_resv1);
|
||||
puts_P(_n("\n"));
|
||||
|
||||
|
||||
|
@ -21,7 +21,8 @@
|
||||
//LANG - Multi-language support
|
||||
//#define LANG_MODE 0 // primary language only
|
||||
#define LANG_MODE 1 // sec. language support
|
||||
#define LANG_SIZE_RESERVED 0x2800 // reserved space for secondary language (10kb)
|
||||
#define LANG_SIZE_RESERVED 0x2700 // reserved space for secondary language (~10kb)
|
||||
//#define LANG_SIZE_RESERVED 0x1ef8 // reserved space for secondary language (~10kb)
|
||||
|
||||
|
||||
#endif //_CONFIG_H
|
||||
|
@ -39,7 +39,19 @@ const char* lang_get_translation(const char* s)
|
||||
uint16_t 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 + 16); //return calculated pointer
|
||||
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; //pointer to _SEC_LANG reserved space
|
||||
ui += 0x00ff; //add 1 page
|
||||
ui &= 0xff00; //align to page
|
||||
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
|
||||
}
|
||||
|
||||
const char* lang_select(unsigned char lang)
|
||||
@ -54,10 +66,10 @@ const char* lang_select(unsigned char lang)
|
||||
return;
|
||||
}
|
||||
uint16_t ui = (uint16_t)&_SEC_LANG; //pointer to _SEC_LANG reserved space
|
||||
ui += 0x0100; //add 1 page
|
||||
ui += 0x00ff; //add 1 page
|
||||
ui &= 0xff00; //align to page
|
||||
lang_table = ui; //set table pointer
|
||||
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 + 16); //return calculated pointer
|
||||
return (const char*)((char*)lang_table + ui); //return calculated pointer
|
||||
#endif //(LANG_MODE == 0)
|
||||
}
|
@ -70,6 +70,7 @@ extern const char _SEC_LANG[LANG_SIZE_RESERVED];
|
||||
#endif //(LANG_MODE == 0)
|
||||
|
||||
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);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
@ -78,21 +78,22 @@ cat lang_$LANG.txt | sed "s/\\\\/\\\\\\\\/g" | while read s; do
|
||||
done >lang_$LANG.dat
|
||||
echo "OK" >&2
|
||||
|
||||
#generate lang_xx.ofs (secondary language text data offset table)
|
||||
echo -n " generating lang_$LANG.ofs..." >&2
|
||||
cat lang_$LANG.txt | sed "s/\\\\x[0-9a-f][0-9a-f]/\./g;s/\\\\[0-7][0-7][0-7]/\./g" |\
|
||||
awk 'BEGIN { o=0;} { printf("%d\n",o); o+=(length($0)-1); }' > lang_$LANG.ofs
|
||||
echo "OK" >&2
|
||||
|
||||
lt_data_size=$(wc -c lang_$LANG.dat | cut -f1 -d' ')
|
||||
|
||||
#calculate variables
|
||||
lt_magic='\xa5\x5a\xb4\x4b'
|
||||
lt_count=$(grep -c '^' lang_$LANG.txt)
|
||||
lt_size=$((16 + 2 * $lt_count + $lt_data_size))
|
||||
lt_data_size=$(wc -c lang_$LANG.dat | cut -f1 -d' ')
|
||||
lt_offs_size=$((2 * $lt_count))
|
||||
lt_size=$((16 + $lt_offs_size + $lt_data_size))
|
||||
lt_chsum=1
|
||||
lt_resv0='\xff\xff'
|
||||
lt_resv1='\xff\xff\xff\xff'
|
||||
|
||||
#generate lang_xx.ofs (secondary language text data offset table)
|
||||
echo -n " generating lang_$LANG.ofs..." >&2
|
||||
cat lang_$LANG.txt | sed "s/\\\\x[0-9a-f][0-9a-f]/\./g;s/\\\\[0-7][0-7][0-7]/\./g" |\
|
||||
awk 'BEGIN { o='$((16 + $lt_offs_size))';} { printf("%d\n",o); o+=(length($0)-1); }' > lang_$LANG.ofs
|
||||
echo "OK" >&2
|
||||
|
||||
#generate lang_xx.bin (secondary language result binary file)
|
||||
echo " generating lang_$LANG.bin:" >&2
|
||||
#create empty file
|
||||
@ -117,13 +118,13 @@ echo -n -e "$lt_resv1" |\
|
||||
dd of=lang_$LANG.bin bs=1 count=4 seek=12 conv=notrunc 2>/dev/null
|
||||
echo "OK" >&2
|
||||
|
||||
echo -n " writing offset table ($((2 * $lt_count)) bytes)..." >&2
|
||||
echo -n " writing offset table ($lt_offs_size bytes)..." >&2
|
||||
echo -n -e $(cat lang_$LANG.ofs | awk "$awk_ui16" | tr -d '\n'; echo) |\
|
||||
dd of=./lang_$LANG.bin bs=1 count=$((2 * $lt_count)) seek=16 conv=notrunc 2>/dev/null
|
||||
dd of=./lang_$LANG.bin bs=1 count=$lt_offs_size seek=16 conv=notrunc 2>/dev/null
|
||||
echo "OK" >&2
|
||||
|
||||
echo -n " writing text data ($lt_data_size bytes)..." >&2
|
||||
dd if=./lang_$LANG.dat of=./lang_$LANG.bin bs=1 count=$lt_data_size seek=$((16 + 2 * $lt_count)) conv=notrunc 2>/dev/null
|
||||
dd if=./lang_$LANG.dat of=./lang_$LANG.bin bs=1 count=$lt_data_size seek=$((16 + $lt_offs_size)) conv=notrunc 2>/dev/null
|
||||
echo "OK" >&2
|
||||
|
||||
echo " lang_table details:" >&2
|
||||
@ -132,3 +133,6 @@ echo " lt_size = $lt_size" >&2
|
||||
echo " lt_chsum = $lt_chsum" >&2
|
||||
|
||||
finish 0
|
||||
|
||||
|
||||
|
||||
|
@ -81,7 +81,7 @@ echo " updating binary:" >&2
|
||||
#update progmem1 id entries in binary file
|
||||
echo -n " primary language ids..." >&2
|
||||
cat textaddr.txt | grep "^ADDR OK" | cut -f3- -d' ' | sed "s/^0000/0x/" |\
|
||||
awk '{ hi = int($2 / 256); lo = int($2 - 256 * hi); printf("%d \\\\x%02x\\\\x%02x\n", strtonum($1), lo, hi); }' |\
|
||||
awk '{ id = $2 - 1; hi = int(id / 256); lo = int(id - 256 * hi); printf("%d \\\\x%02x\\\\x%02x\n", strtonum($1), lo, hi); }' |\
|
||||
while read addr data; do
|
||||
echo -n -e $data | dd of=./firmware.bin bs=1 count=2 seek=$addr conv=notrunc oflag=nonblock 2>/dev/null
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user