Pages: 1 [2]   Go Down
Author Topic: Serial print of arrays  (Read 1207 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 1
Posts: 225
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24450
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
PROGMEM float Theta [1001...whatever] = {3.45,6.27};
?
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24450
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So, read it back as a type you can read, and cast the result to float.
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
PROGMEM float Theta[]={1,2,3,4...};

and read it out:

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

Thank you all, cheers.
« Last Edit: March 20, 2012, 04:41:06 pm by Pero_2912 » Logged

Pages: 1 [2]   Go Up
Jump to: