From 610991455d335663de1dd6c0c6a3e0247ffd46df Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 7 Jun 2023 09:50:25 +1000 Subject: R4 pre-emptive bringup Includes stripping out the IC-specific I2S stuff, and doing more manual volume control using pots --- src/drivers/include/digital_pot.hpp | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/drivers/include/digital_pot.hpp (limited to 'src/drivers/include/digital_pot.hpp') diff --git a/src/drivers/include/digital_pot.hpp b/src/drivers/include/digital_pot.hpp new file mode 100644 index 00000000..e2ca00b1 --- /dev/null +++ b/src/drivers/include/digital_pot.hpp @@ -0,0 +1,49 @@ +/* + * Copyright 2023 jacqueline + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#pragma once + +#include +#include + +#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 -- cgit v1.2.3