About a month and a half ago I asked about how to upload a bitmap file to a GLK240128-25 since I couldn't get it to work as in the manual. Clark kindly posted a reply saying the manual was wrong and I should try this approach:
---------------------------------------------------------------
Host: Transmit(0xFE); //Command Prefix
Transmit(0x5E); //Bitmap file upload command
Transmit(0x05); //Reference ID for bitmap file
Transmit(0x19); //Transmit bitmap file size LSB
Transmit(0x00); //Transmit bitmap file size MSB
Module: FileFits(0x01); //Send confirmation that file fits
Host: Receive(); //Receive confirmation that file fits
Transmit(0x05); //Transmit first byte of file data
Module: Echo(0x05); //Echo first byte of file
Host: Receive(); //Receive echo
Confirm(0x05); //Confirm echo
Transmit(0x07); //Transmit second byte of file data
etc...
If any byte other than 0x01 is seen for confirmation by host or module (usually 0x08) the upload it aborted.
------------------------------------------------------------
well, life being what it is, I am now getting around to trying this approach. First, the line that says Confirm(0x05) should be Confirm(0x01), ie, send 0x01 as a confirmation. Second, while the above does indeed upload a file the file appears as garbage when the display shows it. The same bitmap (ie, Windows bitmap) file when uploaded through MOGD# looks just fine.
So, there is a step missing somewhere. Any ideas as to what it is?
Thanks!
Ron
Uploading a bitmap file programmatically (again)
-
- LCD?
- Posts: 5
- Joined: Fri Aug 31, 2007 6:34 am
-
- Matrix Orbital
- Posts: 745
- Joined: Thu Dec 13, 2001 4:00 pm
- Location: Earth.... I think..
- Contact:
here's the relevant part out of mogd#
The reason your bitmap maybe garbled is that between rev 1.x and 2.x the way the bitmap is stored has been changed, V1 scanned the bitmap vertically while V2 scans it horizontally.
Code: Select all
// Write command
Write(254);
Write((byte)uploadType);
Write((byte)reference);
//In unit does not echo back the id, bail out.
if (revision == PcbRev.rev1X)
{
Echo = Read();
if (Echo ==reference)
Write(1);
else
return false;
}
//Write FileSize to unit and wait for echo's
byte SizeLo = (byte) (data.Length & 0xff);
byte SizeHi = (byte) (data.Length >> 8);
Write(SizeLo);
if (revision == PcbRev.rev1X)
{
Echo = Read();
if (Echo == SizeLo)
Write(1);
else
return false;
}
Write(SizeHi);
if (revision == PcbRev.rev1X)
{
Echo = Read();
if (Echo != SizeHi)
return false;
}
Echo = Read();
if (Echo == 0x01) //If it stil fits go on
{
for (int i=0; i < data.Length; i++) //Write the whole stream and check for echo's
{
Write(data[i]);
Echo = Read();
if (Echo != data[i])
{
return false;
}
else
Write(1);
}
}
else //Font or bitmap to big for unit / unit rejects font/bitmap
return false;
return true; //Got all the way to the end? success!
-
- LCD?
- Posts: 5
- Joined: Fri Aug 31, 2007 6:34 am
Uploading a bitmap file programmatically (again)
>The reason your bitmap maybe garbled is that between rev 1.x and 2.x the way the bitmap is
>stored has been changed, V1 scanned the bitmap vertically while V2 scans it horizontally.
So, the actual bitmap file is not uploaded but rather the pixel data only? If so, what specifies the dimensions of the image?
Ron
>stored has been changed, V1 scanned the bitmap vertically while V2 scans it horizontally.
So, the actual bitmap file is not uploaded but rather the pixel data only? If so, what specifies the dimensions of the image?
Ron
-
- Matrix Orbital
- Posts: 745
- Joined: Thu Dec 13, 2001 4:00 pm
- Location: Earth.... I think..
- Contact:
There was a section on this in the manual but it seems to have gone missing, I'll inform the manual team on this.
Bitmaps are stored almost the same as a font but with a simpler header
[Width (1 byte)] [Height ( 1 byte )] [Data (as much as needed)]
The data is enocded the same way as the individual characters in a font file, see section 5.2.1 Creating a font in your manual to see how its done.
Bitmaps are stored almost the same as a font but with a simpler header
[Width (1 byte)] [Height ( 1 byte )] [Data (as much as needed)]
The data is enocded the same way as the individual characters in a font file, see section 5.2.1 Creating a font in your manual to see how its done.
-
- LCD?
- Posts: 5
- Joined: Fri Aug 31, 2007 6:34 am