diff options
author | Alex Ong <the.onga@gmail.com> | 2019-01-04 19:39:14 +1100 |
---|---|---|
committer | Alex Ong <the.onga@gmail.com> | 2019-01-04 19:39:14 +1100 |
commit | 47c91fc7f75ae0a477e55b687aa0fc30da0a283c (patch) | |
tree | 65ad39452748ff2e6d4a83ce54ede6ca22c9ada9 /keyboards/sol/common/knob_v2.h | |
parent | ac9b88e8ccbbf38762871504cd827ff0d941c426 (diff) | |
parent | 563ce3f225d981ce460c12ca5130dfe47af41df0 (diff) | |
download | qmk_firmware-47c91fc7f75ae0a477e55b687aa0fc30da0a283c.tar.gz qmk_firmware-47c91fc7f75ae0a477e55b687aa0fc30da0a283c.zip |
Merge branch 'master' of https://github.com/qmk/qmk_firmware
Diffstat (limited to 'keyboards/sol/common/knob_v2.h')
-rw-r--r-- | keyboards/sol/common/knob_v2.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/keyboards/sol/common/knob_v2.h b/keyboards/sol/common/knob_v2.h new file mode 100644 index 0000000000..45196eb1a6 --- /dev/null +++ b/keyboards/sol/common/knob_v2.h @@ -0,0 +1,28 @@ +// Rotary knob implementation - Version 2. +// Uses 2 digital pins - D2 (via interrupt) & D6. +// #include "rev1.h" +#include <avr/io.h> +#include <avr/interrupt.h> +#include <stdbool.h> + +#ifndef ENCODER_PIN_1 + #define ENCODER_PIN_1 PD2 +#endif +#ifndef ENCODER_PIN_2 + #define ENCODER_PIN_2 PD6 +#endif +#ifndef ENCODER_INT + #define ENCODER_INT INT2_vect +#endif + +typedef struct knob_report_t { + int8_t dir; // Contains number of rotations that happened + int8_t phase; // Contains 0 if last rotation happened on 90 degrees, 1 if on 270 +} knob_report_t; + +void knob_init(void); +knob_report_t knob_report_read(void); +void knob_report_reset(void); + +bool knob_prev_a; +int8_t knob_dir; |