ESP32 compilation error (I think) with floating point maths

Use this section to discuss your embedded Flowcode projects.
Post Reply
canary_wharfe
Posts: 110
http://meble-kuchenne.info.pl
Joined: Thu Dec 10, 2020 3:54 pm
Has thanked: 6 times
Been thanked: 12 times

ESP32 compilation error (I think) with floating point maths

Post by canary_wharfe »

Just updated an old project from PIC24 that simulated and compiled without issue.
However, on porting into ESP32, a section of floating point calculations is breaking
the compiler. It simulates perfectly just like the PIC24 version and it builds the c code
without issue. But something is going wrong in the compiler.
Here is the back end of the report file and at the end of that section I have added in the section
of floating point maths commands that I think may be the problem.
Can someone knowledgeable able to analyse exactly what the report is saying about my calculation?
Do I need to ammend the instructions or is it a problem with the files the compiler is using? As
stated above its been fine on the PIC24 series. I really would love to find a fix. I've spent over a week on updating my project to ESP32 and to receive a compile problem right at the end of the road is gut wrenching.

---------------------------------------------------------------------------------
In file included from C:\ProgramData\MatrixTSL\FlowcodeV10\CAL\internals.c:612,
from C:/FC_ESP/mtxlolin32_lite_sdkconfig/main/esp-project.c:50:
C:/FC_ESP/mtxlolin32_lite_sdkconfig/main/esp-project.c: In function 'FCM_Abs_Calc':
C:\ProgramData\MatrixTSL\FlowcodeV10\CAL\ESP\ESP_CAL_Float.c:50:28: error: value computed is not used [-Werror=unused-value]
50 | #define flt_div(a, b) ((a) / (b))
| ^
C:\ProgramData\MatrixTSL\FlowcodeV10\CAL\ESP\ESP_CAL_Float.c:73:24: note: in expansion of macro 'flt_div'
73 | #define fround(a, b) (flt_div(flt_round(flt_mul(a,pow(10,b))),pow(10,b)))
| ^~~~~~~
C:/FC_ESP/mtxlolin32_lite_sdkconfig/main/esp-project.c:12189:3: note: in expansion of macro 'fround'
12189 | // Component Macro
| ^~~~~~
cc1.exe: some warnings being treated as errors
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
Executing action: all (aliases: build)
Running ninja in directory C:\FC_ESP\mtxlolin32_lite_sdkconfig\build
Executing "ninja all"...

Build Failed.
--------------------------------------------------------------------
(Calculation) Maths commands follows for Abs_Calc. The variables
a, b, c, abs, temperature and humidity are floating point.

a = fadd (temperature,237.6)
b = fmul (17.2694,temperature)
b = fdiv (b,a)
b = exp (b)
b = fmul (b,110.03446012)
b = fmul (b,humidity)
c = fadd (temperature,273.15)
c = fmul (c,8.3145)
abs = fdiv (b,c)
fround(abs,1)
-------------------------------------------------------------------

Steve-Matrix
Matrix Staff
Posts: 1512
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 211 times
Been thanked: 351 times

Re: ESP32 compilation error (I think) with floating point maths

Post by Steve-Matrix »

I think your "fround(abs,1)" needs to set a variable. For example "myvar = fround(abs,1)".

Or if your intention is to round the value of <abs> then: "abs = fround(abs,1)".

canary_wharfe
Posts: 110
Joined: Thu Dec 10, 2020 3:54 pm
Has thanked: 6 times
Been thanked: 12 times

Re: ESP32 compilation error (I think) with floating point maths

Post by canary_wharfe »

Steve.... Of course!!! That's it ... now compiled ... AND that last fround line was the one line that was NOT in my PIC24 project. I should have remembered that. Can't honestly remember now why that fround line had to be added in to the ESP32 version but much appreciated and much relieved.
(BTW I haven't forgotten either about that other issue re. html file missing the UI graphics when run on an iOS device. I haven't forgotten and will report back to you when I got MACbook hooked up. Just been snowed under with current project and helping elderly sister through the heatwave).
Thanks again :-)

Post Reply