FastLED 3.9.15
Loading...
Searching...
No Matches

◆ normalized()

float Potentiometer::normalized ( ) const

Definition at line 46 of file potentiometer.cpp.hpp.

46 {
47 // Handle invalid range
48 if (mMaxValue <= mMinValue) {
49 return 0.0f;
50 }
51
52 // Clamp current value to calibrated range
53 u16 clamped_value;
55 clamped_value = mMinValue;
56 } else if (mCurrentValue > mMaxValue) {
57 clamped_value = mMaxValue;
58 } else {
59 clamped_value = mCurrentValue;
60 }
61
62 // Map calibrated range to [0.0, 1.0]
63 u16 range = mMaxValue - mMinValue;
64 u16 offset = clamped_value - mMinValue;
65 return static_cast<float>(offset) / static_cast<float>(range);
66}
fl::UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)

References mCurrentValue, mMaxValue, mMinValue, and offset().

+ Here is the call graph for this function: