displaying problems

LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series

Moderators: Henry, Mods

Post Reply
Adan_T
LCD!
Posts: 15
Joined: Sun Mar 26, 2006 12:35 pm

displaying problems

Post by Adan_T »

Hi Raquel and Jon,

Thanks for the suggestions. I was able to make the program count but I can not
display the numbers as desired. The program counts well displaying the
numbers
1 on row1 column1 then , 2 on row1 column2 , 3 on row1 column3, ... etc. The program
displays up to 3-digit numbers (e.g. 147) and maybe even more. I want to be able to display these numbers
on a specific location
for example display 1-digit numbers (1-9) on row1 column1 then for
2-digit numbers (10-99)
display on row1 column1 and column2 then for 3-digit numbers display on row1 column1 column2 and column3 and so forth.
Is this possible?
I tried doing this by sending the cursor home (row1 column1) after displaying a 1-digit number
but the program behaved weird since it would only count up to 9 and then
reset the
count back to zero to start all over again. I also tried the "destructive backspace"
technique expained in the LK204-25 manual as well as other techniques but none
seemed to work. Any suggestions?
This is the code:

void printNumber(int number)
{

char string[10];


sprintf( string, "%i", number );
printString(string);
}

void printString(char txt[])
{

char i;

for(i=0;i<strlen(txt);i++)
{
USART_Transmit(txt);
USART_Transmit_Send_Cursor_Home(); // sends cursor home
}
}
Jon
Matrix Orbital
Matrix Orbital
Posts: 231
Joined: Mon Oct 24, 2005 10:38 am
Location: Calgary, AB, Canada
Contact:

Post by Jon »

Your send cursor home command is in the wrong spot. This function is intended to print out the full number at the current cursor position. For example if the functions input is 232, it will first convert 232 into chars "2", "3", and "2". It will then go through a loop printing "2", "3" and "2". Because the module will automatically move the cursor position after print a number no further instructions are warrented.

However if you wanted to print numbers lets say 1-1000 at a certain position you would simply do this:

int i,j;
for(i=0;i<1001;i++)
{
//begin code of clearing 4 spaces where the numbers will go
USART_Transmit_Send_Cursor_Home();
for(j=0;j<5;j++){
USART_Transmit(" ");
}
USART_Transmit_Send_Cursor_Home();
//end code of clearing 4 spaces for where the numbers will go
printNumber(i); //after ensuring that the space is empty print your numbers
}
Adan_T
LCD!
Posts: 15
Joined: Sun Mar 26, 2006 12:35 pm

Post by Adan_T »

Hi Jon,

Thanks for your suggestions. They worked beautifully!!!
Jon
Matrix Orbital
Matrix Orbital
Posts: 231
Joined: Mon Oct 24, 2005 10:38 am
Location: Calgary, AB, Canada
Contact:

Post by Jon »

Glad to hear it! How is the application going? What were you building it for anyways?
Post Reply