Go Down

Topic: Serial print of arrays (Read 1 time) previous topic - next topic

Professor Chaos

I believe Mikal Hart's Flash library supports storing float arrays in Flash memory:

http://arduiniana.org/libraries/flash/

Pero_2912

So,if I got you right, I should save my Theta as a some compatible type in Flash, in.e. signed long, and after reading convert it to float. But how to save my values in range from 0 to 1 from truncating and rounding? Maybe to multiply them with in.e. 100000 before saving? Ok, this could work.. thanks man

AWOL

Quote
So,if I got you right, I should save my Theta as a some compatible type in Flash, in.e. signed long,

Not sure what you mean here.
What's wrong with
Code: [Select]
PROGMEM float Theta [1001...whatever] = {3.45,6.27};?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pero_2912

well, libraty pgmspace.h does not support float type. And I could not find any function that reads it properly.. So i thought, before saving, adapt my data to intiger type, and the return it float, after reading.

AWOL

So, read it back as a type you can read, and cast the result to float.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pero_2912

#20
Mar 20, 2012, 10:39 pm Last Edit: Mar 20, 2012, 10:41 pm by Pero_2912 Reason: 1
OK, just to inform you guys, I finally made it. Seems like there is support for storing float type data in Flash. All you have to do is store it:
Code: [Select]

PROGMEM float Theta[]={1,2,3,4...};


and read it out:

Code: [Select]

float a;
a =(float) pgm_read_float(&Theta[i]); // i can be some constant or counter


Thank you all, cheers.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy