Francesco cembrola
Newbie level 6
- Joined
- Jul 22, 2006
- Messages
- 11
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,362
The code below works OK.
It calles the function 'text_pos' an passes ascii caracters to it.
Then 'text_pos' convert them to ascii codes.
These are send to the I2C interface to controll an LCD display.
These characters represent the cursor coordinates on the LCD display
However I need to modify the code to pass parameters like : text_pos ('34',65'), (two digits).
otherwise I can only get the coordinates up to 9X,9Y.
If I call the function like: text_pos('10','12'), how do I read each of the digit indivually?
I need to assign something like: int X0= first digit of row. int X1= second digit of row.
int Y0=first digit of col. int Y1 = second digit of col.
Do i need to declare two arrayes in the function?
I have tried some experiments with out success.
Can you please help to modify the code?
Thank you.:-?
It calles the function 'text_pos' an passes ascii caracters to it.
Then 'text_pos' convert them to ascii codes.
These are send to the I2C interface to controll an LCD display.
These characters represent the cursor coordinates on the LCD display
However I need to modify the code to pass parameters like : text_pos ('34',65'), (two digits).
otherwise I can only get the coordinates up to 9X,9Y.
If I call the function like: text_pos('10','12'), how do I read each of the digit indivually?
I need to assign something like: int X0= first digit of row. int X1= second digit of row.
int Y0=first digit of col. int Y1 = second digit of col.
Do i need to declare two arrayes in the function?
I have tried some experiments with out success.
Can you please help to modify the code?
Thank you.:-?
Code:
#include <p18F26k22.h>
#include <stdlib.h>
#include <delays.h>
#include <stdio.h>
#include <I2C.h>
#include <string.h>
void text_pos(char row, char col);
int xpos=0;
int ypos=0;
void main(void)
{
text_pos('5','9'); // call function to set cursor coordinates
}
void text_pos(char row,char col)
}
xpos=col;// convert char to int
// xpos second digit
ypos=row;
// ypos second digit
StartI2C2();
putcI2C2(0x64); //device address
putcI2C2(27); //esc
putcI2C2(91); // [
putcI2C2(ypos); //row
// putcI2C2(ypos);// need here the second digit for y pos
putcI2C2(59); // ;
putcI2C2(xpos); // column
// putcI2C2(xpos2); //need here the second digit for X pos
putcI2C2(72); // H
Delay10KTCYx(100);
StopI2C2();
}