libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
daisy::MappedFloatValue Class Reference

#include <MappedValue.h>

Inheritance diagram for daisy::MappedFloatValue:
daisy::MappedValue

Public Types

enum class  Mapping { lin , log , pow2 }
 

Public Member Functions

 MappedFloatValue (float min, float max, float defaultValue, Mapping mapping=Mapping::lin, const char *unitStr="", uint8_t numDecimals=1, bool forceSign=false)
 
 ~MappedFloatValue () override
 
float Get () const
 
const floatGetPtr () const
 
void Set (float newValue)
 
 operator float () const
 
MappedFloatValueoperator= (float val)
 
void AppentToString (FixedCapStrBase< char > &string) const override
 
void ResetToDefault () override
 
float GetAs0to1 () const override
 
void SetFrom0to1 (float normalizedValue0to1) override
 
void Step (int16_t numStepsUp, bool useCoarseStepSize) override
 
- Public Member Functions inherited from daisy::MappedValue
virtual ~MappedValue ()
 

Member Enumeration Documentation

◆ Mapping

The availablke mapping functions

Enumerator
lin 

The value is mapped linearly between min and max.

log 

The value is mapped logarithmically. Note that the valid values must be strictly larger than zero, so: min > 0, max > 0

pow2 

The value is mapped with a square law

Constructor & Destructor Documentation

◆ MappedFloatValue()

daisy::MappedFloatValue::MappedFloatValue ( float  min,
float  max,
float  defaultValue,
Mapping  mapping = Mapping::lin,
const char unitStr = "",
uint8_t  numDecimals = 1,
bool  forceSign = false 
)

Creates a MappedFloatValue.

Parameters
minThe lower end of the range of possible values
maxThe upper end of the range of possible values
defaultValueThe default value
mappingThe Mapping to use. Note that for Mapping::log min, max and `defaultValue must be > 0
unitStrA string for the unit, e.g. "Hz"
numDecimalsControls the number of decimals in AppendToString()
forceSignControls whether AppendToString() always prints the sign, even for positive numbers

◆ ~MappedFloatValue()

daisy::MappedFloatValue::~MappedFloatValue ( )
inlineoverride

Member Function Documentation

◆ AppentToString()

void daisy::MappedFloatValue::AppentToString ( FixedCapStrBase< char > &  string) const
overridevirtual

Generates a string representation and adds it to an existing string.

Parameters
stringThe string to add to

Implements daisy::MappedValue.

◆ Get()

float daisy::MappedFloatValue::Get ( ) const
inline

Returns the current value.

◆ GetAs0to1()

float daisy::MappedFloatValue::GetAs0to1 ( ) const
overridevirtual

Returns the 0..1 normalized representation of the value, e.g. to display a slider/knob on a UI.

Implements daisy::MappedValue.

◆ GetPtr()

const float * daisy::MappedFloatValue::GetPtr ( ) const
inline

Returns a const pointer to the current value.

◆ operator float()

daisy::MappedFloatValue::operator float ( ) const
inline

Returns the current value.

◆ operator=()

MappedFloatValue & daisy::MappedFloatValue::operator= ( float  val)
inline

Sets the value, clamping it to the valid range.

◆ ResetToDefault()

void daisy::MappedFloatValue::ResetToDefault ( )
overridevirtual

Resets the value to its default.

Implements daisy::MappedValue.

◆ Set()

void daisy::MappedFloatValue::Set ( float  newValue)

Sets the value, clamping it to the valid range.

◆ SetFrom0to1()

void daisy::MappedFloatValue::SetFrom0to1 ( float  normalizedValue0to1)
overridevirtual

Sets the value so that GetAs0to1() returns normalizedValue0to1.

Implements daisy::MappedValue.

◆ Step()

void daisy::MappedFloatValue::Step ( int16_t  numStepsUp,
bool  useCoarseStepSize 
)
overridevirtual

Steps the 0..1 normalized representation of the value up or down in 1% or 5% steps.

Implements daisy::MappedValue.


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