Little cosmetic for serial LCD

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download

Little cosmetic for serial LCD

Postby flyman777 » Sun Nov 13, 2011 6:36 pm

Hi,

I had always spurious caracters on my first screen using a self made Sparkfun serial LCD 2x16, mostly when I restarted the LCD config after an Exit.

So I modify the fonction LCDclear() in LCD.pde and it's working well now.

//Modif LCDclear() to avoid spurious caracters on serial LCD Sparkfun

void initLCD() {
blinkLED(20,30,1);
#if defined(LCD_TEXTSTAR)
// Cat's Whisker Technologies 'TextStar' Module CW-LCD-02
// http://cats-whisker.com/resources/docum ... asheet.pdf
// Modified by Luca Brizzi aka gtrick90 @ RCG
LCDprint(0xFE);LCDprint(0x43);LCDprint(0x02); //cursor blink mode
#elif defined(LCD_ETPP)
// Eagle Tree Power Panel - I2C & Daylight Readable LCD
// Contributed by Danal
i2c_ETPP_init();
#else
Serial.end();
//init LCD
PINMODE_LCD; //TX PIN for LCD = Arduino RX PIN (more convenient to connect a servo plug on arduino pro mini)
#endif
LCDclear();
LCDsetLine(1);
LCDprintChar("MultiWii Config ");

delay(2500);
LCDclear();
}
...
void LCDclear() {
#if defined(LCD_ETPP)
i2c_ETPP_send_cmd(0x01); // Clear display command, which does NOT clear an Eagle Tree because character set "R" has a '>' at 0x20
for (byte i = 0; i<80; i++) i2c_ETPP_send_char(' '); // Blanks for all 80 bytes of RAM in the controller, not just the 2x16 display
#elseif defined(LCD_TEXTSTAR)
LCDprint(0x0c); //clear screen
#else
LCDprint(0xFE);LCDprint(0x01);delay(10);LCDprint(0xFE);LCDprint(0x02);delay(10); // clear screen, cursor line 1, pos 0 for serial LCD Sparkfun

#endif
}

OK, it's not so important but it's nice when all works well.

Regards
flyman777
flyman777
 
Posts: 55
Joined: Mon Sep 19, 2011 1:44 pm

Re: Little cosmetic for serial LCD

Postby flyman777 » Mon Jan 02, 2012 3:45 pm

Hi,

Happy New Year to All.

I will come back since I tried all the last devs.
There are much positive improvements, thanks to all developpers.
But I have always problems with the LCD display , 3 wires Sparkfun.
So I added this:

LCDprint(0xFE);LCDprint(0x01);delay(10);LCDprint(0xFE);LCDprint(0x02);delay(10); // clear screen, cursor line 1, pos 0 for serial LCD Sparkfun

instead of //nothing ? !!

in LCDclear();:

void LCDclear() {
#if (LCD_TYPE == SERIAL3W)
LCDprint(0xFE);LCDprint(0x01);delay(10);LCDprint(0xFE);LCDprint(0x02);delay(10); // clear screen, cursor line 1, pos 0 for serial LCD Sparkfun// nothing ???
#elif (LCD_TYPE == TEXTSTAR)
LCDprint(0x0c); //clear screen
#elif (LCD_TYPE == ETPP)
i2c_ETPP_send_cmd(0x01); // Clear display command, which does NOT clear an Eagle Tree because character set "R" has a '>' at 0x20
for (byte i = 0; i<80; i++) i2c_ETPP_send_char(' '); // Blanks for all 80 bytes of RAM in the controller, not just the 2x16 display
#endif
}

Yet it's works fine.

Regards
flyman777
flyman777
 
Posts: 55
Joined: Mon Sep 19, 2011 1:44 pm

Re: Little cosmetic for serial LCD

Postby UndCon » Mon Jan 02, 2012 4:05 pm

does it also behaves strange when you are only using the LCD?

I use mine frequently with other projects with codes like this



Code: Select all

#include <SoftwareSerial.h>

#define txPin 2
int counter=9999;

SoftwareSerial LCD = SoftwareSerial(0, txPin);
// since the LCD does not send data back to the Arduino, we should only define the txPin
const int LCDdelay=10;  // conservative, 2 actually works

// wbp: goto with row & column
void goTo(int row, int col) {
  LCD.print(0xFE, BYTE);   //command flag
  LCD.print((col + row*64 + 128), BYTE);    //position
  delay(LCDdelay);
}
void clearLCD(){
  LCD.print(0xFE, BYTE);   //command flag
  LCD.print(0x01, BYTE);   //clear command.
  delay(LCDdelay);
}
void backlightOn() {  //turns on the backlight
  LCD.print(0x7C, BYTE);   //command flag for backlight stuff
  LCD.print(157, BYTE);    //light level.
  delay(LCDdelay);
}
void backlightOff(){  //turns off the backlight
  LCD.print(0x7C, BYTE);   //command flag for backlight stuff
  LCD.print(128, BYTE);     //light level for off.
   delay(LCDdelay);
}
void serCommand(){   //a general function to call the command flag for issuing all other commands   
  LCD.print(0xFE, BYTE);
}

void setup()
{
 
  pinMode(txPin, OUTPUT);
  LCD.begin(9600);
  clearLCD();
  goTo(0,0);
  LCD.print("Hello world!");
}

void loop()
{
  clearLCD();
  goTo(0,0);
  LCD.print("Loop:");
  counter--;
  LCD.print(counter);
  delay(1000);
}





This clearLCD() works perfect for me...

//UndCon
User avatar
UndCon
 
Posts: 293
Joined: Mon Feb 21, 2011 2:10 pm

Re: Little cosmetic for serial LCD

Postby flyman777 » Mon Jan 02, 2012 5:43 pm

OK,

this will work too, but there was a empty line to fill and the look is better especially since the upgrades in LCD.pde were made ( shortening of the strings).
The command codes are the same and follow the Sparkfun's datasheet for 3W LCD.
I added some tempo, my LCD is perhaps a bit slow (old piece from my trick box !).

Best regards

flyman777
flyman777
 
Posts: 55
Joined: Mon Sep 19, 2011 1:44 pm

Re: Little cosmetic for serial LCD

Postby Danal » Mon Jan 02, 2012 6:35 pm

Good stuff.

I added LCDclear some time ago, and never went back and put the right things in the up the sparkfun/serial section of it. I committed your change to the "shared" branch in the google code repository.

Excellent!
Danal
 
Posts: 137
Joined: Tue Oct 18, 2011 5:15 pm


Return to Software development

Who is online

Users browsing this forum: Exabot [Bot] and 2 guests