Skip to content

WIP: initial support for fixed-point data for sensors#17408

Draft
raiden00pl wants to merge 7 commits intoapache:masterfrom
raiden00pl:sensors_fixedmath
Draft

WIP: initial support for fixed-point data for sensors#17408
raiden00pl wants to merge 7 commits intoapache:masterfrom
raiden00pl:sensors_fixedmath

Conversation

@raiden00pl
Copy link
Member

@raiden00pl raiden00pl commented Nov 29, 2025

Summary

WIP code for fixed-math data type for sensors.

All sensor math operations will require modification to use sensor_data_xxx macros.

At the moment, no sensor is modified to handle this properly. I'll probably choose the easiest sensor to port with a small amount of math operations to provide PoC.

EDIT: ported bmp280_uorb to fixed-math, probably the easiest one :)

Ultimately, all sensor units must be checked to see if the data unit make sense for the b16_t type.

Doing this work all at once is a lot of work which I don't want to do, so I suggest introducing this change gradually:

  1. introducing a configurable sensor data type and raise compilation error in all sensors that don't support fixed-point data type
  2. gradually port sensors to use fixed-point data and remove compilation errors
  3. on the app side we need to modify uorb tools to work with fixed-point data. At this moment we can just raise compilation error for fixed-point data type, and add depends on SENSORS_USE_FLOAT

Impact

Testing

@github-actions github-actions bot added Area: OS Components OS Components issues Area: Sensors Sensors issues Size: L The size of the change in this PR is large labels Nov 29, 2025
@raiden00pl raiden00pl force-pushed the sensors_fixedmath branch 2 times, most recently from 4dfeb92 to 8cd1558 Compare November 29, 2025 21:15
@raiden00pl raiden00pl force-pushed the sensors_fixedmath branch 8 times, most recently from 5fdb41a to 329d6ff Compare December 1, 2025 14:22
@github-actions github-actions bot added the Area: Documentation Improvements or additions to documentation label Dec 1, 2025
new sensor framework can now select between float data type and
fixed-point data type

Signed-off-by: raiden00pl <raiden00@railab.me>
support for fixed-point data for bmp280_uorb

Signed-off-by: raiden00pl <raiden00@railab.me>
support for fixed-point data for bmp180_uorb

Signed-off-by: raiden00pl <raiden00@railab.me>
support for fixed-point data for hyt271_uorb

Signed-off-by: raiden00pl <raiden00@railab.me>
support for fixed-point data for adxl362_uorb

Signed-off-by: raiden00pl <raiden00@railab.me>
@raiden00pl raiden00pl force-pushed the sensors_fixedmath branch 2 times, most recently from 0404a32 to dde5a82 Compare December 1, 2025 16:52
support for fixed-point data for adxl372_uorb

Signed-off-by: raiden00pl <raiden00@railab.me>
support for fixed-point data for bh1749nuc_uorb

Signed-off-by: raiden00pl <raiden00@railab.me>
@linguini1 linguini1 added this to the v13.0.0 milestone Feb 25, 2026
@linguini1
Copy link
Contributor

One more thing about this; we should investigate if b16 is ever too small for a sensor's resolution. I would imagine float might have this same problem when compared to double for high-resolution sensors, but if there are any values that would fit in float and not b16, we should consider:

a) having those sensors depend on the float representation, so users can only use them with floats
b) allowing the user to choose b16 vs b32 (and maybe also float vs double)?

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Documentation Improvements or additions to documentation Area: OS Components OS Components issues Area: Sensors Sensors issues Size: L The size of the change in this PR is large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants