Browse Source

fix text rendering

Thomas Buck 1 year ago
parent
commit
bac6f6b7ca
4 changed files with 25 additions and 12 deletions
  1. 7
    5
      include/config.h
  2. 1
    0
      src/console.c
  3. 7
    0
      src/lcd.c
  4. 10
    7
      src/text.c

+ 7
- 5
include/config.h View File

22
 #define MENU_PREFER_VOLCANO
22
 #define MENU_PREFER_VOLCANO
23
 //#define MENU_PREFER_CRAFTY
23
 //#define MENU_PREFER_CRAFTY
24
 
24
 
25
-#ifdef MENU_PREFER_VOLCANO
26
-#define VOLCANO_AUTO_CONNECT_TIMEOUT_MS 2000
27
-#endif // MENU_PREFER_VOLCANO
28
-
29
 #ifdef NDEBUG
25
 #ifdef NDEBUG
30
 // Release build
26
 // Release build
27
+
31
 #define AUTO_MOUNT_MASS_STORAGE
28
 #define AUTO_MOUNT_MASS_STORAGE
32
 #define AUTO_LOG_ON_MASS_STORAGE
29
 #define AUTO_LOG_ON_MASS_STORAGE
33
 #define DEBUG_DISK_WRITE_SOURCES
30
 #define DEBUG_DISK_WRITE_SOURCES
34
-#endif
31
+
32
+#ifdef MENU_PREFER_VOLCANO
33
+#define VOLCANO_AUTO_CONNECT_TIMEOUT_MS 2000
34
+#endif // MENU_PREFER_VOLCANO
35
+
36
+#endif // NDEBUG
35
 
37
 
36
 #define WATCHDOG_PERIOD_MS 1000
38
 #define WATCHDOG_PERIOD_MS 1000
37
 
39
 

+ 1
- 0
src/console.c View File

233
                 .width = 240,
233
                 .width = 240,
234
                 .height = 240 - y_off,
234
                 .height = 240 - y_off,
235
                 .margin = 5,
235
                 .margin = 5,
236
+                .fg = RGB_565(0xFF, 0xFF, 0xFF),
236
                 .bg = TEXT_BG_NONE,
237
                 .bg = TEXT_BG_NONE,
237
                 .font = &font,
238
                 .font = &font,
238
             };
239
             };

+ 7
- 0
src/lcd.c View File

273
 }
273
 }
274
 
274
 
275
 void lcd_write_rect(uint16_t left, uint16_t top, uint16_t right, uint16_t bottom, uint32_t color) {
275
 void lcd_write_rect(uint16_t left, uint16_t top, uint16_t right, uint16_t bottom, uint32_t color) {
276
+    if (right >= ST7789_PICO_ROW) {
277
+        right = ST7789_PICO_ROW - 1;
278
+    }
279
+    if (bottom >= ST7789_PICO_COLUMN) {
280
+        bottom = ST7789_PICO_COLUMN - 1;
281
+    }
282
+    //                 handle,       left,         top,      right,    bottom, color);
276
     st7789_fill_rect(&gs_handle, 240 - bottom - 1, left, 240 - top - 1, right, color);
283
     st7789_fill_rect(&gs_handle, 240 - bottom - 1, left, 240 - top - 1, right, color);
277
 }
284
 }
278
 
285
 

+ 10
- 7
src/text.c View File

19
 #include "config.h"
19
 #include "config.h"
20
 #include "log.h"
20
 #include "log.h"
21
 #include "lcd.h"
21
 #include "lcd.h"
22
+#include "menu.h"
22
 #include "text.h"
23
 #include "text.h"
23
 
24
 
24
 typedef struct {
25
 typedef struct {
50
                            void *state) {
51
                            void *state) {
51
     state_t *s = (state_t*)state;
52
     state_t *s = (state_t*)state;
52
 
53
 
53
-    if (y < 0 || y >= s->options->height) return;
54
-    if (x < 0 || x + count >= s->options->width) return;
54
+    if ((y < 0) || (y >= (s->options->y + s->options->height))
55
+        || (x < 0) || ((x + count) >= (s->options->x + s->options->width))) {
56
+        return;
57
+    }
55
 
58
 
56
     while (count--) {
59
     while (count--) {
57
         lcd_write_point(x, y,
60
         lcd_write_point(x, y,
167
     int width = 240;
170
     int width = 240;
168
 
171
 
169
     int y = 50;
172
     int y = 50;
170
-    int height = 120;
173
+    int height = MENU_MAX_LINES * (20 + 2);
171
 
174
 
172
     struct text_conf text = {
175
     struct text_conf text = {
173
         .text = "",
176
         .text = "",
175
         .y = y,
178
         .y = y,
176
         .justify = false,
179
         .justify = false,
177
         .alignment = centered ? MF_ALIGN_CENTER : MF_ALIGN_LEFT,
180
         .alignment = centered ? MF_ALIGN_CENTER : MF_ALIGN_LEFT,
178
-        .width = width - 4,
179
-        .height = height - 4,
181
+        .width = width,
182
+        .height = height,
180
         .margin = 2,
183
         .margin = 2,
181
         .fg = RGB_565(0xFF, 0xFF, 0xFF),
184
         .fg = RGB_565(0xFF, 0xFF, 0xFF),
182
-        .bg = RGB_565(0x00, 0x00, 0x00),
185
+        .bg = TEXT_BG_NONE,
183
         .font = &font,
186
         .font = &font,
184
     };
187
     };
185
 
188
 
187
                    y,
190
                    y,
188
                    x + width - 1,
191
                    x + width - 1,
189
                    y + height - 1,
192
                    y + height - 1,
190
-                   text.bg);
193
+                   RGB_565(0x00, 0x00, 0x00));
191
 
194
 
192
     text.text = s;
195
     text.text = s;
193
     text_draw(&text);
196
     text_draw(&text);

Loading…
Cancel
Save