raiden00pl commented on issue #10644:
URL: https://github.com/apache/nuttx/issues/10644#issuecomment-2592061754

   > The biggest problem I see now is forcing the user to use float. This is 
not the best solution for applications without FPU (e.g. CM0 which are often 
used in sensor nodes). What if we made the sensor data type configurable? It 
would be nice if we had an interface that return data in RAW format, but this 
may unnecessarily complicate the framework. Support for fixedmath type seems to 
be a good compromise (b16_t ?).
   
   If we want to adopt the new framework on a larger scale, we have to solve 
this problem.
   @xiaoxiang781216 @Donny9 do you have any ideas for this?
   
   Something like this is a solution, but it creates 2 alternative interfaces 
that are incompatible with each other:
   
   ```
   Kconfig:
   
   config SENSORS_USE_B16
      bool "Use fixed-math type as sensors data"
      default !ARCH_FPU
   
   sensors.h:
   
   #ifndef CONFIG_SENSORS_USE_B16
   typedef float sensors_data_t;
   #else
   typedef b16_t sensors_data_t;
   #endif
   ```
   
   Math operations on `sensors_data_t` won't be compatible with each other, but 
we can create a portable interface with macros that operate on this type like 
`sensor_data_add(x1, x2)`, `sensor_data_div(x1,x2)`, `sensor_data_mul(x1,x2)` 
etc.
   If we want to use fractional numeric types, then I don't see any other 
option at the moment.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to