Closed kritzikratzi closed 1 year ago
I haven't looked yet, but how much precision do these calculations require? 32-bits?
good question.
frequency is among the inputs and is in the mhz range.
time is the output and is in the milliseconds range.
that's a larger value span than 32 bit integer can do, so a bit of scaling here and there will be required (maybe it's as simple as dividing the frequencies by 1000 first, and then the result outmatically comes out as milliseconds integers and the problem magically goes away, but i don't have the code in front of me and don't know).
I note that ST re-wrote RadioTimeOnAir() to use integer math. Probably a good example here. I'm using the STM32WL firmware v1.3.
I don't know which version of this project you are using. However, since October 2020 (v4.4.5) the time on air functions as well as functions handling frequencies for all supported radios do use integer math based computations. Please refer to CHANGELOG.md file [4.4.5] - 2020-10-14
At some point in time we have tried to remove all double
/float
usage.
The only places where double
/float
are still in use are gps.c/h
, functions handling temperature rtc-board.c/h
and CayenneLpp.c/h
.
Please take a look at this project master branch radio drivers implementation. You may also take a look at v5.0.0-branch as it implements completely refactored radio drivers.
thanks. i will pass on the information.
copy and pasting my bug report from https://github.com/HelTecAutomation/CubeCell-Arduino/issues/261
radio.c uses floating point numbers (doubles, to be precise) to calculate the air time (maybe there are other places too), however it would be quite trivial to rewrite this computation to fixed point maths.
the goal would be to get rid of the generated code for float/double support when there is no hf unit:
8035: 0000f7bd 1464 FUNC GLOBAL HIDDEN 2 aeabi_ddiv 8141: 0000f0d1 1772 FUNC GLOBAL HIDDEN 2 __aeabi_dadd 8045: 0000ffb1 1252 FUNC GLOBAL HIDDEN 2 aeabi_dmul 8097: 0000ecc9 840 FUNC GLOBAL HIDDEN 2 __aeabi_fsub 8279: 0000ea99 560 FUNC GLOBAL HIDDEN 2 __aeabi_fdiv
in total this accounts for 5.8kB of flash on cortex-m0 mcus.