LK204-7T-1U custom character

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

Moderators: Henry, Mods

Post Reply
user8547
LCD?
Posts: 2
Joined: Thu Oct 16, 2014 3:53 am

LK204-7T-1U custom character

Post by user8547 »

I can't seem to create and display a custom character on my LK204-7T-1U display. (weird signs appear)
here's my code for the degree " °c " example from the manual page 21.

Code: Select all

//LK204-7T-1U

byte degree[8] = { 00001000, 00010100, 00001000, 00000011, 00000100, 00000100, 00000011, 00000000 };

void setup() 
{
  ClearLCD();
  Serial1.begin(19200);//serial1 port  for  communication with my arduino
}
void loop() {
ClearLCD();
CursorPos(1,1);
createchar();
 delay(20000);
}

void createchar(){
  Serial1.write(254);
  Serial1.write(78);
  Serial1.write(1); //Character ID, value between 0 and 7
  Serial1.write( degree[8]); //character pixel data 
}

void ClearLCD(){
  Serial1.write(254);
  Serial1.write(88); 
}

void CursorPos(int xpos, int ypos){  
  Serial1.write(254);
  Serial1.write(71);               
  Serial1.write(xpos);   
 Serial1.write(ypos); 
}
Am I doing something wrong?

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Re: LK204-7T-1U custom character

Post by Clark »

Hi user8547,

The implementation of your createchar function looks good, until the last line. You are only transmitting a single byte, which is the uninitialized ninth value or your degree array. You might try the following:

Code: Select all

Serial1.write(degree, sizeof(degree));
Also, please note that Serial.write expects a byte, string, or byte array parameter, so you may experience undesirable behaviour within your CursorPos function.

Cheers,
Troy
Troy Clark
Design & Development
Matrix Orbital

user8547
LCD?
Posts: 2
Joined: Thu Oct 16, 2014 3:53 am

Re: LK204-7T-1U custom character

Post by user8547 »

solution:

Code: Select all

//LK204-7T-1U

//byte degree[8] = { 00001000, 00010100, 00001000, 00000011, 00000100, 00000100, 00000011, 00000000 };
byte degree[8] = { 8, 20, 8, 3, 4, 4, 3, 0 };//changed bytes to decimals
void setup() 
{
  ClearLCD();
  Serial1.begin(19200);
}
void loop() {
ClearLCD();
CursorPos(1,1);
createchar();
 delay(20000);
}

void createchar(){
  Serial1.write(254);
  Serial1.write(78);
  Serial1.write(1); //Character ID, value between 0 and 7
  Serial1.write(degree, sizeof(degree)); //character pixel data 
  Serial1.write(1); //repeat Character ID to actually display it on the LCD screen 
}

void ClearLCD(){
  Serial1.write(254);
  Serial1.write(88); 
}

void CursorPos(int xpos, int ypos){  
  Serial1.write(254);
  Serial1.write(71);               
  Serial1.write(xpos);   
 Serial1.write(ypos); 
}
Thanks Mr Clark

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Re: LK204-7T-1U custom character

Post by Clark »

No worries user8547, glad to see your code is running. Thanks for posting the solution.
Troy
Troy Clark
Design & Development
Matrix Orbital

Post Reply