blob: e2ca00b1eb30e1358694f23ddf67f920d567e03e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/*
* Copyright 2023 jacqueline <me@jacqueline.id.au>
*
* SPDX-License-Identifier: GPL-3.0-only
*/
#pragma once
#include <stdint.h>
#include <functional>
#include "esp_err.h"
#include "result.hpp"
#include "gpio_expander.hpp"
namespace drivers {
/*
* Driver for a two-channel digital potentiometer, with steps measured in
* decibels.
*/
class DigitalPot {
public:
explicit DigitalPot(GpioExpander* gpios);
~DigitalPot() {}
// Not copyable or movable.
DigitalPot(const DigitalPot&) = delete;
DigitalPot& operator=(const DigitalPot&) = delete;
enum class Channel {
kLeft,
kRight,
};
auto SetRelative(int_fast8_t change) -> void;
auto SetRelative(Channel ch, int_fast8_t change) -> void;
auto SetZeroCrossDetect(bool enabled) -> void;
auto GetMaxAttenuation() -> int_fast8_t;
auto GetMinAttenuation() -> int_fast8_t;
private:
GpioExpander* gpios_;
};
} // namespace drivers
|