ItemFloatRange

Defines

ITEM_FLOAT_RANGE(...)
class ItemFloatRange : public ItemRangeBase<float>
#include <ItemFloatRange.h>

Item that allows user to input float information within a range. The value can be incremented or decremented by a specified step.

Public Functions

inline ItemFloatRange(const char *text, const float min, const float max, float startingValue, fptrFloat callback, const char *unit = NULL, float step = 0.1f, bool commitOnChange = false)
inline virtual char *getDisplayValue() override

Returns the value to be displayed. If a unit is provided, it will be concatenated to the value.

Returns:

The value to be displayed.

Public Static Functions

static inline uint8_t calculateWidth(float currentValue, uint8_t decimalPlaces)

Calculates the width of a floating-point number when displayed with a specified number of decimal places.

This function computes the width of the string representation of a floating-point number, including the decimal point and the specified number of decimal places.

Parameters:
  • currentValue – The floating-point number whose width is to be calculated.

  • decimalPlaces – The number of decimal places to include in the width calculation.

Returns:

The width of the floating-point number when displayed as a string.

static inline uint8_t calculateDecimalPlaces(float step)

Calculates the number of decimal places in a given floating-point step value.

This function converts the floating-point step value to a string representation, then determines the number of decimal places by counting the digits after the decimal point. Trailing zeros are not counted as decimal places.

Parameters:

step – The floating-point step value to analyze.

Returns:

The number of decimal places in the step value.

Private Members

uint8_t decimalPlaces = 1