45 Slider(
const char *name,
float value = 128.0f,
float min = 1,
float max = 255,
float step = -1.f)
46 : mValue(value), mMin(MIN(min, max)), mMax(MAX(min, max)) {
49 if (value < min) { mValue = min; }
50 if (value > max) { mValue = max; }
53 float value()
const {
return mValue; }
54 void setValue(
float value) { mValue = MAX(mMin, MIN(mMax, value)); }
55 operator float()
const {
return mValue; }
56 operator uint8_t()
const {
return static_cast<uint8_t
>(mValue); }
57 operator uint16_t()
const {
return static_cast<uint16_t
>(mValue); }
58 operator int()
const {
return static_cast<int>(mValue); }
59 template <
typename T> T as()
const {
return static_cast<T
>(mValue); }
61 Slider& operator=(
float value) { setValue(value);
return *
this; }
62 Slider& operator=(
int value) { setValue(
static_cast<float>(value));
return *
this; }
115 NumberField(
const char *name,
double value,
double min = 0,
double max = 100)
116 : mValue(value), mMin(MIN(min, max)), mMax(MAX(min, max)) {
117 FASTLED_UNUSED(name);
120 double value()
const {
return mValue; }
121 void setValue(
double value) { mValue = MAX(mMin, MIN(mMax, value)); }
122 operator double()
const {
return mValue; }
123 operator int()
const {
return static_cast<int>(mValue); }
124 NumberField& operator=(
double value) { setValue(value);
return *
this; }
125 NumberField& operator=(
int value) { setValue(
static_cast<double>(value));
return *
this; }