SparkFun GLCD Serial Backpack woes

Hello,

I have a new SparkFun Serial Graphic LCD backpack (datasheet).

For initial testing I've hooked it up to the serial tx pin 1 on my Uno.

I have had success in issuing simple commands to the board, so sending the Clear (0x7C00) or the Demo (0x7C04) commands seem to work great, but I'm having little luck with the commands requiring more parameters. These are always completely ignored.

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  // demo
  Serial.print(0x7C, BYTE); // Command
  Serial.print(0x00, BYTE); // Clear
  Serial.print(0x7C, BYTE); // Command
  Serial.print(0x04, BYTE); // Demo
  delay(5000);

  // dots
  Serial.print(0x7C, BYTE); // Command
  Serial.print(0x00, BYTE); // Clear
  Serial.print(0x7C, BYTE); // Command
  Serial.print(0x10, BYTE); // Clear
  Serial.print(0x50, BYTE); // Pixel X
  Serial.print(0x40, BYTE); // Pixel Y
  Serial.print(0x01, BYTE); // Pixel State
  delay(5000);

  // rectangle
  Serial.print(0x7C, BYTE); // Command
  Serial.print(0x00, BYTE); // Clear
  Serial.print(0x7C, BYTE); // Command
  Serial.print(0x0F, BYTE); // Rect
  Serial.print(0x00, BYTE); // Rect X1
  Serial.print(0x0A, BYTE); // Rect Y1
  Serial.print(0x32, BYTE); // Rect X2
  Serial.print(0x3C, BYTE); // Rect Y2
  Serial.print(0x01, BYTE); // Rect State
  delay(2000);
}

Okay, some progress using the hardware serial ‘port’.

While I’m working this out, is there an easy way to send 0x7C00 or 0x7C103F1F01, without having to do them one byte at a time?

Serial.print(0x7C, BYTE); // Command
Serial.print(0x00, BYTE); // Clear

Serial.print(0x7C, BYTE); // Command
Serial.print(0x10, BYTE); // Pixel
Serial.print(0x3F, BYTE); // Pixel X (0-127, 0x00-0x7F)
Serial.print(0x1F, BYTE); // Pixel Y (0-63, 0x00-0x3F)
Serial.print(0x01, BYTE); // Pixel State

I’ve created a minimally-failing-code sample.

It’s supposed to draw a series of 6 boxes from bottom-left to about top-middle, which it does. It then over-draws these boxes every frame. (So the picture shouldn’t change each frame).

The problem is that after a few frames I get the artifacts shown in the attached “failed” image.

Lowering the final delay() makes the problem appear faster and worse.

/*
 * Test and demo of the failing LCD backpack commands
 */
 
void setup()
{
  delay(5000);
  Serial.begin(9600);
  Serial.print(0x7C, BYTE); // Command
  Serial.print(0x00, BYTE); // Clear
  delay(5000);
}

int frame = 0;
int MAX_BOXES = 6;

void loop()
{
  int X1;
  int Y1;
  int X2;
  int Y2;
  int boxSize = 10;
  int spacing = 10;

  if (frame >= MAX_BOXES)
  {
    frame = 0;
  }

  X1 = (frame*spacing);
  Y1 = (frame*spacing);
  X2 = X1 + boxSize;
  Y2 = Y1 + boxSize;
  Serial.print(0x7C, BYTE); // Command
  Serial.print(0x0F, BYTE); // Box
  Serial.print(X1, BYTE);   // X1
  Serial.print(Y1, BYTE);   // Y1
  Serial.print(X2, BYTE);   // X2
  Serial.print(Y2, BYTE);   // Y2
//  Serial.print(1, BYTE); // State - this breaks

  frame++; 
  delay(200);
}

FailingLCD.pde (769 Bytes)

Apologies for the marginally necroposting nature, but I just thought I'd pop in to say that I've picked up this confounded display+backpack this week, and I have:

  • tidied all the wiring
  • tidied all the code
  • used a nice regulated power source in the required range for the screen
  • tried with hardware serial
  • tried with SoftwareSerial

All with no success. (All that wasn't quite as painful as it sounds)

So I can only assume I'm victim of the notoriously sucky firmware on the backpack, and tonight will try using my Arduino as an ISP to burn on SummoningDark's custom firmware.

Fingers crossed :)

I wonder if it is a serial speed problem. You are communicating at 9600 and looping commands constantly if I am correct. Giving a larger delay at the end gives the backpack more time to process the serial and write to the display. I think if you put a small delay between each Serial.print and one at the end you will get more reliable results.

Ultimately, it might work the best with a higher baud rate and also give the backpack time for writing to the display.

I haven't used a backpack this is just my thoughts.

I have an update! I think all my woes were due to the completely broken firmware shipped on those backpacks. As soon as I put the custom firmware from SummoningDark on there, everything "just worked".

(Oh, and it's only when I just tried to find my post that I realised it's in LED, and not LCD. Is that easily moved?)