M5Unit-METER 0.2.0 git rev:3a4ce01
Loading...
Searching...
No Matches
unit_av_base.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
10#ifndef M5_UNIT_METER_UNIT_AV_BASE_HPP
11#define M5_UNIT_METER_UNIT_AV_BASE_HPP
12
13#include "unit_ADS1115.hpp"
14#include "unit_EEPROM.hpp"
15
16namespace m5 {
17namespace unit {
18
23class UnitAVmeterBase : public UnitADS1115 {
24 M5_UNIT_COMPONENT_HPP_BUILDER(UnitAVmeterBase, 0x00);
25
26public:
27 explicit UnitAVmeterBase(const uint8_t addr = DEFAULT_ADDRESS, const uint8_t eepromAddr = 0x00);
28 virtual ~UnitAVmeterBase()
29 {
30 }
31
32 virtual bool begin() override;
33
34 inline float calibrationFactor() const
35 {
36 return _calibrationFactor;
37 }
38
39 virtual bool writeGain(const ads111x::Gain gain) override;
40
41protected:
42 std::shared_ptr<Adapter> ensure_adapter(const uint8_t ch);
43 void apply_calibration(const ads111x::Gain gain);
44 bool validChild() const
45 {
46 return _valid;
47 }
48
49protected:
51
52private:
53 float _calibrationFactor{1.0f};
54 bool _valid{}; // Did the constructor correctly add the child unit?
55};
56
57} // namespace unit
58} // namespace m5
59#endif
ads111x::Gain gain() const
Gets the programmable gain amplifier.
Definition unit_ADS111x.cpp:104
virtual bool writeGain(const ads111x::Gain gain) override
Write the programmable gain amplifier.
Definition unit_av_base.cpp:48
Accessor unit to EEPROM that holds calibration data.
Top level namespace of M5stack.
Unit-related namespace.
ADS1115 Unit for M5UnitUnified.
Accessor unit to EEPROM that holds calibration information.