1#ifndef J_DEADZONE_REMOVER_H
2#define J_DEADZONE_REMOVER_H
20inline float calculate(
float value,
float start,
float max,
float deadzone = 0)
22 value = constrain(value, -1.0, 1.0);
23 if (abs(value) <= abs(deadzone)) {
26 if (value > deadzone) {
28 return (value - deadzone) * (max - start) / (1.0 - deadzone) + start;
30 if (value < -deadzone) {
32 return (value + deadzone) * (-max + start) / (-1.0 + deadzone) - start;
53 for (
int i = 0; i < 3; i++) {
54 float currentValue = constrain(value.
getByNumber(i), -1.0, 1.0);
55 float currentDeadzone = deadzone.getByNumber(i);
59 if (abs(currentValue) <= abs(currentDeadzone)) {
62 if (currentValue > currentDeadzone) {
64 ret = (currentValue - currentDeadzone) * (currentMax - currentStart) / (1.0 - currentDeadzone) + currentStart;
66 if (currentValue < -currentDeadzone) {
68 ret = (currentValue + currentDeadzone) * (-currentMax + currentStart) / (-1.0 + currentDeadzone) - currentStart;
Definition JDeadzoneRemover.h:5
float calculate(float value, float start, float max, float deadzone=0)
If a motor's minimum speed is high, you can use this function to reduce the deadzone where nothing mo...
Definition JDeadzoneRemover.h:20