Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» General 'MediaFile' type alias (MarlinFirmware#24424)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhapsodyv authored and lukasradek committed Apr 2, 2023
1 parent e85ec4d commit 7467f44
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 6 deletions.
76 changes: 74 additions & 2 deletions Marlin/src/lcd/extui/mks_ui/wifi_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,80 @@ static void wifi_gcode_exec(uint8_t * const cmd_line) {
send_ok_to_wifi();
}
}
}
break;
break;

case 24:
if (strcmp_P(list_file.file_name[sel_id], PSTR("notValid")) != 0) {
if (uiCfg.print_state == IDLE) {
clear_cur_ui();
reset_print_time();
start_print_time();
preview_gcode_prehandle(list_file.file_name[sel_id]);
uiCfg.print_state = WORKING;
lv_draw_printing();

#if ENABLED(SDSUPPORT)
if (!gcode_preview_over) {
char *cur_name = strrchr(list_file.file_name[sel_id], '/');

MediaFile file;
MediaFile *curDir;
card.abortFilePrintNow();
const char * const fname = card.diveToFile(false, curDir, cur_name);
if (!fname) return;
if (file.open(curDir, fname, O_READ)) {
gCfgItems.curFilesize = file.fileSize();
file.close();
update_spi_flash();
}
card.openFileRead(cur_name);
if (card.isFileOpen()) {
//saved_feedrate_percentage = feedrate_percentage;
feedrate_percentage = 100;
#if HAS_EXTRUDERS
planner.flow_percentage[0] = 100;
planner.e_factor[0] = planner.flow_percentage[0] * 0.01f;
#endif
#if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = 100;
planner.e_factor[1] = planner.flow_percentage[1] * 0.01f;
#endif
card.startOrResumeFilePrinting();
TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
once_flag = false;
}
}
#endif
}
else if (uiCfg.print_state == PAUSED) {
uiCfg.print_state = RESUMING;
clear_cur_ui();
start_print_time();

if (gCfgItems.from_flash_pic)
flash_preview_begin = true;
else
default_preview_flg = true;
lv_draw_printing();
}
else if (uiCfg.print_state == REPRINTING) {
uiCfg.print_state = REPRINTED;
clear_cur_ui();
start_print_time();
if (gCfgItems.from_flash_pic)
flash_preview_begin = true;
else
default_preview_flg = true;
lv_draw_printing();
}
}
SEND_OK_TO_WIFI;
break;

case 25:
// Pause print file
if (uiCfg.print_state == WORKING) {
stop_print_time();

case 24:
if (strcmp_P(list_file.file_name[sel_id], PSTR("notValid")) != 0) {
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/sd/cardreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD,
//
// Get the number of (compliant) items in the folder
//
int16_t CardReader::countVisibleItems(MediaFile dir) {
int CardReader::countItems(MediaFile dir) {
dir_t p;
int16_t c = 0;
dir.rewind();
Expand All @@ -239,7 +239,7 @@ int16_t CardReader::countVisibleItems(MediaFile dir) {
//
// Get file/folder info for an item by index
//
void CardReader::selectByIndex(MediaFile dir, const int16_t index) {
void CardReader::selectByIndex(MediaFile dir, const uint8_t index) {
dir_t p;
for (int16_t cnt = 0; dir.readDir(&p, longFilename) > 0;) {
if (is_visible_entity(p)) {
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/sd/cardreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ class CardReader {
// Directory items
//
static bool is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false));
static int16_t countVisibleItems(MediaFile dir);
static void selectByIndex(MediaFile dir, const int16_t index);
static int countItems(MediaFile dir);
static void selectByIndex(MediaFile dir, const uint8_t index);
static void selectByName(MediaFile dir, const char * const match);
static void printListing(
MediaFile parent, const char * const prepend, const uint8_t lsflags
Expand Down

0 comments on commit 7467f44

Please sign in to comment.