Deluge Firmware
Loading...
Searching...
No Matches
encoder.h
Go to the documentation of this file.
1/*
2 * Copyright © 2014-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16*/
17
18#ifndef Encoder_h
19#define Encoder_h
20
21
22#define encMinBacktrackTime (20 * 44) // In milliseconds/44
23#include "r_typedefs.h"
24
26{
27public:
28 Encoder();
29 void read();
30 void setPins(uint8_t pinA1New, uint8_t pinA2New, uint8_t pinB1New, uint8_t pinB2New);
31 void setNonDetentMode();
32 void interrupt(int which);
34 int8_t encPos; // Keeps track of knob's position relative to centre of closest detent
35 int8_t detentPos; // Number of full detents offset since functions last dealt with
36private:
37 uint8_t portA;
38 uint8_t pinA;
39 uint8_t portB;
40 uint8_t pinB;
41 bool pinALastSwitch;
42 bool pinBLastSwitch;
43 bool pinALastRead;
44 bool pinBLastRead;
45 int8_t encLastChange; // The "change" applied on the most recently detected action on this knob. Probably 1 or -1.
46 bool doDetents;
47 bool valuesNow[2];
48};
49
50#endif
Definition: encoder.h:26
void setNonDetentMode()
Definition: encoder.cpp:128
int8_t encPos
Definition: encoder.h:34
int8_t detentPos
Definition: encoder.h:35
void read()
Definition: encoder.cpp:39
void setPins(uint8_t pinA1New, uint8_t pinA2New, uint8_t pinB1New, uint8_t pinB2New)
Definition: encoder.cpp:118
void interrupt(int which)
Definition: encoder.cpp:94
Encoder()
Definition: encoder.cpp:26
int getLimitedDetentPosAndReset()
Definition: encoder.cpp:135