Pages: [1]   Go Down
Author Topic: Individual pixel controll through serial lcd?  (Read 2258 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 121
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is is possible to control individual pixels through a serial lcd interface.

This is the one I'm using with one of their 16x2 displays:
http://www.sparkfun.com/datasheets/LCD/SerLCD_V2_5.PDF

In the datasheet it says something to the effect that it can use any HD44780 command so I should be able to have total control over the lcd if I want, right?  

My other thought is to do a couple of user definable characters, but I'm not sure where to start.  It should have room for 8 of them right?  That would be all I need.  These would be: http://www.quinapalus.com/hd44780udg.html fifth row on the left.

(The reason I am doing this:  I have sensor information displayed on the LCD.  Right now it is a discrete number + a pseudo-analog display/bar graph.  Currently it is using the block character as an increment.  I'd like to fill a character block from left to right with vertical lines to get more resolution out of the pseudo-analog part of the display.)
Logged

Wuppertal/Germany
Offline Offline
God Member
*****
Karma: 1
Posts: 895
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is is possible to control individual pixels through a serial lcd interface.

This is the one I'm using with one of their 16x2 displays:
http://www.sparkfun.com/datasheets/LCD/SerLCD_V2_5.PDF

In the datasheet it says something to the effect that it can use any HD44780 command so I should be able to have total control over the lcd if I want, right?  
Sorry wrong!
You would need a graphics led to do this. This one (and all other HD44780 compatible) displays only characters from a limited set (ASCII + some japanese usally)

But your second idea does work!
You can define 8 characters to do some minimum (as in Retro,8Bit, ;-) ) graphics .

Eberhard
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 121
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Would you happen to know how I define some user defined characters via the serial interface.  Can I even do that through the serial interface?  
Logged

Wuppertal/Germany
Offline Offline
God Member
*****
Karma: 1
Posts: 895
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No I'm don't think so,

I had a look at the datasheet in the link. The HD44780 can do it, but I doesn't look like think it can be done  with this serial version.
There is an article http://www.arduino.cc/playground/Code/LCD in the playground about using an hd44780 in 4 bit mode. You would need 4 pins on the arduino but this gives you access to the be the full commandset.

Eberhard
  
Logged

0
Offline Offline
Full Member
***
Karma: 1
Posts: 223
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can define custom characters on the serLCD, I've done it.

Here's the code that uses custom characters to generate a "analogue" bar:

Code:
void writecharLCD() {
  short charArray[][8] = {
    0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,
    0x1F,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,
    0x1F,0x18,0x18,0x18,0x18,0x18,0x18,0x1F,
    0x1F,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1F,
    0x1F,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1F,
    0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
    0x10,0x18,0x1C,0x1E,0x1E,0x1C,0x18,0x10,             // bar terminator
    0x0A,0x15,0x1F,0x00,0x1F,0x0C,0x1F,0x00    };        // mb

  for (j = 0; j < 8; j++) {
    Serial.print(254,BYTE);
    Serial.print(64+j*8,BYTE);

    for (i = 0; i < 8; i++) {
      Serial.print(charArray[j][i],BYTE);
    } //end inner char for
  }// end outter for  
  delay(100);  
}


void LCDbar10(short percent, int value, short line, short terminator) {
  short cols, blox, numchar;

  Serial.print(0xFE,BYTE);
  Serial.print(128+line,BYTE);

  if (percent > 100) {
    percent = 100;
  }

  cols = percent/2;                     // x 0.5 (100% = 50 pixels)
  blox = cols/5;                        // calculate whole blocks

  if (blox > 0) {
    for (short idx = 1; idx <= blox; idx++) {
      Serial.print(5, BYTE);
    }
  }

  Serial.print(cols % 5, BYTE);
  
  while (blox < 9) {                  // clear end of graph display
    Serial.print(0, BYTE);
    blox ++;
  }
  
  Serial.print(0xFE,BYTE);
  Serial.print(128+10+line,BYTE);
  Serial.print(terminator, BYTE);
  
  if (value < 10)   {Serial.print(" ");} //Number formating
  if (value < 100)  {Serial.print(" ");}
  if (value < 1000) {Serial.print(" ");}
  
  Serial.print(value, DEC);
}
« Last Edit: July 09, 2007, 04:44:29 am by zitron » Logged

Moss
Offline Offline
Full Member
***
Karma: 1
Posts: 119
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Sorry to wake an old post, but I want to make scandinavian letters to my serial LCD. I have the Hex code for the letters, but how do I go about defining them to the screen?

Joachim
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Sorry to wake an old post, but I want to make scandinavian letters to my serial LCD. I have the Hex code for the letters, but how do I go about defining them to the screen?

I think this makes it clear? Just use ASCII 0 to 8 to print the custom ones.
Code:
void setChar(byte pos,byte b1,byte b2,byte b3,byte b4,byte b5,byte b6,byte b7,byte b8) {
  //character designer here: http://www.geocities.com/dinceraydin/lcd/charcalc.htm
  //pos from 0-7 (max 8 custom characters)
  Serial.print(0xFE,BYTE); //HD44780 command (254)
  Serial.print(64+pos*8,BYTE); //CG RAM start
  Serial.print(b1,BYTE);
  Serial.print(b2,BYTE);
  Serial.print(b3,BYTE);
  Serial.print(b4,BYTE);
  Serial.print(b5,BYTE);
  Serial.print(b6,BYTE);
  Serial.print(b7,BYTE);
  Serial.print(b8,BYTE);
  Serial.print(254,BYTE); //switch to command mode to leave
  Serial.print(1,BYTE);  //then do something (clear screen)
}

void setup() {
  Serial.begin(9600);
  setChar(0,159,159,159,159,159,159,159,159); //black box
  for (int i=0; i<8; i++) { //print custom chars
    Serial.print(i,BYTE);
  }
}

void loop() {
}
Logged

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3496
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

As some posters already noted you need to define custom characters. However the best approach today is to use the LCD library by Adafruit. The Sparkfun libraries and the older Arduino libraries are no match to this one. The Adafruit library delivers much better performance plus a high level interface to creating custom characters. This is what you most probably need. Although you will be only able to define 8 custom characters this is not to bad. This is 25% of the display.
Logged

Check out my experiments http://blog.blinkenlight.net

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3496
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Oops, forgot to mention. The adafruit library is included with Arduino 17. So either upgrade or download it here: http://www.adafruit.com/blog/2009/07/10/arduino-updated-liquidcrystal-library/
Logged

Check out my experiments http://blog.blinkenlight.net

Moss
Offline Offline
Full Member
***
Karma: 1
Posts: 119
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot!

I will try this and start using the new lib from now on... At least when I have enough pins.

Thanks again

Joachim
Logged

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3496
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the correlation of the library with the Pins? The new one uses exactly the same number of pins as the old one.
Logged

Check out my experiments http://blog.blinkenlight.net

Spokane, Washington
Offline Offline
God Member
*****
Karma: 1
Posts: 686
My name is Bob, and I'm an addict.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, you can set the LiquidCrystal to use 1 less pin.. by grounding the R/W (read/write). Since you can only Write to most HD47780 compatible LCDs, you only need the Write mode.

But you also need to specify this in the code, so it doesn't try to set it low every time it tries to write.
Take a look at this LadyAda tutorial on her website, about halfway down shows how she connects it. She mentions using USING_RW(false) as well, to turn off the RW pin, so won't need to be connected to the Arduino, but I haven't experimented with this so you'll have to read and experiment for yourself:D
http://www.ladyada.net/learn/arduino/lcd.html

Hope that clarifies some.

For the original post,
You can use Binary (easiest way for me) to design some graphics simply by using arrays, for example:
(This is just a box, empty in the center)
Code:
int boxArray[8] = {
B11111, // Each 1 is a pixel on the first line, all set to On
B10001; // Each 1 is a pixel on the Second line..
B10001; // Etc etc..
B10001; //
B10001; // Each "letterspace" on the LCD is 5x8 (bottomrow = cursor)
B10001; // Hence 5 across, 7 down
B11111; // Only 7 lines are addressable, 8th is saved for Cursor
}
You'd need to set that before your setup(), then to use it in a sketch, INSIDE your setup(), you need to assign that array to a character on the LCD (you can use up to 8 custom characters) by using the lcd.createChar command. Example below;
Code:
lcd.createChar(0, boxArray); // 0 == storage address, boxArray is the name you used to name the Array.
lcd.home();
NOTE: You must use lcd.home() after using the lcd.creatChar command, before the lcd will cooperate!

Now, finally, to use that box in your sketches, include this in your loop() or setup():
Code:
lcd.print(0, BYTE); // prints out the addressed array, as a byte

Hopefully this helps some, I'm sure other people can clarify or have better suggestions, but this was the easiest way to learn from no background in electronics for me!:D
« Last Edit: August 26, 2009, 01:57:00 pm by thoed » Logged

Moss
Offline Offline
Full Member
***
Karma: 1
Posts: 119
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

With regard to pin use, I am currently using a serial backpack, ie only one pin plus vcc and gnd. I assume you are talking about connecting directly to the 44780, and the original question was serial lcd...

Thanks anyway. I assume we haven't come any farther on serial lcd's?

Joachim
Logged

Moss
Offline Offline
Full Member
***
Karma: 1
Posts: 119
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, post #6 seems to be talking about serial lcd's
I'll try that first!

Joachim
Logged

Pages: [1]   Go Up
Jump to: