lib Modulove
Library for building custom scripts for Modulove modules.
Loading...
Searching...
No Matches
encoder_dir.h
Go to the documentation of this file.
1
11#ifndef ENCODER_DIR_H
12#define ENCODER_DIR_H
13
14namespace modulove {
15namespace arythmatik {
16
19 DIRECTION_UNCHANGED,
20 DIRECTION_INCREMENT,
21 DIRECTION_DECREMENT,
22};
23
24inline Direction rotate_(int dir) {
25 switch (dir) {
26 case 1:
27 return DIRECTION_INCREMENT;
28 case -1:
29 return DIRECTION_DECREMENT;
30 default:
31 return DIRECTION_UNCHANGED;
32 }
33}
34
35inline Direction rotate_reversed_(int dir) {
36 switch (dir) {
37 case 1:
38 return DIRECTION_DECREMENT;
39 case -1:
40 return DIRECTION_INCREMENT;
41 default:
42 return DIRECTION_UNCHANGED;
43 }
44}
45
48inline Direction Rotate(int dir, bool reversed) {
49 int _dir = dir > 0 ? 1 : -1;
50 return (reversed) ? rotate_reversed_(_dir) : rotate_(_dir);
51}
52
53} // namespace arythmatik
54} // namespace modulove
55
56#endif
Direction Rotate(int dir, bool reversed)
Parse EncoderButton increment direction.
Definition encoder_dir.h:48
Direction
Enum constants for encoder rotation increment/decrement state.
Definition encoder_dir.h:18