Browse Source

Merge Configuration Macros (PR#2495)

pull/1/head
Richard Wackerbarth 9 years ago
parent
commit
72b9e3a6ac
  1. 1
      Marlin/Configuration.h
  2. 8
      Marlin/Marlin.h
  3. 4
      Marlin/Marlin_main.cpp
  4. 4
      Marlin/Sd2PinMap.h
  5. 2
      Marlin/configuration_store.cpp
  6. 1
      Marlin/configurator/config/Configuration.h
  7. 2
      Marlin/digipot_mcp4451.cpp
  8. 1
      Marlin/example_configurations/Felix/Configuration.h
  9. 1
      Marlin/example_configurations/Felix/Configuration_DUAL.h
  10. 1
      Marlin/example_configurations/Hephestos/Configuration.h
  11. 1
      Marlin/example_configurations/K8200/Configuration.h
  12. 1
      Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h
  13. 1
      Marlin/example_configurations/RigidBot/Configuration.h
  14. 1
      Marlin/example_configurations/SCARA/Configuration.h
  15. 1
      Marlin/example_configurations/WITBOX/Configuration.h
  16. 1
      Marlin/example_configurations/adafruit/ST7565/Configuration.h
  17. 1
      Marlin/example_configurations/delta/biv2.5/Configuration.h
  18. 1
      Marlin/example_configurations/delta/generic/Configuration.h
  19. 1
      Marlin/example_configurations/delta/kossel_mini/Configuration.h
  20. 1
      Marlin/example_configurations/delta/kossel_pro/Configuration.h
  21. 1
      Marlin/example_configurations/makibox/Configuration.h
  22. 1
      Marlin/example_configurations/tvrrug/Round2/Configuration.h
  23. 27
      Marlin/macros.h
  24. 2
      Marlin/stepper.cpp
  25. 2
      Marlin/stepper_indirection.h
  26. 11
      Marlin/thermistortables.h

1
Marlin/Configuration.h

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

8
Marlin/Marlin.h

@ -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

4
Marlin/Marlin_main.cpp

@ -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;

4
Marlin/Sd2PinMap.h

@ -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")));

2
Marlin/configuration_store.cpp

@ -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
} }

1
Marlin/configurator/config/Configuration.h

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

2
Marlin/digipot_mcp4451.cpp

@ -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]);
} }
} }

1
Marlin/example_configurations/Felix/Configuration.h

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

1
Marlin/example_configurations/Felix/Configuration_DUAL.h

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

1
Marlin/example_configurations/Hephestos/Configuration.h

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

1
Marlin/example_configurations/K8200/Configuration.h

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

1
Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h

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

1
Marlin/example_configurations/RigidBot/Configuration.h

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

1
Marlin/example_configurations/SCARA/Configuration.h

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

1
Marlin/example_configurations/WITBOX/Configuration.h

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

1
Marlin/example_configurations/adafruit/ST7565/Configuration.h

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

1
Marlin/example_configurations/delta/biv2.5/Configuration.h

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

1
Marlin/example_configurations/delta/generic/Configuration.h

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

1
Marlin/example_configurations/delta/kossel_mini/Configuration.h

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

1
Marlin/example_configurations/delta/kossel_pro/Configuration.h

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

1
Marlin/example_configurations/makibox/Configuration.h

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

1
Marlin/example_configurations/tvrrug/Round2/Configuration.h

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

27
Marlin/macros.h

@ -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

2
Marlin/stepper.cpp

@ -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
} }

2
Marlin/stepper_indirection.h

@ -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)

11
Marlin/thermistortables.h

@ -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