Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if DISABLED(NO_SD_AUTOSTART)
- /**
- * Run all the auto#.g files. Called:
- * - On boot after successful card init.
- * - From the LCD command to Run Auto Files
- */
- void CardReader::autofile_begin() {
- autofile_index = 1;
- (void)autofile_check();
- }
- /**
- * Run the next auto#.g file. Called:
- * - On boot after successful card init
- * - After finishing the previous auto#.g file
- * - From the LCD command to begin the auto#.g files
- *
- * Return 'true' if an auto file was started
- */
- bool CardReader::autofile_check() {
- if (!autofile_index) return false;
- if (!isMounted())
- mount();
- else if (ENABLED(SDCARD_EEPROM_EMULATION))
- settings.first_load();
- // Don't run auto#.g when a PLR file exists
- if (isMounted() && TERN1(POWER_LOSS_RECOVERY, !recovery.valid())) {
- char autoname[10];
- sprintf_P(autoname, PSTR("/auto%c.g"), '0' + autofile_index - 1);
- if (fileExists(autoname)) {
- cdroot();
- openAndPrintFile(autoname);
- // Generate a random number between 2 and 10
- int randomNumber = random(2,10);
- autofile_index = randomNumber;
- //
- return true;
- }
- }
- autofile_cancel();
- return false;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement