M5UnitUnified 0.0.5 git rev:3b942a7
Loading...
Searching...
No Matches
M5UnitComponent.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
10#ifndef M5_UNIT_COMPONENT_HPP
11#define M5_UNIT_COMPONENT_HPP
12
15#include <cstdint>
16#include <vector>
17#include <algorithm>
18#include <iterator>
19#include <type_traits>
20#include <memory>
21
22class TwoWire;
23
24namespace m5 {
25namespace unit {
26class UnitUnified;
27class Adapter;
28} // namespace unit
29} // namespace m5
30
31namespace m5 {
32namespace unit {
33
38class Component {
39public:
46 uint32_t clock{100000};
48 uint32_t stored_size{1};
50 bool self_update{false};
52 uint8_t max_children{0};
53 };
54
58 static const types::uid_t uid;
59 static const types::attr_t attr;
60 static const char name[];
62
66 explicit Component(const uint8_t addr = 0x00);
67
68 Component(const Component&) = delete;
69
70 Component(Component&&) noexcept = default;
72
76 Component& operator=(const Component&) = delete;
77
78 Component& operator=(Component&&) noexcept = default;
80
81 virtual ~Component() = default;
82
85
87 {
88 return _component_cfg;
89 }
91 inline void component_config(const component_config_t& cfg)
92 {
93 _component_cfg = cfg;
94 }
96
99
103 virtual bool begin()
104 {
105 return true;
106 }
111 virtual void update(const bool force = false)
112 {
113 (void)force;
114 }
116
119
120 inline const char* deviceName() const
121 {
122 return unit_device_name();
123 }
126 {
127 return unit_identifier();
128 }
131 {
132 return unit_attribute();
133 }
135 inline uint32_t order() const
136 {
137 return _order;
138 }
140 inline int16_t channel() const
141 {
142 return _channel;
143 }
145 inline bool isRegistered() const
146 {
147 return _manager != nullptr;
148 }
150 inline uint8_t address() const
151 {
152 return _addr;
153 }
158 inline Adapter* adapter() const
159 {
160 return _adapter.get();
161 }
163
166
167 inline bool inPeriodic() const
168 {
169 return in_periodic();
170 }
172 inline bool updated() const
173 {
174 return _updated;
175 }
181 {
182 return _latest;
183 }
189 {
190 return _interval;
191 }
193
196
197 virtual bool assign(m5::hal::bus::Bus* bus);
199 virtual bool assign(TwoWire& wire);
201
205
206 inline bool hasParent() const
207 {
208 return _parent;
209 }
211 inline bool hasSiblings() const
212 {
213 return _prev || _next;
214 }
216 inline bool hasChildren() const
217 {
218 return _child;
219 }
221 size_t childrenSize() const;
223 bool existsChild(const uint8_t ch) const;
225 Component* child(const uint8_t chhanle) const;
227 bool add(Component& c, const int16_t channel);
229 bool selectChannel(const uint8_t ch = 8);
231
233 template <typename T>
234 class iterator {
235 public:
236 using iterator_category = std::forward_iterator_tag;
237 using difference_type = std::ptrdiff_t;
238 using value_type = T;
239 using pointer = T*;
240 using reference = T&;
241
242 explicit iterator(Component* c = nullptr) : _ptr(c)
243 {
244 }
245
246 reference operator*() const
247 {
248 return *_ptr;
249 }
250 pointer operator->() const
251 {
252 return _ptr;
253 }
254 iterator& operator++()
255 {
256 _ptr = _ptr ? _ptr->_next : nullptr;
257 return *this;
258 }
259 iterator operator++(int)
260 {
261 auto tmp = *this;
262 ++(*this);
263 return tmp;
264 }
265 friend bool operator==(const iterator& a, const iterator& b)
266 {
267 return a._ptr == b._ptr;
268 }
269 friend bool operator!=(const iterator& a, const iterator& b)
270 {
271 return a._ptr != b._ptr;
272 }
273
274 private:
275 Component* _ptr;
276 };
277
278 using child_iterator = iterator<Component>;
279 using const_child_iterator = iterator<const Component>;
280 inline child_iterator childBegin() noexcept
281 {
282 return child_iterator(_child);
283 }
284 inline child_iterator childEnd() noexcept
285 {
286 return child_iterator();
287 }
288 inline const_child_iterator childBegin() const noexcept
289 {
290 return const_child_iterator(_child);
291 }
292 inline const_child_iterator childEnd() const noexcept
293 {
294 return const_child_iterator();
295 }
297
299 bool generalCall(const uint8_t* data, const size_t len);
300
302 virtual std::string debugInfo() const;
303
305 m5::hal::error::error_t readWithTransaction(uint8_t* data, const size_t len);
306
307 template <typename Reg,
308 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
309 std::nullptr_t>::type = nullptr>
310 bool readRegister(const Reg reg, uint8_t* rbuf, const size_t len, const uint32_t delayMillis,
311 const bool stop = true);
312 template <typename Reg,
313 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
314 std::nullptr_t>::type = nullptr>
315 bool readRegister8(const Reg reg, uint8_t& result, const uint32_t delayMillis, const bool stop = true);
316
317 template <typename Reg,
318 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
319 std::nullptr_t>::type = nullptr>
320 inline bool readRegister16BE(const Reg reg, uint16_t& result, const uint32_t delayMillis, const bool stop = true)
321 {
322 return read_register16E(reg, result, delayMillis, stop, true);
323 }
324
325 template <typename Reg,
326 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
327 std::nullptr_t>::type = nullptr>
328 inline bool readRegister16LE(const Reg reg, uint16_t& result, const uint32_t delayMillis, const bool stop = true)
329 {
330 return read_register16E(reg, result, delayMillis, stop, false);
331 }
332
333 template <typename Reg,
334 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
335 std::nullptr_t>::type = nullptr>
336 inline bool readRegister32BE(const Reg reg, uint32_t& result, const uint32_t delayMillis, const bool stop = true)
337 {
338 return read_register32E(reg, result, delayMillis, stop, true);
339 }
340
341 template <typename Reg,
342 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
343 std::nullptr_t>::type = nullptr>
344 inline bool readRegister32LE(const Reg reg, uint32_t& result, const uint32_t delayMillis, const bool stop = true)
345 {
346 return read_register32E(reg, result, delayMillis, stop, false);
347 }
348
349 m5::hal::error::error_t writeWithTransaction(const uint8_t* data, const size_t len, const bool stop = true);
350
351 template <typename Reg,
352 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
353 std::nullptr_t>::type = nullptr>
354 m5::hal::error::error_t writeWithTransaction(const Reg reg, const uint8_t* data, const size_t len,
355 const bool stop = true);
356
357 template <typename Reg,
358 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
359 std::nullptr_t>::type = nullptr>
360 bool writeRegister(const Reg reg, const uint8_t* buf = nullptr, const size_t len = 0U, const bool stop = true);
361
362 template <typename Reg,
363 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
364 std::nullptr_t>::type = nullptr>
365 bool writeRegister8(const Reg reg, const uint8_t value, const bool stop = true);
366
367 template <typename Reg,
368 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
369 std::nullptr_t>::type = nullptr>
370 inline bool writeRegister16BE(const Reg reg, const uint16_t value, const bool stop = true)
371 {
372 return write_register16E(reg, value, stop, true);
373 }
374
375 template <typename Reg,
376 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
377 std::nullptr_t>::type = nullptr>
378 inline bool writeRegister16LE(const Reg reg, const uint16_t value, const bool stop = true)
379 {
380 return write_register16E(reg, value, stop, false);
381 }
382
383 template <typename Reg,
384 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
385 std::nullptr_t>::type = nullptr>
386 inline bool writeRegister32BE(const Reg reg, const uint32_t value, const bool stop = true)
387 {
388 return write_register32E(reg, value, stop, true);
389 }
390
391 template <typename Reg,
392 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
393 std::nullptr_t>::type = nullptr>
394 inline bool writeRegister32LE(const Reg reg, const uint32_t value, const bool stop = true)
395 {
396 return write_register32E(reg, value, stop, false);
397 }
398
399 // clang-format off
400 template <typename Reg,
401 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
402 std::nullptr_t>::type = nullptr>
403 [[deprecated("Use readRegister16BE() or readRegister16LE(). To be removed in the next minor version increase")]]
404 inline bool readRegister16(const Reg reg, uint16_t& result, const uint32_t delayMillis, const bool stop = true)
405 {
406 return read_register16E(reg, result, delayMillis, stop, true);
407 }
408
409 template <typename Reg,
410 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
411 std::nullptr_t>::type = nullptr>
412 [[deprecated("Use writeRegister16BE() or writeRegister16LE(). To be removed in the next minor version increase")]]
413 inline bool writeRegister16(const Reg reg, const uint16_t value, const bool stop = true)
414 {
415 return write_register16E(reg, value, stop, true);
416 }
417 // clang-format on
419
420#if defined(DOXYGEN_PROCESS)
421 // There is a problem with the Doxygen output of templates containing std::enable_if,
422 // so we need a section for Dxygen output
426 m5::hal::error::error_t readWithTransaction(uint8_t* data, const size_t len);
428 template <typename Reg>
429 bool readRegister(const Reg reg, uint8_t* rbuf, const size_t len, const uint32_t delayMillis,
430 const bool stop = true);
432 template <typename Reg>
433 bool readRegister8(const Reg reg, uint8_t& result, const uint32_t delayMillis, const bool stop = true);
435 template <typename Reg>
436 bool readRegister16BE(const Reg reg, uint16_t& result, const uint32_t delayMillis, const bool stop = true);
438 template <typename Reg>
439 bool readRegister16LE(const Reg reg, uint16_t& result, const uint32_t delayMillis, const bool stop = true);
441 template <typename Reg>
442 bool readRegister32BE(const Reg reg, uint32_t& result, const uint32_t delayMillis, const bool stop = true);
444 template <typename Reg>
445 bool readRegister32LE(const Reg reg, uint32_t& result, const uint32_t delayMillis, const bool stop = true);
446
448 m5::hal::error::error_t writeWithTransaction(const uint8_t* data, const size_t len, const bool stop = true);
450 template <typename Reg>
451 m5::hal::error::error_t writeWithTransaction(const Reg reg, const uint8_t* data, const size_t len,
452 const bool stop = true);
454 template <typename Reg>
455 bool writeRegister(const Reg reg, const uint8_t* buf = nullptr, const size_t len = 0U, const bool stop = true);
457 template <typename Reg>
458 bool writeRegister8(const Reg reg, const uint8_t value, const bool stop = true);
460 template <typename Reg>
461 bool writeRegister16BE(const Reg reg, const uint16_t value, const bool stop = true);
463 template <typename Reg>
464 bool writeRegister16LE(const Reg reg, const uint16_t value, const bool stop = true);
466 template <typename Reg>
467 bool writeRegister32BE(const Reg reg, const uint32_t value, const bool stop = true);
469 template <typename Reg>
470 bool writeRegister32LE(const Reg reg, const uint32_t value, const bool stop = true);
472#endif
473
474protected:
475 // Proper implementation in derived classes is required
476 virtual const char* unit_device_name() const = 0;
477 virtual types::uid_t unit_identifier() const = 0;
478 virtual types::attr_t unit_attribute() const = 0;
479 inline virtual bool in_periodic() const
480 {
481 return _periodic;
482 }
483
484 // Duplicate the adapter for children
485 // Note that ownership of the return pointer is delegated to the destination
486 inline virtual Adapter* duplicate_adapter(const uint8_t /*ch*/)
487 {
488 return nullptr;
489 }
490 // Select valid channel if exists(Hub etc...)
491 inline virtual m5::hal::error::error_t select_channel(const uint8_t)
492 {
493 return m5::hal::error::error_t::OK;
494 }
495
496 inline size_t stored_size() const
497 {
498 return _component_cfg.stored_size;
499 }
500 bool add_child(Component* c);
501 bool changeAddress(const uint8_t addr); // Functions for dynamically addressable devices
502
503 template <typename Reg,
504 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
505 std::nullptr_t>::type = nullptr>
506 bool read_register16E(const Reg reg, uint16_t& result, const uint32_t delayMillis, const bool stop,
507 const bool endian);
508 template <typename Reg,
509 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
510 std::nullptr_t>::type = nullptr>
511 bool write_register16E(const Reg reg, const uint16_t value, const bool stop, const bool endifan);
512 template <typename Reg,
513 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
514 std::nullptr_t>::type = nullptr>
515 bool read_register32E(const Reg reg, uint32_t& result, const uint32_t delayMillis, const bool stop,
516 const bool endian);
517 template <typename Reg,
518 typename std::enable_if<std::is_integral<Reg>::value && std::is_unsigned<Reg>::value && sizeof(Reg) <= 2,
519 std::nullptr_t>::type = nullptr>
520 bool write_register32E(const Reg reg, const uint32_t value, const bool stop, const bool endifan);
521
522protected:
523 // For periodic measurement
524 types::elapsed_time_t _latest{}, _interval{};
525 bool _periodic{}; // During periodic measurement?
526 bool _updated{};
527
528private:
529 UnitUnified* _manager{};
530 std::unique_ptr<m5::unit::Adapter> _adapter{};
531
532 uint32_t _order{};
533 component_config_t _component_cfg{};
534 int16_t _channel{-1}; // valid [0...]
535 uint8_t _addr{};
536 bool _begun{};
537
538 // for chain
539 Component* _parent{};
540 Component* _next{};
541 Component* _prev{};
542 Component* _child{};
543
544 friend class UnitUnified;
545};
546
564template <class Derived, typename MD>
566public:
569
575 template <typename... Args>
576 inline bool startPeriodicMeasurement(Args&&... args)
577 {
578 // Prepare for future common initiation preprocessing needs
579 return static_cast<Derived*>(this)->start_periodic_measurement(std::forward<Args>(args)...);
580 }
587 template <typename... Args>
588 inline bool stopPeriodicMeasurement(Args&&... args)
589 {
590 // Prepare for future common stopping preprocessing needs
591 return static_cast<Derived*>(this)->stop_periodic_measurement(std::forward<Args>(args)...);
592 }
594
598 inline size_t available() const
599 {
600 return available_periodic_measurement_data();
601 }
603 inline bool empty() const
604 {
605 return empty_periodic_measurement_data();
606 }
608 inline bool full() const
609 {
610 return full_periodic_measurement_data();
611 }
613 inline MD oldest() const
614 {
615 return static_cast<const Derived*>(this)->oldest_periodic_data();
616 }
618 inline MD latest() const
619 {
620 return static_cast<const Derived*>(this)->latest_periodic_data();
621 }
623 inline void discard()
624 {
625 discard_periodic_measurement_data();
626 }
628 inline void flush()
629 {
630 flush_periodic_measurement_data();
631 }
633
634protected:
638 virtual size_t available_periodic_measurement_data() const = 0;
639 virtual bool empty_periodic_measurement_data() const = 0;
640 virtual bool full_periodic_measurement_data() const = 0;
641 virtual void discard_periodic_measurement_data() = 0;
642 virtual void flush_periodic_measurement_data() = 0;
644};
645
646} // namespace unit
647} // namespace m5
648
649// Helper for creating derived classes from Component
651#define M5_UNIT_COMPONENT_HPP_BUILDER(cls, reg) \
652public: \
653 constexpr static uint8_t DEFAULT_ADDRESS{(reg)}; \
654 static const types::uid_t uid; \
655 static const types::attr_t attr; \
656 static const char name[]; \
657 \
658 cls(const cls&) = delete; \
659 \
660 cls& operator=(const cls&) = delete; \
661 \
662 cls(cls&&) noexcept = default; \
663 \
664 cls& operator=(cls&&) noexcept = default; \
665 \
666protected: \
667 inline virtual const char* unit_device_name() const override \
668 { \
669 return name; \
670 } \
671 inline virtual types::uid_t unit_identifier() const override \
672 { \
673 return uid; \
674 } \
675 inline virtual types::attr_t unit_attribute() const override \
676 { \
677 return attr; \
678 }
679
680// Helper for creating derived class from PeriodicMeasurementAdapter
681#define M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER(cls, md) \
682protected: \
683 friend class PeriodicMeasurementAdapter<cls, md>; \
684 \
685 inline md oldest_periodic_data() const \
686 { \
687 return !_data->empty() ? _data->front().value() : md{}; \
688 } \
689 inline md latest_periodic_data() const \
690 { \
691 return !_data->empty() ? _data->back().value() : md{}; \
692 } \
693 inline virtual size_t available_periodic_measurement_data() const override \
694 { \
695 return _data->size(); \
696 } \
697 inline virtual bool empty_periodic_measurement_data() const override \
698 { \
699 return _data->empty(); \
700 } \
701 inline virtual bool full_periodic_measurement_data() const override \
702 { \
703 return _data->full(); \
704 } \
705 inline virtual void discard_periodic_measurement_data() override \
706 { \
707 _data->pop_front(); \
708 } \
709 inline virtual void flush_periodic_measurement_data() override \
710 { \
711 _data->clear(); \
712 }
713
715#endif
Adapters to treat M5HAL and TwoWire in the same way.
Adapters to treat M5HAL and TwoWire in the same way.
Definition adapter.hpp:28
Base class of unit component.
Definition M5UnitComponent.hpp:38
virtual void update(const bool force=false)
Update unit.
Definition M5UnitComponent.hpp:111
types::attr_t attribute() const
Gets the attributes.
Definition M5UnitComponent.hpp:130
bool existsChild(const uint8_t ch) const
Is there an other unit connected to the specified channel?
Definition M5UnitComponent.cpp:38
bool readRegister16BE(const Reg reg, uint16_t &result, const uint32_t delayMillis, const bool stop=true)
Read word in big-endian order with transaction from register.
void component_config(const component_config_t &cfg)
Set the common configurations in each unit.
Definition M5UnitComponent.hpp:91
bool readRegister8(const Reg reg, uint8_t &result, const uint32_t delayMillis, const bool stop=true)
Read byte with transaction from register.
static const types::uid_t uid
Unique identifier.
Definition M5UnitComponent.hpp:58
bool selectChannel(const uint8_t ch=8)
Select valid channel if exists.
Definition M5UnitComponent.cpp:127
bool writeRegister8(const Reg reg, const uint8_t value, const bool stop=true)
Write byte with transaction to register.
virtual std::string debugInfo() const
Output information for debug.
component_config_t component_config()
Gets the common configurations in each unit.
Definition M5UnitComponent.hpp:86
bool writeRegister32BE(const Reg reg, const uint32_t value, const bool stop=true)
Write dword in big-endian order with transaction from register.
bool hasChildren() const
Are there other devices connected to me?
Definition M5UnitComponent.hpp:216
bool isRegistered() const
Is the unit registered with the manager?
Definition M5UnitComponent.hpp:145
static const char name[]
Device name string.
Definition M5UnitComponent.hpp:60
bool writeRegister32LE(const Reg reg, const uint32_t value, const bool stop=true)
Write dword in little-endian order with transaction from register.
bool inPeriodic() const
In periodic measurement?
Definition M5UnitComponent.hpp:167
bool writeRegister16BE(const Reg reg, const uint16_t value, const bool stop=true)
Write word in big-endian order with transaction from register.
Component * child(const uint8_t chhanle) const
Gets the deviceconnected to the specified channel.
Definition M5UnitComponent.cpp:97
Adapter * adapter() const
Gets the access adapter.
Definition M5UnitComponent.hpp:158
m5::hal::error::error_t writeWithTransaction(const Reg reg, const uint8_t *data, const size_t len, const bool stop=true)
Write any data with transaction to register.
bool hasParent() const
Has parent unit?
Definition M5UnitComponent.hpp:206
bool hasSiblings() const
Are there any other devices connected to the same parent unit besides yourself?
Definition M5UnitComponent.hpp:211
size_t childrenSize() const
Number of units connected to me.
Definition M5UnitComponent.cpp:27
types::uid_t identifier() const
Gets the identifier.
Definition M5UnitComponent.hpp:125
const char * deviceName() const
Gets the device name.
Definition M5UnitComponent.hpp:120
virtual bool assign(m5::hal::bus::Bus *bus)
Assgin m5::hal::bus.
Definition M5UnitComponent.cpp:109
bool updated() const
Periodic measurement data updated?
Definition M5UnitComponent.hpp:172
types::elapsed_time_t updatedMillis() const
Time elapsed since start-up when the measurement data was updated in update()
Definition M5UnitComponent.hpp:180
static const types::attr_t attr
Attributes.
Definition M5UnitComponent.hpp:59
bool readRegister(const Reg reg, uint8_t *rbuf, const size_t len, const uint32_t delayMillis, const bool stop=true)
Read any data with transaction from register.
bool writeRegister(const Reg reg, const uint8_t *buf=nullptr, const size_t len=0U, const bool stop=true)
Write any data with transaction to register.
bool readRegister16LE(const Reg reg, uint16_t &result, const uint32_t delayMillis, const bool stop=true)
Read word in little-endian order with transaction from register.
bool readRegister32BE(const Reg reg, uint32_t &result, const uint32_t delayMillis, const bool stop=true)
Read dword in big-endian order with transaction from register.
m5::hal::error::error_t readWithTransaction(uint8_t *data, const size_t len)
Read any data with transaction.
Definition M5UnitComponent.cpp:139
bool writeRegister16LE(const Reg reg, const uint16_t value, const bool stop=true)
Write word in little-endian order with transaction from register.
m5::hal::error::error_t writeWithTransaction(const uint8_t *data, const size_t len, const bool stop=true)
Write any data with transaction.
Definition M5UnitComponent.cpp:146
uint8_t address() const
Address used to access the device.
Definition M5UnitComponent.hpp:150
virtual bool begin()
Begin unit.
Definition M5UnitComponent.hpp:103
int16_t channel() const
Gets the channel if connected to another unit.
Definition M5UnitComponent.hpp:140
types::elapsed_time_t interval() const
Gets the periodic measurement interval.
Definition M5UnitComponent.hpp:188
bool generalCall(const uint8_t *data, const size_t len)
General call for I2C.
bool add(Component &c, const int16_t channel)
Connect the unit to the specified channel.
Definition M5UnitComponent.cpp:46
bool readRegister32LE(const Reg reg, uint32_t &result, const uint32_t delayMillis, const bool stop=true)
Read dword in little-endian order with transaction from register.
uint32_t order() const
Gets the registered order (== 0 means not yet)
Definition M5UnitComponent.hpp:135
Interface class for periodic measurement (CRTP)
Definition M5UnitComponent.hpp:565
MD oldest() const
Retrieve oldest stored data.
Definition M5UnitComponent.hpp:613
size_t available() const
Gets the number of stored data.
Definition M5UnitComponent.hpp:598
bool startPeriodicMeasurement(Args &&... args)
Start periodic measurement.
Definition M5UnitComponent.hpp:576
void discard()
Discard the oldest data accumulated.
Definition M5UnitComponent.hpp:623
MD latest() const
Retrieve latest stored data.
Definition M5UnitComponent.hpp:618
bool stopPeriodicMeasurement(Args &&... args)
Stop periodic measurement.
Definition M5UnitComponent.hpp:588
bool empty() const
Is empty stored data?
Definition M5UnitComponent.hpp:603
bool full() const
Is stored data full?
Definition M5UnitComponent.hpp:608
void flush()
Discard all data.
Definition M5UnitComponent.hpp:628
Top level namespace of M5stack.
Definition test_helper.hpp:18
Unit-related namespace.
Component basic settings for begin.
Definition M5UnitComponent.hpp:44
uint32_t clock
Clock for communication (default as 100000)
Definition M5UnitComponent.hpp:46
uint32_t stored_size
Maximum number of periodic measurement data to be stored.
Definition M5UnitComponent.hpp:48
uint8_t max_children
Maximum number of units that can be connected (default as 0)
Definition M5UnitComponent.hpp:52
bool self_update
Does the user call Unit's update? (default as false)
Definition M5UnitComponent.hpp:50
Type and enumerator definitions.
unsigned long elapsed_time_t
Elapsed time unit (ms)
Definition types.hpp:25
uint32_t attr_t
Component attribute bits.
Definition types.hpp:24
uint32_t uid_t
Component unique identifier.
Definition types.hpp:23