Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,8 @@
#if ENABLED(MULTI_VOLUME)
#define VOLUME_SD_ONBOARD
#define VOLUME_USB_FLASH_DRIVE
#define DEFAULT_SHARED_VOLUME SV_USB_FLASH_DRIVE
#define DEFAULT_VOLUME SD_ONBOARD // :[ 'SD_ONBOARD', 'USB_FLASH_DRIVE' ]
#define DEFAULT_SHARED_VOLUME USB_FLASH_DRIVE // :[ 'SD_ONBOARD', 'USB_FLASH_DRIVE' ]
#endif

#endif // HAS_MEDIA
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/HAL/STM32/sd/msc_sd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
class Sd2CardUSBMscHandler : public USBMscHandler {
public:
DiskIODriver* diskIODriver() {
// TODO: Explore a variable shared volume, or auto share the un-mounted volume(s)
#if HAS_MULTI_VOLUME
#if SHARED_VOLUME_IS(SD_ONBOARD)
return &card.media_driver_sdcard;
Expand Down
7 changes: 5 additions & 2 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1349,8 +1349,11 @@ void setup() {
#endif
#endif

#if HAS_MEDIA && ANY(SDCARD_EEPROM_EMULATION, POWER_LOSS_RECOVERY)
SETUP_RUN(card.mount()); // Mount media with settings before first_load
#if HAS_MEDIA
SETUP_RUN(card.init()); // Prepare for media usage
#if ANY(SDCARD_EEPROM_EMULATION, POWER_LOSS_RECOVERY)
SETUP_RUN(card.mount()); // Mount media with settings before first_load
#endif
#endif

// Prepare some LCDs to display early
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/password/password.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ uint32_t Password::value, Password::value_entry;

//
// Authenticate user with password.
// Called from Setup, after SD Prinitng Stops/Aborts, and M510
// Called from Setup, after SD Printing Stops/Aborts, and M510
//
void Password::lock_machine() {
is_locked = true;
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/feature/password/password.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class Password {
static void access_menu_password();
static void authentication_done();
static void media_gatekeeper();
static void media_gatekeeper_sd();
static void media_gatekeeper_usb();

private:
static void authenticate_user(const screenFunc_t, const screenFunc_t);
Expand Down
28 changes: 28 additions & 0 deletions Marlin/src/inc/Changes.h
Original file line number Diff line number Diff line change
Expand Up @@ -799,3 +799,31 @@
#undef _POWERSTEP01
#undef _TMC26X
#undef _TMC26X_STANDALONE

#if ENABLED(MULTI_VOLUME)
// Change to a generic ID without SV_ prefix
#define SV_SD_ONBOARD 201
#define SV_USB_FLASH_DRIVE 202
#if DEFAULT_VOLUME_IS(SV_SD_ONBOARD) || SHARED_VOLUME_IS(SV_SD_ONBOARD)
#error "SV_SD_ONBOARD is now SD_ONBOARD."
#elif DEFAULT_VOLUME_IS(SV_USB_FLASH_DRIVE) || SHARED_VOLUME_IS(SV_USB_FLASH_DRIVE)
#error "SV_USB_FLASH_DRIVE is now USB_FLASH_DRIVE."
#endif
// Skip less clear "bad value" errors in inc/SanityCheck.h
#if DEFAULT_VOLUME_IS(SV_SD_ONBOARD)
#undef DEFAULT_VOLUME
#define DEFAULT_VOLUME SD_ONBOARD
#elif DEFAULT_VOLUME_IS(SV_USB_FLASH_DRIVE)
#undef DEFAULT_VOLUME
#define DEFAULT_VOLUME USB_FLASH_DRIVE
#endif
#if SHARED_VOLUME_IS(SV_SD_ONBOARD)
#undef DEFAULT_SHARED_VOLUME
#define DEFAULT_SHARED_VOLUME SD_ONBOARD
#elif SHARED_VOLUME_IS(SV_USB_FLASH_DRIVE)
#undef DEFAULT_SHARED_VOLUME
#define DEFAULT_SHARED_VOLUME USB_FLASH_DRIVE
#endif
#undef SV_SD_ONBOARD
#undef SV_USB_FLASH_DRIVE
#endif
9 changes: 5 additions & 4 deletions Marlin/src/inc/Conditionals-4-adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1248,11 +1248,12 @@

#if ENABLED(MULTI_VOLUME)
#define HAS_MULTI_VOLUME 1
#define SV_SD_ONBOARD 101
#define SV_USB_FLASH_DRIVE 102
#define _VOLUME_ID(N) _CAT(SV_, N)
#define SHARED_VOLUME_IS(N) (DEFAULT_SHARED_VOLUME == _VOLUME_ID(N))
#define SD_ONBOARD 101
#define USB_FLASH_DRIVE 102
#define DEFAULT_VOLUME_IS(N) (DEFAULT_VOLUME == N)
#define SHARED_VOLUME_IS(N) (DEFAULT_SHARED_VOLUME == N)
#else
#define DEFAULT_VOLUME_IS(...) 0
#define SHARED_VOLUME_IS(...) 0
#endif

Expand Down
16 changes: 13 additions & 3 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,20 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
/**
* SD Card Settings
*/
#if ALL(HAS_MEDIA, HAS_SD_DETECT, SD_CONNECTION_TYPICAL, ELB_FULL_GRAPHIC_CONTROLLER, HAS_MARLINUI_MENU) && SD_DETECT_STATE == LOW
#error "SD_DETECT_STATE must be set HIGH for SD on the ELB_FULL_GRAPHIC_CONTROLLER."
#if HAS_MEDIA
#if HAS_MULTI_VOLUME
#if !(DEFAULT_VOLUME_IS(SD_ONBOARD) || DEFAULT_VOLUME_IS(USB_FLASH_DRIVE))
#error "DEFAULT_VOLUME must be either SD_ONBOARD or USB_FLASH_DRIVE."
#endif
#if !(SHARED_VOLUME_IS(SD_ONBOARD) || SHARED_VOLUME_IS(USB_FLASH_DRIVE))
#error "DEFAULT_SHARED_VOLUME must be either SD_ONBOARD or USB_FLASH_DRIVE."
#endif
#endif
#if ALL(ELB_FULL_GRAPHIC_CONTROLLER, HAS_MARLINUI_MENU, SD_CONNECTION_TYPICAL, HAS_SD_DETECT) && SD_DETECT_STATE == LOW
#error "SD_DETECT_STATE must be set HIGH for SD on the ELB_FULL_GRAPHIC_CONTROLLER."
#endif
#undef SD_CONNECTION_TYPICAL
#endif
#undef SD_CONNECTION_TYPICAL

/**
* SD File Sorting
Expand Down
8 changes: 2 additions & 6 deletions Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ void TFTGLCD::clr_screen() {
SPI_SEND_ONE(CLR_SCREEN);
WRITE(TFTGLCD_CS, HIGH);
#else
Wire.beginTransmission(uint8_t(LCD_I2C_ADDRESS)); //set I2C device address
Wire.beginTransmission(uint8_t(LCD_I2C_ADDRESS)); // Transmit to LCD via I2C
Wire.write(CLR_SCREEN);
Wire.endTransmission(); //transmit data
Wire.endTransmission(); // Send the data
#endif
}

Expand Down Expand Up @@ -378,10 +378,6 @@ void MarlinUI::clear_for_drawing() { clear_lcd(); }
void MarlinUI::_set_contrast() { lcd.setContrast(contrast); }
#endif

#if !IS_TFTGLCD_PANEL
void lcd_moveto(const uint8_t col, const uint8_t row) { lcd.setCursor(col, row); }
#endif

static void center_text(FSTR_P const fstart, const uint8_t y) {
const uint8_t len = utf8_strlen(fstart);
lcd_moveto(len < LCD_WIDTH ? (LCD_WIDTH - len) / 2 : 0, y);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ void ChironTFT::panelAction(uint8_t req) {
break;

case 26: // A26 Refresh SD
if (card.isMounted())card.release();
card.release();
card.mount();
safe_delay(500);
filenavigator.reset();
Expand Down
24 changes: 4 additions & 20 deletions Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,32 +131,16 @@ void tft_lvgl_init() {
// Init TFT first!
SPI_TFT.spiInit(SPI_FULL_SPEED);
SPI_TFT.lcdInit();

hal.watchdog_refresh(); // LVGL init takes time

#if HAS_USB_FLASH_DRIVE
#if HAS_MULTI_VOLUME && !HAS_SD_HOST_DRIVE
if (card.isSDCardInserted())
card.selectMediaSDCard();
else
card.selectMediaFlashDrive();
#endif
// Wait up to two seconds for USB Drive to mount
for (uint16_t usb_flash_loop = 500; --usb_flash_loop;) {
hal.watchdog_refresh();
card.media_driver_usbFlash.idle();
delay(4);
if (card.media_driver_usbFlash.isInserted()) break;
}
card.mount();
#elif HAS_LOGO_IN_FLASH
#if HAS_LOGO_IN_FLASH
// Leave the boot screen visible for a moment
delay(1000);
hal.watchdog_refresh();
hal.watchdog_refresh(); // LVGL init takes time
delay(1000);
hal.watchdog_refresh(); // LVGL init takes time
#endif

hal.watchdog_refresh(); // LVGL init takes time

#if HAS_MEDIA
UpdateAssets();
hal.watchdog_refresh(); // LVGL init takes time
Expand Down
9 changes: 7 additions & 2 deletions Marlin/src/lcd/language/language_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -574,10 +574,8 @@ namespace LanguageNarrow_en {
LSTR MSG_CANCEL_OBJECT = _UxGT("Cancel Obj");
LSTR MSG_CANCEL_OBJECT_N = _UxGT("Cancel Obj {");
LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Continue Job");
LSTR MSG_MEDIA_MENU = MEDIA_TYPE_EN _UxGT(" Print");
LSTR MSG_TURN_OFF = _UxGT("Turn off now");
LSTR MSG_END_LOOPS = _UxGT("End Loops");
LSTR MSG_NO_MEDIA = _UxGT("No ") MEDIA_TYPE_EN;
LSTR MSG_DWELL = _UxGT("Sleep...");
LSTR MSG_USERWAIT = _UxGT("Click to Resume...");
LSTR MSG_PRINT_PAUSED = _UxGT("Print Paused");
Expand Down Expand Up @@ -641,6 +639,10 @@ namespace LanguageNarrow_en {
LSTR MSG_RUN_AUTOFILES = _UxGT("Run Autofiles");
LSTR MSG_RUN_AUTOFILES_SD = _UxGT("Run SD Autofiles");
LSTR MSG_RUN_AUTOFILES_USB = _UxGT("Run USB Autofiles");
LSTR MSG_MEDIA_MENU = MEDIA_TYPE_EN _UxGT(" Print");
LSTR MSG_MEDIA_MENU_SD = _UxGT("Select from SD");
LSTR MSG_MEDIA_MENU_USB = _UxGT("Select from USB");
LSTR MSG_NO_MEDIA = _UxGT("No ") MEDIA_TYPE_EN _UxGT(" Detected");

LSTR MSG_ZPROBE_OUT = _UxGT("Z Probe Past Bed");
LSTR MSG_SKEW_FACTOR = _UxGT("Skew Factor");
Expand Down Expand Up @@ -1130,6 +1132,9 @@ namespace LanguageWide_en {
LSTR MSG_CANCEL_OBJECT_N = _UxGT("Cancel Object {");
LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Continue Print Job");
LSTR MSG_MEDIA_MENU = _UxGT("Select from ") MEDIA_TYPE_EN;
LSTR MSG_MEDIA_MENU_SD = _UxGT("Select from SD Card");
LSTR MSG_MEDIA_MENU_USB = _UxGT("Select from USB Drive");
LSTR MSG_NO_MEDIA = _UxGT("No ") MEDIA_TYPE_EN _UxGT(" Found");
LSTR MSG_TURN_OFF = _UxGT("Turn off the printer");
LSTR MSG_END_LOOPS = _UxGT("End Repeat Loops");
LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("No media inserted."); // ProUI
Expand Down
36 changes: 28 additions & 8 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1891,40 +1891,60 @@ uint8_t expand_u8str_P(char * const outstr, PGM_P const ptpl, const int8_t ind,
#include "extui/ui_api.h"
#endif

void MarlinUI::media_changed(const uint8_t old_status, const uint8_t status) {
void MarlinUI::media_changed(const MediaPresence old_status, const MediaPresence status) {
TERN_(HAS_DISPLAY_SLEEP, refresh_screen_timeout());
if (old_status == status) {
TERN_(EXTENSIBLE_UI, ExtUI::onMediaError()); // Failed to mount/unmount
return;
}

if (old_status < 2) { // Skip this section on first boot check
if (status) { // Media Mounted
if (old_status > MEDIA_BOOT) { // Skip this section on first boot check

if (status > old_status) { // Media Mounted

#if ENABLED(EXTENSIBLE_UI)

ExtUI::onMediaMounted();

#elif ENABLED(BROWSE_MEDIA_ON_INSERT)

clear_menu_history();
quick_feedback();
goto_screen(MEDIA_MENU_GATEWAY);

#else

if (card.isSDCardSelected())
LCD_MESSAGE(MSG_MEDIA_INSERTED_SD);
else if (card.isFlashDriveSelected())
LCD_MESSAGE(MSG_MEDIA_INSERTED_USB);
else
LCD_MESSAGE(MSG_MEDIA_INSERTED);

#endif
}
else { // Media Removed

#if ENABLED(EXTENSIBLE_UI)

ExtUI::onMediaRemoved();
#elif HAS_SD_DETECT // Q: Does "Media Removed" need to be shown for manual release too?
LCD_MESSAGE(MSG_MEDIA_REMOVED);
#if HAS_MARLINUI_MENU
if (ENABLED(HAS_WIRED_LCD) || !defer_return_to_status) return_to_status();
#endif

#elif HAS_SD_DETECT || HAS_USB_FLASH_DRIVE // Q: Does "Media Removed" need to be shown for manual release too?

if ((old_status ^ status) & INSERT_SD)
LCD_MESSAGE(MSG_MEDIA_REMOVED_SD);
else if ((old_status ^ status) & INSERT_USB)
LCD_MESSAGE(MSG_MEDIA_REMOVED_USB);
else
LCD_MESSAGE(MSG_MEDIA_REMOVED);

if (ENABLED(HAS_WIRED_LCD) || !defer_return_to_status)
return_to_status();

#elif HAS_WIRED_LCD

return_to_status();

#endif
}
}
Expand Down
8 changes: 5 additions & 3 deletions Marlin/src/lcd/marlinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,10 @@ class MarlinUI {
#endif

#if HAS_MEDIA
#define MEDIA_MENU_GATEWAY TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper, menu_media)
static void media_changed(const uint8_t old_stat, const uint8_t stat);
#define MEDIA_MENU_GATEWAY TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper, menu_file_selector)
#define MEDIA_MENU_GATEWAY_SD TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper_sd, menu_file_selector_sd)
#define MEDIA_MENU_GATEWAY_USB TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper_usb, menu_file_selector_usb)
static void media_changed(const MediaPresence old_stat, const MediaPresence stat);
#endif

#if HAS_LCD_BRIGHTNESS
Expand Down Expand Up @@ -864,7 +866,7 @@ class MarlinUI {
TERN_(REVERSE_SELECT_DIRECTION, encoderDirection = -(ENCODERBASE));
}

#else
#else // !HAS_ENCODER_ACTION

static void update_buttons() {}
static bool hw_button_pressed() { return false; }
Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/lcd/menu/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ void menu_move();

#if HAS_MEDIA
void menu_file_selector();
void menu_media();
void menu_file_selector_sd();
void menu_file_selector_usb();
#endif

////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/lcd/menu/menu_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ class MenuItem_bool : public MenuEditItemBase {
* should be done before the menu loop (START_MENU / START_SCREEN).
*/

// CAUTION! When using menu items in a lambda or sub-function always use:
#define INJECT_MENU_ITEMS(FN) { FN; if (ui.screen_changed) return; }

/**
* SCREEN_OR_MENU_LOOP generates header code for a screen or menu
*
Expand Down
Loading
Loading