Used for generating output signals based on upper and lower thresholds.
More...
#include <generators.hpp>
|
|
| ThresholdGenerator () |
| | Default constructor for ThresholdGenerator. Does not initialize board hardware. Call begin() to set up the generator.
|
|
void | begin () |
| | Initialize the ThresholdGenerator.
|
|
void | debugPrint () |
| | Print debug information about the ThresholdGenerator to the Serial console.
|
|
void | enable () |
| | Enable the ThresholdGenerator.
|
|
void | disable () |
| | Disable the ThresholdGenerator.
|
| void | setLowerCallback (void(*callback_function)()) |
| | Set the callback function to be called when the input crosses the lower threshold.
|
| void | setUpperCallback (void(*callback_function)()) |
| | Set the callback function to be called when the input crosses the upper threshold.
|
| void | setUpperThreshold (float64_t upper_threshold, bool clamp_to_upper=false) |
| | Set the upper threshold value and optionally enable clamping to the upper threshold. This must be called to activate the upper threshold.
|
| void | setLowerThreshold (float64_t lower_threshold, bool clamp_to_lower=false) |
| | Set the lower threshold value and optionally enable clamping to the lower threshold. This must be called to activate the lower threshold.
|
|
void | clearUpperThreshold () |
| | Clear the upper threshold, disabling its effect.
|
|
void | clearLowerThreshold () |
| | Clear the lower threshold, disabling its effect.
|
Used for generating output signals based on upper and lower thresholds.
The ThresholdGenerator monitors an input signal and triggers callbacks or clamps output when the input crosses specified upper or lower thresholds. It can be used to restrict a motion signal within defined bounds and/or to trigger events when those bounds are exceeded.
Here's an example of how to instantiate and configure a ThresholdGenerator:
#define module_driver
#include "stepdance.hpp"
void setup() {
output_a.
begin(OUTPUT_A);
enable_drivers();
threshold_gen.
output.
map(channel_a.input_target_position);
channel_a.
begin(&output_a, SIGNAL_E);
dance_start();
}
void onLowerThresholdCrossed() {
Serial.println("Lower threshold crossed!");
}
void onUpperThresholdCrossed() {
Serial.println("Upper threshold crossed!");
}
void loop(){
dance_loop();
}
◆ setLowerCallback()
| void ThresholdGenerator::setLowerCallback |
( |
void(* | callback_function )() | ) |
|
Set the callback function to be called when the input crosses the lower threshold.
- Parameters
-
| callback_function | Pointer to the callback function. |
◆ setLowerThreshold()
| void ThresholdGenerator::setLowerThreshold |
( |
float64_t | lower_threshold, |
|
|
bool | clamp_to_lower = false ) |
Set the lower threshold value and optionally enable clamping to the lower threshold. This must be called to activate the lower threshold.
- Parameters
-
| lower_threshold | The lower threshold value. |
| clamp_to_lower | If true, output will be clamped to the lower threshold when exceeded. |
◆ setUpperCallback()
| void ThresholdGenerator::setUpperCallback |
( |
void(* | callback_function )() | ) |
|
Set the callback function to be called when the input crosses the upper threshold.
- Parameters
-
| callback_function | Pointer to the callback function. |
◆ setUpperThreshold()
| void ThresholdGenerator::setUpperThreshold |
( |
float64_t | upper_threshold, |
|
|
bool | clamp_to_upper = false ) |
Set the upper threshold value and optionally enable clamping to the upper threshold. This must be called to activate the upper threshold.
- Parameters
-
| upper_threshold | The upper threshold value. |
| clamp_to_upper | If true, output will be clamped to the upper threshold when exceeded. |
◆ input
Input BlockPort for the ThresholdGenerator. This is what you map to with an upstream component.
input_a.output_x.map(threshold_gen.input);
◆ output
Output BlockPort for the ThresholdGenerator. This is what you map from to a downstream component. If clamping is enabled, the output will be clamped to the threshold values.
threshold_gen.output.map(channelX.input_target_position);
The documentation for this class was generated from the following file: