Skip to content

Commit

Permalink
Merge pull request #3153 from thinkyhead/rc_fix_macro_expansion
Browse files Browse the repository at this point in the history
Additional macro wrapping, patches for #3140
  • Loading branch information
thinkyhead committed Mar 15, 2016
2 parents 1c38493 + 6e1bc03 commit 91cdea4
Show file tree
Hide file tree
Showing 21 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6699,7 +6699,7 @@ void plan_arc(

float mm_of_travel = hypot(angular_travel * radius, fabs(linear_travel));
if (mm_of_travel < 0.001) return;
uint16_t segments = floor(mm_of_travel / MM_PER_ARC_SEGMENT);
uint16_t segments = floor(mm_of_travel / (MM_PER_ARC_SEGMENT));
if (segments == 0) segments = 1;

float theta_per_segment = angular_travel / segments;
Expand Down
4 changes: 2 additions & 2 deletions Marlin/example_configurations/Felix/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l

#if ENABLED(MESH_BED_LEVELING)
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MIN_Y 10
#define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y))
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_Y_POINTS 3
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.

Expand Down
4 changes: 2 additions & 2 deletions Marlin/example_configurations/Felix/Configuration_DUAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l

#if ENABLED(MESH_BED_LEVELING)
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MIN_Y 10
#define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y))
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_Y_POINTS 3
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.

Expand Down
4 changes: 2 additions & 2 deletions Marlin/example_configurations/Hephestos/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo

#if ENABLED(MESH_BED_LEVELING)
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MIN_Y 10
#define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y))
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_Y_POINTS 3
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.

Expand Down
4 changes: 2 additions & 2 deletions Marlin/example_configurations/Hephestos_2/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l

#if ENABLED(MESH_BED_LEVELING)
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MIN_Y 10
#define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y))
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_Y_POINTS 3
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.

Expand Down
4 changes: 2 additions & 2 deletions Marlin/example_configurations/K8200/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l

#if ENABLED(MESH_BED_LEVELING)
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MIN_Y 10
#define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y))
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_Y_POINTS 3
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l

#if ENABLED(MESH_BED_LEVELING)
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MIN_Y 10
#define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y))
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_Y_POINTS 3
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.

Expand Down
4 changes: 2 additions & 2 deletions Marlin/example_configurations/RigidBot/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l

#if ENABLED(MESH_BED_LEVELING)
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MIN_Y 10
#define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y))
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_Y_POINTS 3
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.

Expand Down
4 changes: 2 additions & 2 deletions Marlin/example_configurations/SCARA/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l

#if ENABLED(MESH_BED_LEVELING)
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MIN_Y 10
#define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y))
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_Y_POINTS 3
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.

Expand Down
4 changes: 2 additions & 2 deletions Marlin/example_configurations/TAZ4/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l

#if ENABLED(MESH_BED_LEVELING)
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MIN_Y 10
#define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y))
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_Y_POINTS 3
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.

Expand Down
4 changes: 2 additions & 2 deletions Marlin/example_configurations/WITBOX/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo

#if ENABLED(MESH_BED_LEVELING)
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MIN_Y 10
#define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y))
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_Y_POINTS 3
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l

#if ENABLED(MESH_BED_LEVELING)
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MIN_Y 10
#define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y))
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_Y_POINTS 3
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.

Expand Down
4 changes: 2 additions & 2 deletions Marlin/example_configurations/delta/kossel_xl/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l

#if ENABLED(MESH_BED_LEVELING)
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MIN_Y 10
#define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y))
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_Y_POINTS 3
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.

Expand Down
4 changes: 2 additions & 2 deletions Marlin/example_configurations/makibox/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l

#if ENABLED(MESH_BED_LEVELING)
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MIN_Y 10
#define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y))
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_Y_POINTS 3
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.

Expand Down
4 changes: 2 additions & 2 deletions Marlin/example_configurations/tvrrug/Round2/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo

#if ENABLED(MESH_BED_LEVELING)
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
#define MESH_MIN_Y 10
#define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y))
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
#define MESH_NUM_Y_POINTS 3
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.

Expand Down
4 changes: 2 additions & 2 deletions Marlin/mesh_bed_leveling.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

void reset();

float get_x(int i) { return MESH_MIN_X + MESH_X_DIST * i; }
float get_y(int i) { return MESH_MIN_Y + MESH_Y_DIST * i; }
float get_x(int i) { return MESH_MIN_X + (MESH_X_DIST) * i; }
float get_y(int i) { return MESH_MIN_Y + (MESH_Y_DIST) * i; }
void set_z(int ix, int iy, float z) { z_values[iy][ix] = z; }

int select_x_index(float x) {
Expand Down
8 changes: 4 additions & 4 deletions Marlin/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void planner_recalculate_trapezoids() {
// Last/newest block in buffer. Exit speed is set with MINIMUM_PLANNER_SPEED. Always recalculated.
if (next) {
float nom = next->nominal_speed;
calculate_trapezoid_for_block(next, next->entry_speed / nom, MINIMUM_PLANNER_SPEED / nom);
calculate_trapezoid_for_block(next, next->entry_speed / nom, (MINIMUM_PLANNER_SPEED) / nom);
next->recalculate_flag = false;
}
}
Expand Down Expand Up @@ -389,8 +389,8 @@ void plan_init() {
float t = autotemp_min + high * autotemp_factor;
t = constrain(t, autotemp_min, autotemp_max);
if (oldt > t) {
t *= (1 - AUTOTEMP_OLDWEIGHT);
t += AUTOTEMP_OLDWEIGHT * oldt;
t *= (1 - (AUTOTEMP_OLDWEIGHT));
t += (AUTOTEMP_OLDWEIGHT) * oldt;
}
oldt = t;
setTargetHotend0(t);
Expand Down Expand Up @@ -839,7 +839,7 @@ float junction_deviation = 0.1;
max_y_segment_time = max(ys0, max(ys1, ys2)),
min_xy_segment_time = min(max_x_segment_time, max_y_segment_time);
if (min_xy_segment_time < MAX_FREQ_TIME) {
float low_sf = speed_factor * min_xy_segment_time / MAX_FREQ_TIME;
float low_sf = speed_factor * min_xy_segment_time / (MAX_FREQ_TIME);
speed_factor = min(speed_factor, low_sf);
}
#endif // XY_FREQUENCY_LIMIT
Expand Down
8 changes: 4 additions & 4 deletions Marlin/servo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays // 12 August 2009

//#define NBR_TIMERS (MAX_SERVOS / SERVOS_PER_TIMER)
//#define NBR_TIMERS ((MAX_SERVOS) / (SERVOS_PER_TIMER))

static ServoInfo_t servo_info[MAX_SERVOS]; // static array of servo info structures
static volatile int8_t Channel[_Nbr_16timers ]; // counter for the servo being pulsed for each timer (or -1 if refresh interval)
Expand All @@ -66,9 +66,9 @@ uint8_t ServoCount = 0; // the total number


// convenience macros
#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo
#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer
#define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel
#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / (SERVOS_PER_TIMER))) // returns the timer controlling this servo
#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % (SERVOS_PER_TIMER)) // returns the index of the servo on this timer
#define SERVO_INDEX(_timer,_channel) ((_timer*(SERVOS_PER_TIMER)) + _channel) // macro to access servo index by timer and channel
#define SERVO(_timer,_channel) (servo_info[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel

#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo
Expand Down
6 changes: 3 additions & 3 deletions Marlin/stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1220,9 +1220,9 @@ void digipot_current(uint8_t driver, int current) {
digitalPotWrite(digipot_ch[driver], current);
#elif defined(MOTOR_CURRENT_PWM_XY_PIN)
switch (driver) {
case 0: analogWrite(MOTOR_CURRENT_PWM_XY_PIN, 255L * current / MOTOR_CURRENT_PWM_RANGE); break;
case 1: analogWrite(MOTOR_CURRENT_PWM_Z_PIN, 255L * current / MOTOR_CURRENT_PWM_RANGE); break;
case 2: analogWrite(MOTOR_CURRENT_PWM_E_PIN, 255L * current / MOTOR_CURRENT_PWM_RANGE); break;
case 0: analogWrite(MOTOR_CURRENT_PWM_XY_PIN, 255L * current / (MOTOR_CURRENT_PWM_RANGE)); break;
case 1: analogWrite(MOTOR_CURRENT_PWM_Z_PIN, 255L * current / (MOTOR_CURRENT_PWM_RANGE)); break;
case 2: analogWrite(MOTOR_CURRENT_PWM_E_PIN, 255L * current / (MOTOR_CURRENT_PWM_RANGE)); break;
}
#else
UNUSED(driver);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ void lcd_set_home_offsets() {

static void _lcd_babystep(int axis, const char* msg) {
if (encoderPosition != 0) {
babystepsTodo[axis] += BABYSTEP_MULTIPLICATOR * (int)encoderPosition;
babystepsTodo[axis] += (BABYSTEP_MULTIPLICATOR) * (int)encoderPosition;
encoderPosition = 0;
lcdDrawUpdate = 1;
}
Expand Down
6 changes: 3 additions & 3 deletions Marlin/ultralcd_st7920_u8glib_rrd.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
ST7920_WRITE_BYTE(0x01); //clear CGRAM ram
u8g_Delay(15); //delay for CGRAM clear
ST7920_WRITE_BYTE(0x3E); //extended mode + GDRAM active
for (y = 0; y < LCD_PIXEL_HEIGHT / 2; y++) { //clear GDRAM
for (y = 0; y < (LCD_PIXEL_HEIGHT) / 2; y++) { //clear GDRAM
ST7920_WRITE_BYTE(0x80 | y); //set y
ST7920_WRITE_BYTE(0x80); //set x = 0
ST7920_SET_DAT();
Expand Down Expand Up @@ -91,7 +91,7 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
ST7920_WRITE_BYTE(0x80 | 8); //x=64
}
ST7920_SET_DAT();
ST7920_WRITE_BYTES(ptr, LCD_PIXEL_WIDTH / 8); //ptr is incremented inside of macro
ST7920_WRITE_BYTES(ptr, (LCD_PIXEL_WIDTH) / 8); //ptr is incremented inside of macro
y++;
}
ST7920_NCS();
Expand All @@ -107,7 +107,7 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
#endif
}

uint8_t u8g_dev_st7920_128x64_rrd_buf[LCD_PIXEL_WIDTH * (PAGE_HEIGHT / 8)] U8G_NOCOMMON;
uint8_t u8g_dev_st7920_128x64_rrd_buf[(LCD_PIXEL_WIDTH) * (PAGE_HEIGHT) / 8] U8G_NOCOMMON;
u8g_pb_t u8g_dev_st7920_128x64_rrd_pb = {{PAGE_HEIGHT, LCD_PIXEL_HEIGHT, 0, 0, 0}, LCD_PIXEL_WIDTH, u8g_dev_st7920_128x64_rrd_buf};
u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn, &u8g_dev_st7920_128x64_rrd_pb, &u8g_com_null_fn};

Expand Down

0 comments on commit 91cdea4

Please sign in to comment.