input: analog_axis: rework deadzone calibration code

Rework the data scaling algorithm for the "deadzone" mode so that the
deadzone is subtracted from the input rather than from the output. This
makes the whole output range usable rather than making the output jump
from the center value to the minimum deadzone range.

This changes the calibration data structure as well so now all values
refer to the input data, which is more coherent.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
Fabio Baltieri 2024-03-18 01:25:46 +00:00 committed by Anas Nashif
commit 55c14e6fa6
6 changed files with 64 additions and 21 deletions

View file

@ -16,7 +16,7 @@ description: |
poll-period-ms = <15>;
axis-x {
io-channels = <&adc 0>;
out-deadzone = <8>;
in-deadzone = <50>;
in-min = <100>;
in-max = <800>;
zephyr,axis = <INPUT_ABS_X>;
@ -56,13 +56,13 @@ child-binding:
Maximum value to output on input events. Defaults to 255 if
unspecified.
out-deadzone:
in-deadzone:
type: int
default: 0
description: |
Deadzone for the output center value. If specified output values
between the center of the range plus or minus this value will be
reported as center. Defaults to 0, no deadzone.
Deadzone for the input center value. If specified input values between
the center of the range plus or minus this value will be reported as
center. Defaults to 0, no deadzone.
in-min:
type: int