Skip to content

Commit

Permalink
Merge pull request #4256 from thinkyhead/rc_fix_singlenozzle_temp
Browse files Browse the repository at this point in the history
Additional tweaks for HOTENDS == 1
  • Loading branch information
thinkyhead authored Jul 11, 2016
2 parents 5b87dee + ee0983a commit 5b0e46c
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 169 deletions.
125 changes: 61 additions & 64 deletions Marlin/M100_Free_Mem_Chk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ void prt_hex_byte(unsigned int);
void prt_hex_word(unsigned int);
int how_many_E5s_are_here(unsigned char*);




void gcode_M100() {
static int m100_not_initialized = 1;
unsigned char* sp, *ptr;
Expand All @@ -73,49 +70,49 @@ void gcode_M100() {
// probably caused by bad pointers. Any unexpected values will be flagged in
// the right hand column to help spotting them.
//
#if ENABLED(M100_FREE_MEMORY_DUMPER) // Disable to remove Dump sub-command
if (code_seen('D')) {
ptr = (unsigned char*) __brkval;
//
// We want to start and end the dump on a nice 16 byte boundry even though
// the values we are using are not 16 byte aligned.
//
SERIAL_ECHOPGM("\n__brkval : ");
prt_hex_word((unsigned int) ptr);
ptr = (unsigned char*)((unsigned long) ptr & 0xfff0);
sp = top_of_stack();
SERIAL_ECHOPGM("\nStack Pointer : ");
prt_hex_word((unsigned int) sp);
SERIAL_EOL;
sp = (unsigned char*)((unsigned long) sp | 0x000f);
n = sp - ptr;
//
// This is the main loop of the Dump command.
//
while (ptr < sp) {
prt_hex_word((unsigned int) ptr); // Print the address
SERIAL_CHAR(':');
for (i = 0; i < 16; i++) { // and 16 data bytes
prt_hex_byte(*(ptr + i));
SERIAL_CHAR(' ');
delay(2);
}
SERIAL_CHAR('|'); // now show where non 0xE5's are
for (i = 0; i < 16; i++) {
delay(2);
if (*(ptr + i) == 0xe5)
#if ENABLED(M100_FREE_MEMORY_DUMPER) // Disable to remove Dump sub-command
if (code_seen('D')) {
ptr = (unsigned char*) __brkval;
//
// We want to start and end the dump on a nice 16 byte boundry even though
// the values we are using are not 16 byte aligned.
//
SERIAL_ECHOPGM("\n__brkval : ");
prt_hex_word((unsigned int) ptr);
ptr = (unsigned char*)((unsigned long) ptr & 0xfff0);
sp = top_of_stack();
SERIAL_ECHOPGM("\nStack Pointer : ");
prt_hex_word((unsigned int) sp);
SERIAL_EOL;
sp = (unsigned char*)((unsigned long) sp | 0x000f);
n = sp - ptr;
//
// This is the main loop of the Dump command.
//
while (ptr < sp) {
prt_hex_word((unsigned int) ptr); // Print the address
SERIAL_CHAR(':');
for (i = 0; i < 16; i++) { // and 16 data bytes
prt_hex_byte(*(ptr + i));
SERIAL_CHAR(' ');
else
SERIAL_CHAR('?');
delay(2);
}
SERIAL_CHAR('|'); // now show where non 0xE5's are
for (i = 0; i < 16; i++) {
delay(2);
if (*(ptr + i) == 0xe5)
SERIAL_CHAR(' ');
else
SERIAL_CHAR('?');
}
SERIAL_EOL;
ptr += 16;
delay(2);
}
SERIAL_EOL;
ptr += 16;
delay(2);
SERIAL_ECHOLNPGM("Done.");
return;
}
SERIAL_ECHOLNPGM("Done.");
return;
}
#endif
#endif
//
// M100 F requests the code to return the number of free bytes in the memory pool along with
// other vital statistics that define the memory pool.
Expand Down Expand Up @@ -158,28 +155,28 @@ void gcode_M100() {
// M100 C x Corrupts x locations in the free memory pool and reports the locations of the corruption.
// This is useful to check the correctness of the M100 D and the M100 F commands.
//
#if ENABLED(M100_FREE_MEMORY_CORRUPTOR)
if (code_seen('C')) {
int x = code_value_int(); // x gets the # of locations to corrupt within the memory pool
SERIAL_ECHOLNPGM("Corrupting free memory block.\n");
ptr = (unsigned char*) __brkval;
SERIAL_ECHOPAIR("\n__brkval : ", ptr);
ptr += 8;
sp = top_of_stack();
SERIAL_ECHOPAIR("\nStack Pointer : ", sp);
SERIAL_ECHOLNPGM("\n");
n = sp - ptr - 64; // -64 just to keep us from finding interrupt activity that
// has altered the stack.
j = n / (x + 1);
for (i = 1; i <= x; i++) {
*(ptr + (i * j)) = i;
SERIAL_ECHOPGM("\nCorrupting address: 0x");
prt_hex_word((unsigned int)(ptr + (i * j)));
#if ENABLED(M100_FREE_MEMORY_CORRUPTOR)
if (code_seen('C')) {
int x = code_value_int(); // x gets the # of locations to corrupt within the memory pool
SERIAL_ECHOLNPGM("Corrupting free memory block.\n");
ptr = (unsigned char*) __brkval;
SERIAL_ECHOPAIR("\n__brkval : ", ptr);
ptr += 8;
sp = top_of_stack();
SERIAL_ECHOPAIR("\nStack Pointer : ", sp);
SERIAL_ECHOLNPGM("\n");
n = sp - ptr - 64; // -64 just to keep us from finding interrupt activity that
// has altered the stack.
j = n / (x + 1);
for (i = 1; i <= x; i++) {
*(ptr + (i * j)) = i;
SERIAL_ECHOPGM("\nCorrupting address: 0x");
prt_hex_word((unsigned int)(ptr + (i * j)));
}
SERIAL_ECHOLNPGM("\n");
return;
}
SERIAL_ECHOLNPGM("\n");
return;
}
#endif
#endif
//
// M100 I Initializes the free memory pool so it can be watched and prints vital
// statistics that define the free memory pool.
Expand Down
19 changes: 10 additions & 9 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4365,7 +4365,7 @@ inline void gcode_M104() {
SERIAL_PROTOCOL_F(thermalManager.degTargetBed(), 1);
#endif
#if HOTENDS > 1
for (int8_t e = 0; e < HOTENDS; ++e) {
HOTEND_LOOP() {
SERIAL_PROTOCOLPGM(" T");
SERIAL_PROTOCOL(e);
SERIAL_PROTOCOLCHAR(':');
Expand All @@ -4391,7 +4391,7 @@ inline void gcode_M104() {
SERIAL_PROTOCOL(thermalManager.getHeaterPower(target_extruder));
#endif
#if HOTENDS > 1
for (int8_t e = 0; e < HOTENDS; ++e) {
HOTEND_LOOP() {
SERIAL_PROTOCOLPGM(" @");
SERIAL_PROTOCOL(e);
SERIAL_PROTOCOLCHAR(':');
Expand All @@ -4410,13 +4410,13 @@ inline void gcode_M104() {
SERIAL_PROTOCOLPGM("C->");
SERIAL_PROTOCOL_F(thermalManager.rawBedTemp() / OVERSAMPLENR, 0);
#endif
for (int8_t cur_hotend = 0; cur_hotend < HOTENDS; ++cur_hotend) {
HOTEND_LOOP() {
SERIAL_PROTOCOLPGM(" T");
SERIAL_PROTOCOL(cur_hotend);
SERIAL_PROTOCOL(e);
SERIAL_PROTOCOLCHAR(':');
SERIAL_PROTOCOL_F(thermalManager.degHotend(cur_hotend), 1);
SERIAL_PROTOCOL_F(thermalManager.degHotend(e), 1);
SERIAL_PROTOCOLPGM("C->");
SERIAL_PROTOCOL_F(thermalManager.rawHotendTemp(cur_hotend) / OVERSAMPLENR, 0);
SERIAL_PROTOCOL_F(thermalManager.rawHotendTemp(e) / OVERSAMPLENR, 0);
}
#endif
}
Expand Down Expand Up @@ -5436,7 +5436,7 @@ inline void gcode_M206() {

SERIAL_ECHO_START;
SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
for (int e = 0; e < HOTENDS; e++) {
HOTEND_LOOP() {
SERIAL_CHAR(' ');
SERIAL_ECHO(hotend_offset[X_AXIS][e]);
SERIAL_CHAR(',');
Expand Down Expand Up @@ -7968,8 +7968,9 @@ void prepare_move_to_destination() {
float max_temp = 0.0;
if (ELAPSED(millis(), next_status_led_update_ms)) {
next_status_led_update_ms += 500; // Update every 0.5s
for (int8_t cur_hotend = 0; cur_hotend < HOTENDS; ++cur_hotend)
max_temp = max(max(max_temp, thermalManager.degHotend(cur_hotend)), thermalManager.degTargetHotend(cur_hotend));
HOTEND_LOOP() {
max_temp = max(max(max_temp, thermalManager.degHotend(e)), thermalManager.degTargetHotend(e));
}
#if HAS_TEMP_BED
max_temp = max(max(max_temp, thermalManager.degTargetBed()), thermalManager.degBed());
#endif
Expand Down
16 changes: 8 additions & 8 deletions Marlin/configuration_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ void Config_ResetDefault() {

#if ENABLED(PIDTEMP)
#if ENABLED(PID_PARAMS_PER_HOTEND)
for (uint8_t e = 0; e < HOTENDS; e++)
HOTEND_LOOP
#else
int e = 0; UNUSED(e); // only need to write once
#endif
Expand Down Expand Up @@ -834,15 +834,15 @@ void Config_PrintSettings(bool forReplay) {
#if ENABLED(PIDTEMP)
#if HOTENDS > 1
if (forReplay) {
for (uint8_t i = 0; i < HOTENDS; i++) {
HOTEND_LOOP() {
CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" M301 E", i);
SERIAL_ECHOPAIR(" P", PID_PARAM(Kp, i));
SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, i)));
SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, i)));
SERIAL_ECHOPAIR(" M301 E", e);
SERIAL_ECHOPAIR(" P", PID_PARAM(Kp, e));
SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, e)));
SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, e)));
#if ENABLED(PID_ADD_EXTRUSION_RATE)
SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, i));
if (i == 0) SERIAL_ECHOPAIR(" L", lpq_len);
SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, e));
if (e == 0) SERIAL_ECHOPAIR(" L", lpq_len);
#endif
SERIAL_EOL;
}
Expand Down
2 changes: 1 addition & 1 deletion Marlin/dogm_lcd_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static void lcd_implementation_status_screen() {
#endif

// Extruders
for (int i = 0; i < HOTENDS; i++) _draw_heater_status(5 + i * 25, i);
HOTEND_LOOP() _draw_heater_status(5 + e * 25, e);

// Heated bed
#if HOTENDS < 4 && HAS_TEMP_BED
Expand Down
Loading

0 comments on commit 5b0e46c

Please sign in to comment.