diff options
author | David A. Mellis <d.mellis@arduino.cc> | 2007-11-21 17:08:07 +0000 |
---|---|---|
committer | David A. Mellis <d.mellis@arduino.cc> | 2007-11-21 17:08:07 +0000 |
commit | 0292fe91fc2de0e5c5b374a6d0e0c3879fe49387 (patch) | |
tree | f6361f290f3a2621e39f442ddda4c89cd4e5b915 /cores/arduino/wiring.h | |
parent | 72d917f70cdf8edbb11c0648b59bb9afeae64065 (diff) |
Adding map(), fixing radians() and degrees(), adding cast functions (int(x) instead of (int) x), adding interrupts() and noInterrupts(), etc.
Diffstat (limited to 'cores/arduino/wiring.h')
-rwxr-xr-x | cores/arduino/wiring.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cores/arduino/wiring.h b/cores/arduino/wiring.h index 3c77389..e0c5315 100755 --- a/cores/arduino/wiring.h +++ b/cores/arduino/wiring.h @@ -44,6 +44,8 @@ extern "C"{ #define PI 3.14159265 #define HALF_PI 1.57079 #define TWO_PI 6.283185 +#define DEG_TO_RAD 0.01745329 +#define RAD_TO_DEG 57.2957786 #define SERIAL 0x0 #define DISPLAY 0x1 @@ -55,14 +57,30 @@ extern "C"{ #define FALLING 2 #define RISING 3 +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif + +#define int(x) ((int)(x)) +#define char(x) ((char)(x)) +#define long(x) ((long)(x)) +#define byte(x) ((uint8_t)(x)) +#define float(x) ((float)(x)) +#define boolean(x) ((uint8_t)((x)==0?0:1)) + #define min(a,b) ((a)<(b)?(a):(b)) #define max(a,b) ((a)>(b)?(a):(b)) #define abs(x) ((x)>0?(x):-(x)) #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) #define radians(deg) ((deg)*DEG_TO_RAD) #define degrees(rad) ((rad)*RAD_TO_DEG) #define sq(x) ((x)*(x)) +#define interrupts() sei() +#define noInterrupts() cli() + #define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) #define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) |