Browse Source

fix text rendering

Thomas Buck 11 months 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,16 +22,18 @@
22 22
 #define MENU_PREFER_VOLCANO
23 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 25
 #ifdef NDEBUG
30 26
 // Release build
27
+
31 28
 #define AUTO_MOUNT_MASS_STORAGE
32 29
 #define AUTO_LOG_ON_MASS_STORAGE
33 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 38
 #define WATCHDOG_PERIOD_MS 1000
37 39
 

+ 1
- 0
src/console.c View File

@@ -233,6 +233,7 @@ static void cnsl_interpret(const char *line) {
233 233
                 .width = 240,
234 234
                 .height = 240 - y_off,
235 235
                 .margin = 5,
236
+                .fg = RGB_565(0xFF, 0xFF, 0xFF),
236 237
                 .bg = TEXT_BG_NONE,
237 238
                 .font = &font,
238 239
             };

+ 7
- 0
src/lcd.c View File

@@ -273,6 +273,13 @@ void lcd_write_point(uint16_t x, uint16_t y, uint32_t color) {
273 273
 }
274 274
 
275 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 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,6 +19,7 @@
19 19
 #include "config.h"
20 20
 #include "log.h"
21 21
 #include "lcd.h"
22
+#include "menu.h"
22 23
 #include "text.h"
23 24
 
24 25
 typedef struct {
@@ -50,8 +51,10 @@ static void pixel_callback(int16_t x, int16_t y, uint8_t count, uint8_t alpha,
50 51
                            void *state) {
51 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 59
     while (count--) {
57 60
         lcd_write_point(x, y,
@@ -167,7 +170,7 @@ void text_box(const char *s, bool centered) {
167 170
     int width = 240;
168 171
 
169 172
     int y = 50;
170
-    int height = 120;
173
+    int height = MENU_MAX_LINES * (20 + 2);
171 174
 
172 175
     struct text_conf text = {
173 176
         .text = "",
@@ -175,11 +178,11 @@ void text_box(const char *s, bool centered) {
175 178
         .y = y,
176 179
         .justify = false,
177 180
         .alignment = centered ? MF_ALIGN_CENTER : MF_ALIGN_LEFT,
178
-        .width = width - 4,
179
-        .height = height - 4,
181
+        .width = width,
182
+        .height = height,
180 183
         .margin = 2,
181 184
         .fg = RGB_565(0xFF, 0xFF, 0xFF),
182
-        .bg = RGB_565(0x00, 0x00, 0x00),
185
+        .bg = TEXT_BG_NONE,
183 186
         .font = &font,
184 187
     };
185 188
 
@@ -187,7 +190,7 @@ void text_box(const char *s, bool centered) {
187 190
                    y,
188 191
                    x + width - 1,
189 192
                    y + height - 1,
190
-                   text.bg);
193
+                   RGB_565(0x00, 0x00, 0x00));
191 194
 
192 195
     text.text = s;
193 196
     text_draw(&text);

Loading…
Cancel
Save