Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
encoder.h
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#pragma once
19
20#define encMinBacktrackTime (20 * 44) // In milliseconds/44
21#include <cstdint>
22
23namespace deluge::hid::encoders {
24
25class Encoder {
26public:
27 Encoder();
28
29 Encoder(Encoder& other) = delete;
30 Encoder(Encoder&& other) = delete;
31 Encoder& operator=(Encoder& other) = delete;
32 Encoder&& operator=(Encoder&& other) = delete;
33
34 void read();
35 void setPins(uint8_t pinA1New, uint8_t pinA2New, uint8_t pinB1New, uint8_t pinB2New);
36 void setNonDetentMode();
37 int32_t getLimitedDetentPosAndReset();
38 int8_t encPos; // Keeps track of knob's position relative to centre of closest detent
39 int8_t detentPos; // Number of full detents offset since functions last dealt with
40private:
41 uint8_t portA;
42 uint8_t pinA;
43 uint8_t portB;
44 uint8_t pinB;
45 bool pinALastSwitch;
46 bool pinBLastSwitch;
47 bool pinALastRead;
48 bool pinBLastRead;
49 int8_t encLastChange; // The "change" applied on the most recently detected action on this knob. Probably 1 or -1.
50 bool doDetents;
51 bool valuesNow[2];
52};
53
54} // namespace deluge::hid::encoders