PIDUINO
Loading...
Searching...
No Matches
mcp4728.h
1/* Copyright © 2018-2025 Pascal JEAN, All rights reserved.
2 This file is part of the Piduino Library.
3
4 The Piduino Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8
9 The Piduino Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with the Piduino Library; if not, see <http://www.gnu.org/licenses/>.
16*/
17#pragma once
18
19#include <array>
20#include <piduino/converter.h>
21#include <piduino/i2cdev.h>
22
23namespace Piduino {
24
42 class Mcp4728 : public Converter {
43
44 public:
45
46 static constexpr int DefaultAddress = 0x60;
47 static constexpr int DefaultReferenceId = VddReference;
48 static constexpr double DefaultFullScaleRange = 3.3;
49 static constexpr double InternalFullScaleRange = 2.048;
50
61 Mcp4728 (int busId = I2cDev::Info::defaultBus().id(), int address = DefaultAddress);
62
69 virtual ~Mcp4728();
70
88 explicit Mcp4728 (const std::string &parameters);
89
101 static std::string registeredName() {
102 return "mcp4728";
103 }
104
174 bool fastWrite (const uint16_t values[4]);
175
188 bool fastWrite (const std::array<uint16_t, 4> &values) {
189 return fastWrite (values.data());
190 }
191
192
193 protected:
201 class Private;
202
213
214 private:
223 };
224}
225
226/* ========================================================================== */
The Converter class provides an interface for analog-to-digital and digital-to-analog converters.
Definition converter.h:34
@ VddReference
Vdd reference voltage (analog or digital power supply depending on the converter)
Definition converter.h:185
static Info defaultBus()
Gets information about the default I2C bus on the system.
Class for the MCP4728 series of digital-to-analog converters.
Definition mcp4728.h:42
static constexpr double InternalFullScaleRange
Internal full-scale range for the MCP4728.
Definition mcp4728.h:49
virtual ~Mcp4728()
Virtual destructor for the Mcp4728 class.
static constexpr int DefaultAddress
Default I2C address for the MCP4728.
Definition mcp4728.h:46
static constexpr double DefaultFullScaleRange
Default full-scale range for the MCP4728.
Definition mcp4728.h:48
static constexpr int DefaultReferenceId
Default reference ID for the MCP4728.
Definition mcp4728.h:47
static std::string registeredName()
Returns the name registered for this converter.
Definition mcp4728.h:101
Mcp4728(int busId=I2cDev::Info::defaultBus().id(), int address=DefaultAddress)
Constructs a Mcp4728 object with the specified I2C device and parameters.
bool fastWrite(const uint16_t values[4])
Writes multiple values to the MCP4728 DAC channels in a single operation.
Mcp4728(const std::string &parameters)
Constructs a Mcp4728 object from a string of parameters.
bool fastWrite(const std::array< uint16_t, 4 > &values)
Writes multiple values to the MCP4728 DAC channels in a single operation.
Definition mcp4728.h:188
Mcp4728(Private &dd)
Protected constructor for internal use with PIMPL pattern.
Internal implementation class for GpioDevice.
#define PIMP_DECLARE_PRIVATE(Class)
PIMP_DECLARE_PRIVATE.
Definition global.h:82
Global namespace for Piduino.
Definition board.h:28