Skip to content

Commit

Permalink
Remove unnecessary whitespace changes
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyjboyle committed Apr 21, 2020
1 parent 08ba909 commit e07b7de
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 288 deletions.
138 changes: 46 additions & 92 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2821,8 +2821,7 @@ static void clean_up_after_endstop_or_probe_move() {

}

static void print_bilinear_leveling_grid()
{
static void print_bilinear_leveling_grid() {
SERIAL_ECHOLNPGM("Bilinear Leveling Grid:");
print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 3,
[](const uint8_t ix, const uint8_t iy) { return z_values[ix][iy]; }
Expand Down Expand Up @@ -5977,17 +5976,14 @@ void home_all_axes() { gcode_G28(true); }
/**
* G92: Set current position to given X Y Z E
*/
inline void gcode_G92()
{
inline void gcode_G92() {
bool didXYZ = false,
didE = parser.seenval('E');

if (!didE) stepper.synchronize();

LOOP_XYZE(i)
{
if (parser.seenval(axis_codes[i]))
{
LOOP_XYZE(i) {
if (parser.seenval(axis_codes[i])) {
#if IS_SCARA
current_position[i] = parser.value_axis_units((AxisEnum)i);
if (i != E_AXIS) didXYZ = true;
Expand All @@ -5999,11 +5995,9 @@ inline void gcode_G92()

current_position[i] = v;

if (i != E_AXIS)
{
if (i != E_AXIS) {
didXYZ = true;
if (i == Z_AXIS)
{
if (i == Z_AXIS) {
axis_known_position[Z_AXIS] = true;
}
#if HAS_POSITION_SHIFT
Expand Down Expand Up @@ -6535,8 +6529,7 @@ inline void gcode_M17() {
/**
* M21: Init SD Card
*/
inline void gcode_M21()
{
inline void gcode_M21() {
card.initsd();
#if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
init_power_off_info();
Expand All @@ -6560,8 +6553,7 @@ inline void gcode_M17() {
/**
* M24: Start or Resume SD Print
*/
inline void gcode_M24()
{
inline void gcode_M24() {
#if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
card.removePowerOffFile();
#endif
Expand Down Expand Up @@ -7342,17 +7334,15 @@ inline void gcode_M77() { print_job_timer.stop(); }
/**
* M104: Set hot end temperature
*/
inline void gcode_M104()
{
inline void gcode_M104() {
if (get_target_extruder_from_command(104)) return;
if (DEBUGGING(DRYRUN)) return;

#if ENABLED(SINGLENOZZLE)
if (target_extruder != active_extruder) return;
#endif

if (parser.seenval('S'))
{
if (parser.seenval('S')) {
const int16_t temp = parser.value_celsius();
thermalManager.setTargetHotend(temp, target_extruder);

Expand All @@ -7368,18 +7358,14 @@ inline void gcode_M104()
* standby mode, for instance in a dual extruder setup, without affecting
* the running print timer.
*/
if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2)
{
if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) {
print_job_timer.stop();
LCD_MESSAGEPGM(WELCOME_MSG);
}
#endif

if (parser.value_celsius() > thermalManager.degHotend(target_extruder))
{
// lcd_status_printf_P(0, PSTR("E%i %s"), target_extruder + 1, MSG_HEATING);
lcd_status_printf_P(0, PSTR("Extruder %s"), MSG_HEATING);
}
lcd_status_printf_P(0, PSTR("Extruder %s"), MSG_HEATING);
}

#if ENABLED(AUTOTEMP)
Expand Down Expand Up @@ -7565,8 +7551,8 @@ inline void gcode_M105() {
#define MIN_COOLING_SLOPE_TIME 60
#endif

inline void gcode_M109()
{
inline void gcode_M109() {

if (get_target_extruder_from_command(109)) return;
if (DEBUGGING(DRYRUN)) return;

Expand All @@ -7575,8 +7561,7 @@ inline void gcode_M109()
#endif

const bool no_wait_for_cooling = parser.seenval('S');
if (no_wait_for_cooling || parser.seenval('R'))
{
if (no_wait_for_cooling || parser.seenval('R')) {
const int16_t temp = parser.value_celsius();
thermalManager.setTargetHotend(temp, target_extruder);

Expand All @@ -7591,17 +7576,15 @@ inline void gcode_M109()
* standby mode, (e.g., in a dual extruder setup) without affecting
* the running print timer.
*/
if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2)
{
if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) {
print_job_timer.stop();
LCD_MESSAGEPGM(WELCOME_MSG);
}
else
print_job_timer.start();
#endif

if (thermalManager.isHeatingHotend(target_extruder))
{
if (thermalManager.isHeatingHotend(target_extruder)) {
// lcd_status_printf_P(0, PSTR("E%i %s"), target_extruder + 1, MSG_HEATING);
lcd_status_printf_P(0, PSTR("Extruder %s"), MSG_HEATING);
}
Expand Down Expand Up @@ -7635,11 +7618,9 @@ inline void gcode_M109()
uint8_t old_blue = 0;
#endif

do
{
do {
// Target temperature might be changed during the loop
if (target_temp != thermalManager.degTargetHotend(target_extruder))
{
if (target_temp != thermalManager.degTargetHotend(target_extruder)) {
wants_to_cool = thermalManager.isCoolingHotend(target_extruder);
target_temp = thermalManager.degTargetHotend(target_extruder);

Expand All @@ -7648,9 +7629,7 @@ inline void gcode_M109()
}

now = millis();
if (ELAPSED(now, next_temp_ms))
{
// Print temp & remaining time every 1s while waiting
if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
next_temp_ms = now + 1000UL;
print_heaterstates();
#if TEMP_RESIDENCY_TIME > 0
Expand All @@ -7670,11 +7649,9 @@ inline void gcode_M109()

#if ENABLED(PRINTER_EVENT_LEDS)
// Gradually change LED strip from violet to red as nozzle heats up
if (!wants_to_cool)
{
if (!wants_to_cool) {
const uint8_t blue = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 255, 0);
if (blue != old_blue)
{
if (blue != old_blue) {
old_blue = blue;
set_led_color(255, 0, blue
#if ENABLED(NEOPIXEL_LED)
Expand All @@ -7693,26 +7670,22 @@ inline void gcode_M109()

const float temp_diff = FABS(target_temp - temp);

if (!residency_start_ms)
{
if (!residency_start_ms) {
// Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
if (temp_diff < TEMP_WINDOW) residency_start_ms = now;
}
else if (temp_diff > TEMP_HYSTERESIS)
{
else if (temp_diff > TEMP_HYSTERESIS) {
// Restart the timer whenever the temperature falls outside the hysteresis.
residency_start_ms = now;
}

#endif

// Prevent a wait-forever situation if R is misused i.e. M109 R0
if (wants_to_cool)
{
if (wants_to_cool) {
// break after MIN_COOLING_SLOPE_TIME seconds
// if the temperature did not drop at least MIN_COOLING_SLOPE_DEG
if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms))
{
if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
if (old_temp - temp < MIN_COOLING_SLOPE_DEG) break;
next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME;
old_temp = temp;
Expand All @@ -7721,8 +7694,7 @@ inline void gcode_M109()

} while (wait_for_heatup && TEMP_CONDITIONS);

if (wait_for_heatup)
{
if (wait_for_heatup) {
LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
#if ENABLED(PRINTER_EVENT_LEDS)
#if ENABLED(RGB_LED) || ENABLED(BLINKM) || ENABLED(PCA9632) || ENABLED(RGBW_LED)
Expand Down Expand Up @@ -7752,14 +7724,12 @@ inline void gcode_M109()
* M190: Sxxx Wait for bed current temp to reach target temp. Waits only when heating
* Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
*/
inline void gcode_M190()
{
inline void gcode_M190() {
if (DEBUGGING(DRYRUN)) return;

LCD_MESSAGEPGM(MSG_BED_HEATING);
const bool no_wait_for_cooling = parser.seenval('S');
if (no_wait_for_cooling || parser.seenval('R'))
{
if (no_wait_for_cooling || parser.seenval('R')) {
thermalManager.setTargetBed(parser.value_celsius());
#if ENABLED(PRINTJOB_TIMER_AUTOSTART)
if (parser.value_celsius() > BED_MINTEMP)
Expand Down Expand Up @@ -7804,9 +7774,7 @@ inline void gcode_M109()
}

now = millis();
if (ELAPSED(now, next_temp_ms))
{
// Print Temp Reading every 1 second while heating up.
if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
next_temp_ms = now + 1000UL;
print_heaterstates();
#if TEMP_BED_RESIDENCY_TIME > 0
Expand All @@ -7826,11 +7794,9 @@ inline void gcode_M109()

#if ENABLED(PRINTER_EVENT_LEDS)
// Gradually change LED strip from blue to violet as bed heats up
if (!wants_to_cool)
{
if (!wants_to_cool) {
const uint8_t red = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 0, 255);
if (red != old_red)
{
if (red != old_red) {
old_red = red;
set_led_color(red, 0, 255
#if ENABLED(NEOPIXEL_LED)
Expand All @@ -7848,26 +7814,22 @@ inline void gcode_M109()

const float temp_diff = FABS(target_temp - temp);

if (!residency_start_ms)
{
if (!residency_start_ms) {
// Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
if (temp_diff < TEMP_BED_WINDOW) residency_start_ms = now;
}
else if (temp_diff > TEMP_BED_HYSTERESIS)
{
else if (temp_diff > TEMP_BED_HYSTERESIS) {
// Restart the timer whenever the temperature falls outside the hysteresis.
residency_start_ms = now;
}

#endif // TEMP_BED_RESIDENCY_TIME > 0

// Prevent a wait-forever situation if R is misused i.e. M190 R0
if (wants_to_cool)
{
if (wants_to_cool) {
// Break after MIN_COOLING_SLOPE_TIME_BED seconds
// if the temperature did not drop at least MIN_COOLING_SLOPE_DEG_BED
if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms))
{
if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
if (old_temp - temp < MIN_COOLING_SLOPE_DEG_BED) break;
next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME_BED;
old_temp = temp;
Expand Down Expand Up @@ -13953,22 +13915,20 @@ void setup() {
* - Call endstop manager
* - Call LCD update
*/
void loop()
{
void loop() {
if (commands_in_queue < BUFSIZE) get_available_commands();

#if ENABLED(SDSUPPORT)
card.checkautostart(false);
#endif

if (commands_in_queue)
{
if (commands_in_queue) {

#if ENABLED(SDSUPPORT)
if (card.saving)
{

if (card.saving) {
char* command = command_queue[cmd_queue_index_r];
if (strstr_P(command, PSTR("M29")))
{
if (strstr_P(command, PSTR("M29"))) {
// M29 closes the file
card.closefile();
SERIAL_PROTOCOLLNPGM(MSG_FILE_SAVED);
Expand All @@ -13983,8 +13943,7 @@ void loop()

ok_to_send();
}
else
{
else {
// Write the string from the read buffer to SD
card.write_command(command);
if (card.logging)
Expand All @@ -13993,8 +13952,7 @@ void loop()
ok_to_send();
}
}
else
{
else {
process_next_command();
#if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
save_power_off_info();
Expand All @@ -14008,13 +13966,9 @@ void loop()
#endif // SDSUPPORT

// The queue may be reset by a command handler or by code invoked by idle() within a handler
if (commands_in_queue)
{
if (commands_in_queue) {
--commands_in_queue;
if (++cmd_queue_index_r >= BUFSIZE)
{
cmd_queue_index_r = 0;
}
if (++cmd_queue_index_r >= BUFSIZE) cmd_queue_index_r = 0;
}
}
endstops.report_state();
Expand Down
10 changes: 3 additions & 7 deletions Marlin/cardreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,20 +918,16 @@ void CardReader::updir() {

#endif // SDCARD_SORT_ALPHA

void CardReader::printingHasFinished()
{
void CardReader::printingHasFinished() {
stepper.synchronize();
file.close();
if (file_subcall_ctr > 0)
{
// Heading up to a parent file that called current as a procedure.
if (file_subcall_ctr > 0) { // Heading up to a parent file that called current as a procedure.
file_subcall_ctr--;
openFile(proc_filenames[file_subcall_ctr], true, true);
setIndex(filespos[file_subcall_ctr]);
startFileprint();
}
else
{
else {
sdprinting = false;
#if ENABLED(POWEROFF_SAVE_SD_FILE)
openPowerOffFile(power_off_info.power_off_filename, O_CREAT | O_WRITE | O_TRUNC | O_SYNC);
Expand Down
Loading

0 comments on commit e07b7de

Please sign in to comment.