Arduino

ThresholdAPI DOCUMENTATION

Set and check numeric quantile scales.

See Example  Public Methods  Release Notes
Overview

Set and check numeric quantile scales. Provide an input domain and this library will convert it to a numeric quantile output range. This is different from the Arduino map() function because this library can handle a non-uniform input range.

Example Setup
  • Install this library and load the example sketch onto an Arduino
  • Open a serial connection at 115200 baud
  • Watch as converted values are printed to serial output

This example takes an input domain of:

  • [under 0]
  • [0 - 10.49]
  • [10.5 - 19.99]
  • [20 - 30]
  • [over 30]

and converts it to the quantile output range:

  1. UNDER
  2. LOW
  3. MEDIUM
  4. HIGH
  5. OVER
Example SketchArduinoC++
Public Methods

RBD::Threshold constructor(level_count)

Create a new instance and provide an integer for the maximum number of threshold levels. For example; set the level_count to 3 if you have levels of low, medium, and high. If you need more levels, this library will dynamically allocate an array to accommodate the size you provide the constructor.

EXAMPLE SKETCH
threshold
.setLevel(index, value)

Provide an integer for a level index and an integer, float, or double for the threshold value. This is not zero based, the first level starts at 1. You must also call setMaxLevel() at the end to set an upper bounds of your last level.

EXAMPLE SKETCH
threshold
.setMaxLevel(value)

Provide an integer, float, or double to set the upper-bounds threshold of the last level.

EXAMPLE SKETCH
threshold
.getLevel(index)

Provide an integer for the level index, and this returns the value originally provided to setLevel().

EXAMPLE SKETCH
threshold
.getMaxLevel()

Returns the value originally provided to setMaxLevel().

EXAMPLE SKETCH
threshold
.computeLevel(value)

Provide an integer, float, or double value to compare against the thresholds for setLevel() and setMaxLevel(). This returns an integer for the computed level.

  • it returns 0 for values that are under the first level
  • 1 for your first level
  • 2 for your second level
  • n for your nth level
  • sizeof(n) + 1 for any value greater than getMaxLevel()
  • -1 if the value was not found
EXAMPLE SKETCH