Merge Configuration Macros (PR#2495)

2.0.x
Richard Wackerbarth 9 years ago
commit 72b9e3a6ac

@ -2,6 +2,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -28,14 +28,6 @@
#include "Arduino.h" #include "Arduino.h"
#define BIT(b) (1<<(b))
#define TEST(n,b) (((n)&BIT(b))!=0)
#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b))
#define RADIANS(d) ((d)*M_PI/180.0)
#define DEGREES(r) ((r)*180.0/M_PI)
#define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
#define NOMORE(v,n) do{ if (v > n) v = n; }while(0)
typedef unsigned long millis_t; typedef unsigned long millis_t;
// Arduino < 1.0.0 does not define this, so we need to do it ourselves // Arduino < 1.0.0 does not define this, so we need to do it ourselves

@ -3047,7 +3047,7 @@ inline void gcode_M42() {
if (code_seen('P') && pin_status >= 0 && pin_status <= 255) if (code_seen('P') && pin_status >= 0 && pin_status <= 255)
pin_number = code_value_short(); pin_number = code_value_short();
for (int8_t i = 0; i < (int8_t)(sizeof(sensitive_pins) / sizeof(*sensitive_pins)); i++) { for (int8_t i = 0; i < COUNT(sensitive_pins); i++) {
if (sensitive_pins[i] == pin_number) { if (sensitive_pins[i] == pin_number) {
pin_number = -1; pin_number = -1;
break; break;
@ -4192,7 +4192,7 @@ inline void gcode_M226() {
if (pin_state >= -1 && pin_state <= 1) { if (pin_state >= -1 && pin_state <= 1) {
for (int8_t i = 0; i < (int8_t)(sizeof(sensitive_pins)/sizeof(*sensitive_pins)); i++) { for (int8_t i = 0; i < COUNT(sensitive_pins); i++) {
if (sensitive_pins[i] == pin_number) { if (sensitive_pins[i] == pin_number) {
pin_number = -1; pin_number = -1;
break; break;

@ -19,6 +19,8 @@
*/ */
// Warning this file was generated by a program. // Warning this file was generated by a program.
#include "Marlin.h" #include "Marlin.h"
#include "macros.h"
#ifdef SDSUPPORT #ifdef SDSUPPORT
#ifndef Sd2PinMap_h #ifndef Sd2PinMap_h
@ -385,7 +387,7 @@ static const pin_map_t digitalPinMap[] = {
#error unknown chip #error unknown chip
#endif // defined(__AVR_ATmega1280__) #endif // defined(__AVR_ATmega1280__)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
static const uint8_t digitalPinCount = sizeof(digitalPinMap)/sizeof(pin_map_t); static const uint8_t digitalPinCount = COUNT(digitalPinMap);
uint8_t badPinNumber(void) uint8_t badPinNumber(void)
__attribute__((error("Pin number is too large or not a constant"))); __attribute__((error("Pin number is too large or not a constant")));

@ -475,7 +475,7 @@ void Config_ResetDefault() {
max_feedrate[i] = tmp2[i]; max_feedrate[i] = tmp2[i];
max_acceleration_units_per_sq_second[i] = tmp3[i]; max_acceleration_units_per_sq_second[i] = tmp3[i];
#ifdef SCARA #ifdef SCARA
if (i < sizeof(axis_scaling) / sizeof(*axis_scaling)) if (i < COUNT(axis_scaling))
axis_scaling[i] = 1; axis_scaling[i] = 1;
#endif #endif
} }

@ -2,6 +2,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -50,7 +50,7 @@ void digipot_i2c_init() {
const float digipot_motor_current[] = DIGIPOT_I2C_MOTOR_CURRENTS; const float digipot_motor_current[] = DIGIPOT_I2C_MOTOR_CURRENTS;
Wire.begin(); Wire.begin();
// setup initial currents as defined in Configuration_adv.h // setup initial currents as defined in Configuration_adv.h
for(int i = 0; i <= sizeof(digipot_motor_current) / sizeof(float); i++) { for(int i = 0; i < COUNT(digipot_motor_current); i++) {
digipot_i2c_set_current(i, digipot_motor_current[i]); digipot_i2c_set_current(i, digipot_motor_current[i]);
} }
} }

@ -2,6 +2,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -2,6 +2,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -2,6 +2,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -7,6 +7,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -2,6 +2,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -2,6 +2,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -2,6 +2,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -2,6 +2,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -2,6 +2,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -2,6 +2,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -2,6 +2,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -2,6 +2,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -6,6 +6,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -2,6 +2,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -2,6 +2,7 @@
#define CONFIGURATION_H #define CONFIGURATION_H
#include "boards.h" #include "boards.h"
#include "macros.h"
//=========================================================================== //===========================================================================
//============================= Getting Started ============================= //============================= Getting Started =============================

@ -0,0 +1,27 @@
#ifndef MACROS_H
#define MACROS_H
// Macros for bit masks
#define BIT(b) (1<<(b))
#define TEST(n,b) (((n)&BIT(b))!=0)
#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b))
// Macros for maths shortcuts
#define RADIANS(d) ((d)*M_PI/180.0)
#define DEGREES(r) ((r)*180.0/M_PI)
// Macros to contrain values
#define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
#define NOMORE(v,n) do{ if (v > n) v = n; }while(0)
// Macros to support option testing
#define _CAT(a, ...) a ## __VA_ARGS__
#define SWITCH_ENABLED_0 0
#define SWITCH_ENABLED_1 1
#define SWITCH_ENABLED_ 1
#define ENABLED(b) _CAT(SWITCH_ENABLED_, b)
#define DISABLED(b) (!_CAT(SWITCH_ENABLED_, b))
#define COUNT(a) (sizeof(a)/sizeof(*a))
#endif //__MACROS_H

@ -1249,7 +1249,7 @@ void microstep_init() {
pinMode(E0_MS1_PIN,OUTPUT); pinMode(E0_MS1_PIN,OUTPUT);
pinMode(E0_MS2_PIN,OUTPUT); pinMode(E0_MS2_PIN,OUTPUT);
const uint8_t microstep_modes[] = MICROSTEP_MODES; const uint8_t microstep_modes[] = MICROSTEP_MODES;
for (uint16_t i = 0; i < sizeof(microstep_modes) / sizeof(microstep_modes[0]); i++) for (uint16_t i = 0; i < COUNT(microstep_modes); i++)
microstep_mode(i, microstep_modes[i]); microstep_mode(i, microstep_modes[i]);
#endif #endif
} }

@ -22,6 +22,8 @@
#ifndef STEPPER_INDIRECTION_H #ifndef STEPPER_INDIRECTION_H
#define STEPPER_INDIRECTION_H #define STEPPER_INDIRECTION_H
#include "macros.h"
// X motor // X motor
#define X_STEP_INIT SET_OUTPUT(X_STEP_PIN) #define X_STEP_INIT SET_OUTPUT(X_STEP_PIN)
#define X_STEP_WRITE(STATE) WRITE(X_STEP_PIN,STATE) #define X_STEP_WRITE(STATE) WRITE(X_STEP_PIN,STATE)

@ -2,6 +2,7 @@
#define THERMISTORTABLES_H_ #define THERMISTORTABLES_H_
#include "Marlin.h" #include "Marlin.h"
#include "macros.h"
#define OVERSAMPLENR 16 #define OVERSAMPLENR 16
@ -1123,7 +1124,7 @@ const short temptable_1047[][2] PROGMEM = {
#ifdef THERMISTORHEATER_0 #ifdef THERMISTORHEATER_0
# define HEATER_0_TEMPTABLE TT_NAME(THERMISTORHEATER_0) # define HEATER_0_TEMPTABLE TT_NAME(THERMISTORHEATER_0)
# define HEATER_0_TEMPTABLE_LEN (sizeof(HEATER_0_TEMPTABLE)/sizeof(*HEATER_0_TEMPTABLE)) # define HEATER_0_TEMPTABLE_LEN COUNT(HEATER_0_TEMPTABLE)
#else #else
# ifdef HEATER_0_USES_THERMISTOR # ifdef HEATER_0_USES_THERMISTOR
# error No heater 0 thermistor table specified # error No heater 0 thermistor table specified
@ -1146,7 +1147,7 @@ const short temptable_1047[][2] PROGMEM = {
#ifdef THERMISTORHEATER_1 #ifdef THERMISTORHEATER_1
# define HEATER_1_TEMPTABLE TT_NAME(THERMISTORHEATER_1) # define HEATER_1_TEMPTABLE TT_NAME(THERMISTORHEATER_1)
# define HEATER_1_TEMPTABLE_LEN (sizeof(HEATER_1_TEMPTABLE)/sizeof(*HEATER_1_TEMPTABLE)) # define HEATER_1_TEMPTABLE_LEN COUNT(HEATER_1_TEMPTABLE)
#else #else
# ifdef HEATER_1_USES_THERMISTOR # ifdef HEATER_1_USES_THERMISTOR
# error No heater 1 thermistor table specified # error No heater 1 thermistor table specified
@ -1169,7 +1170,7 @@ const short temptable_1047[][2] PROGMEM = {
#ifdef THERMISTORHEATER_2 #ifdef THERMISTORHEATER_2
# define HEATER_2_TEMPTABLE TT_NAME(THERMISTORHEATER_2) # define HEATER_2_TEMPTABLE TT_NAME(THERMISTORHEATER_2)
# define HEATER_2_TEMPTABLE_LEN (sizeof(HEATER_2_TEMPTABLE)/sizeof(*HEATER_2_TEMPTABLE)) # define HEATER_2_TEMPTABLE_LEN COUNT(HEATER_2_TEMPTABLE)
#else #else
# ifdef HEATER_2_USES_THERMISTOR # ifdef HEATER_2_USES_THERMISTOR
# error No heater 2 thermistor table specified # error No heater 2 thermistor table specified
@ -1192,7 +1193,7 @@ const short temptable_1047[][2] PROGMEM = {
#ifdef THERMISTORHEATER_3 #ifdef THERMISTORHEATER_3
# define HEATER_3_TEMPTABLE TT_NAME(THERMISTORHEATER_3) # define HEATER_3_TEMPTABLE TT_NAME(THERMISTORHEATER_3)
# define HEATER_3_TEMPTABLE_LEN (sizeof(HEATER_3_TEMPTABLE)/sizeof(*HEATER_3_TEMPTABLE)) # define HEATER_3_TEMPTABLE_LEN COUNT(HEATER_3_TEMPTABLE)
#else #else
# ifdef HEATER_3_USES_THERMISTOR # ifdef HEATER_3_USES_THERMISTOR
# error No heater 3 thermistor table specified # error No heater 3 thermistor table specified
@ -1215,7 +1216,7 @@ const short temptable_1047[][2] PROGMEM = {
#ifdef THERMISTORBED #ifdef THERMISTORBED
# define BEDTEMPTABLE TT_NAME(THERMISTORBED) # define BEDTEMPTABLE TT_NAME(THERMISTORBED)
# define BEDTEMPTABLE_LEN (sizeof(BEDTEMPTABLE)/sizeof(*BEDTEMPTABLE)) # define BEDTEMPTABLE_LEN COUNT(BEDTEMPTABLE)
#else #else
# ifdef BED_USES_THERMISTOR # ifdef BED_USES_THERMISTOR
# error No bed thermistor table specified # error No bed thermistor table specified

Loading…
Cancel
Save