31 lines
467 B
C++
31 lines
467 B
C++
|
|
#pragma once
|
|
|
|
template <typename T>
|
|
inline T clamp(T v, T a, T b) {
|
|
return min(max(v, a), b);
|
|
}
|
|
|
|
template <typename T>
|
|
inline void swap(T& a, T& b) {
|
|
T t = b;
|
|
b = a;
|
|
a = t;
|
|
}
|
|
|
|
#ifdef DEBUG_BLINK
|
|
inline void debug_blink() {
|
|
digitalWrite(9, 0);
|
|
delay(120);
|
|
digitalWrite(9, 1);
|
|
delay(10);
|
|
digitalWrite(9, 0);
|
|
delay(120);
|
|
}
|
|
#endif
|
|
|
|
#define bm(V) (((uint64_t)1 << V) - 1)
|
|
#define size(V) (sizeof(V) / sizeof(V[0]))
|
|
#define AW_IN __attribute__((always_inline))
|
|
|