Move macros, add ENABLED/DISABLED, add includes

This commit is contained in:
Scott Lahteine 2015-07-22 15:39:23 -07:00 committed by Richard Wackerbarth
parent 17960fd2b0
commit d85861d296
20 changed files with 44 additions and 8 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

25
Marlin/macros.h Normal file
View file

@ -0,0 +1,25 @@
#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))
#endif //__MACROS_H

View file

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