From 24ebbd942c0cc2557b43fb54e058d967cc28f3b3 Mon Sep 17 00:00:00 2001 From: Dmitry Mikhirev Date: Wed, 29 Aug 2012 01:26:25 +0400 Subject: fix UTF-8 strings conversion --- lcdprint.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'lcdprint.cpp') diff --git a/lcdprint.cpp b/lcdprint.cpp index 585b2de..c79bb1c 100644 --- a/lcdprint.cpp +++ b/lcdprint.cpp @@ -17,12 +17,11 @@ along with this program. If not, see . */ - +#include #include "lcdprint.h" -#include "font_ru-en.h" -//#include "font_en.h" +#include "font.h" -char* convert(utf8 str) +size_t uprint(utf8 str, LiquidCrystal *lcd) { int32_t ucode; int i, j; @@ -36,9 +35,9 @@ char* convert(utf8 str) result[i] = char(ucode); } else { result[i] = 0xff; - for (j = 0; j < numcodes && charmap[j].uni < ucode; j++) { - if (charmap[j].uni == ucode) { - result[i] = charmap[j].font; + for (j = 0; (j < numcodes) && (pgm_read_dword(&charmap[j].uni) <= ucode); j++) { + if (pgm_read_dword(&charmap[j].uni) == ucode) { + result[i] = pgm_read_byte(&charmap[j].font); } } } @@ -47,6 +46,5 @@ char* convert(utf8 str) break; } } - - return result; + return lcd->print(result); } -- cgit v1.2.1