Hi,
I'm using a LK204-7T-1U using RS232 serial and programming with C on a PLC. I can read and write to it fine and can get it to display all the information I want without any issues and process key presses.
But I want it to display the blinkling block or underline cursor and no matter what I do, I cannot get the cursor to move from the home position.
my code to set the cursor position is below:
void setCursor(char row, char col)
{
unsigned char cursorCmd[4];
auto int cmdResult;
cursorCmd[0] = 254;
cursorCmd[1] = 71;
cursorCmd[2] = (unsigned char) col;
cursorCmd[3] = (unsigned char) row;
cmdResult = lcdWrite(cursorCmd, sizeof(cursorCmd));
}
I call this command setCursor(row, col) in a different part of my code and I have tried passing it a variety of parameters but the blinking block always stays at home position.
I also cannot use the Cursor move function (254, 77), the cursor just will not budge.
I can disable and enable the cursor without any problems using (254,83) and (254,84), but it always remains in the home position.
Regards,
Steven
Cursor Problem on LK204-7T-1U
Hi Steven,
I should preface my response by letting you know that I'm no C programmer, but I see no glaring mistakes in your code and the fact that you are getting responses to other commands indicates your code does send information correctly. I am however, wary of the char type you use for command parameters (I usually use byte), if you can, please step through that section keeping in mind valid numbers will be between 1 and 20 or 4 (decimal) respectively.
I quickly tweaked my very basic hello world appnote to move the cursor around a few times this morning and have attached it below. Unfortunately, it is in C#, but it does prove functionality of the command and might give you a few ideas.
~Troy
I should preface my response by letting you know that I'm no C programmer, but I see no glaring mistakes in your code and the fact that you are getting responses to other commands indicates your code does send information correctly. I am however, wary of the char type you use for command parameters (I usually use byte), if you can, please step through that section keeping in mind valid numbers will be between 1 and 20 or 4 (decimal) respectively.
I quickly tweaked my very basic hello world appnote to move the cursor around a few times this morning and have attached it below. Unfortunately, it is in C#, but it does prove functionality of the command and might give you a few ideas.
~Troy
- Attachments
-
- CursorProgram.txt
- Simple C# Cursor Movement Demo
- (3.6 KiB) Downloaded 414 times
Troy Clark
Design & Development
Matrix Orbital
Design & Development
Matrix Orbital
-
- LCD?
- Posts: 3
- Joined: Mon Oct 18, 2010 10:25 pm
No worries Steven,
There is an outside chance you might have a data lock set, probably the command lock, that might cause this behaviour. When you do get it figured out we'd love to have a post in case another user is faced with a similar problem.
Thanks,
~Troy
There is an outside chance you might have a data lock set, probably the command lock, that might cause this behaviour. When you do get it figured out we'd love to have a post in case another user is faced with a similar problem.
Thanks,
~Troy
Troy Clark
Design & Development
Matrix Orbital
Design & Development
Matrix Orbital
-
- LCD?
- Posts: 3
- Joined: Mon Oct 18, 2010 10:25 pm
Hi,
I figured out my problem, it was my main writing function. It was causing the cursor to be reset to the home position after each time it wrote to the screen and it was on a continuous cycle, so no matter what I did the cursor was always reset.
My solution was simply to pause that particular function when I desired it to and I got free reign to do what I wanted with the cursor.
Regards,
Steven
I figured out my problem, it was my main writing function. It was causing the cursor to be reset to the home position after each time it wrote to the screen and it was on a continuous cycle, so no matter what I did the cursor was always reset.
My solution was simply to pause that particular function when I desired it to and I got free reign to do what I wanted with the cursor.
Regards,
Steven