From f02a3467f46b7c1008e0a9d74cd2066414bc52a6 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Sun, 17 Jun 2018 21:25:57 +0200 Subject: [PATCH 1/2] New ML support - replaced LANG to LNG because of colission with env. var. --- lang/make_lang.sh | 86 +++++++++++++++++++-------------------- lang/po/make_po.sh | 58 +++++++++++++------------- lang/po_new/merge_lang.sh | 12 +++--- lang/postbuild.sh | 8 ++-- lang/update_lang.sh | 14 +++---- 5 files changed, 89 insertions(+), 89 deletions(-) diff --git a/lang/make_lang.sh b/lang/make_lang.sh index d34aad3f..0f7bc7d4 100644 --- a/lang/make_lang.sh +++ b/lang/make_lang.sh @@ -5,18 +5,18 @@ # # Input files: # lang_en.txt -# lang_en_$LANG.txt +# lang_en_xx.txt # # Output files: # lang_en.tmp (temporary, will be removed when finished) -# lang_en_$LANG.tmp ==||== -# lang_en_$LANG.dif ==||== -# lang_$LANG.txt +# lang_en_xx.tmp ==||== +# lang_en_xx.dif ==||== +# lang_xx.txt # # # Selected language: -LANG=$1 -if [ -z "$LANG" ]; then LANG='cz'; fi +LNG=$1 +if [ -z "$LNG" ]; then LNG='cz'; fi # # @@ -24,8 +24,8 @@ finish() { if [ $1 -eq 0 ]; then if [ -e lang_en.tmp ]; then rm lang_en.tmp; fi - if [ -e lang_en_$LANG.tmp ]; then rm lang_en_$LANG.tmp; fi - if [ -e lang_en_$LANG.dif ]; then rm lang_en_$LANG.dif; fi + if [ -e lang_en_$LNG.tmp ]; then rm lang_en_$LNG.tmp; fi + if [ -e lang_en_$LNG.dif ]; then rm lang_en_$LNG.dif; fi fi # echo >&2 if [ $1 -eq 0 ]; then @@ -38,59 +38,59 @@ finish() make_lang() { -LANG=$1 +LNG=$1 echo "make_lang.sh started" >&2 -echo "selected language=$LANG" >&2 +echo "selected language=$LNG" >&2 #check if input files exists echo -n " checking input files..." >&2 if [ ! -e lang_en.txt ]; then echo "NG! file lang_en.txt not found!" >&2; exit 1; fi -if [ ! -e lang_en_$LANG.txt ]; then echo "NG! file lang_en_$LANG.txt not found!" >&2; exit 1; fi +if [ ! -e lang_en_$LNG.txt ]; then echo "NG! file lang_en_$LNG.txt not found!" >&2; exit 1; fi echo "OK" >&2 #filter comment and empty lines from key and dictionary files, create temporary files echo -n " creating tmp files..." >&2 cat lang_en.txt | sed "/^$/d;/^#/d" > lang_en.tmp -cat lang_en_$LANG.txt | sed "/^$/d;/^#/d" > lang_en_$LANG.tmp +cat lang_en_$LNG.txt | sed "/^$/d;/^#/d" > lang_en_$LNG.tmp echo "OK" >&2 -#cat lang_en_$LANG.tmp | sed 'n;d' >test1.txt +#cat lang_en_$LNG.tmp | sed 'n;d' >test1.txt #compare files using diff and check for differences echo -n " comparing tmp files..." >&2 -if ! cat lang_en_$LANG.tmp | sed 'n;d' | diff lang_en.tmp - > lang_en_$LANG.dif; then +if ! cat lang_en_$LNG.tmp | sed 'n;d' | diff lang_en.tmp - > lang_en_$LNG.dif; then echo "NG!" >&2 - echo "Entries in lang_en_$LANG.txt are different from lang_en.txt!" >&2 - echo "please check lang_en_$LANG.dif" >&2 + echo "Entries in lang_en_$LNG.txt are different from lang_en.txt!" >&2 + echo "please check lang_en_$LNG.dif" >&2 finish 1 fi echo "OK" >&2 #generate lang_xx.txt (secondary language text data sorted by ids) -echo -n " generating lang_$LANG.txt..." >&2 -cat lang_en_$LANG.tmp | sed '1~2d' | sed "s/^\"\\\\x00/\"/" > lang_$LANG.txt +echo -n " generating lang_$LNG.txt..." >&2 +cat lang_en_$LNG.tmp | sed '1~2d' | sed "s/^\"\\\\x00/\"/" > lang_$LNG.txt echo "OK" >&2 #generate lang_xx.dat (secondary language text data in binary form) -echo -n " generating lang_$LANG.dat..." >&2 -cat lang_$LANG.txt | sed "s/\\\\/\\\\\\\\/g" | while read s; do +echo -n " generating lang_$LNG.dat..." >&2 +cat lang_$LNG.txt | sed "s/\\\\/\\\\\\\\/g" | while read s; do s=${s#\"} s=${s%\"} /bin/echo -e -n "$s\x00" -done >lang_$LANG.dat +done >lang_$LNG.dat echo "OK" >&2 #calculate variables lt_magic='\xa5\x5a\xb4\x4b' -lt_count=$(grep -c '^' lang_$LANG.txt) -lt_data_size=$(wc -c lang_$LANG.dat | cut -f1 -d' ') +lt_count=$(grep -c '^' lang_$LNG.txt) +lt_data_size=$(wc -c lang_$LNG.dat | cut -f1 -d' ') lt_offs_size=$((2 * $lt_count)) lt_size=$((16 + $lt_offs_size + $lt_data_size)) lt_chsum=0 lt_code='\xff\xff' lt_resv1='\xff\xff\xff\xff' -case "$LANG" in +case "$LNG" in *en*) lt_code='\x6e\x65' ;; *cz*) lt_code='\x73\x63' ;; *de*) lt_code='\x65\x64' ;; @@ -100,15 +100,15 @@ case "$LANG" in esac #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 -n " generating lang_$LNG.ofs..." >&2 +cat lang_$LNG.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_$LNG.ofs echo "OK" >&2 #generate lang_xx.bin (secondary language result binary file) -echo " generating lang_$LANG.bin:" >&2 +echo " generating lang_$LNG.bin:" >&2 #create empty file -dd if=/dev/zero of=lang_$LANG.bin bs=1 count=$lt_size 2>/dev/null +dd if=/dev/zero of=lang_$LNG.bin bs=1 count=$lt_size 2>/dev/null #awk code to format ui16 variables for dd awk_ui16='{ h=int($1/256); printf("\\x%02x\\x%02x\n", int($1-256*h), h); }' @@ -116,32 +116,32 @@ awk_ui16='{ h=int($1/256); printf("\\x%02x\\x%02x\n", int($1-256*h), h); }' echo -n " writing header (16 bytes)..." >&2 /bin/echo -n -e "$lt_magic" |\ - dd of=lang_$LANG.bin bs=1 count=4 seek=0 conv=notrunc 2>/dev/null + dd of=lang_$LNG.bin bs=1 count=4 seek=0 conv=notrunc 2>/dev/null /bin/echo -n -e $(echo -n "$lt_size" | awk "$awk_ui16") |\ - dd of=lang_$LANG.bin bs=1 count=2 seek=4 conv=notrunc 2>/dev/null + dd of=lang_$LNG.bin bs=1 count=2 seek=4 conv=notrunc 2>/dev/null /bin/echo -n -e $(echo -n "$lt_count" | awk "$awk_ui16") |\ - dd of=lang_$LANG.bin bs=1 count=2 seek=6 conv=notrunc 2>/dev/null + dd of=lang_$LNG.bin bs=1 count=2 seek=6 conv=notrunc 2>/dev/null /bin/echo -n -e $(echo -n "$lt_chsum" | awk "$awk_ui16") |\ - dd of=lang_$LANG.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null + dd of=lang_$LNG.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null /bin/echo -n -e "$lt_code" |\ - dd of=lang_$LANG.bin bs=1 count=2 seek=10 conv=notrunc 2>/dev/null + dd of=lang_$LNG.bin bs=1 count=2 seek=10 conv=notrunc 2>/dev/null /bin/echo -n -e "$lt_resv1" |\ - dd of=lang_$LANG.bin bs=1 count=4 seek=12 conv=notrunc 2>/dev/null + dd of=lang_$LNG.bin bs=1 count=4 seek=12 conv=notrunc 2>/dev/null echo "OK" >&2 echo -n " writing offset table ($lt_offs_size bytes)..." >&2 -/bin/echo -n -e $(cat lang_$LANG.ofs | awk "$awk_ui16" | tr -d '\n'; echo) |\ - dd of=./lang_$LANG.bin bs=1 count=$lt_offs_size seek=16 conv=notrunc 2>/dev/null +/bin/echo -n -e $(cat lang_$LNG.ofs | awk "$awk_ui16" | tr -d '\n'; echo) |\ + dd of=./lang_$LNG.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 + $lt_offs_size)) conv=notrunc 2>/dev/null +dd if=./lang_$LNG.dat of=./lang_$LNG.bin bs=1 count=$lt_data_size seek=$((16 + $lt_offs_size)) conv=notrunc 2>/dev/null echo "OK" >&2 #calculate and update checksum -lt_chsum=$(cat lang_$LANG.bin | xxd | cut -c11-49 | tr ' ' "\n" | sed '/^$/d' | awk 'BEGIN { sum = 0; } { sum += strtonum("0x"$1); if (sum > 0xffff) sum -= 0x10000; } END { printf("%x\n", sum); }') +lt_chsum=$(cat lang_$LNG.bin | xxd | cut -c11-49 | tr ' ' "\n" | sed '/^$/d' | awk 'BEGIN { sum = 0; } { sum += strtonum("0x"$1); if (sum > 0xffff) sum -= 0x10000; } END { printf("%x\n", sum); }') /bin/echo -n -e $(echo -n $((0x$lt_chsum)) | awk "$awk_ui16") |\ - dd of=lang_$LANG.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null + dd of=lang_$LNG.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null echo " lang_table details:" >&2 echo " lt_count = $lt_count" >&2 @@ -149,9 +149,9 @@ echo " lt_size = $lt_size" >&2 echo " lt_chsum = $lt_chsum" >&2 } -echo $LANG +echo $LNG -if [ "$LANG" = "all" ]; then +if [ "$LNG" = "all" ]; then make_lang cz make_lang de make_lang es @@ -159,7 +159,7 @@ if [ "$LANG" = "all" ]; then make_lang pl exit 0 else - make_lang $LANG + make_lang $LNG fi finish 0 diff --git a/lang/po/make_po.sh b/lang/po/make_po.sh index 881db316..315a2706 100644 --- a/lang/po/make_po.sh +++ b/lang/po/make_po.sh @@ -5,11 +5,11 @@ # SRCDIR="../../Firmware" # -LANG=$1 -if [ -z "$LANG" ]; then LANG=cz; fi +LNG=$1 +if [ -z "$LNG" ]; then LNG=cz; fi # -if [ "$LANG" == "all" ]; then +if [ "$LNG" == "all" ]; then ./make_po.sh cz ./make_po.sh de ./make_po.sh es @@ -19,13 +19,13 @@ if [ "$LANG" == "all" ]; then fi echo "make_po.sh started" >&2 -echo " selected language=$LANG" >&2 +echo " selected language=$LNG" >&2 #remove output file if exists -if [ -e lang_$LANG.po ]; then rm lang_$LANG.po; fi +if [ -e lang_$LNG.po ]; then rm lang_$LNG.po; fi lang_name=$(\ - case "$LANG" in + case "$LNG" in *en*) echo "English" ;; *cz*) echo "Czech" ;; *de*) echo "German" ;; @@ -35,7 +35,7 @@ lang_name=$(\ esac) lang_short=$(\ - case "$LANG" in + case "$LNG" in *en*) echo "en" ;; *cz*) echo "cs" ;; *de*) echo "de" ;; @@ -47,29 +47,29 @@ lang_short=$(\ po_date=$(date) #write po header -echo "# Translation of Prusa-Firmware into $lang_name." > lang_$LANG.po -echo "#" >> lang_$LANG.po -echo 'msgid ""' >> lang_$LANG.po -echo 'msgstr ""' >> lang_$LANG.po -echo '"MIME-Version: 1.0\n"' >> lang_$LANG.po -echo '"Content-Type: text/plain; charset=UTF-8\n"' >> lang_$LANG.po -echo '"Content-Transfer-Encoding: 8bit\n"' >> lang_$LANG.po -echo '"Language: '$lang_short'\n"' >> lang_$LANG.po -echo '"Project-Id-Version: Prusa-Firmware\n"' >> lang_$LANG.po -echo '"POT-Creation-Date: '$po_date'\n"' >> lang_$LANG.po -echo '"PO-Revision-Date: '$po_date'\n"' >> lang_$LANG.po -echo '"Language-Team: \n"' >> lang_$LANG.po -echo '"X-Generator: Poedit 2.0.7\n"' >> lang_$LANG.po -echo '"X-Poedit-SourceCharset: UTF-8\n"' >> lang_$LANG.po -echo '"Last-Translator: \n"' >> lang_$LANG.po -echo '"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"' >> lang_$LANG.po -echo >> lang_$LANG.po +echo "# Translation of Prusa-Firmware into $lang_name." > lang_$LNG.po +echo "#" >> lang_$LNG.po +echo 'msgid ""' >> lang_$LNG.po +echo 'msgstr ""' >> lang_$LNG.po +echo '"MIME-Version: 1.0\n"' >> lang_$LNG.po +echo '"Content-Type: text/plain; charset=UTF-8\n"' >> lang_$LNG.po +echo '"Content-Transfer-Encoding: 8bit\n"' >> lang_$LNG.po +echo '"Language: '$lang_short'\n"' >> lang_$LNG.po +echo '"Project-Id-Version: Prusa-Firmware\n"' >> lang_$LNG.po +echo '"POT-Creation-Date: '$po_date'\n"' >> lang_$LNG.po +echo '"PO-Revision-Date: '$po_date'\n"' >> lang_$LNG.po +echo '"Language-Team: \n"' >> lang_$LNG.po +echo '"X-Generator: Poedit 2.0.7\n"' >> lang_$LNG.po +echo '"X-Poedit-SourceCharset: UTF-8\n"' >> lang_$LNG.po +echo '"Last-Translator: \n"' >> lang_$LNG.po +echo '"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"' >> lang_$LNG.po +echo >> lang_$LNG.po #list .cpp, .c and .h files files=$(ls "$SRCDIR"/*.cpp "$SRCDIR"/*.c "$SRCDIR"/*.h) -num_texts=$(grep '^#' -c ../lang_en_$LANG.txt) -num_texts_nt=$(grep '^\"\\x00\"' -c ../lang_en_$LANG.txt) +num_texts=$(grep '^#' -c ../lang_en_$LNG.txt) +num_texts_nt=$(grep '^\"\\x00\"' -c ../lang_en_$LNG.txt) echo " $num_texts texts, $num_texts_nt not translated" >&2 #loop over all messages @@ -77,7 +77,7 @@ s0='' s1='' s2='' num=1 -cat ../lang_en_$LANG.txt | sed "s/\\\\/\\\\\\\\/g" | while read -r s; do +cat ../lang_en_$LNG.txt | sed "s/\\\\/\\\\\\\\/g" | while read -r s; do if [ "$s" == "" ]; then echo " processing $num of $num_texts" >&2 if [ "$s0" == "\"\\\\x00\"" ]; then @@ -103,11 +103,11 @@ cat ../lang_en_$LANG.txt | sed "s/\\\\/\\\\\\\\/g" | while read -r s; do s2=$s1 s1=$s0 s0=$s -done >> lang_$LANG.po +done >> lang_$LNG.po #replace LF with CRLF sync -sed -i 's/$/\r/' lang_$LANG.po +sed -i 's/$/\r/' lang_$LNG.po echo "make_po.sh finished" >&2 #read diff --git a/lang/po_new/merge_lang.sh b/lang/po_new/merge_lang.sh index 0393572e..da7032c1 100644 --- a/lang/po_new/merge_lang.sh +++ b/lang/po_new/merge_lang.sh @@ -2,14 +2,14 @@ # # -LANG=$1 -if [ -z "$LANG" ]; then exit -1; fi +LNG=$1 +if [ -z "$LNG" ]; then exit -1; fi #convert '\\e' sequencies to 'x1b' and '\\' to '\' -cat $LANG.po | sed 's/\\\\e/\\x1b/g;s/\\\\/\\/g' > $LANG'_filtered.po' +cat $LNG.po | sed 's/\\\\e/\\x1b/g;s/\\\\/\\/g' > $LNG'_filtered.po' #join lines with multi-line string constants -cat $LANG'_filtered.po' | sed ':a;N;$!ba;s/\x22\n\x22//g' > $LANG'_new.po' +cat $LNG'_filtered.po' | sed ':a;N;$!ba;s/\x22\n\x22//g' > $LNG'_new.po' #generate dictionary cat ../lang_en.txt | sed 's/\\/\\\\/g' | while read -r s; do @@ -17,7 +17,7 @@ cat ../lang_en.txt | sed 's/\\/\\\\/g' | while read -r s; do if [ "${s:0:1}" = "\"" ]; then # /bin/echo -e "$s" s=$(/bin/echo -e "$s") - s2=$(grep -F -A1 -B0 "$s" "$LANG"_new.po | tail -n1 | sed 's/^msgstr //') + s2=$(grep -F -A1 -B0 "$s" "$LNG"_new.po | tail -n1 | sed 's/^msgstr //') if [ -z "$s2" ]; then echo '"\x00"' else @@ -25,4 +25,4 @@ cat ../lang_en.txt | sed 's/\\/\\\\/g' | while read -r s; do fi # echo fi -done > lang_en_$LANG.txt +done > lang_en_$LNG.txt diff --git a/lang/postbuild.sh b/lang/postbuild.sh index 8ca5b77f..6e9ff870 100644 --- a/lang/postbuild.sh +++ b/lang/postbuild.sh @@ -23,8 +23,8 @@ if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi # # Selected language: -LANG=$1 -#if [ -z "$LANG" ]; then LANG='cz'; fi +LNG=$1 +#if [ -z "$LNG" ]; then LNG='cz'; fi # # Params: IGNORE_MISSING_TEXT=1 @@ -99,8 +99,8 @@ echo "OK" >&2 #update _SEC_LANG in binary file if language is selected echo -n " secondary language data..." >&2 -if [ ! -z "$LANG" ]; then - ./update_lang.sh $LANG 2>./update_lang.out +if [ ! -z "$LNG" ]; then + ./update_lang.sh $LNG 2>./update_lang.out if [ $? -ne 0 ]; then echo "NG! - check update_lang.out file" >&2; finish 1; fi echo "OK" >&2 finish 0 diff --git a/lang/update_lang.sh b/lang/update_lang.sh index b28081b6..cc660463 100644 --- a/lang/update_lang.sh +++ b/lang/update_lang.sh @@ -9,8 +9,8 @@ if [ -z "$OBJCOPY" ]; then echo 'variable OBJCOPY not set!' >&2; exit 1; fi if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi # # Selected language: -LANG=$1 -if [ -z "$LANG" ]; then LANG='cz'; fi +LNG=$1 +if [ -z "$LNG" ]; then LNG='cz'; fi # finish() @@ -28,11 +28,11 @@ finish() } echo "update_lang.sh started" >&2 -echo " selected language=$LANG" >&2 +echo " selected language=$LNG" >&2 echo -n " checking files..." >&2 if [ ! -e text.sym ]; then echo "NG! file text.sym not found!" >&2; finish 1; fi -if [ ! -e lang_$LANG.bin ]; then echo "NG! file lang_$LANG.bin not found!" >&2; finish 1; fi +if [ ! -e lang_$LNG.bin ]; then echo "NG! file lang_$LNG.bin not found!" >&2; finish 1; fi if [ ! -e firmware.bin ]; then echo "NG! file firmware.bin not found!" >&2; finish 1; fi echo "OK" >&2 @@ -62,17 +62,17 @@ lang_table_size=$((256*$((($sec_lang_size - ($lang_table_addr - $sec_lang_addr)) printf " lang_table_size =0x%04x (=%d bytes)\n" $lang_table_size $lang_table_size >&2 #get lang_xx.bin file size -lang_file_size=$(wc -c lang_$LANG.bin | cut -f1 -d' ') +lang_file_size=$(wc -c lang_$LNG.bin | cut -f1 -d' ') printf " lang_file_size =0x%04x (=%d bytes)\n" $lang_file_size $lang_file_size >&2 if [ $lang_file_size -gt $lang_table_size ]; then echo "Lanaguage binary file size too big!" >&2; finish 1; fi echo "updating 'firmware.bin'..." >&2 -dd if=lang_$LANG.bin of=firmware.bin bs=1 seek=$lang_table_addr conv=notrunc 2>/dev/null +dd if=lang_$LNG.bin of=firmware.bin bs=1 seek=$lang_table_addr conv=notrunc 2>/dev/null #convert bin to hex echo "converting to hex..." >&2 -$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware_$LANG.hex +$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware_$LNG.hex finish 0 From 2070c01b624626288d22c8d54212ade178f5808f Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Mon, 18 Jun 2018 14:53:42 +0200 Subject: [PATCH 2/2] LCD menu printf test --- Firmware/ultralcd.cpp | 64 +++++++++++++------ .../variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 1 + 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 74e0b349..53a53d20 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -27,23 +27,6 @@ #endif //TMC2130 -#include - -int lcd_puts_P(const char* str) -{ - return fputs_P(str, lcdout); -} - -int lcd_printf_P(const char* format, ...) -{ - va_list args; - va_start(args, format); - int ret = vfprintf_P(lcdout, format, args); - va_end(args); - return ret; -} - - int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */ extern int lcd_change_fil_state; @@ -315,7 +298,6 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l #endif #endif - /* Helper macros for menus */ #define START_MENU() do { \ if (encoderPosition > 0x8000) encoderPosition = 0; \ @@ -427,6 +409,48 @@ static void lcd_goto_menu(menuFunc_t menu, const uint32_t encoder = 0, const boo /* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */ +#include + +int lcd_puts_P(const char* str) +{ + return fputs_P(str, lcdout); +} + +int lcd_printf_P(const char* format, ...) +{ + va_list args; + va_start(args, format); + int ret = vfprintf_P(lcdout, format, args); + va_end(args); + return ret; +} + +#ifdef DEBUG_MENU_PRINTF_TEST +int menu_item_printf_P(uint8_t& item, uint8_t line, const char* format, ...) +{ + va_list args; + va_start(args, format); + int ret = 0; + if (item == line) + { + if (lcdDrawUpdate) + { + //ret = + lcd.setCursor(0, line); + lcd.print(' '); + int cnt = vfprintf_P(lcdout, format, args); + for (int i = cnt; i < 19; i++) + lcd.print(' '); + lcd.print('>'); + } + } + item++; + va_end(args); + return ret; +} +#endif //DEBUG_MENU_PRINTF_TEST + + static void lcd_status_screen() { if (firstrun == 1) @@ -5589,6 +5613,10 @@ static void lcd_main_menu() MENU_ITEM(submenu, _i("Support"), lcd_support_menu);////MSG_SUPPORT c=0 r=0 MENU_ITEM(submenu, _i("W25x20XL init"), lcd_test_menu);////MSG_SUPPORT c=0 r=0 +#ifdef DEBUG_MENU_PRINTF_TEST + menu_item_printf_P(_menuItemNr, _lineNr, _N("Test %d %d %d"), 0, 1, 2); +#endif //DEBUG_MENU_PRINTF_TEST + END_MENU(); } diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 2cf61d55..4c9f2433 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -149,6 +149,7 @@ //#define DEBUG_BUILD //#define DEBUG_SEC_LANG //secondary language debug output at startup //#define DEBUG_W25X20CL //debug external spi flash +//#define DEBUG_MENU_PRINTF_TEST #ifdef DEBUG_BUILD //#define _NO_ASM #define DEBUG_DCODES //D codes