Code: Select all
char text[] = "G01 X97.166667 Y-5.794118 Z4.666667";
char zh;
char g_code;
char x_axis;
char y_axis;
char z_axis;
char x_txt[] = "9";
char y_txt[] = "5";
char z_txt[] = "0";
float x_res;
float y_res;
float z_res;
char xreturn;
char yreturn;
char zreturn;
sbit LCD_RS at RA0_bit;
sbit LCD_EN at RA1_bit;
sbit LCD_D4 at RA2_bit;
sbit LCD_D5 at RA3_bit;
sbit LCD_D6 at RA4_bit;
sbit LCD_D7 at RA5_bit;
sbit LCD_RS_Direction at TRISA0_bit;
sbit LCD_EN_Direction at TRISA1_bit;
sbit LCD_D4_Direction at TRISA2_bit;
sbit LCD_D5_Direction at TRISA3_bit;
sbit LCD_D6_Direction at TRISA4_bit;
sbit LCD_D7_Direction at TRISA5_bit;
void main() {
ANSEL = 0x00;
ANSELH = 0x00;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
zh = strtok(text, ' ');
Lcd_Out(1,1,zh);
x_axis = strtok(0, " ");
Lcd_Out(2,1,x_axis);
y_axis = strtok(0, " ");
Lcd_Out(3,1,y_axis);
z_axis = strtok(0, " ");
Lcd_Out(4,1,z_axis);
//x_res = atof(x_axis);
//y_res = atof(y_axis);
//z_res = atof(z_axis);
//floattostr(x_res, xreturn);
//floattostr(y_res, yreturn);
//floattostr(z_res, zreturn);
//Lcd_Out(1,1,xreturn);
//Lcd_Out(2,1,yreturn);
//Lcd_Out(3,1,zreturn);
}
at point Lcd_Out(4,1,z_axis) i have 4 values which are as
zh
x_axis
y_axis
z_axis
i can also remove x y z from the starting of the string.
but unable to convert strings in to float for calculation purpose
and again turning float back to string for display purpose
any ideas and help plz waiting.