Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Pretest DEBUG_X constants for non-zero and && the test with all existing

& tests of the debug_flags. Currently the compiler is able to eliminate
the block and the & operation when the constant is zero, but since
the debug_flags variable is a volatile the compiler does not eliminate
the load of the variable. By pretesting and shortcutting the load is
eliminated. Saves a small number of bytes when the debug build is
disabled and costs nothing when it is enabled.
  • Loading branch information...
commit 85a9f63dfbc1b0588bc7e0141d9982adf75d1c2b 1 parent f22e691
madscifi madscifi authored committed
2  clock.c
View
@@ -36,7 +36,7 @@ void clock_250ms() {
}
ifclock(clock_flag_1s) {
- if (debug_flags & DEBUG_POSITION) {
+ if (DEBUG_POSITION && (debug_flags & DEBUG_POSITION)) {
// current position
sersendf_P(PSTR("Pos: %ld,%ld,%ld,%ld,%lu\n"), current_position.X, current_position.Y, current_position.Z, current_position.E, current_position.F);
20 dda.c
View
@@ -177,7 +177,7 @@ void dda_create(DDA *dda, TARGET *target) {
// initialise DDA to a known state
dda->allflags = 0;
- if (debug_flags & DEBUG_DDA)
+ if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
serial_writestr_P(PSTR("\n{DDA_CREATE: ["));
// we end at the passed target
@@ -193,7 +193,7 @@ void dda_create(DDA *dda, TARGET *target) {
dda->z_direction = (target->Z >= startpoint.Z)?1:0;
dda->e_direction = (target->E >= startpoint.E)?1:0;
- if (debug_flags & DEBUG_DDA)
+ if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
sersendf_P(PSTR("%ld,%ld,%ld,%ld] ["), target->X - startpoint.X, target->Y - startpoint.Y, target->Z - startpoint.Z, target->E - startpoint.E);
dda->total_steps = dda->x_delta;
@@ -204,7 +204,7 @@ void dda_create(DDA *dda, TARGET *target) {
if (dda->e_delta > dda->total_steps)
dda->total_steps = dda->e_delta;
- if (debug_flags & DEBUG_DDA)
+ if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
sersendf_P(PSTR("ts:%lu"), dda->total_steps);
if (dda->total_steps == 0) {
@@ -230,7 +230,7 @@ void dda_create(DDA *dda, TARGET *target) {
if (distance < 2)
distance = dda->e_delta * UM_PER_STEP_E;
- if (debug_flags & DEBUG_DDA)
+ if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
sersendf_P(PSTR(",ds:%lu"), distance);
#ifdef ACCELERATION_TEMPORAL
@@ -287,7 +287,7 @@ void dda_create(DDA *dda, TARGET *target) {
if (dda->end_c < c_limit)
dda->end_c = c_limit;
- if (debug_flags & DEBUG_DDA)
+ if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
sersendf_P(PSTR(",md:%lu,c:%lu"), move_duration, dda->c >> 8);
if (dda->c != dda->end_c) {
@@ -307,24 +307,24 @@ void dda_create(DDA *dda, TARGET *target) {
// we'll have to do it a few different ways depending on the msb locations of each
if ((msb_tot + msb_ssq) <= 30) {
// we have room to do all the multiplies first
- if (debug_flags & DEBUG_DDA)
+ if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
serial_writechar('A');
dda->n = ((int32_t) (dda->total_steps * ssq) / dsq) + 1;
}
else if (msb_tot >= msb_ssq) {
// total steps has more precision
- if (debug_flags & DEBUG_DDA)
+ if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
serial_writechar('B');
dda->n = (((int32_t) dda->total_steps / dsq) * (int32_t) ssq) + 1;
}
else {
// otherwise
- if (debug_flags & DEBUG_DDA)
+ if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
serial_writechar('C');
dda->n = (((int32_t) ssq / dsq) * (int32_t) dda->total_steps) + 1;
}
- if (debug_flags & DEBUG_DDA)
+ if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
sersendf_P(PSTR("\n{DDA:CA end_c:%lu, n:%ld, md:%lu, ssq:%lu, esq:%lu, dsq:%lu, msbssq:%u, msbtot:%u}\n"), dda->end_c >> 8, dda->n, move_duration, ssq, esq, dsq, msb_ssq, msb_tot);
dda->accel = 1;
@@ -349,7 +349,7 @@ void dda_create(DDA *dda, TARGET *target) {
#endif
}
- if (debug_flags & DEBUG_DDA)
+ if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
serial_writestr_P(PSTR("] }\n"));
// next dda starts where we finish
28 gcode_parse.c
View
@@ -127,12 +127,12 @@ void gcode_parse_char(uint8_t c) {
switch (last_field) {
case 'G':
next_target.G = read_digit.mantissa;
- if (debug_flags & DEBUG_ECHO)
+ if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_uint8(next_target.G);
break;
case 'M':
next_target.M = read_digit.mantissa;
- if (debug_flags & DEBUG_ECHO)
+ if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_uint8(next_target.M);
break;
case 'X':
@@ -140,7 +140,7 @@ void gcode_parse_char(uint8_t c) {
next_target.target.X = decfloat_to_int(&read_digit, STEPS_PER_IN_X, 0);
else
next_target.target.X = decfloat_to_int(&read_digit, STEPS_PER_M_X, 1);
- if (debug_flags & DEBUG_ECHO)
+ if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_int32(next_target.target.X);
break;
case 'Y':
@@ -148,7 +148,7 @@ void gcode_parse_char(uint8_t c) {
next_target.target.Y = decfloat_to_int(&read_digit, STEPS_PER_IN_Y, 0);
else
next_target.target.Y = decfloat_to_int(&read_digit, STEPS_PER_M_Y, 1);
- if (debug_flags & DEBUG_ECHO)
+ if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_int32(next_target.target.Y);
break;
case 'Z':
@@ -156,7 +156,7 @@ void gcode_parse_char(uint8_t c) {
next_target.target.Z = decfloat_to_int(&read_digit, STEPS_PER_IN_Z, 0);
else
next_target.target.Z = decfloat_to_int(&read_digit, STEPS_PER_M_Z, 1);
- if (debug_flags & DEBUG_ECHO)
+ if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_int32(next_target.target.Z);
break;
case 'E':
@@ -164,7 +164,7 @@ void gcode_parse_char(uint8_t c) {
next_target.target.E = decfloat_to_int(&read_digit, STEPS_PER_IN_E, 0);
else
next_target.target.E = decfloat_to_int(&read_digit, STEPS_PER_M_E, 1);
- if (debug_flags & DEBUG_ECHO)
+ if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_uint32(next_target.target.E);
break;
case 'F':
@@ -173,7 +173,7 @@ void gcode_parse_char(uint8_t c) {
next_target.target.F = decfloat_to_int(&read_digit, 25400, 1);
else
next_target.target.F = decfloat_to_int(&read_digit, 1, 0);
- if (debug_flags & DEBUG_ECHO)
+ if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_uint32(next_target.target.F);
break;
case 'S':
@@ -187,27 +187,27 @@ void gcode_parse_char(uint8_t c) {
next_target.S = decfloat_to_int(&read_digit, PID_SCALE, 0);
else
next_target.S = decfloat_to_int(&read_digit, 1, 0);
- if (debug_flags & DEBUG_ECHO)
+ if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_uint16(next_target.S);
break;
case 'P':
next_target.P = decfloat_to_int(&read_digit, 1, 0);
- if (debug_flags & DEBUG_ECHO)
+ if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_uint16(next_target.P);
break;
case 'T':
next_target.T = read_digit.mantissa;
- if (debug_flags & DEBUG_ECHO)
+ if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_uint8(next_target.T);
break;
case 'N':
next_target.N = decfloat_to_int(&read_digit, 1, 0);
- if (debug_flags & DEBUG_ECHO)
+ if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_uint32(next_target.N);
break;
case '*':
next_target.checksum_read = decfloat_to_int(&read_digit, 1, 0);
- if (debug_flags & DEBUG_ECHO)
+ if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serwrite_uint8(next_target.checksum_read);
break;
}
@@ -222,7 +222,7 @@ void gcode_parse_char(uint8_t c) {
// new field?
if ((c >= 'A' && c <= 'Z') || c == '*') {
last_field = c;
- if (debug_flags & DEBUG_ECHO)
+ if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serial_writechar(c);
}
@@ -331,7 +331,7 @@ void gcode_parse_char(uint8_t c) {
// end of line
if ((c == 10) || (c == 13)) {
- if (debug_flags & DEBUG_ECHO)
+ if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO))
serial_writechar(c);
if (
2  gcode_process.c
View
@@ -273,7 +273,7 @@ void process_gcode_command() {
return;
}
#ifdef DEBUG
- if (debug_flags & DEBUG_POSITION)
+ if (DEBUG_POSITION && (debug_flags & DEBUG_POSITION))
print_queue();
#endif
}
4 heater.c
View
@@ -240,7 +240,7 @@ void heater_tick(heater_t h, temp_sensor_t t, uint16_t current_temp, uint16_t ta
pid_output = pid_output_intermed & 0xFF;
#ifdef DEBUG
- if (debug_flags & DEBUG_PID)
+ if (DEBUG_PID && (debug_flags & DEBUG_PID))
sersendf_P(PSTR("T{E:%d, P:%d * %ld = %ld / I:%d * %ld = %ld / D:%d * %ld = %ld # O: %ld = %u}\n"), t_error, heater_p, heaters_pid[h].p_factor, (int32_t) heater_p * heaters_pid[h].p_factor / PID_SCALE, heaters_runtime[h].heater_i, heaters_pid[h].i_factor, (int32_t) heaters_runtime[h].heater_i * heaters_pid[h].i_factor / PID_SCALE, heater_d, heaters_pid[h].d_factor, (int32_t) heater_d * heaters_pid[h].d_factor / PID_SCALE, pid_output_intermed, pid_output);
#endif
#else
@@ -324,7 +324,7 @@ void heater_set(heater_t index, uint8_t value) {
if (heaters[index].heater_pwm) {
*(heaters[index].heater_pwm) = value;
#ifdef DEBUG
- if (debug_flags & DEBUG_PID)
+ if (DEBUG_PID && (debug_flags & DEBUG_PID))
sersendf_P(PSTR("PWM{%u = %u}\n"), index, OCR0A);
#endif
}
6 temp.c
View
@@ -177,7 +177,7 @@ void temp_sensor_tick() {
if (pgm_read_word(&(temptable[table_num][j][0])) > temp) {
// Thermistor table is already in 14.2 fixed point
#ifndef EXTRUDER
- if (debug_flags & DEBUG_PID)
+ if (DEBUG_PID && (debug_flags & DEBUG_PID))
sersendf_P(PSTR("pin:%d Raw ADC:%d table entry: %d"),temp_sensors[i].temp_pin,temp,j);
#endif
// Linear interpolating temperature value
@@ -204,14 +204,14 @@ void temp_sensor_tick() {
// (x₁ - x₀)
(pgm_read_word(&(temptable[table_num][j][0])) - pgm_read_word(&(temptable[table_num][j-1][0])));
#ifndef EXTRUDER
- if (debug_flags & DEBUG_PID)
+ if (DEBUG_PID && (debug_flags & DEBUG_PID))
sersendf_P(PSTR(" temp:%d.%d"),temp/4,(temp%4)*25);
#endif
break;
}
}
#ifndef EXTRUDER
- if (debug_flags & DEBUG_PID)
+ if (DEBUG_PID && (debug_flags & DEBUG_PID))
sersendf_P(PSTR(" Sensor:%d\n"),i);
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.