Experimental steps .
1, First of all fatfs example . Don't learn to transplant first . Time to transplant later .
2, stay SD In card , establish 1.txt text file ;
Enter data in it : Pay attention to the format , This experiment needs this way to read and write the data of the text correctly ; Otherwise, some errors will occur in reading .
Write the wrong way :
In text , write in
23.56,89.35,( Carriage return )
68.23,25.00,( Carriage return )
85.36,54.24,( Carriage return )
In the input method here , If you use the following program to read , You get the data , But on the return line , obtain 0.005, Original data 68.23,85.36 There will be errors , Can't convert .
Due to the urgency of time . So I didn't go into the reasons .
The second time , Format text data , Change to
25.36,89.35,68.23,25,85.36,54.24,
Consecutive numbers , You can read it . Note that this comma must have , The data here is separated by commas .

3, utilize f_open To open a file ;
4, utilize f_read Read the file inside ; Put it in ReadBuf In memory space ; Will return a read byte of data , Get the byte length of the data in it ; For the follow-up use ; Then close the file .
5, Find examples online , How to put text , Comma separated , take out .
Then put each coordinate in a character array .
j=0;mm=0;
for(iii=0;iii<br0;iii++)
{
delay_ms(5);
// If it's not a comma , Just one character at a time str99 inside .
if(ReadBuf[iii]!=’,’)
{ LCD_ShowString(30,170,200,16,16,"1234"); str99[j]=ReadBuf[iii];
sprintf((char*)tbuf,"%s",str99); LCD_ShowString(30,210,210,16,16,tbuf);
delay_ms(1000); LCD_Clear(WHITE); j++; }
// If a comma is encountered , Explain the end of a number , Convert the number to double. And then put it in the doublexy in . take str99 empty , Make room for the next decimal . else
if(ReadBuf[iii]==',')// Read to a character array ; Put it in there . Array of characters , Change to floating point {
LCD_ShowString(30,170,200,16,16,"ef0f"); doublexy[mm]=StrToDouble(str99); mm++;
memset(str99,0,sizeof(str99)); j=0; } }
6, convert to double after , Put odd numbers in xx Array of coordinates , Even put yy Array of coordinates .
ttt=0;ggg=0;
for(iii=0;iii<br0;iii++)
{
if(iii%2==0)// even numbers , put to x coordinate
{xx[ttt]=doublexy[iii];ttt++; }
else
{ yy[ggg]=doublexy[iii];ggg++;}
}
7, Can print in cycles , See if the read data is successful ;
for(iii=0;iii<br0/12;iii++)
{
sprintf((char*)tbuf,“xx:%.2f”,xx[iii]);
LCD_ShowString(30,210,210,16,16,tbuf);
delay_ms(1000);
LCD_Clear(WHITE);
}
for(iii=0;iii<br0/12;iii++) { sprintf((char*)tbuf,"yy:%.2f",yy[iii]);
LCD_ShowString(30,210,210,16,16,tbuf); delay_ms(1000); LCD_Clear(WHITE); }
8, A program to convert this string into a floating-point number , It's on the Internet , stay devc++ Middle school experiment , It can be used . Post transplant to stm32 In this procedure , I'll think about the specific principle later .
// String conversion double
double StrToDouble(char *s)
{
int i = 0;
int k = 0;
double j;
int flag =1;
double result = 0.0;
if (s == NULL)
{
// printf(“ Input string is empty ”);
// exit(-1);
return 0;
} while (s[i] == ' ') { i++; } if (s[i] == '+') { i++; } if (s[i] == '-') {
i++; flag = -1; } while (s[i] != '\0' && s[i] != '.') { if (s[i] < '0' || s[i]
> '9') { // printf(" String contains non numeric characters , Cannot convert !\n"); return 0; // exit(-1); } j = (s[i] -
'0')*1.0; result = result * 10 + j; if((result>0x7fffffff)) { return 0; } i++;
} if (s[i] == '.') { i++; while (s[i] != '\0') { if (s[i] < '0' || s[i] > '9')
{ //printf(" String contains non numeric characters , Cannot convert !\n"); return 0; } k++; j = s[i] - '0'; result =
result + (1.0 * j) / pow(10.0, k); // There are warnings here at compile time i++; } } result = flag * result;
return result;
}

Technology
©2019-2020 Toolsou All rights reserved,
Result Encapsulation of return result information Vue Development tips airflow Timed tasks + Time setting +cron expression ( Essence )2020 year 7 month 15 day Wechat applet import and include difference The project followed for a year , The customer finally said no Ai Wei also talks about project management , On grass roots management Cheats developers apologize Programmer and architect Hua Shan SSM Project's excel File upload and add to database airflow Question series 2 —— task keep running Suspended animation