Skip to content

UBL cleanup, optimization #6152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 69 additions & 104 deletions Marlin/G26_Mesh_Validation_Tool.cpp

Large diffs are not rendered by default.

30 changes: 10 additions & 20 deletions Marlin/M100_Free_Mem_Chk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,25 @@ void gcode_M100() {
// 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("\nbss_end : ");
prt_hex_word((unsigned int) ptr);
ptr = (char*)((unsigned long) ptr & 0xfff0);
SERIAL_ECHOPAIR("\nbss_end : ", hex_word((uint16_t)ptr));
ptr = (char*)((uint32_t)ptr & 0xfff0);
sp = top_of_stack();
SERIAL_ECHOPGM("\nStack Pointer : ");
prt_hex_word((unsigned int) sp);
SERIAL_EOL;
sp = (char*)((unsigned long) sp | 0x000f);
SERIAL_ECHOLNPAIR("\nStack Pointer : ", hex_word((uint16_t)sp));
sp = (char*)((uint32_t)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
print_hex_word((uint16_t)ptr); // Print the address
SERIAL_CHAR(':');
for (i = 0; i < 16; i++) { // and 16 data bytes
prt_hex_byte(*(ptr + i));
print_hex_byte(*(ptr + i));
SERIAL_CHAR(' ');
}
SERIAL_CHAR('|'); // now show where non 0xE5's are
for (i = 0; i < 16; i++) {
if (*(ptr + i) == (char)0xe5)
SERIAL_CHAR(' ');
else
SERIAL_CHAR('?');
}
for (i = 0; i < 16; i++)
SERIAL_CHAR((*(ptr + i) == (char)0xe5) ? ' ' : '?');
SERIAL_EOL;
ptr += 16;
}
Expand All @@ -127,9 +120,7 @@ void gcode_M100() {
j = how_many_E5s_are_here(ptr + i);
if (j > 8) {
SERIAL_ECHOPAIR("Found ", j);
SERIAL_ECHOPGM(" bytes free at 0x");
prt_hex_word((int) ptr + i);
SERIAL_EOL;
SERIAL_ECHOLNPAIR(" bytes free at 0x", hex_word((uint16_t)(ptr + i)));
i += j;
block_cnt++;
}
Expand Down Expand Up @@ -164,8 +155,7 @@ void gcode_M100() {
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_ECHOPAIR("\nCorrupting address: 0x", hex_word((uint16_t)(ptr + i * j)));
}
SERIAL_ECHOLNPGM("\n");
return;
Expand Down
5 changes: 4 additions & 1 deletion Marlin/Marlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,10 @@ float code_value_temp_diff();
#endif

#if ENABLED(HOST_KEEPALIVE_FEATURE)
extern uint8_t host_keepalive_interval;
extern MarlinBusyState busy_state;
#define KEEPALIVE_STATE(n) do{ busy_state = n; }while(0)
#else
#define KEEPALIVE_STATE(n) NOOP
#endif

#if FAN_COUNT > 0
Expand Down
34 changes: 17 additions & 17 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,11 +655,9 @@ static bool send_ok[BUFSIZE];
static MarlinBusyState busy_state = NOT_BUSY;
static millis_t next_busy_signal_ms = 0;
uint8_t host_keepalive_interval = DEFAULT_KEEPALIVE_INTERVAL;
#define KEEPALIVE_STATE(n) do{ busy_state = n; }while(0)
#else
#define host_keepalive() ;
#define KEEPALIVE_STATE(n) ;
#endif // HOST_KEEPALIVE_FEATURE
#define host_keepalive() NOOP
#endif

#define DEFINE_PGM_READ_ANY(type, reader) \
static inline type pgm_read_any(const type *p) \
Expand Down Expand Up @@ -1031,7 +1029,7 @@ inline void get_serial_commands() {
// send "wait" to indicate Marlin is still waiting.
#if defined(NO_TIMEOUTS) && NO_TIMEOUTS > 0
static millis_t last_command_time = 0;
millis_t ms = millis();
const millis_t ms = millis();
if (commands_in_queue == 0 && !MYSERIAL.available() && ELAPSED(ms, last_command_time + NO_TIMEOUTS)) {
SERIAL_ECHOLNPGM(MSG_WAIT);
last_command_time = ms;
Expand Down Expand Up @@ -4710,8 +4708,8 @@ inline void gcode_G92() {

#endif

wait_for_user = true;
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true;

stepper.synchronize();
refresh_cmd_timeout();
Expand Down Expand Up @@ -5050,7 +5048,7 @@ inline void gcode_M42() {
if (first_pin > NUM_DIGITAL_PINS - 1) return;
}

bool ignore_protection = code_seen('I') ? code_value_bool() : false;
const bool ignore_protection = code_seen('I') ? code_value_bool() : false;

// Watch until click, M108, or reset
if (code_seen('W') && code_value_bool()) { // watch digital pins
Expand Down Expand Up @@ -6324,8 +6322,8 @@ inline void gcode_M121() { endstops.enable_globally(false); }

#if DISABLED(SDSUPPORT)
// Wait for lcd click or M108
wait_for_user = true;
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true;
while (wait_for_user) idle();
KEEPALIVE_STATE(IN_HANDLER);

Expand Down Expand Up @@ -7591,7 +7589,7 @@ inline void gcode_M503() {
disable_e_steppers();
safe_delay(100);

millis_t nozzle_timeout = millis() + (millis_t)(FILAMENT_CHANGE_NOZZLE_TIMEOUT) * 1000L;
const millis_t nozzle_timeout = millis() + (millis_t)(FILAMENT_CHANGE_NOZZLE_TIMEOUT) * 1000UL;
bool nozzle_timed_out = false;
float temps[4];

Expand All @@ -7606,25 +7604,25 @@ inline void gcode_M503() {

HOTEND_LOOP() temps[e] = thermalManager.target_temperature[e]; // Save nozzle temps

KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true; // LCD click or M108 will clear this
while (wait_for_user) {
millis_t current_ms = millis();

if (nozzle_timed_out)
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_CLICK_TO_HEAT_NOZZLE);

#if HAS_BUZZER
filament_change_beep();
#endif

if (current_ms >= nozzle_timeout) {
if (!nozzle_timed_out) {
if (!nozzle_timed_out && ELAPSED(millis(), nozzle_timeout)) {
nozzle_timed_out = true; // on nozzle timeout remember the nozzles need to be reheated
HOTEND_LOOP() thermalManager.setTargetHotend(0, e); // Turn off all the nozzles
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_CLICK_TO_HEAT_NOZZLE);
}
}
idle(true);
}
KEEPALIVE_STATE(IN_HANDLER);

if (nozzle_timed_out) // Turn nozzles back on if they were turned off
HOTEND_LOOP() thermalManager.setTargetHotend(temps[e], e);
Expand Down Expand Up @@ -7652,13 +7650,15 @@ inline void gcode_M503() {
filament_change_beep(true);
#endif

KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true; // LCD click or M108 will clear this
while (wait_for_user && nozzle_timed_out) {
#if HAS_BUZZER
filament_change_beep();
#endif
idle(true);
}
KEEPALIVE_STATE(IN_HANDLER);

// Show "load" message
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_LOAD);
Expand Down Expand Up @@ -10137,9 +10137,9 @@ void prepare_move_to_destination() {
#if HAS_CONTROLLERFAN

void controllerFan() {
static millis_t lastMotorOn = 0; // Last time a motor was turned on
static millis_t nextMotorCheck = 0; // Last time the state was checked
millis_t ms = millis();
static millis_t lastMotorOn = 0, // Last time a motor was turned on
nextMotorCheck = 0; // Last time the state was checked
const millis_t ms = millis();
if (ELAPSED(ms, nextMotorCheck)) {
nextMotorCheck = ms + 2500UL; // Not a time critical function, so only check every 2.5s
if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON || thermalManager.soft_pwm_bed > 0
Expand Down Expand Up @@ -10472,7 +10472,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {

if (commands_in_queue < BUFSIZE) get_available_commands();

millis_t ms = millis();
const millis_t ms = millis();

if (max_inactive_time && ELAPSED(ms, previous_cmd_ms + max_inactive_time)) {
SERIAL_ERROR_START;
Expand Down
Loading