Skip to content

Commit

Permalink
Some tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
GOB52 committed Sep 16, 2024
1 parent bf773a2 commit 5d7b864
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 33 deletions.
20 changes: 8 additions & 12 deletions examples/demo/MultipleDevices/main/MultipleDevices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "ui/ui_UnitTVOC.hpp"
#include "ui/ui_UnitVmeter.hpp"
#include "ui/ui_UnitENV3.hpp"
// #include "ui/ui_UnitCO2.hpp"

using namespace m5::unit;

Expand Down Expand Up @@ -112,7 +111,7 @@ void prepare() {
// Setup fro begin
auto cfg = unitQMP6988.config();
cfg.standby_time =
m5::unit::qmp6988::StandbyTime::Time50ms; // about 16 mps (Calculated from other parameters and this value
m5::unit::qmp6988::Standby::Time50ms; // about 16 mps (Calculated from other parameters and this value
unitQMP6988.config(cfg);
}

Expand All @@ -128,7 +127,7 @@ void prepare() {
tvocSmallUI.construct();
vmeterSmallUI.construct();
env3SmallUI.construct();
heartSmallUI.heartRate().setSamplingRate(m5::max30100::HeartRate::getSamplingRate(unitHeart.config().samplingRate));
heartSmallUI.heartRate().setSampleRate(m5::max30100::HeartRate::getSampleRate(unitHeart.config().sample_rate));
}

// task for Vmeter
Expand Down Expand Up @@ -161,7 +160,7 @@ void update_vmeter(void*) {
auto now = m5::utility::millis();
if (now >= start_at + 1000) {
mps = fcnt;
M5_LOGW("Vmeter:%u (%u)", mps, mcnt);
M5_LOGD("Vmeter:%u (%u)", mps, mcnt);
fcnt = mcnt = 0;
start_at = now;
}
Expand Down Expand Up @@ -211,7 +210,7 @@ void update_tvoc(void*) {
auto now = m5::utility::millis();
if (now >= start_at + 1000) {
mps = fcnt;
M5_LOGW("TVOC:%u (%u)", mps, mcnt);
M5_LOGD("TVOC:%u (%u)", mps, mcnt);
fcnt = mcnt = 0;
start_at = now;
}
Expand Down Expand Up @@ -247,7 +246,7 @@ void update_sht30(void*) {
auto now = m5::utility::millis();
if (now >= start_at + 1000) {
mps = fcnt;
M5_LOGW("SHT30:%u (%u)", mps, mcnt);
M5_LOGD("SHT30:%u (%u)", mps, mcnt);
fcnt = mcnt = 0;
start_at = now;
}
Expand Down Expand Up @@ -283,7 +282,7 @@ void update_qmp6988(void*) {
auto now = m5::utility::millis();
if (now >= start_at + 1000) {
mps = fcnt;
M5_LOGW("QMP6988:%u (%u)", mps, mcnt);
M5_LOGD("QMP6988:%u (%u)", mps, mcnt);
fcnt = mcnt = 0;
start_at = now;
}
Expand Down Expand Up @@ -320,7 +319,7 @@ void update_heart(void*) {
auto now = m5::utility::millis();
if (now >= start_at + 1000) {
mps = fcnt;
M5_LOGW("Heart:%u (%u)", mps, mcnt);
M5_LOGD("Heart:%u (%u)", mps, mcnt);
fcnt = mcnt = 0;
start_at = now;
}
Expand All @@ -336,12 +335,9 @@ void drawUI(LovyanGFX& dst, const uint32_t x, const uint32_t yoffset) {
} // namespace

void setup() {
m5::utility::delay(1500);

M5.begin();
lcd.startWrite();
lcd.clear(TFT_DARKGRAY);

//
strip_height = lcd.height() / SPLIT_NUM;
uint32_t cnt{};
Expand Down Expand Up @@ -402,7 +398,7 @@ void loop() {
auto now = m5::utility::millis();
if (now >= start_at + 1000) {
fps = fpsCnt;
M5_LOGW("FPS:%u", fps);
M5_LOGD("FPS:%u", fps);
fpsCnt = 0;
start_at = now;
}
Expand Down
19 changes: 7 additions & 12 deletions src/M5UnitComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ class Component {
uint8_t max_children{0};
};

/*!
@struct config_t
@brief Base settings for begin
@note Derived classes are defined by deriving their own config_t from this
*/
struct config_t {};

///@warning Define the same name and type in the derived class.
///@name Fixed parameters for class
///@{
Expand Down Expand Up @@ -89,11 +82,11 @@ class Component {

///@name Component settings
///@{
/*! @brief Gets the configuration */
/*! @brief Gets the common configurations in each unit */
inline component_config_t component_config() {
return _component_cfg;
}
//! @brief Set the configuration
//! @brief Set the common configurations in each unit
inline void component_config(const component_config_t& cfg) {
_component_cfg = cfg;
}
Expand Down Expand Up @@ -366,7 +359,7 @@ class Component {

/*!
@class PeriodicMeasurementAdapter
@brief Interface class for periodic measurement
@brief Interface class for periodic measurement (CRTP)
@details Common interface for accumulated periodic measurement data
@details Provide a common interface for periodic measurements for each unit
@tparam Derived Derived class
Expand All @@ -393,7 +386,8 @@ class PeriodicMeasurementAdapter {
@note Call Derived::start_periodic_measurement
*/
template <typename... Args>
bool startPeriodicMeasurement(Args&&... args) {
inline bool startPeriodicMeasurement(Args&&... args) {
// Prepare for future common initiation preprocessing needs
return static_cast<Derived*>(this)->start_periodic_measurement(std::forward<Args>(args)...);
}
/*!
Expand All @@ -403,7 +397,8 @@ class PeriodicMeasurementAdapter {
@note Call Derived::stop_periodic_measurement
*/
template <typename... Args>
bool stopPeriodicMeasurement(Args&&... args) {
inline bool stopPeriodicMeasurement(Args&&... args) {
// Prepare for future common stopping preprocessing needs
return static_cast<Derived*>(this)->stop_periodic_measurement(std::forward<Args>(args)...);
}
///@}
Expand Down
2 changes: 1 addition & 1 deletion src/M5UnitUnified.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool UnitUnified::add_children(Component& u) {
M5_LIB_LOGV("%s duplicate %u", u.deviceName(), ch);
auto ad = u.duplicate_adapter(ch);
if (!ad) {
M5_LIB_LOGE("Failed to ensure_adapter() %s:%u", u.deviceName(), ch);
M5_LIB_LOGE("Failed to duplicate_adapter() %s:%u", u.deviceName(), ch);
return false;
}
if (!add(*it, ad)) {
Expand Down
19 changes: 13 additions & 6 deletions src/M5UnitUnified.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
@brief Main header of M5UnitUnified
@mainpage M5UnitUnified
Library for abstracted M5 units. C++11 or later
M5UnitUnified is a library for unified handling of various M5 unit products.
- Unified APIs
- Unified Connections
- Unified Licensing
*/
#ifndef M5_UNIT_UNIFIED_HPP
#define M5_UNIT_UNIFIED_HPP
Expand Down Expand Up @@ -40,18 +43,20 @@ class UnitUnified {
public:
using container_type = std::vector<Component*>;

///@warning COPY PROHIBITED
///@name Constructor
///@{
UnitUnified() = default;
UnitUnified(const UnitUnified&) = delete;
UnitUnified(UnitUnified&&) = default;
UnitUnified() = default;
UnitUnified(const UnitUnified&) = delete;
UnitUnified(UnitUnified&&) noexcept = default;
///@}

///@warning COPY PROHIBITED
///@name Assignment
///@{
UnitUnified& operator=(const UnitUnified&) = delete;

UnitUnified& operator=(UnitUnified&&) = default;
UnitUnified& operator=(UnitUnified&&) noexcept = default;
///@}

///@name Adding unit to be managed
Expand All @@ -63,7 +68,9 @@ class UnitUnified {
bool add(Component& u, TwoWire& wire);
///@}

//! @brief Begin of all units under management
bool begin();
//! @brief Update of all units under management
void update();

//! @brief Output information for debug
Expand All @@ -76,7 +83,7 @@ class UnitUnified {
std::string make_unit_info(const Component* u, const uint8_t indent = 0) const;

protected:
container_type _units;
container_type _units{};

private:
static uint32_t _registerCount;
Expand Down
2 changes: 1 addition & 1 deletion src/googletest/test_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
/*!
@file test_helper.hpp
@brief Helper for testing m5::unit::Component-derived classes
@brief Helper for testing UnitComponent
@note Depends on GoogleTest
*/
#ifndef M5_UNIT_COMPONENT_GOOGLETEST_HELPER_HPP
Expand Down
2 changes: 1 addition & 1 deletion src/googletest/test_template.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
/*!
@file test_template.hpp
@brief Template for testing m5::unit::Component-derived classes
@brief Helper for testing UnitComponent
@note Depends on GoogleTest
*/
#ifndef M5_UNIT_COMPONENT_GOOGLETEST_TEMPLATE_HPP
Expand Down

0 comments on commit 5d7b864

Please sign in to comment.