Fix compile warnings, serial alias

This commit is contained in:
Scott Lahteine 2020-11-13 18:27:31 -06:00
parent ddc997c81f
commit 1d43e81be0
6 changed files with 19 additions and 8 deletions

View file

@ -303,14 +303,14 @@ extern uint8_t marlin_debug_flags;
void serial_echopair_PGM(PGM_P const s_P, const char *v);
void serial_echopair_PGM(PGM_P const s_P, char v);
void serial_echopair_PGM(PGM_P const s_P, int v);
void serial_echopair_PGM(PGM_P const s_P, unsigned int v);
void serial_echopair_PGM(PGM_P const s_P, long v);
void serial_echopair_PGM(PGM_P const s_P, unsigned long v);
void serial_echopair_PGM(PGM_P const s_P, float v);
void serial_echopair_PGM(PGM_P const s_P, double v);
void serial_echopair_PGM(PGM_P const s_P, unsigned int v);
void serial_echopair_PGM(PGM_P const s_P, unsigned long v);
inline void serial_echopair_PGM(PGM_P const s_P, uint8_t v) { serial_echopair_PGM(s_P, (int)v); }
inline void serial_echopair_PGM(PGM_P const s_P, bool v) { serial_echopair_PGM(s_P, (int)v); }
inline void serial_echopair_PGM(PGM_P const s_P, void *v) { serial_echopair_PGM(s_P, (unsigned long)v); }
inline void serial_echopair_PGM(PGM_P const s_P, void *v) { serial_echopair_PGM(s_P, (uintptr_t)v); }
void serialprintPGM(PGM_P str);
void serial_echo_start();

View file

@ -30,7 +30,7 @@
* M31: Get the time since the start of SD Print (or last M109)
*/
void GcodeSuite::M31() {
char buffer[21];
char buffer[22];
duration_t(print_job_timer.duration()).toString(buffer);
ui.set_status(buffer);

View file

@ -774,9 +774,15 @@ void MarlinUI::draw_status_screen() {
mixer.update_mix_from_vtool();
mix_label = PSTR("Mx");
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-overflow"
sprintf_P(mixer_messages, PSTR(S_FMT " %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
lcd_put_u8str(X_LABEL_POS, XYZ_BASELINE, mixer_messages);
#pragma GCC diagnostic pop
#else
if (show_e_total) {

View file

@ -217,7 +217,7 @@ void DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var) {
// It is using a hex display for that: It expects BSD coded data in the format xxyyzz
void DGUSScreenHandler::DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var) {
printStatistics state = print_job_timer.getStats();
char buf[21];
char buf[22];
duration_t elapsed = state.printTime;
elapsed.toString(buf);
dgusdisplay.WriteVariable(VP_PrintAccTime, buf, var.size, true);
@ -225,7 +225,7 @@ void DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var) {
void DGUSScreenHandler::DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var) {
printStatistics state = print_job_timer.getStats();
char buf[21];
char buf[10];
sprintf_P(buf, PSTR("%u"), state.totalPrints);
dgusdisplay.WriteVariable(VP_PrintsTotal, buf, var.size, true);
}

View file

@ -106,6 +106,9 @@ struct duration_t {
return this->value;
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-overflow"
/**
* @brief Formats the duration as a string
* @details String will be formated using a "full" representation of duration
@ -127,7 +130,7 @@ struct duration_t {
m = this->minute() % 60,
s = this->second() % 60;
if (y) sprintf_P(buffer, PSTR("%iy %id %ih %im %is"), y, d, h, m, s);
if (y) sprintf_P(buffer, PSTR("%iy %id %ih %im %is"), y, d, h, m, s);
else if (d) sprintf_P(buffer, PSTR("%id %ih %im %is"), d, h, m, s);
else if (h) sprintf_P(buffer, PSTR("%ih %im %is"), h, m, s);
else if (m) sprintf_P(buffer, PSTR("%im %is"), m, s);
@ -163,4 +166,6 @@ struct duration_t {
return 6;
}
}
#pragma GCC diagnostic pop
};

View file

@ -177,7 +177,7 @@ void PrintCounter::saveStats() {
#endif
void PrintCounter::showStats() {
char buffer[21];
char buffer[22];
SERIAL_ECHOPGM(STR_STATS);
SERIAL_ECHOLNPAIR(