From 54d35230df8e89277ece36c708f4be5179c29115 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Tue, 12 Jul 2016 19:59:03 +0200 Subject: [PATCH 1/2] Don't use UTF-strlen() if the text is not UTF --- Marlin/ultralcd.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index b39617c15a..267fc213a0 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -2481,7 +2481,11 @@ void lcd_init() { int lcd_strlen(const char* s) { int i = 0, j = 0; while (s[i]) { - if ((s[i] & 0xc0) != 0x80) j++; + #ifdef MAPPER_NON + j++; + #else + if ((s[i] & 0xc0) != 0x80) j++; + #endif i++; } return j; @@ -2490,7 +2494,11 @@ int lcd_strlen(const char* s) { int lcd_strlen_P(const char* s) { int j = 0; while (pgm_read_byte(s)) { - if ((pgm_read_byte(s) & 0xc0) != 0x80) j++; + #ifdef MAPPER_NON + j++; + #else + if ((pgm_read_byte(s) & 0xc0) != 0x80) j++; + #endif s++; } return j; From b27373696261f52ba63418762bc1bb53bf219195 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Tue, 12 Jul 2016 19:42:42 +0200 Subject: [PATCH 2/2] Make MAPPER_NON the fall back mapper Make MAPPER_NON the fall back mapper - if no other is defined. One list less to maintain. --- Marlin/language_an.h | 1 - Marlin/language_ca.h | 1 - Marlin/language_cn.h | 2 -- Marlin/language_cz.h | 1 - Marlin/language_en.h | 4 ---- Marlin/language_es.h | 1 - Marlin/language_eu.h | 1 - Marlin/language_fr.h | 1 - Marlin/language_hr.h | 1 - Marlin/language_it.h | 1 - Marlin/language_kana.h | 1 - Marlin/language_nl.h | 1 - Marlin/language_pl.h | 1 - Marlin/language_pt-br.h | 1 - Marlin/language_pt-br_utf8.h | 1 - Marlin/language_pt.h | 1 - Marlin/language_pt_utf8.h | 1 - Marlin/language_test.h | 3 +-- Marlin/utf_mapper.h | 18 ++++++++---------- 19 files changed, 9 insertions(+), 33 deletions(-) diff --git a/Marlin/language_an.h b/Marlin/language_an.h index 968fa5168f..37ae982e19 100644 --- a/Marlin/language_an.h +++ b/Marlin/language_an.h @@ -30,7 +30,6 @@ #ifndef LANGUAGE_AN_H #define LANGUAGE_AN_H -#define MAPPER_NON // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT #define DISPLAY_CHARSET_ISO10646_1 diff --git a/Marlin/language_ca.h b/Marlin/language_ca.h index 9c2ba49d30..1c2e4924be 100644 --- a/Marlin/language_ca.h +++ b/Marlin/language_ca.h @@ -30,7 +30,6 @@ #ifndef LANGUAGE_CA_H #define LANGUAGE_CA_H -//#define MAPPER_NON #define MAPPER_C2C3 // because of "รณ" // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT diff --git a/Marlin/language_cn.h b/Marlin/language_cn.h index e2306a401d..de52af44ff 100644 --- a/Marlin/language_cn.h +++ b/Marlin/language_cn.h @@ -29,8 +29,6 @@ */ #ifndef LANGUAGE_CN_H #define LANGUAGE_CN_H - -#define MAPPER_NON // For direct ascii codes #define DISPLAY_CHARSET_ISO10646_CN #define WELCOME_MSG "\xa4\xa5\xa6\xa7" diff --git a/Marlin/language_cz.h b/Marlin/language_cz.h index a4bfdf9335..030b92e85e 100644 --- a/Marlin/language_cz.h +++ b/Marlin/language_cz.h @@ -34,7 +34,6 @@ #ifndef LANGUAGE_CZ_H #define LANGUAGE_CZ_H -#define MAPPER_NON // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT #define DISPLAY_CHARSET_ISO10646_1 diff --git a/Marlin/language_en.h b/Marlin/language_en.h index 57bc4a5fa8..a1612bdf21 100644 --- a/Marlin/language_en.h +++ b/Marlin/language_en.h @@ -35,10 +35,6 @@ #define DISPLAY_CHARSET_ISO10646_1 // use the better font on full graphic displays. #endif -#if DISABLED(MAPPER_NON) && DISABLED(MAPPER_C2C3) && DISABLED(MAPPER_D0D1) && DISABLED(MAPPER_D0D1_MOD) && DISABLED(MAPPER_E382E383) && DISABLED(MAPPER_CECF) - #define MAPPER_NON // For direct ascii codes -#endif - #ifndef WELCOME_MSG #define WELCOME_MSG MACHINE_NAME " ready." #endif diff --git a/Marlin/language_es.h b/Marlin/language_es.h index 9722ccd2ef..c5b3e0e7a4 100644 --- a/Marlin/language_es.h +++ b/Marlin/language_es.h @@ -30,7 +30,6 @@ #ifndef LANGUAGE_ES_H #define LANGUAGE_ES_H -#define MAPPER_NON // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT #define DISPLAY_CHARSET_ISO10646_1 diff --git a/Marlin/language_eu.h b/Marlin/language_eu.h index f87ac2f1c1..361fe0c457 100644 --- a/Marlin/language_eu.h +++ b/Marlin/language_eu.h @@ -30,7 +30,6 @@ #ifndef LANGUAGE_EU_H #define LANGUAGE_EU_H -#define MAPPER_NON // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT #define DISPLAY_CHARSET_ISO10646_1 diff --git a/Marlin/language_fr.h b/Marlin/language_fr.h index f22abce00f..63bba3c3ff 100644 --- a/Marlin/language_fr.h +++ b/Marlin/language_fr.h @@ -30,7 +30,6 @@ #ifndef LANGUAGE_FR_H #define LANGUAGE_FR_H -#define MAPPER_NON // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT #define DISPLAY_CHARSET_ISO10646_1 diff --git a/Marlin/language_hr.h b/Marlin/language_hr.h index d48e58ccb1..e6ebe7db80 100644 --- a/Marlin/language_hr.h +++ b/Marlin/language_hr.h @@ -30,7 +30,6 @@ #ifndef LANGUAGE_HR_H #define LANGUAGE_HR_H -#define MAPPER_NON // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT diff --git a/Marlin/language_it.h b/Marlin/language_it.h index 481b725abf..a8e08391f0 100644 --- a/Marlin/language_it.h +++ b/Marlin/language_it.h @@ -30,7 +30,6 @@ #ifndef LANGUAGE_IT_H #define LANGUAGE_IT_H -#define MAPPER_NON // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT #define DISPLAY_CHARSET_ISO10646_1 diff --git a/Marlin/language_kana.h b/Marlin/language_kana.h index 7eb6f592a5..3a824e9ae7 100644 --- a/Marlin/language_kana.h +++ b/Marlin/language_kana.h @@ -31,7 +31,6 @@ #ifndef LANGUAGE_KANA_H #define LANGUAGE_KANA_H -#define MAPPER_NON // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h #define SIMULATE_ROMFONT #define DISPLAY_CHARSET_ISO10646_KANA diff --git a/Marlin/language_nl.h b/Marlin/language_nl.h index c74ad8fbd7..4dd07d82e8 100644 --- a/Marlin/language_nl.h +++ b/Marlin/language_nl.h @@ -30,7 +30,6 @@ #ifndef LANGUAGE_NL_H #define LANGUAGE_NL_H -#define MAPPER_NON // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT #define DISPLAY_CHARSET_ISO10646_1 diff --git a/Marlin/language_pl.h b/Marlin/language_pl.h index 9c38a6db51..71d664c3c1 100644 --- a/Marlin/language_pl.h +++ b/Marlin/language_pl.h @@ -30,7 +30,6 @@ #ifndef LANGUAGE_PL_H #define LANGUAGE_PL_H -#define MAPPER_NON // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT #define DISPLAY_CHARSET_ISO10646_1 diff --git a/Marlin/language_pt-br.h b/Marlin/language_pt-br.h index cc37f31dae..e9f27ecc80 100644 --- a/Marlin/language_pt-br.h +++ b/Marlin/language_pt-br.h @@ -30,7 +30,6 @@ #ifndef LANGUAGE_PT_BR_H #define LANGUAGE_PT_BR_H -#define MAPPER_NON // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT #define DISPLAY_CHARSET_ISO10646_1 diff --git a/Marlin/language_pt-br_utf8.h b/Marlin/language_pt-br_utf8.h index feb38b4968..2909b3d552 100644 --- a/Marlin/language_pt-br_utf8.h +++ b/Marlin/language_pt-br_utf8.h @@ -30,7 +30,6 @@ #ifndef LANGUAGE_PT_BR_UTF_H #define LANGUAGE_PT_BR_UTF_H -#define MAPPER_NON // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT #define DISPLAY_CHARSET_ISO10646_1 diff --git a/Marlin/language_pt.h b/Marlin/language_pt.h index 4c857a7c1d..2e88f11922 100644 --- a/Marlin/language_pt.h +++ b/Marlin/language_pt.h @@ -30,7 +30,6 @@ #ifndef LANGUAGE_PT_H #define LANGUAGE_PT_H -#define MAPPER_NON // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT #define DISPLAY_CHARSET_ISO10646_1 diff --git a/Marlin/language_pt_utf8.h b/Marlin/language_pt_utf8.h index c2fab4d636..9040951b3f 100644 --- a/Marlin/language_pt_utf8.h +++ b/Marlin/language_pt_utf8.h @@ -30,7 +30,6 @@ #ifndef LANGUAGE_PT_UTF_H #define LANGUAGE_PT_UTF_H -#define MAPPER_NON // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT #define DISPLAY_CHARSET_ISO10646_1 diff --git a/Marlin/language_test.h b/Marlin/language_test.h index d2f99f6876..ea1b0c4dbc 100644 --- a/Marlin/language_test.h +++ b/Marlin/language_test.h @@ -46,11 +46,10 @@ // Kanji (an other Japanese symbol set) uses far more than two codepages. So currently I don't see a chance to map the Unicodes. Its not // impossible to have a close to direct mapping but will need giant conversion tables and fonts (we don't want to have in a embedded system). - -#define MAPPER_NON // For direct ascii codes ( until now all languages except ru, de, fi, kana_utf8, ... ) //#define MAPPER_C2C3 // For most European languages when language file is in utf8 //#define MAPPER_D0D1 // For Cyrillic //#define MAPPER_E382E383 // For Katakana +//#define MAPPER_NON // For direct ascii codes. Fall back mapper - if no other is defined. // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT diff --git a/Marlin/utf_mapper.h b/Marlin/utf_mapper.h index 829741756f..bba85e180d 100644 --- a/Marlin/utf_mapper.h +++ b/Marlin/utf_mapper.h @@ -146,14 +146,7 @@ #endif // DISPLAY_CHARSET_HD44780 #endif // SIMULATE_ROMFONT -#if ENABLED(MAPPER_NON) - - char charset_mapper(char c) { - HARDWARE_CHAR_OUT( c ); - return 1; - } - -#elif ENABLED(MAPPER_C2C3) +#if ENABLED(MAPPER_C2C3) char charset_mapper(char c) { static uint8_t utf_hi_char; // UTF-8 high part @@ -353,8 +346,13 @@ #else - #error "You have to define one of the DISPLAY_INPUT_CODE_MAPPERs in your language_xx.h file" // should not occur because (en) will set. + #define MAPPER_NON -#endif // code mappers + char charset_mapper(char c) { + HARDWARE_CHAR_OUT( c ); + return 1; + } + + #endif // code mappers #endif // UTF_MAPPER_H