How to: Change SparkFun serLCD splash

This code can be used to easily change the splash screen on a SparkFun Serial LCD module.

Enjoy

//sets serial lcd splash screen

// 1)make sure tx of lcd is unplugged
// 2)change lines to whatever you want (see below)
// 3)upload sketch to board
// 4)power down board and plug in tx of lcd
// 5)power up board
// 6)reset to test after the screen goes blank (old splash - new splash - blank screen - reset to test)

void setup()
{
  Serial.begin(9600);
  backlightOn();
  delay(100);
  clearLCD();
  selectLineOne();
  delay(100);
  Serial.print("Hello, Dave"); //type in the first line of the splash here (16 char max)
  selectLineTwo();
  delay(100);
  Serial.print("..."); //type the second line of the splash here (16 char max)
  delay(500);
  Serial.print(0x7C, BYTE); //these lines...
  Serial.print(10, BYTE); //set the splash to memory (this is the <control> j char or line feed
  delay(100);
  clearLCD();
}

void loop()
{  
  delay(100);
}

void selectLineOne(){  //puts the cursor at line 0 char 0.
   Serial.print(0xFE, BYTE);   //command flag
   Serial.print(128, BYTE);    //position 
}
void selectLineTwo(){  //puts the cursor at line 0 char 0.
   Serial.print(0xFE, BYTE);   //command flag
   Serial.print(192, BYTE);    //position
}
void clearLCD(){
   Serial.print(0xFE, BYTE);   //command flag
   Serial.print(0x01, BYTE);   //clear command.
}
void backlightOn(){  //turns on the backlight
    Serial.print(0x7C, BYTE);   //command flag for backlight stuff
    Serial.print(157, BYTE);    //light level.
}
void backlightOff(){  //turns off the backlight
    Serial.print(0x7C, BYTE);   //command flag for backlight stuff
    Serial.print(128, BYTE);     //light level for off.
}
void serCommand(){   //a general function to call the command flag for issuing all other commands   
  Serial.print(0xFE, BYTE);
}

Here's a couple functions I've written for the serlcd

#define lcdwipe           0x01  

void lcdPos(int x, int y){  //takes x (0-15) and y (0-1) position arguments
  if (y==0)  y=128;
  if (y==1)  y=192;
  Serial.print(0xFE, BYTE);
  Serial.print(x+y, BYTE);
}

void lcdLight(int x){   // takes argument from 1 (off) to 30 (on)
  Serial.print(0x7C, BYTE);
  Serial.print(x+127, BYTE);
}

void lcdCode(int x){   //a general function to call the command flag for issuing all other commands   
  Serial.print(0xFE, BYTE);
  Serial.print(x, BYTE);
}

Here are my code for producing a smooth “analogue” bar for displaying CPU and RAM usage, it uses custom defined characters:

void writecharLCD() {
  unsigned short charArray[][8] = {                         //Self defined bar characters
    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 charactor
    0x0A,0x15,0x1F,0x00,0x1F,0x0C,0x1F,0x00          };        //single character that says "MB" sideways

  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);
}

hey guys

it would be great if, in addition to putting your code here, you could also make a little wiki page with your hacks and code in the Playground. Code tends to get lost in here.. after a few months it is really difficult to find! When it is in the Playground then it becomes part of a bigger library of ready-to-use functions and code.

D

How does one do that? I click on edit, it asks me for a user name and password. Can anyone just register?

I agree though, it seems like lots of stuff get lost and repeated in the forum.

-Z-

hi

yes you just register and then you can make any pages you like.

The steps are: 1. Register 2. Try some basic editing in the sandbox 3. When you're ready to make a page, type in a page name or url that does not exist 4. when you get the page saying that the requested URL does not exist, click "edit" 5. edit the page and save.. now it exists 6. link the page form the tutorial or code pages, so people know where it is...

hope this helps

Daniel

I haven't been able to figure the whole editing in the wiki thing out. More specifically, we can create pages as you state but we can't complete step 6 and edit a main page/sidebar/referring page to make them visible in the wiki.

Can someone else put all this code there under a single page. Maybe title it "helpful SparkFun SerLCD code and functions"

@sti robot … THANK YOU!!!

i was so thrown by the J thing!??!!!?!?

but now i have my screen looking the way i want it to … so thanks!

But i would like to know how one would know what J was referring to?

when i was trying to figure out this code, all i could find was something saying:

“Ctl-J
Newline (line feed). In a script, may also be expressed in octal notation – ‘\012’ or in hexadecimal – ‘\x0a’.”

yet i see you used 10 ???

any insight would appreciated…

thanks again for the code bit!!!

octal notation -- '\012' hexadecimal -- '\x0a'

And what would that value be in decimal? You don't even need to take your shoes off to count that high.

Unless your missing a finger, that is.

lol !! ... gotcha!

i shoulda known, considering everything else was in decimal... duh

THANK YOU!