Receiving data back from GLK12232-25

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

Moderators: Henry, Mods

whookey
LCD!
Posts: 15
Joined: Fri Feb 15, 2002 4:00 pm
Location: hull, quebec
Contact:

Post by whookey »

I'm trying to negotiate bitmap transfers to my GLK12232-25 in linux. The system I installed the display in doesn't run Windows. I've modified the connectors, and it's really a tough to extract mounting job, so I hope I don't have to go back to a windows machine for mogd.exe. I couldn't seem to get the handshaking working, so I tested the "Read NN Number" commands, 254 [53,54,55]. When I issue "254 55", nothing comes back across the serial device, but a dollar sign ('$') appears on the display. Is this correct? I'm fairly sure the Rx line is still connected, but I'll recheck when I can get the box open again.

But the text display and graphics drawing commands work great!

Thanks!

Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3002
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

Double check your cabling... try using a hyperterminal style program to see if you can get keystrokes sent back to you, this will test back and forth comunication.

_________________
Henry J.
Technical Support
Matrix Orbital

<font size=-1>[ This Message was edited by: Henry on 2002-02-21 12:45 ]</font>

Thlayli
LCD Geek
Posts: 34
Joined: Sun Jan 20, 2002 4:00 pm
Location: Madison, WI
Contact:

Post by Thlayli »

I'm a bit confused about what you're doing, you're coding a new program, right? What language? Perl would rock if you're doing what I think you're doing =) You could just open FILE "dev<insert device here>"; and read directly from it for responses, how cool is that =)Ok, so I think programming languages are cool, so what.

whookey
LCD!
Posts: 15
Joined: Fri Feb 15, 2002 4:00 pm
Location: hull, quebec
Contact:

Post by whookey »

Right now I'm just trying to upload bitmaps, and come up with some linux tools to do the bitmap conversion and file transer (like pngtopnm <file> | pnmtomobmp | mo_upload -N 2 ). I've found lots of perl/python libraries for text LCD manipulation, but now the world needs my forthcoming python graphic LCD library. :smile: Right now I've just got a simple perl script which makes it easy to send commands to the LCD, such as "lcd 88" to clear the display.

Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3002
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

Do you want some C/C++ sample code for uploading?
Henry J.
President
Matrix Orbital

Thlayli
LCD Geek
Posts: 34
Joined: Sun Jan 20, 2002 4:00 pm
Location: Madison, WI
Contact:

Post by Thlayli »

Heh, being that I absolutely love perl I could code that for you if you'd like, but I wouldn't be able to give a definate guarentee that it works since I was cheap and didn't get a graphic one *cry*

word of advice if you're buying one of these: just buy the expensive one or you'll regret it later =)

Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3002
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »


Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3002
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

hehehehehehe

whookey
LCD!
Posts: 15
Joined: Fri Feb 15, 2002 4:00 pm
Location: hull, quebec
Contact:

Post by whookey »

Examples would be grrreat! As mentioned in the hardware forum, i'm happily talking with the little guy now, e.g. (254,55) returns the correct model type (0x24).
I've been having trouble with bitmap uploading. I'm following the protocol example for font uploads (I've gone through the initial steps of font uploading to reference #3, (254,36,3) and things seem happy, I get an echo from the module "0x03" as the documentation says). When I try the same for bitmaps (254,110,2), I don't get an echo, so can't continue with the uploading process.
Help?

Thanks!

Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3002
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

I'll post source tomorow morning..
Henry J.
President
Matrix Orbital

Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3002
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

Code: Select all


void __fastcall TForm1::BitBtn4Click(TObject *Sender)
{
  TCanvas *pCanvas = Image1->Canvas;
  char BitCounter = 0;
  unsigned char dat, HSval;
  unsigned short int Size16;
  float Size;

  if (BRSmode)
  {
    ZComm1->WriteCommByte(0xfe); // Leave Buffer Return Status Mode
    ZComm1->WriteCommByte(';');
    BRSmode = false;
  }

  int Len;

  // Send the Command and preamble
  ZComm1->WriteCommByte(0xfe);  // Command prefix
  ZComm1->WriteCommByte('^');   // Upload Bitmap command
  dat = CSpinEdit1->Value;      // Retrieve the reference number from the user

  ZComm1->WriteCommByte(dat);   // Send Reference Number
  while (!ZComm1->ReadComm(&HSval,1)); // Wait for return from LCD
  if (dat != HSval)
  {
    ShowMessage("Error in transmission - 1");
    ZComm1->WriteCommByte(0x08);  // Send bad confirmation just in case
    return;
  }
  ZComm1->WriteCommByte(0x01);  // Confirm Echo

  if (CheckBox1->Checked)
    Size = Image1->Width * Image1->Height; // number of pixels in image
  else
    Size = Image1->Picture->Width * Image1->Picture->Height; // number of pixels in image

  if (fmod(Size,8)) // Does the data need to be padded?
  {
    Size /= 8;      // Calculate number of whole bytes
    Size++;         // add one for padding
  }
  else
    Size /= 8;      // Calculate number of whole bytes

  // Size at this point still includes fraction
  Size16 = Size; // cheesy conversion to 16 bit value
  Size16 += 4;  // This is to add the header info
  dat = Size16 & 0x00ff; // Low byte - too lazy for pointers
  ZComm1->WriteCommByte(dat);   // Send Low part of size

  while (!ZComm1->ReadComm(&HSval,1)); // Wait for return from LCD
  if (dat != HSval)
  {
    ShowMessage("Error in transmission - 2");
    ZComm1->WriteCommByte(0x08);  // Send bad confirmation just in case
    return;
  }
  ZComm1->WriteCommByte(0x01);  // Confirm Echo

  dat = Size16 / 256; // high byte - mmmm cheesy!
  ZComm1->WriteCommByte(dat);   // Send High part of size
  while (!ZComm1->ReadComm(&HSval,1)); // Wait for return from LCD
  if (dat != HSval)
  {
    ShowMessage("Error in transmission - 3");
    ZComm1->WriteCommByte(0x08);  // Send bad confirmation just in case
    return;
  }

  while (!ZComm1->ReadComm(&HSval,1)); // Wait for status from LCD
  if (HSval != 0x01)
  {
    ShowMessage("Error in transmission - 4");
    ZComm1->WriteCommByte(0x08);  // Send bad confirmation just in case
    return;
  }

  ZComm1->WriteCommByte(0xff);   // Send First byte of spacer
  while (!ZComm1->ReadComm(&HSval,1)); // Wait for return from LCD
  if (HSval != 0xff)
  {
    ShowMessage("Error in transmission - 5");
    ZComm1->WriteCommByte(0x08);  // Send bad confirmation just in case
    return;
  }
  ZComm1->WriteCommByte(0x01);  // Confirm Echo

  ZComm1->WriteCommByte(0xff);   // Send second byte of spacer
  while (!ZComm1->ReadComm(&HSval,1)); // Wait for return from LCD
  if (HSval != 0xff)
  {
    ShowMessage("Error in transmission - 6");
    ZComm1->WriteCommByte(0x08);  // Send bad confirmation just in case
    return;
  }
  ZComm1->WriteCommByte(0x01);  // Confirm Echo

  ZComm1->WriteCommByte((unsigned char)Image1->Picture->Width);// Send X size of bitmap
  while (!ZComm1->ReadComm(&HSval,1));      // Wait for return from LCD
  if (HSval != (unsigned char)Image1->Picture->Width)
  {
    ShowMessage("Error in transmission - 7");
    ZComm1->WriteCommByte(0x08);  // Send bad confirmation just in case
    return;
  }
  ZComm1->WriteCommByte(0x01);  // Confirm Echo

  ZComm1->WriteCommByte((unsigned char)Image1->Picture->Height);// Send Y size of bitmap
  while (!ZComm1->ReadComm(&HSval,1));      // Wait for return from LCD
  if (HSval != (unsigned char)Image1->Picture->Height)
  {
    ShowMessage("Error in transmission - 8");
    ZComm1->WriteCommByte(0x08);  // Send bad confirmation just in case
    return;
  }
  ZComm1->WriteCommByte(0x01);  // Confirm Echo

  for (int x = 0; x < Image1->Picture->Width; x++)
  {
    for (int y = 0; y < Image1->Picture->Height; y++)
    {
      if (!pCanvas->Pixels[x][y])
      {
        // Black Pixel
        dat |= Bits[BitCounter];
      }

      if (BitCounter == 7)
      {
        // send the byte now that it is full

        ZComm1->WriteCommByte(dat);  // Send data
        while (!ZComm1->QCountIn);   // Wait for return from LCD
        ZComm1->ReadComm(&HSval,1);
        if (HSval != dat)
        {
          ShowMessage("Error in transmission - 9");
          ZComm1->WriteCommByte(0x08);  // Send bad confirmation just in case
          return;
        }
        ZComm1->WriteCommByte(0x01);  // Confirm Echo
        BitCounter = 0;
        dat = 0;
      }
      else
        BitCounter++;
    }
    float progress = ((float)x/(float)Image1->Picture->Width)*100+1;
    ProgressBar1->Position = progress;
  }
  if (BitCounter) // There is a little left over
  {
    ZComm1->WriteCommByte(dat);  // Send data
    while (!ZComm1->ReadComm(&HSval,1)); // Wait for return from LCD
    if (HSval != dat)
    {
      ShowMessage("Error in transmission - 10");
      ZComm1->WriteCommByte(0x08);  // Send bad confirmation just in case
      return;
    }
    ZComm1->WriteCommByte(0x01);  // Confirm Echo
  }
}

This is for a font upload
Henry J.
President
Matrix Orbital

whookey
LCD!
Posts: 15
Joined: Fri Feb 15, 2002 4:00 pm
Location: hull, quebec
Contact:

Post by whookey »

I think you meant "..is for bitmap upload."?

Though I see something I've been worried about:

<CODE>ZComm1->WriteCommByte('^'); // Upload Bitmap command</CODE>

Shoot, my original topic was incorrect, I have a GLK 12232-25SM (which gets a 0x24 back from (255,55)), not a 1223225, but according to the manuals for each module, the commands for bitmap upload are the same, 110 decimal, (or 'n' ascii). '^' in your code above is 94 decimal! The other day I was paging through the manuals for some other modules, and noticed at least one of them (can't recall which) used 94 for bitmap upload, so I tried it, and got an echo back as expected.

Please check the online manuals (110 is listed on my CD as well) and get back to me, so I can scream if I've been using the wrong command all along.

Thanks.

whookey
LCD!
Posts: 15
Joined: Fri Feb 15, 2002 4:00 pm
Location: hull, quebec
Contact:

Post by whookey »

I've successfully uploaded a bitmap, using command 94. (!!yay! look for screenshots in the near future). <B> The manuals should be updated </B> to ensure that no one else wastes time using 110 like I did. Are there printed copies (of the updated version!) available? Are there other errata to watch out for?

Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3002
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

You are correct on the error.. I will fix it up ASAP, thanks for the heads up. There are no other hidden commands or features in the display, the reason why we haven't documented the 0x99 command is that it's not present in the GLK12232-25 but is in the GLK12232-25-WBL and GLK12232-25-SM. We are replacing the GLK12232-25 with GLK12232-25-WBL so we were keeping the command out of it until we finished phasing out the display.
Henry J.
President
Matrix Orbital

specialk
LCD Guru
Posts: 75
Joined: Mon Jan 14, 2002 4:00 pm

Post by specialk »

YES!
I FINALLY UNDERSTAND HOW TO UPLOAD BITMAPS! OMG, I AM SOOO HAPPY! I know it may seem corny, but I *just* figured out how to upload bitmaps... this will make programs *much* easier to work with (know how with my winamp program you had to upload each file? no more!)
:smile: :smile: :smile:

-special [k]

Post Reply