Skip to content

Commit

Permalink
Change API name
Browse files Browse the repository at this point in the history
  • Loading branch information
GOB52 committed Sep 13, 2024
1 parent de6fd37 commit 2547be6
Show file tree
Hide file tree
Showing 15 changed files with 150 additions and 141 deletions.
18 changes: 9 additions & 9 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -202,31 +202,31 @@ extends=StampS3, option_release, arduino_latest
lib_deps = ${StampS3.lib_deps}
${test_fw.lib_deps}
m5stack/M5Dial
test_filter= embedded/test_ameter, arduino_latest
test_filter= embedded/test_ameter

[env:test_Ameter_AtomS3]
extends=AtomS3, option_release
extends=AtomS3, option_release, arduino_latest
lib_deps = ${AtomS3.lib_deps}
${test_fw.lib_deps}
test_filter= embedded/test_ameter, arduino_latest
test_filter= embedded/test_ameter

[env:test_Ameter_NanoC6]
extends=NanoC6, option_release
extends=NanoC6, option_release, arduino_latest
lib_deps = ${NanoC6.lib_deps}
${test_fw.lib_deps}
test_filter= embedded/test_ameter, arduino_latest
test_filter= embedded/test_ameter

[env:test_Ameter_StickCPlus]
extends=StickCPlus, option_release
extends=StickCPlus, option_release, arduino_latest
lib_deps = ${StickCPlus.lib_deps}
${test_fw.lib_deps}
test_filter= embedded/test_ameter, arduino_latest
test_filter= embedded/test_ameter

[env:test_Ameter_Paper]
extends=Paper, option_release
extends=Paper, option_release, arduino_latest
lib_deps = ${Paper.lib_deps}
${test_fw.lib_deps}
test_filter= embedded/test_ameter, arduino_latest
test_filter= embedded/test_ameter

; Vmeter
[env:test_Vmeter_Core]
Expand Down
2 changes: 1 addition & 1 deletion src/unit/unit_ADS1113.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const types::uid_t UnitADS1113::uid{"UnitADS1113"_mmh3};
const types::uid_t UnitADS1113::attr{0};
bool UnitADS1113::on_begin() {
M5_LIB_LOGV("mux, gain, and comp_que not support");
return setSamplingRate(_cfg.rate);
return writeSamplingRate(_cfg.rate);
}
} // namespace unit
} // namespace m5
13 changes: 6 additions & 7 deletions src/unit/unit_ADS1113.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace m5 {
namespace unit {

/*!
@class UnitADS1113
@brief ADS1113 unit
Expand All @@ -31,27 +30,27 @@ class UnitADS1113 : public UnitADS111x {
///@name Configration
///@{
/*! @brief Not support @warning Not support */
virtual bool setMultiplexer(const ads111x::Mux) override {
virtual bool writeMultiplexer(const ads111x::Mux) override {
return false;
}
//! @brief Not support @warning Not support
virtual bool setGain(const ads111x::Gain) override {
virtual bool writeGain(const ads111x::Gain) override {
return false;
}
//! @brief Not support @warning Not support
virtual bool setComparatorMode(const bool) override {
virtual bool writeComparatorMode(const bool) override {
return false;
}
//! @brief Not support @warning Not support
virtual bool setComparatorPolarity(const bool) override {
virtual bool writeComparatorPolarity(const bool) override {
return false;
}
//! @brief Not support @warning Not support
virtual bool setLatchingComparator(const bool) override {
virtual bool writeLatchingComparator(const bool) override {
return false;
}
//! @brief Not support @warning Not support
virtual bool setComparatorQueue(const ads111x::ComparatorQueue) override {
virtual bool writeComparatorQueue(const ads111x::ComparatorQueue) override {
return false;
}
///@}
Expand Down
2 changes: 1 addition & 1 deletion src/unit/unit_ADS1114.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const types::uid_t UnitADS1114::uid{"UnitADS1114"_mmh3};
const types::uid_t UnitADS1114::attr{0};
bool UnitADS1114::on_begin() {
M5_LIB_LOGV("mux is not support");
return setSamplingRate(_cfg.rate) && setGain(_cfg.gain) && setComparatorQueue(_cfg.comp_que);
return writeSamplingRate(_cfg.rate) && writeGain(_cfg.gain) && writeComparatorQueue(_cfg.comp_que);
}
} // namespace unit
} // namespace m5
32 changes: 16 additions & 16 deletions src/unit/unit_ADS1114.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@ class UnitADS1114 : public UnitADS111x {
///@name Configration
///@{
/*! @brief Not support @warning Not support */
virtual bool setMultiplexer(const ads111x::Mux) override {
virtual bool writeMultiplexer(const ads111x::Mux) override {
return false;
}
//! @brief Set the programmable gain amplifier
virtual bool setGain(const ads111x::Gain gain) override {
return set_gain(gain);
//! @brief Write the programmable gain amplifier
virtual bool writeGain(const ads111x::Gain gain) override {
return write_gain(gain);
}
//! @brief Set the comparator mode
virtual bool setComparatorMode(const bool b) override {
return set_comparator_mode(b);
//! @brief Write the comparator mode
virtual bool writeComparatorMode(const bool b) override {
return write_comparator_mode(b);
}
//! @brief Set the comparator polarity
virtual bool setComparatorPolarity(const bool b) override {
return set_comparator_polarity(b);
//! @brief Write the comparator polarity
virtual bool writeComparatorPolarity(const bool b) override {
return write_comparator_polarity(b);
}
//! @brief Set the latching comparator
virtual bool setLatchingComparator(const bool b) override {
return set_latching_comparator(b);
//! @brief Write the latching comparator
virtual bool writeLatchingComparator(const bool b) override {
return write_latching_comparator(b);
}
//! @brief Set the comparator queue
virtual bool setComparatorQueue(const ads111x::ComparatorQueue c) override {
return set_comparator_queue(c);
//! @brief Write the comparator queue
virtual bool writeComparatorQueue(const ads111x::ComparatorQueue c) override {
return write_comparator_queue(c);
}
///@}

Expand Down
10 changes: 5 additions & 5 deletions src/unit/unit_ADS1115.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const char UnitADS1115::name[] = "UnitADS1115";
const types::uid_t UnitADS1115::uid{"UnitADS1115"_mmh3};
const types::uid_t UnitADS1115::attr{0};
bool UnitADS1115::on_begin() {
return setSamplingRate(_cfg.rate) && setMultiplexer(_cfg.mux) && setGain(_cfg.gain) &&
setComparatorQueue(_cfg.comp_que);
return writeSamplingRate(_cfg.rate) && writeMultiplexer(_cfg.mux) && writeGain(_cfg.gain) &&
writeComparatorQueue(_cfg.comp_que);
}

// class UnitAVmeterBase
Expand All @@ -54,12 +54,12 @@ bool UnitAVmeterBase::on_begin() {
if (!_eeprom.readCalibration()) {
return false;
}
apply_calibration(_adsCfg.pga());
apply_calibration(_ads_cfg.pga());
return UnitADS1115::on_begin();
}

bool UnitAVmeterBase::setGain(const ads111x::Gain gain) {
if (UnitADS1115::setGain(gain)) {
bool UnitAVmeterBase::writeGain(const ads111x::Gain gain) {
if (UnitADS1115::writeGain(gain)) {
apply_calibration(gain);
return true;
}
Expand Down
39 changes: 19 additions & 20 deletions src/unit/unit_ADS1115.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

namespace m5 {
namespace unit {

/*!
@class UnitADS1115
@brief ADS1115 unit
Expand All @@ -31,29 +30,29 @@ class UnitADS1115 : public UnitADS111x {

///@name Configration
///@{
/*! @brief Set the input multiplexer */
virtual bool setMultiplexer(const ads111x::Mux mux) override {
return set_multiplexer(mux);
/*! @brief Write the input multiplexer */
virtual bool writeMultiplexer(const ads111x::Mux mux) override {
return write_multiplexer(mux);
}
//! @brief Set the programmable gain amplifier
virtual bool setGain(const ads111x::Gain gain) override {
return set_gain(gain);
//! @brief Write the programmable gain amplifier
virtual bool writeGain(const ads111x::Gain gain) override {
return write_gain(gain);
}
//! @brief Set the comparator mode
virtual bool setComparatorMode(const bool b) override {
return set_comparator_mode(b);
//! @brief Write the comparator mode
virtual bool writeComparatorMode(const bool b) override {
return write_comparator_mode(b);
}
//! @brief Set the comparator polarity
virtual bool setComparatorPolarity(const bool b) override {
return set_comparator_polarity(b);
//! @brief Write the comparator polarity
virtual bool writeComparatorPolarity(const bool b) override {
return write_comparator_polarity(b);
}
//! @brief Set the latching comparator
virtual bool setLatchingComparator(const bool b) override {
return set_latching_comparator(b);
//! @brief Write the latching comparator
virtual bool writeLatchingComparator(const bool b) override {
return write_latching_comparator(b);
}
//! @brief Set the comparator queue
virtual bool setComparatorQueue(const ads111x::ComparatorQueue c) override {
return set_comparator_queue(c);
//! @brief Write the comparator queue
virtual bool writeComparatorQueue(const ads111x::ComparatorQueue c) override {
return write_comparator_queue(c);
}
///@}

Expand All @@ -77,7 +76,7 @@ class UnitAVmeterBase : public UnitADS1115 {
return _calibrationFactor;
}

virtual bool setGain(const ads111x::Gain gain) override;
virtual bool writeGain(const ads111x::Gain gain) override;

protected:
virtual Adapter* duplicate_adapter(const uint8_t ch) override;
Expand Down
40 changes: 20 additions & 20 deletions src/unit/unit_ADS111x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ bool UnitADS111x::begin() {
return false;
}

if (!read_config(_adsCfg)) {
if (!read_config(_ads_cfg)) {
M5_LIB_LOGE("Failed to get config");
return false;
}
apply_interval(_adsCfg.dr());
apply_coefficient(_adsCfg.pga());
apply_interval(_ads_cfg.dr());
apply_coefficient(_ads_cfg.pga());

return _cfg.start_periodic ? startPeriodicMeasurement() : stopPeriodicMeasurement();
}
Expand All @@ -105,15 +105,15 @@ void UnitADS111x::update(const bool force) {
}

Gain UnitADS111x::gain() const {
return gain_table[m5::stl::to_underlying(_adsCfg.pga())];
return gain_table[m5::stl::to_underlying(_ads_cfg.pga())];
}

bool UnitADS111x::setSamplingRate(ads111x::Sampling rate) {
bool UnitADS111x::writeSamplingRate(ads111x::Sampling rate) {
Config c{};
if (read_config(c)) {
c.dr(rate);
if (write_config(c)) {
apply_interval(_adsCfg.dr());
apply_interval(_ads_cfg.dr());
return true;
}
}
Expand All @@ -137,7 +137,7 @@ bool UnitADS111x::start_periodic_measurement() {
}

bool UnitADS111x::start_periodic_measurement(const ads111x::Sampling rate) {
return !inPeriodic() && setSamplingRate(rate) && start_periodic_measurement();
return !inPeriodic() && writeSamplingRate(rate) && start_periodic_measurement();
}

bool UnitADS111x::stop_periodic_measurement() {
Expand Down Expand Up @@ -209,21 +209,21 @@ bool UnitADS111x::generalReset() {
Config c{};
do {
// power-down mode?
if (read_config(_adsCfg) && _adsCfg.mode()) {
if (read_config(_ads_cfg) && _ads_cfg.mode()) {
done = true;
break;
}
m5::utility::delay(1);
} while (!done && m5::utility::millis() <= timeout_at);

if (done) {
apply_interval(_adsCfg.dr());
apply_coefficient(_adsCfg.pga());
apply_interval(_ads_cfg.dr());
apply_coefficient(_ads_cfg.pga());
}
return done;
}

bool UnitADS111x::readThreshould(int16_t& high, int16_t& low) {
bool UnitADS111x::readThreshold(int16_t& high, int16_t& low) {
uint16_t hh{}, ll{};
if (readRegister16(HIGH_THRESHOLD_REG, hh, 0) && readRegister16(LOW_THRESHOLD_REG, ll, 0)) {
high = hh;
Expand All @@ -233,7 +233,7 @@ bool UnitADS111x::readThreshould(int16_t& high, int16_t& low) {
return false;
}

bool UnitADS111x::setThreshould(const int16_t high, const int16_t low) {
bool UnitADS111x::writeThreshold(const int16_t high, const int16_t low) {
if (high <= low) {
M5_LIB_LOGW("high must be greater than low");
return false;
Expand All @@ -248,7 +248,7 @@ bool UnitADS111x::read_config(ads111x::Config& c) {

bool UnitADS111x::write_config(const ads111x::Config& c) {
if (writeRegister16(CONFIG_REG, c.value)) {
_adsCfg = c;
_ads_cfg = c;
return true;
}
return false;
Expand All @@ -267,7 +267,7 @@ void UnitADS111x::apply_coefficient(const ads111x::Gain gain) {
_coefficient = coefficient_table[idx];
}

bool UnitADS111x::set_multiplexer(const ads111x::Mux mux) {
bool UnitADS111x::write_multiplexer(const ads111x::Mux mux) {
Config c{};
if (read_config(c)) {
c.mux(mux);
Expand All @@ -276,19 +276,19 @@ bool UnitADS111x::set_multiplexer(const ads111x::Mux mux) {
return false;
}

bool UnitADS111x::set_gain(const ads111x::Gain gain) {
bool UnitADS111x::write_gain(const ads111x::Gain gain) {
Config c{};
if (read_config(c)) {
c.pga(gain);
if (write_config(c)) {
apply_coefficient(_adsCfg.pga());
apply_coefficient(_ads_cfg.pga());
return true;
}
}
return false;
}

bool UnitADS111x::set_comparator_mode(const bool b) {
bool UnitADS111x::write_comparator_mode(const bool b) {
Config c{};
if (read_config(c)) {
c.comp_mode(b);
Expand All @@ -297,7 +297,7 @@ bool UnitADS111x::set_comparator_mode(const bool b) {
return false;
}

bool UnitADS111x::set_comparator_polarity(const bool b) {
bool UnitADS111x::write_comparator_polarity(const bool b) {
Config c{};
if (read_config(c)) {
c.comp_pol(b);
Expand All @@ -306,7 +306,7 @@ bool UnitADS111x::set_comparator_polarity(const bool b) {
return false;
}

bool UnitADS111x::set_latching_comparator(const bool b) {
bool UnitADS111x::write_latching_comparator(const bool b) {
Config c{};
if (read_config(c)) {
c.comp_lat(b);
Expand All @@ -315,7 +315,7 @@ bool UnitADS111x::set_latching_comparator(const bool b) {
return false;
}

bool UnitADS111x::set_comparator_queue(const ads111x::ComparatorQueue q) {
bool UnitADS111x::write_comparator_queue(const ads111x::ComparatorQueue q) {
Config c{};
if (read_config(c)) {
c.comp_que(q);
Expand Down
Loading

0 comments on commit 2547be6

Please sign in to comment.