PaulStoffregen 9 年之前
父節點
當前提交
2746714809
共有 1 個文件被更改,包括 28 次插入7 次删除
  1. +28
    -7
      teensy3/wiring.h

+ 28
- 7
teensy3/wiring.h 查看文件

@@ -57,15 +57,36 @@ extern "C"{
#undef abs
#endif

#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 min(a, b) ({ \
typeof(a) _a = (a); \
typeof(b) _b = (b); \
(_a < _b) ? _a : _b; \
})
#define max(a, b) ({ \
typeof(a) _a = (a); \
typeof(b) _b = (b); \
(_a > _b) ? _a : _b; \
})
#define abs(x) ({ \
typeof(x) _x = (x); \
(_x > 0) ? _x : -_x; \
})
#define constrain(amt, low, high) ({ \
typeof(amt) _amt = (amt); \
typeof(low) _low = (low); \
typeof(high) _high = (high); \
(_amt < _low) ? _low : ((_amt > _high) ? _high : _amt); \
})
#define round(x) ({ \
typeof(x) _x = (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 sq(x) ({ \
typeof(x) _x = (x); \
_x * _x; \
})
#define sei() __enable_irq()
#define cli() __disable_irq()
#define interrupts() __enable_irq()

Loading…
取消
儲存