Skip to content

Commit

Permalink
🎨 Combine serial echos
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored and Jeremy Fairbanks committed Jul 18, 2022
1 parent 7146d42 commit ababe25
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 55 deletions.
36 changes: 12 additions & 24 deletions Marlin/src/HAL/DUE/eeprom_flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ static bool ee_PageWrite(uint16_t page, const void *data) {
for (i = 0; i <PageSize >> 2; i++)
pageContents[i] = (((uint32_t*)data)[i]) | (~(pageContents[i] ^ ((uint32_t*)data)[i]));

DEBUG_ECHO_START();
DEBUG_ECHOLNPGM("EEPROM PageWrite ", page);
DEBUG_ECHO_MSG("EEPROM PageWrite ", page);
DEBUG_ECHOLNPGM(" in FLASH address ", (uint32_t)addrflash);
DEBUG_ECHOLNPGM(" base address ", (uint32_t)getFlashStorage(0));
DEBUG_FLUSH();
Expand Down Expand Up @@ -245,8 +244,7 @@ static bool ee_PageWrite(uint16_t page, const void *data) {
// Reenable interrupts
__enable_irq();

DEBUG_ECHO_START();
DEBUG_ECHOLNPGM("EEPROM Unlock failure for page ", page);
DEBUG_ECHO_MSG("EEPROM Unlock failure for page ", page);
return false;
}

Expand All @@ -270,8 +268,7 @@ static bool ee_PageWrite(uint16_t page, const void *data) {
// Reenable interrupts
__enable_irq();

DEBUG_ECHO_START();
DEBUG_ECHOLNPGM("EEPROM Write failure for page ", page);
DEBUG_ECHO_MSG("EEPROM Write failure for page ", page);

return false;
}
Expand All @@ -286,8 +283,7 @@ static bool ee_PageWrite(uint16_t page, const void *data) {
if (memcmp(getFlashStorage(page),data,PageSize)) {

#ifdef EE_EMU_DEBUG
DEBUG_ECHO_START();
DEBUG_ECHOLNPGM("EEPROM Verify Write failure for page ", page);
DEBUG_ECHO_MSG("EEPROM Verify Write failure for page ", page);

ee_Dump( page, (uint32_t *)addrflash);
ee_Dump(-page, data);
Expand Down Expand Up @@ -325,8 +321,7 @@ static bool ee_PageErase(uint16_t page) {
uint16_t i;
uint32_t addrflash = uint32_t(getFlashStorage(page));

DEBUG_ECHO_START();
DEBUG_ECHOLNPGM("EEPROM PageErase ", page);
DEBUG_ECHO_MSG("EEPROM PageErase ", page);
DEBUG_ECHOLNPGM(" in FLASH address ", (uint32_t)addrflash);
DEBUG_ECHOLNPGM(" base address ", (uint32_t)getFlashStorage(0));
DEBUG_FLUSH();
Expand Down Expand Up @@ -370,8 +365,7 @@ static bool ee_PageErase(uint16_t page) {
// Reenable interrupts
__enable_irq();

DEBUG_ECHO_START();
DEBUG_ECHOLNPGM("EEPROM Unlock failure for page ",page);
DEBUG_ECHO_MSG("EEPROM Unlock failure for page ",page);

return false;
}
Expand All @@ -394,8 +388,7 @@ static bool ee_PageErase(uint16_t page) {
// Reenable interrupts
__enable_irq();

DEBUG_ECHO_START();
DEBUG_ECHOLNPGM("EEPROM Erase failure for page ",page);
DEBUG_ECHO_MSG("EEPROM Erase failure for page ",page);

return false;
}
Expand All @@ -410,8 +403,7 @@ static bool ee_PageErase(uint16_t page) {
uint32_t * aligned_src = (uint32_t *) addrflash;
for (i = 0; i < PageSize >> 2; i++) {
if (*aligned_src++ != 0xFFFFFFFF) {
DEBUG_ECHO_START();
DEBUG_ECHOLNPGM("EEPROM Verify Erase failure for page ",page);
DEBUG_ECHO_MSG("EEPROM Verify Erase failure for page ",page);
ee_Dump(page, (uint32_t *)addrflash);
return false;
}
Expand Down Expand Up @@ -921,8 +913,7 @@ static void ee_Init() {
// If all groups seem to be used, default to first group
if (curGroup >= GroupCount) curGroup = 0;

DEBUG_ECHO_START();
DEBUG_ECHOLNPGM("EEPROM Current Group: ",curGroup);
DEBUG_ECHO_MSG("EEPROM Current Group: ",curGroup);
DEBUG_FLUSH();

// Now, validate that all the other group pages are empty
Expand All @@ -931,8 +922,7 @@ static void ee_Init() {

for (int page = 0; page < PagesPerGroup; page++) {
if (!ee_IsPageClean(grp * PagesPerGroup + page)) {
DEBUG_ECHO_START();
DEBUG_ECHOLNPGM("EEPROM Page ", page, " not clean on group ", grp);
DEBUG_ECHO_MSG("EEPROM Page ", page, " not clean on group ", grp);
DEBUG_FLUSH();
ee_PageErase(grp * PagesPerGroup + page);
}
Expand All @@ -948,15 +938,13 @@ static void ee_Init() {
}
}

DEBUG_ECHO_START();
DEBUG_ECHOLNPGM("EEPROM Active page: ", curPage);
DEBUG_ECHO_MSG("EEPROM Active page: ", curPage);
DEBUG_FLUSH();

// Make sure the pages following the first clean one are also clean
for (int page = curPage + 1; page < PagesPerGroup; page++) {
if (!ee_IsPageClean(curGroup * PagesPerGroup + page)) {
DEBUG_ECHO_START();
DEBUG_ECHOLNPGM("EEPROM Page ", page, " not clean on active group ", curGroup);
DEBUG_ECHO_MSG("EEPROM Page ", page, " not clean on active group ", curGroup);
DEBUG_FLUSH();
ee_Dump(curGroup * PagesPerGroup + page, getFlashStorage(curGroup * PagesPerGroup + page));
ee_PageErase(curGroup * PagesPerGroup + page);
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/feature/mmu/mmu2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,8 +1031,7 @@ void MMU2::execute_extruder_sequence(const E_Step * sequence, int steps) {
const float es = pgm_read_float(&(step->extrude));
const feedRate_t fr_mm_m = pgm_read_float(&(step->feedRate));

DEBUG_ECHO_START();
DEBUG_ECHOLNPGM("E step ", es, "/", fr_mm_m);
DEBUG_ECHO_MSG("E step ", es, "/", fr_mm_m);

current_position.e += es;
line_to_current_position(MMM_TO_MMS(fr_mm_m));
Expand Down
14 changes: 7 additions & 7 deletions Marlin/src/gcode/probe/M951.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ mpe_settings_t mpe_settings;

inline void mpe_settings_report() {
SERIAL_ECHO_MSG("Magnetic Parking Extruder");
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("L: Left parking :", mpe_settings.parking_xpos[0]);
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("R: Right parking :", mpe_settings.parking_xpos[1]);
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("I: Grab Offset :", mpe_settings.grab_distance);
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("J: Normal speed :", long(MMS_TO_MMM(mpe_settings.slow_feedrate)));
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("H: High speed :", long(MMS_TO_MMM(mpe_settings.fast_feedrate)));
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("D: Distance trav.:", mpe_settings.travel_distance);
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("C: Compenstion :", mpe_settings.compensation_factor);
SERIAL_ECHO_MSG("L: Left parking :", mpe_settings.parking_xpos[0]);
SERIAL_ECHO_MSG("R: Right parking :", mpe_settings.parking_xpos[1]);
SERIAL_ECHO_MSG("I: Grab Offset :", mpe_settings.grab_distance);
SERIAL_ECHO_MSG("J: Normal speed :", long(MMS_TO_MMM(mpe_settings.slow_feedrate)));
SERIAL_ECHO_MSG("H: High speed :", long(MMS_TO_MMM(mpe_settings.fast_feedrate)));
SERIAL_ECHO_MSG("D: Distance trav.:", mpe_settings.travel_distance);
SERIAL_ECHO_MSG("C: Compenstion :", mpe_settings.compensation_factor);
}

void mpe_settings_init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ bool UIFlashStorage::is_present = false;

if (!is_known) {
SERIAL_ECHO_MSG("Unable to locate supported SPI Flash Memory.");
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(" Manufacturer ID, got: ", manufacturer_id);
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(" Device Type , got: ", device_type);
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(" Capacity , got: ", capacity);
SERIAL_ECHO_MSG(" Manufacturer ID, got: ", manufacturer_id);
SERIAL_ECHO_MSG(" Device Type , got: ", device_type);
SERIAL_ECHO_MSG(" Capacity , got: ", capacity);
}

return is_known;
Expand Down Expand Up @@ -247,7 +247,7 @@ bool UIFlashStorage::is_present = false;
case 0xFFFFFFFFul: return read_offset;
case delimiter: read_offset = offset; break;
default:
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("Invalid delimiter in Flash: ", delim);
SERIAL_ECHO_MSG("Invalid delimiter in Flash: ", delim);
return -1;
}
}
Expand Down Expand Up @@ -325,8 +325,7 @@ bool UIFlashStorage::is_present = false;
}

SERIAL_ECHO_START();
SERIAL_ECHOPGM("Writing UI settings to SPI Flash (offset ", write_addr);
SERIAL_ECHOPGM(")...");
SERIAL_ECHOPGM("Writing UI settings to SPI Flash (offset ", write_addr, ")...");

const uint32_t delim = delimiter;
write_addr = write(write_addr, &delim, sizeof(delim));
Expand Down Expand Up @@ -509,7 +508,7 @@ bool UIFlashStorage::is_present = false;

bytes_remaining = get_media_file_size(slot);
if (bytes_remaining != 0xFFFFFFFFUL) {
SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("Boot media file size:", bytes_remaining);
SERIAL_ECHO_MSG("Boot media file size:", bytes_remaining);
addr = get_media_file_start(slot);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1024,9 +1024,7 @@ template <class T> bool CLCD::CommandFifo::write(T data, uint16_t len) {
uint16_t Command_Space = mem_read_32(REG::CMDB_SPACE) & 0x0FFF;
if (Command_Space < (len + padding)) {
#if ENABLED(TOUCH_UI_DEBUG)
SERIAL_ECHO_START();
SERIAL_ECHOPGM("Waiting for ", len + padding);
SERIAL_ECHOLNPGM(" bytes in command queue, now free: ", Command_Space);
SERIAL_ECHO_MSG("Waiting for ", len + padding, " bytes in command queue, now free: ", Command_Space);
#endif
do {
Command_Space = mem_read_32(REG::CMDB_SPACE) & 0x0FFF;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,15 @@ bool DLCache::store(uint32_t min_bytes /* = 0*/) {
if (dl_size > dl_slot_size) {
// Not enough memory to cache the display list.
#if ENABLED(TOUCH_UI_DEBUG)
SERIAL_ECHO_START();
SERIAL_ECHOPGM ("Not enough space in GRAM to cache display list, free space: ", dl_slot_size);
SERIAL_ECHOLNPGM(" Required: ", dl_size);
SERIAL_ECHO_MSG("Not enough space in GRAM to cache display list, free space: ", dl_slot_size, " Required: ", dl_size);
#endif
dl_slot_used = 0;
save_slot();
return false;
}
else {
#if ENABLED(TOUCH_UI_DEBUG)
SERIAL_ECHO_START();
SERIAL_ECHOPGM ("Saving DL to RAMG cache, bytes: ", dl_slot_used);
SERIAL_ECHOLNPGM(" Free space: ", dl_slot_size);
SERIAL_ECHO_MSG("Saving DL to RAMG cache, bytes: ", dl_slot_used, " Free space: ", dl_slot_size);
#endif
dl_slot_used = dl_size;
save_slot();
Expand All @@ -160,9 +156,9 @@ void DLCache::save_slot(uint8_t indx, uint32_t addr, uint16_t size, uint16_t use
}

void DLCache::load_slot(uint8_t indx, uint32_t &addr, uint16_t &size, uint16_t &used) {
addr = CLCD::mem_read_32(DL_CACHE_START + indx * 12 + 0);
size = CLCD::mem_read_32(DL_CACHE_START + indx * 12 + 4);
used = CLCD::mem_read_32(DL_CACHE_START + indx * 12 + 8);
addr = CLCD::mem_read_32(DL_CACHE_START + indx * 12 + 0);
size = CLCD::mem_read_32(DL_CACHE_START + indx * 12 + 4);
used = CLCD::mem_read_32(DL_CACHE_START + indx * 12 + 8);
}

void DLCache::append() {
Expand All @@ -171,9 +167,7 @@ void DLCache::append() {
#if ENABLED(TOUCH_UI_DEBUG)
cmd.execute();
wait_until_idle();
SERIAL_ECHO_START();
SERIAL_ECHOPGM ("Appending to DL from RAMG cache, bytes: ", dl_slot_used);
SERIAL_ECHOLNPGM(" REG_CMD_DL: ", CLCD::mem_read_32(REG::CMD_DL));
SERIAL_ECHO_MSG("Appending to DL from RAMG cache, bytes: ", dl_slot_used, " REG_CMD_DL: ", CLCD::mem_read_32(REG::CMD_DL));
#endif
}

Expand Down

0 comments on commit ababe25

Please sign in to comment.