Make CardReader class static (#12451)

* Make CardReader a static class
* Make CardReader flags into bitfields
This commit is contained in:
Scott Lahteine
2018-11-16 22:39:16 -06:00
committed by GitHub
parent 3e9ffaddb6
commit 66580f32c2
15 changed files with 281 additions and 190 deletions

View File

@ -575,7 +575,7 @@ namespace ExtUI {
}
bool isPrintingFromMedia() {
return IFSD(card.cardOK && card.isFileOpen(), false);
return IFSD(card.flag.cardOK && card.isFileOpen(), false);
}
bool isPrinting() {
@ -583,7 +583,7 @@ namespace ExtUI {
}
bool isMediaInserted() {
return IFSD(IS_SD_INSERTED() && card.cardOK, false);
return IFSD(IS_SD_INSERTED() && card.flag.cardOK, false);
}
void pausePrint() {
@ -612,7 +612,7 @@ namespace ExtUI {
void stopPrint() {
#if ENABLED(SDSUPPORT)
wait_for_heatup = wait_for_user = false;
card.abort_sd_printing = true;
card.flag.abort_sd_printing = true;
ExtUI::onStatusChanged(PSTR(MSG_PRINT_ABORTED));
#endif
}
@ -648,7 +648,7 @@ namespace ExtUI {
}
bool FileList::isDir() {
return IFSD(card.filenameIsDir, false);
return IFSD(card.flag.filenameIsDir, false);
}
uint16_t FileList::count() {
@ -697,13 +697,13 @@ void MarlinUI::update() {
last_sd_status = sd_status;
if (sd_status) {
card.initsd();
if (card.cardOK)
if (card.flag.cardOK)
ExtUI::onMediaInserted();
else
ExtUI::onMediaError();
}
else {
const bool ok = card.cardOK;
const bool ok = card.flag.cardOK;
card.release();
if (ok) ExtUI::onMediaRemoved();
}

View File

@ -278,7 +278,7 @@ void process_lcd_p_command(const char* command) {
// There may be a difference in how V1 and V2 LCDs handle subdirectory
// prints. Investigate more. This matches the V1 motion controller actions
// but the V2 LCD switches to "print" mode on {SYS:DIR} response.
if (card.filenameIsDir) {
if (card.flag.filenameIsDir) {
card.chdir(card.filename);
write_to_lcd_P(PSTR("{SYS:DIR}"));
}
@ -330,7 +330,7 @@ void process_lcd_s_command(const char* command) {
case 'L': {
#if ENABLED(SDSUPPORT)
if (!card.cardOK) card.initsd();
if (!card.flag.cardOK) card.initsd();
// A more efficient way to do this would be to
// implement a callback in the ls_SerialPrint code, but
@ -342,7 +342,7 @@ void process_lcd_s_command(const char* command) {
uint16_t file_count = card.get_num_Files();
for (uint16_t i = 0; i < file_count; i++) {
card.getfilename(i);
sprintf_P(message_buffer, card.filenameIsDir ? PSTR("{DIR:%s}") : PSTR("{FILE:%s}"), card.longest_filename());
sprintf_P(message_buffer, card.flag.filenameIsDir ? PSTR("{DIR:%s}") : PSTR("{FILE:%s}"), card.longest_filename());
write_to_lcd(message_buffer);
}

View File

@ -58,7 +58,7 @@
void lcd_sdcard_stop() {
wait_for_heatup = wait_for_user = false;
card.abort_sd_printing = true;
card.flag.abort_sd_printing = true;
ui.setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1);
ui.return_to_status();
}
@ -86,7 +86,7 @@ void menu_main() {
MENU_BACK(MSG_WATCH);
#if ENABLED(SDSUPPORT)
if (card.cardOK) {
if (card.flag.cardOK) {
if (card.isFileOpen()) {
if (IS_SD_PRINTING())
MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause);

View File

@ -125,7 +125,7 @@ void menu_sdcard() {
card.getfilename_sorted(nr);
if (card.filenameIsDir)
if (card.flag.filenameIsDir)
MENU_ITEM(sdfolder, MSG_CARD_MENU, card);
else
MENU_ITEM(sdfile, MSG_CARD_MENU, card);