Browse Source

FTDI EVE: Cyrillic font, some minor fixes (#20517)

LinFor 3 years ago
parent
commit
6af6a35d9d
No account linked to committer's email address
22 changed files with 3318 additions and 29 deletions
  1. 3
    0
      Marlin/Configuration_adv.h
  2. 8
    0
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp
  3. 1
    0
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.h
  4. 1
    0
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/ftdi_extended.h
  5. 16
    5
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp
  6. 139
    0
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/cyrillic_char_set.cpp
  7. 32
    0
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/cyrillic_char_set.h
  8. 2529
    0
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/cyrillic_char_set_bitmap_31.h
  9. 4
    2
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/font_bitmaps.cpp
  10. 1
    1
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/font_bitmaps.h
  11. BIN
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/font_bitmaps/cyrillic_char_set_bitmap_31.png
  12. 535
    0
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/font_bitmaps/cyrillic_char_set_bitmap_31.svg
  13. BIN
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/font_bitmaps/romfont_31.png
  14. 2
    1
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/standard_char_set.cpp
  15. 1
    1
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/standard_char_set.h
  16. 22
    3
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp
  17. 3
    2
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.h
  18. 10
    5
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/western_char_set.cpp
  19. 3
    1
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/western_char_set.h
  20. 5
    5
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/bitmap2cpp.py
  21. 1
    1
      Marlin/src/lcd/extui/ui_api.cpp
  22. 2
    2
      Marlin/src/sd/SdBaseFile.cpp

+ 3
- 0
Marlin/Configuration_adv.h View File

@@ -1563,6 +1563,9 @@
1563 1563
       //#define TOUCH_UI_UTF8_FRACTIONS     // ¼ ½ ¾
1564 1564
       //#define TOUCH_UI_UTF8_SYMBOLS       // µ ¶ ¦ § ¬
1565 1565
     #endif
1566
+
1567
+    // Cyrillic character set, costs about 27KiB of flash
1568
+    //#define TOUCH_UI_UTF8_CYRILLIC_CHARSET
1566 1569
   #endif
1567 1570
 
1568 1571
   // Use a smaller font when labels don't fit buttons

+ 8
- 0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp View File

@@ -211,6 +211,14 @@ void CLCD::mem_write_32(uint32_t reg_address, uint32_t data) {
211 211
   spi_ftdi_deselect();
212 212
 }
213 213
 
214
+// Fill area of len size with repeated data bytes
215
+void CLCD::mem_write_fill(uint32_t reg_address, uint8_t data, uint16_t len) {
216
+  spi_ftdi_select();
217
+  spi_write_addr(reg_address);
218
+  while (len--) spi_write_8(data);
219
+  spi_ftdi_deselect();
220
+}
221
+
214 222
 /******************* FT800/810 Co-processor Commands *********************************/
215 223
 
216 224
 #if FTDI_API_LEVEL == 800

+ 1
- 0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.h View File

@@ -115,6 +115,7 @@ class CLCD {
115 115
     static void     mem_write_8    (uint32_t reg_address, uint8_t w_data);
116 116
     static void     mem_write_16   (uint32_t reg_address, uint16_t w_data);
117 117
     static void     mem_write_32   (uint32_t reg_address, uint32_t w_data);
118
+    static void     mem_write_fill (uint32_t reg_address, uint8_t w_data, uint16_t len);
118 119
     static void     mem_write_bulk (uint32_t reg_address, const void *data, uint16_t len, uint8_t padding = 0);
119 120
     static void     mem_write_pgm  (uint32_t reg_address, const void *data, uint16_t len, uint8_t padding = 0);
120 121
     static void     mem_write_bulk (uint32_t reg_address, progmem_str str, uint16_t len, uint8_t padding = 0);

+ 1
- 0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/ftdi_extended.h View File

@@ -34,6 +34,7 @@
34 34
   #include "unicode/unicode.h"
35 35
   #include "unicode/standard_char_set.h"
36 36
   #include "unicode/western_char_set.h"
37
+  #include "unicode/cyrillic_char_set.h"
37 38
   #include "unicode/font_bitmaps.h"
38 39
   #include "rgb_t.h"
39 40
   #include "bitmap_info.h"

+ 16
- 5
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp View File

@@ -37,11 +37,22 @@ namespace FTDI {
37 37
     // split and still allow the ellipsis to fit.
38 38
     int16_t lineWidth = 0;
39 39
     char *breakPoint   = str;
40
-    for (char* c = str; *c; c++) {
41
-      lineWidth += fm.get_char_width(*c);
42
-      if (lineWidth + ellipsisWidth < w)
43
-        breakPoint = c;
44
-    }
40
+    #ifdef TOUCH_UI_USE_UTF8
41
+      char *tstr = str;
42
+      while (*tstr) {
43
+        breakPoint = tstr;
44
+        const utf8_char_t c = get_utf8_char_and_inc(tstr);
45
+        lineWidth += fm.get_char_width(c);
46
+        if (lineWidth + ellipsisWidth < w)
47
+          break;
48
+      }
49
+    #else
50
+      for (char* c = str; *c; c++) {
51
+        lineWidth += fm.get_char_width(*c);
52
+        if (lineWidth + ellipsisWidth < w)
53
+          breakPoint = c;
54
+      }
55
+    #endif
45 56
 
46 57
     if (lineWidth > w) {
47 58
       *breakPoint = '\0';

+ 139
- 0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/cyrillic_char_set.cpp View File

@@ -0,0 +1,139 @@
1
+/************************
2
+ * cyrillic_char_set.cpp *
3
+ ************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Kirill Shashlov 2020                                        *
7
+ *              Marcio Teixeira 2019 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <https://www.gnu.org/licenses/>.                             *
21
+ ****************************************************************************/
22
+
23
+#include "../ftdi_extended.h"
24
+
25
+#if ALL(FTDI_EXTENDED, TOUCH_UI_USE_UTF8, TOUCH_UI_UTF8_CYRILLIC_CHARSET)
26
+
27
+  #include "cyrillic_char_set_bitmap_31.h"
28
+
29
+  #define NUM_ELEMENTS(a) (sizeof(a)/sizeof(a[0]))
30
+
31
+  #define UTF8(A) uint16_t(utf8(U##A))
32
+
33
+  using namespace FTDI;
34
+
35
+  constexpr static uint8_t cyrillic_font_handle = 6;
36
+
37
+  uint32_t FTDI::CyrillicCharSet::bitmap_addr;
38
+
39
+  /**
40
+   * Load bitmap data into RAMG. This function is called once at the start
41
+   * of the program.
42
+   *
43
+   * Parameters:
44
+   *
45
+   *   addr  - Address in RAMG where the font data is written
46
+   *
47
+   * Returns: Last wrote address
48
+   */
49
+
50
+  uint32_t FTDI::CyrillicCharSet::load_data(uint32_t addr) {
51
+    if (addr % 4 != 0)
52
+      addr += 4 - (addr % 4);
53
+
54
+    // Load the alternative font metrics
55
+    CLCD::FontMetrics cyrillic_fm;
56
+    cyrillic_fm.ptr    = addr + 148;
57
+    cyrillic_fm.format = L4;
58
+    cyrillic_fm.stride = 20;
59
+    cyrillic_fm.width  = 40;
60
+    cyrillic_fm.height = 49;
61
+    LOOP_L_N(i, 127)
62
+      cyrillic_fm.char_widths[i] = 0;
63
+
64
+    // For cyrillic characters, copy the character widths from the widths tables
65
+    LOOP_L_N(i, NUM_ELEMENTS(cyrillic_font_widths)) {
66
+      cyrillic_fm.char_widths[i] = cyrillic_font_widths[i];
67
+    }
68
+    CLCD::mem_write_bulk(addr, &cyrillic_fm,  148);
69
+
70
+    // Decode the RLE data and load it into RAMG as a bitmap
71
+    uint32_t lastaddr = write_rle_data(addr + 148, cyrillic_font, sizeof(cyrillic_font));
72
+
73
+    bitmap_addr = addr;
74
+
75
+    return lastaddr;
76
+  }
77
+
78
+  /**
79
+   * Populates the bitmap handles for the custom into the display list.
80
+   * This function is called once at the start of each display list.
81
+   *
82
+   * Parameters:
83
+   *
84
+   *   cmd  - Object used for writing to the FTDI chip command queue.
85
+   */
86
+
87
+  void FTDI::CyrillicCharSet::load_bitmaps(CommandProcessor& cmd) {
88
+    CLCD::FontMetrics cyrillic_fm;
89
+    cyrillic_fm.ptr    = bitmap_addr + 148;
90
+    cyrillic_fm.format = L4;
91
+    cyrillic_fm.stride = 20;
92
+    cyrillic_fm.width  = 40;
93
+    cyrillic_fm.height = 49;
94
+    set_font_bitmap(cmd, cyrillic_fm, cyrillic_font_handle);
95
+  }
96
+
97
+  /**
98
+   * Renders a character at location x and y. The x position is incremented
99
+   * by the width of the character.
100
+   *
101
+   * Parameters:
102
+   *
103
+   *   cmd  - If non-NULL the symbol is drawn to the screen.
104
+   *          If NULL, only increment position for text measurement.
105
+   *
106
+   *   x, y - The location at which to draw the character. On output,
107
+   *          incremented to the location of the next character.
108
+   *
109
+   *   fs   - A scaling object used to scale the font. The display will
110
+   *          already be configured to scale bitmaps, but positions
111
+   *          must be scaled using fs.scale()
112
+   *
113
+   *   c    - The unicode code point to draw. If the renderer does not
114
+   *          support the character, it should return false.
115
+   *
116
+   * Returns: Whether the character was supported.
117
+   */
118
+
119
+  bool FTDI::CyrillicCharSet::render_glyph(CommandProcessor* cmd, int &x, int &y, font_size_t fs, utf8_char_t c) {
120
+    // A supported character?
121
+    if ((c < UTF8('А') || c > UTF8('я')) && (c != UTF8('Ё')) && (c != UTF8('ё'))) return false;
122
+
123
+    uint8_t idx = (c == UTF8('Ё')) ? 64 :
124
+                  (c == UTF8('ё')) ? 65 :
125
+                  (c < UTF8('р'))  ? c - UTF8('А') :
126
+                                     c - UTF8('р') + 48
127
+                  ;
128
+
129
+    uint8_t width = cyrillic_font_widths[idx];
130
+
131
+    // Draw the character
132
+    if (cmd) ext_vertex2ii(*cmd, x, y, cyrillic_font_handle, idx);
133
+
134
+    // Increment X to the next character position
135
+    x += fs.scale(width);
136
+    return true;
137
+  }
138
+
139
+#endif // FTDI_EXTENDED && TOUCH_UI_USE_UTF8 && TOUCH_UI_UTF8_WESTERN_CHARSET

+ 32
- 0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/cyrillic_char_set.h View File

@@ -0,0 +1,32 @@
1
+/**********************
2
+ * cyrillic_char_set.h *
3
+ **********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Kirill Shashlov 2020                                        *
7
+ *              Marcio Teixeira 2019 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <https://www.gnu.org/licenses/>.                             *
21
+ ****************************************************************************/
22
+
23
+namespace FTDI {
24
+  class CyrillicCharSet {
25
+    private:
26
+      static uint32_t bitmap_addr;
27
+    public:
28
+      static uint32_t load_data(uint32_t addr);
29
+      static void load_bitmaps(CommandProcessor&);
30
+      static bool render_glyph(CommandProcessor*, int &x, int &y, font_size_t, utf8_char_t);
31
+  };
32
+}

+ 2529
- 0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/cyrillic_char_set_bitmap_31.h
File diff suppressed because it is too large
View File


+ 4
- 2
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/font_bitmaps.cpp View File

@@ -25,12 +25,14 @@
25 25
 
26 26
 namespace FTDI {
27 27
 
28
-  void write_rle_data(uint16_t addr, const uint8_t *data, size_t n) {
28
+  uint32_t write_rle_data(uint32_t addr, const uint8_t *data, size_t n) {
29 29
     for (; n >= 2; n -= 2) {
30 30
       uint8_t count = pgm_read_byte(data++);
31 31
       uint8_t value = pgm_read_byte(data++);
32
-      while (count--) CLCD::mem_write_8(addr++, value);
32
+      CLCD::mem_write_fill(addr, value, count);
33
+      addr += count;
33 34
     }
35
+    return addr;
34 36
   }
35 37
 
36 38
   void set_font_bitmap(CommandProcessor& cmd, CLCD::FontMetrics &fm, uint8_t handle) {

+ 1
- 1
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/font_bitmaps.h View File

@@ -24,7 +24,7 @@
24 24
 class CommandProcessor;
25 25
 
26 26
 namespace FTDI {
27
-  void write_rle_data(uint16_t addr, const uint8_t *data, size_t n);
27
+  uint32_t write_rle_data(uint32_t addr, const uint8_t *data, size_t n);
28 28
   void set_font_bitmap(CommandProcessor& cmd, CLCD::FontMetrics &fm, uint8_t handle);
29 29
   void ext_vertex2ii(CommandProcessor &cmd, int x, int y, uint8_t handle, uint8_t cell);
30 30
 }

BIN
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/font_bitmaps/cyrillic_char_set_bitmap_31.png View File


+ 535
- 0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/font_bitmaps/cyrillic_char_set_bitmap_31.svg
File diff suppressed because it is too large
View File


BIN
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/font_bitmaps/romfont_31.png View File


+ 2
- 1
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/standard_char_set.cpp View File

@@ -48,7 +48,8 @@
48 48
    *   addr  - Address in RAMG where the font data is written
49 49
    */
50 50
 
51
-  void FTDI::StandardCharSet::load_data(uint32_t) {
51
+  uint32_t FTDI::StandardCharSet::load_data(uint32_t addr) {
52
+    return addr;
52 53
   }
53 54
 
54 55
   /**

+ 1
- 1
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/standard_char_set.h View File

@@ -23,7 +23,7 @@ namespace FTDI {
23 23
   class StandardCharSet {
24 24
     public:
25 25
       static uint8_t std_char_width(char);
26
-      static void load_data(uint32_t addr);
26
+      static uint32_t load_data(uint32_t addr);
27 27
       static void load_bitmaps(CommandProcessor&);
28 28
       static bool render_glyph(CommandProcessor*, int &x, int &y, font_size_t, utf8_char_t);
29 29
   };

+ 22
- 3
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp View File

@@ -73,6 +73,13 @@
73 73
     return val;
74 74
   }
75 75
 
76
+  utf8_char_t FTDI::get_utf8_char_and_inc(char *&c) {
77
+    utf8_char_t val = *(uint8_t*)c++;
78
+    while ((*c & 0xC0) == 0x80)
79
+      val = (val << 8) | *(uint8_t*)c++;
80
+    return val;
81
+  }
82
+
76 83
   /**
77 84
    * Helper function to draw and/or measure a UTF8 string
78 85
    *
@@ -92,6 +99,9 @@
92 99
     const int start_x = x;
93 100
     while (*str) {
94 101
       const utf8_char_t c = get_utf8_char_and_inc(str);
102
+      #ifdef TOUCH_UI_UTF8_CYRILLIC_CHARSET
103
+        CyrillicCharSet::render_glyph(cmd, x, y, fs, c) ||
104
+      #endif
95 105
       #ifdef TOUCH_UI_UTF8_WESTERN_CHARSET
96 106
         WesternCharSet::render_glyph(cmd, x, y, fs, c) ||
97 107
       #endif
@@ -108,11 +118,14 @@
108 118
    *   addr  - Address in RAMG where the font data is written
109 119
    */
110 120
 
111
-  void FTDI::load_utf8_data(uint16_t addr) {
121
+  void FTDI::load_utf8_data(uint32_t addr) {
122
+    #ifdef TOUCH_UI_UTF8_CYRILLIC_CHARSET
123
+      addr = CyrillicCharSet::load_data(addr);
124
+    #endif
112 125
     #ifdef TOUCH_UI_UTF8_WESTERN_CHARSET
113
-      WesternCharSet::load_data(addr);
126
+      addr = WesternCharSet::load_data(addr);
114 127
     #endif
115
-    StandardCharSet::load_data(addr);
128
+    addr = StandardCharSet::load_data(addr);
116 129
   }
117 130
 
118 131
   /**
@@ -125,6 +138,9 @@
125 138
    */
126 139
 
127 140
   void FTDI::load_utf8_bitmaps(CommandProcessor &cmd) {
141
+    #ifdef TOUCH_UI_UTF8_CYRILLIC_CHARSET
142
+      CyrillicCharSet::load_bitmaps(cmd);
143
+    #endif
128 144
     #ifdef TOUCH_UI_UTF8_WESTERN_CHARSET
129 145
       WesternCharSet::load_bitmaps(cmd);
130 146
     #endif
@@ -145,6 +161,9 @@
145 161
 
146 162
   uint16_t FTDI::get_utf8_char_width(utf8_char_t c, font_size_t fs) {
147 163
     int x = 0, y = 0;
164
+    #ifdef TOUCH_UI_UTF8_CYRILLIC_CHARSET
165
+      CyrillicCharSet::render_glyph(nullptr, x, y, fs, c) ||
166
+    #endif
148 167
     #ifdef TOUCH_UI_UTF8_WESTERN_CHARSET
149 168
       WesternCharSet::render_glyph(nullptr, x, y, fs, c) ||
150 169
     #endif

+ 3
- 2
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.h View File

@@ -47,19 +47,20 @@ namespace FTDI {
47 47
      * pointer to the next character */
48 48
 
49 49
     utf8_char_t get_utf8_char_and_inc(const char *&c);
50
+    utf8_char_t get_utf8_char_and_inc(char *&c);
50 51
 
51 52
     /* Returns the next character in a UTF8 string, without incrementing */
52 53
 
53 54
     inline utf8_char_t get_utf8_char(const char *c) {return get_utf8_char_and_inc(c);}
54 55
 
55
-    void load_utf8_data(uint16_t addr);
56
+    void load_utf8_data(uint32_t addr);
56 57
   #else
57 58
     typedef char utf8_char_t;
58 59
 
59 60
     inline utf8_char_t get_utf8_char_and_inc(const char *&c) {return *c++;}
60 61
     inline utf8_char_t get_utf8_char(const char *c) {return *c;}
61 62
 
62
-    inline void load_utf8_data(uint16_t) {}
63
+    inline void load_utf8_data(uint32_t) {}
63 64
   #endif
64 65
 
65 66
   void load_utf8_bitmaps(CommandProcessor& cmd);

+ 10
- 5
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/western_char_set.cpp View File

@@ -32,7 +32,7 @@
32 32
   constexpr static uint8_t std_font = 31;
33 33
   constexpr static uint8_t alt_font = 1;
34 34
 
35
-  static uint32_t bitmap_addr;
35
+  uint32_t FTDI::WesternCharSet::bitmap_addr;
36 36
 
37 37
   /* Glyphs in the WesternCharSet bitmap */
38 38
 
@@ -286,7 +286,7 @@
286 286
     #if ENABLED(TOUCH_UI_UTF8_SCANDINAVIAN)
287 287
       {UTF8('þ'),  0 , SML_THORN,          25   },
288 288
     #endif
289
-    {UTF8('ÿ'), 'y', DIAERESIS,          mid_y}
289
+    {UTF8('ÿ'), 'y', DIAERESIS,          mid_y},
290 290
   };
291 291
 
292 292
   static_assert(UTF8('¡') == 0xC2A1, "Incorrect encoding for character");
@@ -331,7 +331,10 @@
331 331
    *   addr  - Address in RAMG where the font data is written
332 332
    */
333 333
 
334
-  void FTDI::WesternCharSet::load_data(uint32_t addr) {
334
+  uint32_t FTDI::WesternCharSet::load_data(uint32_t addr) {
335
+    if (addr % 4 != 0)
336
+      addr += 4 - (addr % 4);
337
+
335 338
     // Load the alternative font metrics
336 339
     CLCD::FontMetrics alt_fm;
337 340
     alt_fm.ptr    = addr + 148;
@@ -352,9 +355,11 @@
352 355
     CLCD::mem_write_bulk(addr, &alt_fm,  148);
353 356
 
354 357
     // Decode the RLE data and load it into RAMG as a bitmap
355
-    write_rle_data(addr + 148, font, sizeof(font));
358
+    uint32_t lastaddr = write_rle_data(addr + 148, font, sizeof(font));
356 359
 
357 360
     bitmap_addr = addr;
361
+
362
+    return lastaddr;
358 363
   }
359 364
 
360 365
   /**
@@ -394,7 +399,7 @@
394 399
    *
395 400
    *   c    - The unicode code point to draw. If the renderer does not
396 401
    *          support the character, it should return false.
397
-
402
+   *
398 403
    * Returns: Whether the character was supported.
399 404
    */
400 405
 

+ 3
- 1
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/western_char_set.h View File

@@ -21,8 +21,10 @@
21 21
 
22 22
 namespace FTDI {
23 23
   class WesternCharSet {
24
+    private:
25
+      static uint32_t bitmap_addr;
24 26
     public:
25
-      static void load_data(uint32_t addr);
27
+      static uint32_t load_data(uint32_t addr);
26 28
       static void load_bitmaps(CommandProcessor&);
27 29
       static bool render_glyph(CommandProcessor*, int &x, int &y, font_size_t, utf8_char_t);
28 30
   };

+ 5
- 5
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/bitmap2cpp.py View File

@@ -49,19 +49,19 @@ class WriteSource:
49 49
 
50 50
   def convert_to_4bpp(self, data, chunk_size = 0):
51 51
     # Invert the image
52
-    data = map(lambda i: 255 - i, data)
52
+    data = list(map(lambda i: 255 - i, data))
53 53
     # Quanitize 8-bit values into 4-bits
54
-    data = map(lambda i: i >> 4, data)
54
+    data = list(map(lambda i: i >> 4, data))
55 55
     # Make sure there is an even number of elements
56 56
     if (len(data) & 1) == 1:
57
-      result.append(0)
57
+      data.append(0)
58 58
     # Combine each two adjacent values into one
59 59
     i = iter(data)
60
-    data = map(lambda a, b: a << 4 | b, i ,i)
60
+    data = list(map(lambda a, b: a << 4 | b, i ,i))
61 61
     # Pack the data
62 62
     data = pack_rle(data)
63 63
     # Convert values into hex strings
64
-    return map(lambda a: "0x" + format(a, '02x'), data)
64
+    return list(map(lambda a: "0x" + format(a, '02x'), data))
65 65
 
66 66
   def end_row(self, y):
67 67
     # Pad each row into even number of values

+ 1
- 1
Marlin/src/lcd/extui/ui_api.cpp View File

@@ -1016,7 +1016,7 @@ namespace ExtUI {
1016 1016
   }
1017 1017
 
1018 1018
   const char* FileList::filename() {
1019
-    return IFSD(card.longFilename[0] ? card.longFilename : card.filename, "");
1019
+    return IFSD(card.longest_filename(), "");
1020 1020
   }
1021 1021
 
1022 1022
   const char* FileList::shortFilename() {

+ 2
- 2
Marlin/src/sd/SdBaseFile.cpp View File

@@ -1077,7 +1077,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) {
1077 1077
 
1078 1078
   // If we have a longFilename buffer, mark it as invalid.
1079 1079
   // If a long filename is found it will be filled automatically.
1080
-  if (longFilename) longFilename[0] = '\0';
1080
+  if (longFilename) { longFilename[0] = '\0'; longFilename[1] = '\0'; }
1081 1081
 
1082 1082
   while (1) {
1083 1083
 
@@ -1089,7 +1089,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) {
1089 1089
 
1090 1090
     // skip deleted entry and entry for .  and ..
1091 1091
     if (dir->name[0] == DIR_NAME_DELETED || dir->name[0] == '.') {
1092
-      if (longFilename) longFilename[0] = '\0';     // Invalidate erased file long name, if any
1092
+      if (longFilename) { longFilename[0] = '\0'; longFilename[1] = '\0'; } // Invalidate erased file long name, if any
1093 1093
       continue;
1094 1094
     }
1095 1095
 

Loading…
Cancel
Save