Refactor serial class with templates (#20783)

This commit is contained in:
X-Ryl669
2021-01-28 09:02:06 +01:00
committed by GitHub
parent c929fb52dd
commit 3f01b222b2
64 changed files with 782 additions and 948 deletions

View File

@ -550,12 +550,11 @@ void openFailed(const char * const fname) {
void announceOpen(const uint8_t doing, const char * const path) {
if (doing) {
PORT_REDIRECT(SERIAL_BOTH);
PORT_REDIRECT(SERIAL_ALL);
SERIAL_ECHO_START();
SERIAL_ECHOPGM("Now ");
serialprintPGM(doing == 1 ? PSTR("doing") : PSTR("fresh"));
SERIAL_ECHOLNPAIR(" file: ", path);
PORT_RESTORE();
}
}
@ -617,10 +616,11 @@ void CardReader::openFileRead(char * const path, const uint8_t subcall_type/*=0*
filesize = file.fileSize();
sdpos = 0;
PORT_REDIRECT(SERIAL_BOTH);
SERIAL_ECHOLNPAIR(STR_SD_FILE_OPENED, fname, STR_SD_SIZE, filesize);
SERIAL_ECHOLNPGM(STR_SD_FILE_SELECTED);
PORT_RESTORE();
{ // Don't remove this block, as the PORT_REDIRECT is a RAII
PORT_REDIRECT(SERIAL_ALL);
SERIAL_ECHOLNPAIR(STR_SD_FILE_OPENED, fname, STR_SD_SIZE, filesize);
SERIAL_ECHOLNPGM(STR_SD_FILE_SELECTED);
}
selectFileByName(fname);
ui.set_status(longFilename[0] ? longFilename : fname);

View File

@ -174,7 +174,7 @@ public:
#if ENABLED(AUTO_REPORT_SD_STATUS)
static void auto_report_sd_status();
static inline void set_auto_report_interval(uint8_t v) {
TERN_(HAS_MULTI_SERIAL, auto_report_port = serial_port_index);
TERN_(HAS_MULTI_SERIAL, auto_report_port = serialHook.portMask);
NOMORE(v, 60);
auto_report_sd_interval = v;
next_sd_report_ms = millis() + 1000UL * v;