[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <17adc0d0-55c1-4608-a4c0-93f9911296f8@gmail.com>
Date: Thu, 23 May 2024 17:45:34 +0200
From: Javier Carrasco <javier.carrasco.cruz@...il.com>
To: Dimitri Fedrau <dima.fedrau@...il.com>
Cc: Li peiyu <579lpy@...il.com>, Jonathan Cameron <jic23@...nel.org>,
Lars-Peter Clausen <lars@...afoo.de>, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iio: humidity: hdc3020: fix hysteresis representation
On 23/05/2024 16:28, Dimitri Fedrau wrote:
> Am Thu, May 23, 2024 at 04:12:37PM +0200 schrieb Javier Carrasco:
>> Hi Dimitri, a few comments inline.
>>
>> On 23/05/2024 13:43, Dimitri Fedrau wrote:
>>> According to the ABI docs hysteresis values are represented as offsets to
>>> threshold values. Current implementation represents hysteresis values as
>>> absolute values which is wrong. Nevertheless the device stores them as
>>> absolute values and the datasheet refers to them as clear thresholds. Fix
>>> the reading and writing of hysteresis values by including thresholds into
>>> calculations.
>>>
>>> Fixes: 3ad0e7e5f0cb ("iio: humidity: hdc3020: add threshold events support")
>>> Signed-off-by: Dimitri Fedrau <dima.fedrau@...il.com>
>>> ---
>>>
>>> Since absolute values are used on the device, the hysteresis values are
>>> influenced by setting thresholds. Is this behavior in line with the ABI docs ?
>>> It can be fixed by readjusting the threshold clear value whenever setting
>>> thresholds to have the same hysteresis value as before. See some example below:
>>>
>>> # echo 25 > /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_value
>>> # cat /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_value
>>> 24.727626459
>>> # echo 5 > /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_hysteresis
>>> # cat /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_hysteresis
>>> 5.127031357
>>> # echo 35 > /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_value
>>> # cat /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_hysteresis
>>> 15.381094071
>>>
> Hi Javier,
>
> thanks for reviewing so quickly. Do you think I should correct the clear
> threshold values once I changed the threshold. I have an example
> provided where I set the threshold and hysteresis. After setting the
> threshold again the hysteresis value also changes.
>
> Dimitri
I am not sure if I got that right. Did the rising hysteresis change its
value automatically from ~5 to ~15 by just adding 10 to the threshold?
If we are treating the hysteresis as an offset, then it should not
change its value i.e. it should keep the configured value.
Best regards,
Javier Carrasco
Powered by blists - more mailing lists