Skip to content

Commit 521e7ea

Browse files
committed
πŸ§‘β€πŸ’» Clarify media "mounted"
1 parent 2d78a80 commit 521e7ea

32 files changed

+87
-88
lines changed

β€ŽMarlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp

+14-16
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,32 @@ extern "C" {
1818
void sd_mmc_spi_mem_init() {
1919
}
2020

21+
inline bool media_ready() {
22+
return IS_SD_INSERTED() && !IS_SD_PRINTING() && !IS_SD_FILE_OPEN() && card.isMounted();
23+
}
24+
25+
bool sd_mmc_spi_unload(bool) { return true; }
26+
27+
bool sd_mmc_spi_wr_protect() { return false; }
28+
29+
bool sd_mmc_spi_removal() { return !media_ready(); }
30+
2131
Ctrl_status sd_mmc_spi_test_unit_ready() {
2232
#ifdef DISABLE_DUE_SD_MMC
2333
return CTRL_NO_PRESENT;
2434
#endif
25-
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
26-
return CTRL_NO_PRESENT;
35+
if (!media_ready()) return CTRL_NO_PRESENT;
2736
return CTRL_GOOD;
2837
}
2938

3039
// NOTE: This function is defined as returning the address of the last block
3140
// in the card, which is cardSize() - 1
3241
Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) {
33-
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
34-
return CTRL_NO_PRESENT;
42+
if (!media_ready()) return CTRL_NO_PRESENT;
3543
*nb_sector = card.diskIODriver()->cardSize() - 1;
3644
return CTRL_GOOD;
3745
}
3846

39-
bool sd_mmc_spi_unload(bool) { return true; }
40-
41-
bool sd_mmc_spi_wr_protect() { return false; }
42-
43-
bool sd_mmc_spi_removal() {
44-
return (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted());
45-
}
46-
4747
#if ACCESS_USB == true
4848
/**
4949
* \name MEM <-> USB Interface
@@ -61,8 +61,7 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
6161
#ifdef DISABLE_DUE_SD_MMC
6262
return CTRL_NO_PRESENT;
6363
#endif
64-
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
65-
return CTRL_NO_PRESENT;
64+
if (!media_ready()) return CTRL_NO_PRESENT;
6665

6766
#ifdef DEBUG_MMC
6867
{
@@ -101,8 +100,7 @@ Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) {
101100
#ifdef DISABLE_DUE_SD_MMC
102101
return CTRL_NO_PRESENT;
103102
#endif
104-
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
105-
return CTRL_NO_PRESENT;
103+
if (!media_ready()) return CTRL_NO_PRESENT;
106104

107105
#ifdef DEBUG_MMC
108106
{

β€ŽMarlin/src/HAL/DUE/usb/sd_mmc_spi_mem.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
//!
7575
//! @brief This function initializes the hw/sw resources required to drive the SD_MMC_SPI.
7676
//!/
77-
extern void sd_mmc_spi_mem_init(void);
77+
void sd_mmc_spi_mem_init();
7878

7979
//!
8080
//! @brief This function tests the state of the SD_MMC memory and sends it to the Host.
@@ -87,7 +87,7 @@ extern void sd_mmc_spi_mem_init(void);
8787
//! Media not present -> CTRL_NO_PRESENT
8888
//! Media has changed -> CTRL_BUSY
8989
//!/
90-
extern Ctrl_status sd_mmc_spi_test_unit_ready(void);
90+
Ctrl_status sd_mmc_spi_test_unit_ready();
9191

9292
//!
9393
//! @brief This function gives the address of the last valid sector.
@@ -98,7 +98,7 @@ extern Ctrl_status sd_mmc_spi_test_unit_ready(void);
9898
//! Media ready -> CTRL_GOOD
9999
//! Media not present -> CTRL_NO_PRESENT
100100
//!/
101-
extern Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector);
101+
Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector);
102102

103103
/*! \brief Unload/Load the SD/MMC card selected
104104
*
@@ -109,7 +109,7 @@ extern Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector);
109109
*
110110
* \return \c true if unload/load done success.
111111
*/
112-
extern bool sd_mmc_spi_unload(bool unload);
112+
bool sd_mmc_spi_unload(bool unload);
113113

114114
//!
115115
//! @brief This function returns the write protected status of the memory.
@@ -120,14 +120,14 @@ extern bool sd_mmc_spi_unload(bool unload);
120120
//!
121121
//! @return false -> the memory is not write-protected (always)
122122
//!/
123-
extern bool sd_mmc_spi_wr_protect(void);
123+
bool sd_mmc_spi_wr_protect();
124124

125125
//!
126126
//! @brief This function tells if the memory has been removed or not.
127127
//!
128128
//! @return false -> The memory isn't removed
129129
//!
130-
extern bool sd_mmc_spi_removal(void);
130+
bool sd_mmc_spi_removal();
131131

132132
//---- ACCESS DATA FUNCTIONS ----
133133

@@ -147,7 +147,7 @@ extern bool sd_mmc_spi_removal(void);
147147
//! It is ready -> CTRL_GOOD
148148
//! A error occur -> CTRL_FAIL
149149
//!
150-
extern Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector);
150+
Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector);
151151

152152
//! This function initializes the SD/MMC memory for a write operation
153153
//!
@@ -161,7 +161,7 @@ extern Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector);
161161
//! It is ready -> CTRL_GOOD
162162
//! An error occurs -> CTRL_FAIL
163163
//!
164-
extern Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector);
164+
Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector);
165165

166166
#endif // #if ACCESS_USB == true
167167

β€ŽMarlin/src/HAL/STM32/MarlinSerial.h

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
inline void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
5454

5555
void _rx_complete_irq(serial_t *obj);
56+
FORCE_INLINE static uint8_t buffer_overruns() { return 0; } // Not implemented. Void to avoid platform-dependent code.
5657

5758
protected:
5859
usart_rx_callback_t _rx_callback;

β€ŽMarlin/src/lcd/e3v2/proui/proui_extui.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ namespace ExtUI {
6565
void onIdle() {}
6666
void onPrinterKilled(FSTR_P const error, FSTR_P const component) {}
6767

68-
void onMediaInserted() {}
69-
void onMediaError() {}
68+
void onMediaMounted() {}
69+
void onMediaError() {}
7070
void onMediaRemoved() {}
7171

7272
void onHeatingError(const heater_id_t heater_id) {

β€ŽMarlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ namespace ExtUI {
4545
chiron.printerKilled(error, component);
4646
}
4747

48-
void onMediaInserted() { chiron.mediaEvent(AC_media_inserted); }
49-
void onMediaError() { chiron.mediaEvent(AC_media_error); }
50-
void onMediaRemoved() { chiron.mediaEvent(AC_media_removed); }
48+
void onMediaMounted() { chiron.mediaEvent(AC_media_inserted); }
49+
void onMediaError() { chiron.mediaEvent(AC_media_error); }
50+
void onMediaRemoved() { chiron.mediaEvent(AC_media_removed); }
5151

5252
void onHeatingError(const heater_id_t header_id) {}
5353
void onMinTempError(const heater_id_t header_id) {}

β€ŽMarlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,8 @@ void ChironTFT::panelInfo(uint8_t req) {
564564
} break;
565565

566566
case 8: // A8 Get SD Card list A8 S0
567-
if (!isMediaInserted()) safe_delay(500);
568-
if (!isMediaInserted()) // Make sure the card is removed
567+
if (!isMediaMounted()) safe_delay(500);
568+
if (!isMediaMounted()) // Make sure the card is removed
569569
tftSendLn(AC_msg_no_sd_card);
570570
else if (panel_command[3] == 'S')
571571
sendFileList( atoi( &panel_command[4] ) );

β€ŽMarlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace ExtUI {
3939
void onIdle() { anycubicTFT.onCommandScan(); }
4040
void onPrinterKilled(FSTR_P const error, FSTR_P const component) { anycubicTFT.onKillTFT(); }
4141

42-
void onMediaInserted() { anycubicTFT.onSDCardStateChange(true); }
42+
void onMediaMounted() { anycubicTFT.onSDCardStateChange(true); }
4343
void onMediaError() { anycubicTFT.onSDCardError(); }
4444
void onMediaRemoved() { anycubicTFT.onSDCardStateChange(false); }
4545

β€ŽMarlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ void AnycubicTFT::onKillTFT() {
138138
SENDLINE_DBG_PGM("J11", "TFT Serial Debug: Kill command... J11");
139139
}
140140

141-
void AnycubicTFT::onSDCardStateChange(bool isInserted) {
142-
DEBUG_ECHOLNPGM("TFT Serial Debug: onSDCardStateChange event triggered...", isInserted);
141+
void AnycubicTFT::onSDCardStateChange(bool isMounted) {
142+
DEBUG_ECHOLNPGM("TFT Serial Debug: onSDCardStateChange event triggered...", isMounted);
143143
doSDCardStateCheck();
144144
}
145145

@@ -363,7 +363,7 @@ void AnycubicTFT::renderCurrentFileList() {
363363

364364
SENDLINE_PGM("FN "); // Filelist start
365365

366-
if (!isMediaInserted() && !specialMenu) {
366+
if (!isMediaMounted() && !specialMenu) {
367367
SENDLINE_DBG_PGM("J02", "TFT Serial Debug: No SD Card mounted to render Current File List... J02");
368368

369369
SENDLINE_PGM("<SPECI~1.GCO");
@@ -579,7 +579,7 @@ void AnycubicTFT::getCommandFromTFT() {
579579
#if HAS_MEDIA
580580
if (isPrintingFromMedia()) {
581581
SEND_PGM("A6V ");
582-
if (isMediaInserted())
582+
if (isMediaMounted())
583583
SENDLINE(ui8tostr3rj(getProgress_percent()));
584584
else
585585
SENDLINE_DBG_PGM("J02", "TFT Serial Debug: No SD Card mounted to return printing status... J02");
@@ -632,7 +632,7 @@ void AnycubicTFT::getCommandFromTFT() {
632632

633633
case 13: // A13 SELECTION FILE
634634
#if HAS_MEDIA
635-
if (isMediaInserted()) {
635+
if (isMediaMounted()) {
636636
starpos = (strchr(tftStrchrPtr + 4, '*'));
637637
if (tftStrchrPtr[4] == '/') {
638638
strcpy(selectedDirectory, tftStrchrPtr + 5);
@@ -831,7 +831,7 @@ void AnycubicTFT::getCommandFromTFT() {
831831

832832
case 26: // A26 refresh SD
833833
#if HAS_MEDIA
834-
if (isMediaInserted()) {
834+
if (isMediaMounted()) {
835835
if (strlen(selectedDirectory) > 0) {
836836
FileList currentFileList;
837837
if ((selectedDirectory[0] == '.') && (selectedDirectory[1] == '.')) {
@@ -883,12 +883,12 @@ void AnycubicTFT::getCommandFromTFT() {
883883
}
884884

885885
void AnycubicTFT::doSDCardStateCheck() {
886-
#if ALL(HAS_MEDIA, HAS_SD_DETECT)
887-
bool isInserted = isMediaInserted();
888-
if (isInserted)
889-
SENDLINE_DBG_PGM("J00", "TFT Serial Debug: SD card state changed... isInserted");
886+
#if HAS_MEDIA
887+
const bool isMounted = isMediaMounted();
888+
if (isMounted)
889+
SENDLINE_DBG_PGM("J00", "TFT Serial Debug: SD card state changed... isMounted");
890890
else
891-
SENDLINE_DBG_PGM("J01", "TFT Serial Debug: SD card state changed... !isInserted");
891+
SENDLINE_DBG_PGM("J01", "TFT Serial Debug: SD card state changed... !isMounted");
892892

893893
#endif
894894
}

β€ŽMarlin/src/lcd/extui/anycubic_vyper/dgus_tft.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ namespace Anycubic {
12681268
break;
12691269

12701270
case 4: // page refresh
1271-
if (!isMediaInserted()) safe_delay(500);
1271+
if (!isMediaMounted()) safe_delay(500);
12721272

12731273
filenavigator.reset();
12741274

β€ŽMarlin/src/lcd/extui/anycubic_vyper/vyper_extui.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ namespace ExtUI {
4545
dgus.printerKilled(error, component);
4646
}
4747

48-
void onMediaInserted() { dgus.mediaEvent(AC_media_inserted); }
49-
void onMediaError() { dgus.mediaEvent(AC_media_error); }
50-
void onMediaRemoved() { dgus.mediaEvent(AC_media_removed); }
48+
void onMediaMounted() { dgus.mediaEvent(AC_media_inserted); }
49+
void onMediaError() { dgus.mediaEvent(AC_media_error); }
50+
void onMediaRemoved() { dgus.mediaEvent(AC_media_removed); }
5151

5252
void onHeatingError(const heater_id_t header_id) {}
5353
void onMinTempError(const heater_id_t header_id) {}

β€ŽMarlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void DGUSScreenHandler::sendHeaterStatusToDisplay(DGUS_VP_Variable &var) {
264264

265265
void DGUSScreenHandler::screenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr) {
266266
// default action executed when there is a SD card, but not printing
267-
if (ExtUI::isMediaInserted() && !ExtUI::isPrintingFromMedia()) {
267+
if (ExtUI::isMediaMounted() && !ExtUI::isPrintingFromMedia()) {
268268
screenChangeHook(var, val_ptr);
269269
dgus.requestScreen(current_screenID);
270270
return;
@@ -279,7 +279,7 @@ void DGUSScreenHandler::sendHeaterStatusToDisplay(DGUS_VP_Variable &var) {
279279
}
280280

281281
// Don't let the user in the dark why there is no reaction.
282-
if (!ExtUI::isMediaInserted()) {
282+
if (!ExtUI::isMediaMounted()) {
283283
setStatusMessage(GET_TEXT_F(MSG_NO_MEDIA));
284284
return;
285285
}

β€ŽMarlin/src/lcd/extui/dgus/dgus_extui.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ namespace ExtUI {
4848
while (!screen.loop()); // Wait while anything is left to be sent
4949
}
5050

51-
void onMediaInserted() { TERN_(HAS_MEDIA, screen.sdCardInserted()); }
52-
void onMediaError() { TERN_(HAS_MEDIA, screen.sdCardError()); }
53-
void onMediaRemoved() { TERN_(HAS_MEDIA, screen.sdCardRemoved()); }
51+
void onMediaMounted() { TERN_(HAS_MEDIA, screen.sdCardInserted()); }
52+
void onMediaError() { TERN_(HAS_MEDIA, screen.sdCardError()); }
53+
void onMediaRemoved() { TERN_(HAS_MEDIA, screen.sdCardRemoved()); }
5454

5555
void onHeatingError(const heater_id_t header_id) {}
5656
void onMinTempError(const heater_id_t header_id) {}

β€ŽMarlin/src/lcd/extui/dgus_e3s1pro/DGUSReturnKeyCodeHandler.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void DGUSReturnKeyCodeHandler::Command_MenuSelect(DGUS_VP &vp, void *data) {
7272
break;
7373

7474
case DGUS_Data::MenuSelectCommand::Print:
75-
if (ExtUI::isMediaInserted()) {
75+
if (ExtUI::isMediaMounted()) {
7676
dgus_sdcard_handler.Reset();
7777
screen.triggerScreenChange(DGUS_ScreenID::FILE1);
7878
}
@@ -241,7 +241,7 @@ void DGUSReturnKeyCodeHandler::Command_CheckOK(DGUS_VP &vp, void *data) {
241241
#endif // HAS_FILAMENT_SENSOR
242242

243243
case DGUS_Data::CheckOKCommand::SDCardCheck_Yes:
244-
if (ExtUI::isMediaInserted()) {
244+
if (ExtUI::isMediaMounted()) {
245245
dgus_sdcard_handler.Reset();
246246
screen.triggerScreenChange(DGUS_ScreenID::FILE1);
247247
}

β€ŽMarlin/src/lcd/extui/dgus_e3s1pro/DGUSTxHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void DGUSTxHandler::levelingProgressIcon(DGUS_VP &vp) {
8484
#endif
8585

8686
void DGUSTxHandler::sdCardInsertionStatus(DGUS_VP &vp) {
87-
const uint16_t data = ExtUI::isMediaInserted() ? 1 : 0;
87+
const uint16_t data = ExtUI::isMediaMounted() ? 1 : 0;
8888
dgus.write((uint16_t)vp.addr, Endianness::toBE(data));
8989
}
9090

β€ŽMarlin/src/lcd/extui/dgus_e3s1pro/dgus_e3s1pro_extui.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ namespace ExtUI {
5555
screen.printerKilled(error, component);
5656
}
5757

58-
void onMediaInserted() { TERN_(HAS_MEDIA, screen.sdCardInserted()); }
59-
void onMediaError() { TERN_(HAS_MEDIA, screen.sdCardError()); }
60-
void onMediaRemoved() { TERN_(HAS_MEDIA, screen.sdCardRemoved()); }
58+
void onMediaMounted() { TERN_(HAS_MEDIA, screen.sdCardInserted()); }
59+
void onMediaError() { TERN_(HAS_MEDIA, screen.sdCardError()); }
60+
void onMediaRemoved() { TERN_(HAS_MEDIA, screen.sdCardRemoved()); }
6161

6262
void onHeatingError(const heater_id_t header_id) {}
6363
void onMinTempError(const heater_id_t header_id) {}

β€ŽMarlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void DGUSRxHandler::screenChange(DGUS_VP &vp, void *data_ptr) {
4949
#if HAS_MEDIA
5050
IF_DISABLED(HAS_SD_DETECT, card.mount());
5151

52-
if (!ExtUI::isMediaInserted()) {
52+
if (!ExtUI::isMediaMounted()) {
5353
screen.setStatusMessage(GET_TEXT_F(MSG_NO_MEDIA));
5454
return;
5555
}

β€ŽMarlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace ExtUI {
5050
screen.printerKilled(error, component);
5151
}
5252

53-
void onMediaInserted() { TERN_(HAS_MEDIA, screen.sdCardInserted()); }
53+
void onMediaMounted() { TERN_(HAS_MEDIA, screen.sdCardInserted()); }
5454
void onMediaError() { TERN_(HAS_MEDIA, screen.sdCardError()); }
5555
void onMediaRemoved() { TERN_(HAS_MEDIA, screen.sdCardRemoved()); }
5656

β€ŽMarlin/src/lcd/extui/example/example.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace ExtUI {
4848
void onIdle() {}
4949
void onPrinterKilled(FSTR_P const error, FSTR_P const component) {}
5050

51-
void onMediaInserted() {}
51+
void onMediaMounted() {}
5252
void onMediaError() {}
5353
void onMediaRemoved() {}
5454

β€ŽMarlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void StatusScreen::draw_overlay_icons(draw_mode_t what) {
244244
void StatusScreen::draw_buttons(draw_mode_t what) {
245245
int16_t x, y, h, v;
246246

247-
const bool has_media = isMediaInserted() && !isPrintingFromMedia();
247+
const bool has_media = isMediaMounted() && !isPrintingFromMedia();
248248

249249
CommandProcessor cmd;
250250
PolyUI ui(cmd, what);

0 commit comments

Comments
Β (0)