Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
sbl::log::TaggedValues< COUNT, LINE > Class Template Reference

Named values written under one tag, on change, at a capped rate. More...

Detailed Description

template<size_t COUNT, size_t LINE = 128>
class sbl::log::TaggedValues< COUNT, LINE >

Named values written under one tag, on change, at a capped rate.

Template Parameters
COUNTNumber of values
LINELine buffer size; a write that needs more is split into several lines

Definition at line 182 of file tagged.hpp.

#include <tagged.hpp>

Inheritance diagram for sbl::log::TaggedValues< COUNT, LINE >:
[legend]

Public Member Functions

 TaggedValues (const char *tag, const char *const (&names)[COUNT])
 
 TaggedValues (const char *tag)
 
void name (size_t index, const char *key)
 
void set_interval_ms (uint32_t ms)
 
void set_threshold (float threshold)
 
void set_decimals (uint8_t decimals)
 
void set (size_t index, float value)
 
float value (size_t index) const
 
void force ()
 
template<typename Output >
bool poll (uint32_t now_ms)
 Write the values if one moved and the interval has passed.
 

Static Public Attributes

static constexpr uint32_t DEFAULT_INTERVAL_MS = 33
 
static constexpr float DEFAULT_THRESHOLD = 1.0f / 1024.0f
 

Constructor & Destructor Documentation

◆ TaggedValues() [1/2]

template<size_t COUNT, size_t LINE = 128>
sbl::log::TaggedValues< COUNT, LINE >::TaggedValues ( const char *  tag,
const char *const (&)  names[COUNT] 
)
inline
Parameters
tagThe line's tag, e.g. "WATCH"
namesKey for each value: [a-z][a-z0-9_]*

Definition at line 196 of file tagged.hpp.

References sbl::log::is_sink_v.

◆ TaggedValues() [2/2]

template<size_t COUNT, size_t LINE = 128>
sbl::log::TaggedValues< COUNT, LINE >::TaggedValues ( const char *  tag)
inlineexplicit

Values named one at a time with name().

Definition at line 203 of file tagged.hpp.

Member Function Documentation

◆ name()

template<size_t COUNT, size_t LINE = 128>
void sbl::log::TaggedValues< COUNT, LINE >::name ( size_t  index,
const char *  key 
)
inline

Set the key of one value: [a-z][a-z0-9_]*.

Definition at line 206 of file tagged.hpp.

References sbl::log::is_sink_v.

◆ set_interval_ms()

template<size_t COUNT, size_t LINE = 128>
void sbl::log::TaggedValues< COUNT, LINE >::set_interval_ms ( uint32_t  ms)
inline

Definition at line 212 of file tagged.hpp.

◆ set_threshold()

template<size_t COUNT, size_t LINE = 128>
void sbl::log::TaggedValues< COUNT, LINE >::set_threshold ( float  threshold)
inline

Definition at line 213 of file tagged.hpp.

◆ set_decimals()

template<size_t COUNT, size_t LINE = 128>
void sbl::log::TaggedValues< COUNT, LINE >::set_decimals ( uint8_t  decimals)
inline

Definition at line 214 of file tagged.hpp.

◆ set()

template<size_t COUNT, size_t LINE = 128>
void sbl::log::TaggedValues< COUNT, LINE >::set ( size_t  index,
float  value 
)
inline

Take a value's current reading.

Definition at line 217 of file tagged.hpp.

References sbl::log::is_sink_v.

◆ value()

template<size_t COUNT, size_t LINE = 128>
float sbl::log::TaggedValues< COUNT, LINE >::value ( size_t  index) const
inline

Definition at line 228 of file tagged.hpp.

◆ force()

template<size_t COUNT, size_t LINE = 128>
void sbl::log::TaggedValues< COUNT, LINE >::force ( )
inline

Write every value at the next poll, whether it moved or not.

Definition at line 231 of file tagged.hpp.

◆ poll()

template<size_t COUNT, size_t LINE = 128>
template<typename Output >
bool sbl::log::TaggedValues< COUNT, LINE >::poll ( uint32_t  now_ms)
inline

Write the values if one moved and the interval has passed.

Parameters
now_msA millisecond clock; wraparound is handled
Returns
true if lines were written

Definition at line 243 of file tagged.hpp.

References sbl::log::is_sink_v.

Member Data Documentation

◆ DEFAULT_INTERVAL_MS

template<size_t COUNT, size_t LINE = 128>
constexpr uint32_t sbl::log::TaggedValues< COUNT, LINE >::DEFAULT_INTERVAL_MS = 33
staticconstexpr

Minimum time between writes, 33 ms (about 30 lines a second).

Definition at line 187 of file tagged.hpp.

◆ DEFAULT_THRESHOLD

template<size_t COUNT, size_t LINE = 128>
constexpr float sbl::log::TaggedValues< COUNT, LINE >::DEFAULT_THRESHOLD = 1.0f / 1024.0f
staticconstexpr

A change smaller than this, in the values' own unit, is not written.

Definition at line 190 of file tagged.hpp.


The documentation for this class was generated from the following file: