Write component property to sd-card

Post here to discuss any new features, components, chips, etc, that you would like to see in Flowcode.
Post Reply
stefan.erni
Valued Contributor
Posts: 1065
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 201 times
Been thanked: 224 times

Write component property to sd-card

Post by stefan.erni »

Hi Ben

I would like to write the component propertis at the beginning of the Excel file.
Append string works with a text, but not with the build in function created string.
Does it work the way I program it?
Attachments
2024-09-10_15-07-51.PNG
2024-09-10_15-07-51.PNG (44.02 KiB) Viewed 8202 times

stefan.erni
Valued Contributor
Posts: 1065
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 201 times
Been thanked: 224 times

Re: Write component property to sd-card

Post by stefan.erni »

It's working in AppDevelopper
but not in the ESP32 program
property_test1.fcsx
(11.63 KiB) Downloaded 341 times
2024-09-11_08-56-07.PNG
2024-09-11_08-56-07.PNG (128 KiB) Viewed 8163 times
2024-09-11_09-00-02.PNG
2024-09-11_09-00-02.PNG (203.07 KiB) Viewed 8163 times

BenR
Matrix Staff
Posts: 1951
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 510 times
Been thanked: 697 times

Re: Write component property to sd-card

Post by BenR »

Hello,

Hmm this one is a little tricky as you can't directly reference component properties.

One trick would be to do the following.

1) Click on a blank area of the panel to select the panel and in the properties window create properties to hold the values
2) Add a macro to the Compile Start event and to the Simulation Start event, this can be the same macro for both events
3) Inside the Compiler Start macro copy the value of the property you want to your local property
4) Reference the local properties in your program as you would variables

That should work.

I've included an example.
PropertyReferenceExample.fcfx
(16.41 KiB) Downloaded 262 times
Let us know how you get on.

stefan.erni
Valued Contributor
Posts: 1065
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 201 times
Been thanked: 224 times

Re: Write component property to sd-card

Post by stefan.erni »

Hi Ben

I have tried but I probably only get the index of the switch and not the text of the property
CSV_number_lsm9.fcfx
(25.93 KiB) Downloaded 393 times
2024-09-12_10-31-54.PNG
2024-09-12_10-31-54.PNG (61.66 KiB) Viewed 8120 times

BenR
Matrix Staff
Posts: 1951
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 510 times
Been thanked: 697 times

Re: Write component property to sd-card

Post by BenR »

Hello,

GetValue returns the property value, if instead you want the label string then use the GetListItem function to get the label assigned to the value.
PropertyDemo.jpg
PropertyDemo.jpg (54.71 KiB) Viewed 7966 times

stefan.erni
Valued Contributor
Posts: 1065
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 201 times
Been thanked: 224 times

Re: Write component property to sd-card

Post by stefan.erni »

Hi Ben

Yes this way is perfect.
Unfortunately working only in the simulation. I cannot compile to hex. There is a fail.
CSV_post2.fcfx
(30.28 KiB) Downloaded 379 times
2024-09-13_15-59-32.PNG
2024-09-13_15-59-32.PNG (86.89 KiB) Viewed 7924 times

BenR
Matrix Staff
Posts: 1951
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 510 times
Been thanked: 697 times

Re: Write component property to sd-card

Post by BenR »

Hello,

Compiling now. Could be the sim event macro is missing a return value and the ESP32 compiler is complaining about that.

Just add a calculation saying .Return = 1

stefan.erni
Valued Contributor
Posts: 1065
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 201 times
Been thanked: 224 times

Re: Write component property to sd-card

Post by stefan.erni »

Hi Ben

I add but still fail compile to hex. Sim is always ok
2024-09-13_17-23-08.PNG
2024-09-13_17-23-08.PNG (26.97 KiB) Viewed 7906 times
2024-09-13_17-23-31.PNG
2024-09-13_17-23-31.PNG (68.73 KiB) Viewed 7906 times

Post Reply