forked from profezzorn/ProffieOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae922c2
commit 3826aff
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef TRANSITIONS_BLINK_H | ||
#define TRANSITIONS_BLINK_H | ||
|
||
#include "base.h" | ||
|
||
// Usage: TrBlinkX<MILLIS_FUNCTION, N, WIDTH_FUNCTION> | ||
// or: TrBlink<MILLIS, N, WIDTH> | ||
// MILLIS_FUNCTION: FUNCTION | ||
// MILLIS: a number | ||
// N: a number | ||
// WIDTH_FUNCTION: FUNCTION, defaults to Int<16384> | ||
// WIDTH: a number, defaults to 16384 | ||
// return value: TRANSITION | ||
// Blinks A-B N times in MILLIS, based on WIDTH (0 ~ 32768) | ||
// If WIDTH = 16384 A and B appear equally, lower decreases length of A, higher increases length of A | ||
template<class MILLIS, int N, class WIDTH = Int<16384>> | ||
class TrBlinkX : public TransitionBaseX<MILLIS> { | ||
public: | ||
void run(BladeBase* blade) { | ||
TransitionBaseX<MILLIS>::run(blade); | ||
width_.run(blade); | ||
blink_ = (this->update(32768 * N) & 0x7fff) < width_.calculate(blade); | ||
} | ||
private: | ||
PONUA SVFWrapper<WIDTH> width_; | ||
bool blink_; | ||
public: | ||
template<class A, class B> | ||
auto getColor(const A& a, const B& b, int led) -> decltype(MixColors(a,b,1,1)) { | ||
if (blink_) { | ||
return a; | ||
} else { | ||
return b; | ||
} | ||
} | ||
}; | ||
|
||
template<int MILLIS, int N, int WIDTH = 16384> using TrBlink = TrBlinkX<Int<MILLIS>, N, Int<WIDTH>>; | ||
|
||
#endif |