lkml.org 
[lkml]   [2018]   [Jul]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v4] iio: chemical: Add support for Bosch BME680 sensor
On Sat, Jul 21, 2018 at 6:43 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Sat, Jul 21, 2018 at 6:36 PM, Himanshu Jha
> <himanshujha199640@gmail.com> wrote:
>
>>> > + /* Look up table 1 for the possible gas range values */
>>> > + u32 lookupTable1[16] = {2147483647u, 2147483647u, 2147483647u,
>>> > + 2147483647u, 2147483647u, 2126008810u,
>>> > + 2147483647u, 2130303777u, 2147483647u,
>>> > + 2147483647u, 2143188679u, 2136746228u,
>>> > + 2147483647u, 2126008810u, 2147483647u,
>>> > + 2147483647u};
>
> This one needs perhaps a bit of though, but...
>
>>> > + /* Look up table 2 for the possible gas range values */
>>> > + u32 lookupTable2[16] = {4096000000u, 2048000000u, 1024000000u,
>>> > + 512000000u, 255744255u, 127110228u, 64000000u,
>>> > + 32258064u, 16016016u, 8000000u, 4000000u,
>>> > + 2000000u, 1000000u, 500000u, 250000u, 125000u};
>
> ...this one obviously just a not needed one. You may replace it with a
> one constant and simple calculation to get either value (index from
> value, or value from index).

Indeed this can be reduce to:

125.000 << (15 - idx).

The real question here is if we approximate 255.744.255u to 256.00.00u how
much different is the result. Being a gas sensor I think it is very
hard to appreciate.

We can go with this formula + adding a comment with the table with the
exact coefficients.

thanks,
Daniel.

\
 
 \ /
  Last update: 2018-07-21 19:46    [W:0.068 / U:0.536 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site