Skip to content

Commit

Permalink
LVGL G-code preview. Legacy MKS WiFi Cura plugin compatibility (Marli…
Browse files Browse the repository at this point in the history
  • Loading branch information
rhapsodyv authored and zillarob committed Feb 25, 2021
1 parent c79d860 commit 1e46827
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions Marlin/src/core/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
#define ANY_BUTTON(V...) DO(BTNEX,||,V)

#define WITHIN(N,L,H) ((N) >= (L) && (N) <= (H))
#define ISEOL(C) ((C) == '\n' || (C) == '\r')
#define NUMERIC(a) WITHIN(a, '0', '9')
#define DECIMAL(a) (NUMERIC(a) || a == '.')
#define HEXCHR(a) (NUMERIC(a) ? (a) - '0' : WITHIN(a, 'a', 'f') ? ((a) - 'a' + 10) : WITHIN(a, 'A', 'F') ? ((a) - 'A' + 10) : -1)
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/feature/e_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class EmergencyParser {
FORCE_INLINE static void disable() { enabled = false; }

FORCE_INLINE static void update(State &state, const uint8_t c) {
#define ISEOL(C) ((C) == '\n' || (C) == '\r')
switch (state) {
case EP_RESET:
switch (c) {
Expand Down
2 changes: 0 additions & 2 deletions Marlin/src/gcode/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ bool GCodeQueue::_enqueue(const char* cmd, bool say_ok/*=false*/
return true;
}

#define ISEOL(C) ((C) == '\n' || (C) == '\r')

/**
* Enqueue with Serial Echo
* Return true if the command was consumed
Expand Down
12 changes: 9 additions & 3 deletions Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,9 @@ lv_fs_res_t spi_flash_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p
}

//sd
extern uint8_t public_buf[512];
char *cur_namefff;
uint32_t sd_read_base_addr = 0,sd_read_addr_offset = 0;
uint32_t sd_read_base_addr = 0, sd_read_addr_offset = 0, small_image_size = 409;
lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode) {
//cur_namefff = strrchr(path, '/');
char name_buf[100];
Expand All @@ -371,6 +372,11 @@ lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_
sd_read_base_addr = lv_open_gcode_file((char *)name_buf);
sd_read_addr_offset = sd_read_base_addr;
if (sd_read_addr_offset == UINT32_MAX) return LV_FS_RES_NOT_EX;
// find small image size
card.read(public_buf, 512);
public_buf[511] = '\0';
char* eol = strpbrk((const char*)public_buf, "\n\r");
small_image_size = (uintptr_t)eol - (uintptr_t)((uint32_t *)(&public_buf[0])) + 1;
return LV_FS_RES_OK;
}

Expand All @@ -396,14 +402,14 @@ lv_fs_res_t sd_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t b
}

lv_fs_res_t sd_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos) {
sd_read_addr_offset = sd_read_base_addr + (pos - 4) / 200 * 409;
sd_read_addr_offset = sd_read_base_addr + (pos - 4) / 200 * small_image_size;
lv_gcode_file_seek(sd_read_addr_offset);
return LV_FS_RES_OK;
}

lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p) {
if (sd_read_addr_offset) *pos_p = 0;
else *pos_p = (sd_read_addr_offset - sd_read_base_addr) / 409 * 200 + 4;
else *pos_p = (sd_read_addr_offset - sd_read_base_addr) / small_image_size * 200 + 4;
return LV_FS_RES_OK;
}

Expand Down

0 comments on commit 1e46827

Please sign in to comment.