Bläddra i källkod

LVGL G-code preview. Legacy MKS WiFi Cura plugin compatibility (#20589)

Victor Oliveira 4 år sedan
förälder
incheckning
90a2b482e6
Inget konto är kopplat till bidragsgivarens mejladress

+ 1
- 0
Marlin/src/core/macros.h Visa fil

216
 #define ANY_BUTTON(V...)    DO(BTNEX,||,V)
216
 #define ANY_BUTTON(V...)    DO(BTNEX,||,V)
217
 
217
 
218
 #define WITHIN(N,L,H)       ((N) >= (L) && (N) <= (H))
218
 #define WITHIN(N,L,H)       ((N) >= (L) && (N) <= (H))
219
+#define ISEOL(C)            ((C) == '\n' || (C) == '\r')
219
 #define NUMERIC(a)          WITHIN(a, '0', '9')
220
 #define NUMERIC(a)          WITHIN(a, '0', '9')
220
 #define DECIMAL(a)          (NUMERIC(a) || a == '.')
221
 #define DECIMAL(a)          (NUMERIC(a) || a == '.')
221
 #define HEXCHR(a)           (NUMERIC(a) ? (a) - '0' : WITHIN(a, 'a', 'f') ? ((a) - 'a' + 10)  : WITHIN(a, 'A', 'F') ? ((a) - 'A' + 10) : -1)
222
 #define HEXCHR(a)           (NUMERIC(a) ? (a) - '0' : WITHIN(a, 'a', 'f') ? ((a) - 'a' + 10)  : WITHIN(a, 'A', 'F') ? ((a) - 'A' + 10) : -1)

+ 0
- 1
Marlin/src/feature/e_parser.h Visa fil

76
   FORCE_INLINE static void disable() { enabled = false; }
76
   FORCE_INLINE static void disable() { enabled = false; }
77
 
77
 
78
   FORCE_INLINE static void update(State &state, const uint8_t c) {
78
   FORCE_INLINE static void update(State &state, const uint8_t c) {
79
-    #define ISEOL(C) ((C) == '\n' || (C) == '\r')
80
     switch (state) {
79
     switch (state) {
81
       case EP_RESET:
80
       case EP_RESET:
82
         switch (c) {
81
         switch (c) {

+ 0
- 2
Marlin/src/gcode/queue.cpp Visa fil

158
   return true;
158
   return true;
159
 }
159
 }
160
 
160
 
161
-#define ISEOL(C) ((C) == '\n' || (C) == '\r')
162
-
163
 /**
161
 /**
164
  * Enqueue with Serial Echo
162
  * Enqueue with Serial Echo
165
  * Return true if the command was consumed
163
  * Return true if the command was consumed

+ 10
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp Visa fil

417
       }
417
       }
418
 
418
 
419
       uint16_t c = card.get();
419
       uint16_t c = card.get();
420
-      // check if we have more data or finished the line (CR)
421
-      if (c == '\r') break;
420
+      // check for more data or end of line (CR or LF)
421
+      if (ISEOL(c)) {
422
+        c = card.get(); // more eol?
423
+        if (!ISEOL(c)) card.setIndex(card.getIndex() - 1);
424
+        break;
425
+      }
422
       card.setIndex(card.getIndex() - 1);
426
       card.setIndex(card.getIndex() - 1);
423
       k++;
427
       k++;
424
       j = 0;
428
       j = 0;
425
       ignore_start = false;
429
       ignore_start = false;
430
+      if (k > 1) {
431
+        card.closefile();
432
+        break;
433
+      }
426
     }
434
     }
427
     #if HAS_TFT_LVGL_UI_SPI
435
     #if HAS_TFT_LVGL_UI_SPI
428
       for (i = 0; i < 200;) {
436
       for (i = 0; i < 200;) {

+ 9
- 3
Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp Visa fil

369
 }
369
 }
370
 
370
 
371
 //sd
371
 //sd
372
+extern uint8_t public_buf[512];
372
 char *cur_namefff;
373
 char *cur_namefff;
373
-uint32_t sd_read_base_addr = 0,sd_read_addr_offset = 0;
374
+uint32_t sd_read_base_addr = 0, sd_read_addr_offset = 0, small_image_size = 409;
374
 lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode) {
375
 lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode) {
375
   //cur_namefff = strrchr(path, '/');
376
   //cur_namefff = strrchr(path, '/');
376
   char name_buf[100];
377
   char name_buf[100];
381
   sd_read_base_addr = lv_open_gcode_file((char *)name_buf);
382
   sd_read_base_addr = lv_open_gcode_file((char *)name_buf);
382
   sd_read_addr_offset = sd_read_base_addr;
383
   sd_read_addr_offset = sd_read_base_addr;
383
   if (sd_read_addr_offset == UINT32_MAX) return LV_FS_RES_NOT_EX;
384
   if (sd_read_addr_offset == UINT32_MAX) return LV_FS_RES_NOT_EX;
385
+  // find small image size
386
+  card.read(public_buf, 512);
387
+  public_buf[511] = '\0';
388
+  char* eol = strpbrk((const char*)public_buf, "\n\r");
389
+  small_image_size = (uintptr_t)eol - (uintptr_t)((uint32_t *)(&public_buf[0])) + 1;
384
   return LV_FS_RES_OK;
390
   return LV_FS_RES_OK;
385
 }
391
 }
386
 
392
 
406
 }
412
 }
407
 
413
 
408
 lv_fs_res_t sd_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos) {
414
 lv_fs_res_t sd_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos) {
409
-  sd_read_addr_offset = sd_read_base_addr + (pos - 4) / 200 * 409;
415
+  sd_read_addr_offset = sd_read_base_addr + (pos - 4) / 200 * small_image_size;
410
   lv_gcode_file_seek(sd_read_addr_offset);
416
   lv_gcode_file_seek(sd_read_addr_offset);
411
   return LV_FS_RES_OK;
417
   return LV_FS_RES_OK;
412
 }
418
 }
413
 
419
 
414
 lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p) {
420
 lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p) {
415
   if (sd_read_addr_offset) *pos_p = 0;
421
   if (sd_read_addr_offset) *pos_p = 0;
416
-  else *pos_p = (sd_read_addr_offset - sd_read_base_addr) / 409 * 200 + 4;
422
+  else *pos_p = (sd_read_addr_offset - sd_read_base_addr) / small_image_size * 200 + 4;
417
   return LV_FS_RES_OK;
423
   return LV_FS_RES_OK;
418
 }
424
 }
419
 
425
 

Laddar…
Avbryt
Spara