Make EVE2-29A look like a green crt display

FTDI/Bridgetek EVE2 & EVE3 & EVE4 SPI TFT Series by Matrix Orbital

Moderator: Mods

bobgardner
LCD!
Posts: 10
Joined: Thu May 09, 2019 11:48 am

Make EVE2-29A look like a green crt display

Post by bobgardner »

Howdy to Daniel and Henri and anyone who has an idea how to solve this problem. I have a green crt that is 208x86 (17888pix, 2236 bytes). I have a bunch of screenshots that I receive in 2 hunks, 1118 bytes each. These dots fill the crt screen nicely. The Matrix Orbital EVE2-29A TFT fits into the spot in the bezel of the KLN90B GPS where the crt was. Daniel wrote a lovely app that draws a Big Button of 208x86 in white, and when I look thru the green bezel screen, it looks green enough and bright enough to pass for a crt. Screens are mostly lat longs and other alphanumeric stuff, but as I described, the 2 1118byte hunks are the top half and bottom half of the screen in graphics, 8 pixels per byte. I want to download the 2236 bytes to somewhere in the eve2, scale it in width by 320/208, scale it in height by 102/86, and draw the bitmap on the eve. I also want to mount the eve upside down so the wide part is at the top, so looks like that is one of the rotation defines. I think I can get the 2236 byte image into flash on the uno so I can use the scoodo shield that talks to the eve. If someone could describe in words or eve2 commands how to do the image upload to the eve and the x scale and y scale, I'd be so appreciative. Right now I dont see any way to cvt the 2236 bytes of 8 pixels per byte to any fmt that eve likes. It doesnt like L1 and L8 is 8 times too big (slow to load?), so I'm stumped right now. Thanks for your ideas.

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: Make EVE2-29A look like a green crt display

Post by Daniel Divino »

Hi Bob,

I've done some testing here, and unfortunately, I wasn't able to display your image successfully in a relatively quick manner. I can display images, but they take a little bit of time to load from the SD card.

I'll continue testing, but I should let you know that I'll be out of the office between May 16-21. The earliest time I'll be able to get back to you will be next Tuesday.

You might find more success messaging FTDI/Bridgetek directly, as they have developed the FT81x Graphics controller chip that we use on our EVE2 displays. They will have more knowledge about the controller, and should be able to suggest the best solution for your project. You can find their contact information here: https://www.ftdichip.com/FTContact.htm

I'll be back on Tuesday to continue assisting your development.

If you have any questions about the EVE2-29A hardware specifically, I suggest you contact our support team at support@matrixorbital.ca. One of my colleagues will be able to help you out there.

Thanks,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

bobgardner
LCD!
Posts: 10
Joined: Thu May 09, 2019 11:48 am

Re: Make EVE2-29A look like a green crt display

Post by bobgardner »

Hi Daniel. I have been trying to display that 208x86 welcomepage.tif onto the eve display. I used irfanview to cvt it to welcompage.png. It was still the same size, about 3k. (should be 2236 bytes, 8 pixels per byte. This is L1 format right?). I ran img_cvt -i welcomepage.png -f 1 -d (I thought the format param was L1, but that gave an error. 1 worked, gives a 3k raw file). Tried to use your makescreen_BMP and makescreen BMP_DL to put this welcomepage.raw file from the sd card to the screen. I think your Send_CMD functions are more readable than the ft style. If you can get that file onto the eve screen as white dots on a black background, you are way smarter than me. The next step would be scale it to 320/208 and 102/86 and rotate it 180 deg, which works fine if I add the SETROTATE define from the ft manual to the eve3_81x.h file. Hope you can show me how to see that file on the eve tft. Thanks!

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: Make EVE2-29A look like a green crt display

Post by Daniel Divino »

Hi Bob,

I've played around with the image you've provided and I'm still having difficulties displaying it properly on the EVE. I am able to get... something. But it definitely isn't what we want.

Would it be possible for you to send me a jpeg version of what you are looking to display?

Cheers,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

bobgardner
LCD!
Posts: 10
Joined: Thu May 09, 2019 11:48 am

Display 208x86 1bpp on 320x102 eve2-29a

Post by bobgardner »

I have seen a black and white bitmap on the eve screen. Here's how to replicate this experiment. My original file was a 1bpp tif. Use irfanview to save this as a png. The 208x86 file is 2236 bytes, has a stride of 26 bytes. You then run it thru "img_cvt -i test.png -f 1" and it makes test.rawh. This is a file full of comma delimited number. Load this up in the editor and edit it up into a c file to compile into the program. I called it testrawh.c and the array was const uint8_t PROGMEM testdat[2236]={ all numbers here Strip last comma, add }; at the end and compile. Now you can load this from flash into eve graphics ram, tell the eve its format L1 stride 26, height 86, and it appears on the screen like magic. My file was 208x86, so tomorrow I'll fiddle with the scale to get it to fill up the screen. The pix on the eve are white, but it shows thru a green bezel and looks just like the original crt.

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: Make EVE2-29A look like a green crt display

Post by Daniel Divino »

Hi Bob,

What kind of speeds were you seeing? Was it relatively fast to update?

Cheers,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

bobgardner
LCD!
Posts: 10
Joined: Thu May 09, 2019 11:48 am

Re: Make EVE2-29A look like a green crt display

Post by bobgardner »

What I have working is loading the raw file from sd using your make_bitmap_dl example. I cant get the scale to work yet.
----------------------------------------------------
case SCR_KLNFLASH:
MakeScreen_KlnFlash(); //loads 208x86 klntestrawh.c from flash no work file attached
break;
case SCR_KLNFLASHSCL:
MakeScreen_KlnFlashScaled(); //loads 208x86 klntestrawh.c from flash and scales it to fullscreen 320x102 no work
break;
case SCR_RAW:
MakeScreen_Bitmap_DL("klntest.raw", 208, 86, 56, 8, 0); //klntest.raw is raw file of img_cvt, from sd works! file attached
break;
-------------------------------------------------------
//--------------------------------------
// Using raw uncompressed bitmap data, the CoProcessor is not needed for inflation and the data is
// stored into RAM_G without the use of the FIFO / CoProcessor.
// This function uses only the Display List and not FIFO
void MakeScreen_Bitmap_DL(uint8_t *filename, uint16_t Xsize, uint16_t Ysize, uint16_t Xloc, uint16_t Yloc, uint8_t Reference)
{
uint32_t BMPBaseAdd = RAM_G + 0x40000UL; // Hard-coded Address lacks panache

//printf("enter bitmap_dl\n\r");
Load_RAW(BMPBaseAdd, filename); // Load a bitmap into RAM_G its a .raw after img_cvt
Log("after loadRAW\n\r");

wr32(RAM_DL + 0, CLEAR_COLOR_RGB(0,0,0)); // Set the color for clearing to black
wr32(RAM_DL + 4, CLEAR(1, 1, 1)); // clear screen

// Define the bitmap
wr32(RAM_DL + 8, BITMAP_HANDLE(Reference)); // handle for this bitmap
wr32(RAM_DL + 12, BITMAP_SOURCE(BMPBaseAdd)); // Starting address in GRAM
wr32(RAM_DL + 16, BITMAP_LAYOUT(L1, 26, 86)); // format, stride, height
wr32(RAM_DL + 20, BITMAP_SIZE(NEAREST, BORDER, BORDER, Xsize, Ysize)); // define the holding area for the bitmap

// Place the bitmap
wr32(RAM_DL + 24, BEGIN(BITMAPS));
wr32(RAM_DL + 28, BITMAP_HANDLE(Reference));
wr32(RAM_DL + 32, VERTEX2II(Xloc, Yloc, Reference, 0)); // Define the placement position of the previously defined holding area.

#if 0 // We are already placing bitmaps, so no need to END and BEGIN bitmap commands again
wr32(RAM_DL + 36, COLOR_RGB(0x0,0xff,0x0)); // Set the text color green
wr32(RAM_DL + 40, VERTEX2II(11, 11, 26, filename[0])); // Assume a 8.3 filename
wr32(RAM_DL + 44, VERTEX2II(19, 11, 26, filename[1]));
wr32(RAM_DL + 48, VERTEX2II(27, 11, 26, filename[2]));
wr32(RAM_DL + 52, VERTEX2II(35, 11, 26, filename[3]));
wr32(RAM_DL + 56, VERTEX2II(43, 11, 26, filename[4]));
wr32(RAM_DL + 60, VERTEX2II(51, 11, 26, filename[5]));
wr32(RAM_DL + 64, VERTEX2II(59, 11, 26, filename[6]));
wr32(RAM_DL + 68, VERTEX2II(67, 11, 26, filename[7]));
wr32(RAM_DL + 72, VERTEX2II(75, 11, 26, filename[8])); // This will be the period
wr32(RAM_DL + 76, VERTEX2II(78, 11, 26, filename[9]));
wr32(RAM_DL + 80, VERTEX2II(83, 11, 26, filename[10]));
wr32(RAM_DL + 84, VERTEX2II(91, 11, 26, filename[11]));
wr32(RAM_DL + 88, END()); // end placing bitmaps
#endif

wr32(RAM_DL + 36, DISPLAY()); // End display list
wr8(REG_DLSWAP + RAM_REG, DLSWAP_FRAME); // swap display lists

Log("Leave Bitmap DL\n\r");
}
-----------------------------------------------------------------------------------
extern const uint8_t klntestdat[2236];
//------------------------------------------
void MakeScreen_KlnFlash(void)
{
//unsigned int i;
//unsigned long lscrndat;

//printf("enter klnflash\n\r");
Send_CMD(CMD_DLSTART);
Send_CMD(CLEAR_COLOR_RGB(0,0,0)); //clear color to black
Send_CMD(CLEAR(1,1,1)); //apply clear color to screen,stencil,tag

BITMAP_HANDLE(0);
BITMAP_SOURCE(RAM_G);
BITMAP_LAYOUT(L1, 26, 86); //format stride height
BITMAP_SIZE(NEAREST, BORDER, BORDER, 208, 86);
WriteBlockRAM(RAM_G,&klntestdat[0], 2236); //208x86, L1 fmt //<---Daniel this must be the prob

Cmd_FGcolor(0xffffff); //kln color white
Send_CMD(BEGIN(BITMAPS));
Send_CMD(VERTEX2II(56,8,0,0)); //draw 208x86 bitmap centered
//Send_CMD(CMD_END);

Send_CMD(DISPLAY());
Send_CMD(CMD_SWAP);
UpdateFIFO(); // Trigger the CoProcessor to start processing the FIFO
//printf("exit klnflash\n\r");
}
--------------------------------------------------------------------------
Attachments
klntestrawh.c
(6.88 KiB) Downloaded 360 times
klntest-dot-raw.c
(2.18 KiB) Downloaded 369 times

bobgardner
LCD!
Posts: 10
Joined: Thu May 09, 2019 11:48 am

Re: Make EVE2-29A look like a green crt display

Post by bobgardner »

Picture of screen attached
Attachments
20190523_150245.jpg
20190523_150245.jpg (2.93 MiB) Viewed 6919 times

bobgardner
LCD!
Posts: 10
Joined: Thu May 09, 2019 11:48 am

Re: Make EVE2-29A look like a green crt display

Post by bobgardner »

Notice how I got it to flip 180 deg?

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: Make EVE2-29A look like a green crt display

Post by Daniel Divino »

Hi Bob,

I finally have some good news for you! I was able to load the image off of the SD card, scale it to fit the screen, and display it on the EVE2-29A.

I'll have to clean up my code, but I'll make sure to upload it later tonight.

Cheers,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: Make EVE2-29A look like a green crt display

Post by Daniel Divino »

Hi Bob,

Please see the attached code.

It's essentially a modified version of our EVE School code, but it draws your test image on screen.

It includes 2 versions of your test screen: a jpg variant and a .raw variant. Their load times are comparable. I used Irfanview to convert your .tif image to a jpg. And then using the img_cvt tool, I converted the jpg to L1 format. Then I uploaded both images onto the SD card.

During my testing I found out that the SD.open() function that is used to read files from the SD card has a filename limit. Filenames are limited to 8 characters, which would explain why you were unable to load your image(s) from the SD card. After I renamed your images, they seemed to work just fine.

Once the images were loaded properly, all I had to do was use the BITMAP_TRANSFORM registers to stretch out the bitmaps.

Give this a quick run and let me know if meets your requirements.

Cheers,
Daniel.
Attachments
EVE2_29A_Test.zip
(32.39 KiB) Downloaded 393 times
Daniel Divino
Technical Support
Matrix Orbital

bobgardner
LCD!
Posts: 10
Joined: Thu May 09, 2019 11:48 am

Re: Make EVE2-29A look like a green crt display

Post by bobgardner »

Hi Daniel. 8:30 Thurs evening, at home. I see how you did the scaling. I left the rig on my bench at work, will load it tomorrow. The target hardware will receive 2 udp pkts ea with half the screen. This is essentially the point right after the raw file is loaded from the sd. I tried a bunch of edits trying to cvt the wr32 style direct write makefile_bitmap_dl into the Send_CMD style, which is better because its a pain to add 4 to every command. I ran the L1 format klntest.png file thru img_cvt and got klntst.rawh (the comma delimited data) and edited that into a c file. it starts with const uint8_t PROGMEM klnscreendat[2236]={ then the data. I'd like to be able to read these flash bytes and send em to the eve like Load_raw and Load_jpg subs do. Then I'll be done! Plan B might be to plug the shield into a mega with 4K ram and load the 2236 bytes in ram. Anyway, do you think having a Send_CMD version of MakeScreen_Bitmap_DL is a Good Idea? Thanks for your help!

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: Make EVE2-29A look like a green crt display

Post by Daniel Divino »

Hi Bob,

You should be able to do that. Just convert all of the wr32 RAM_DL functions to their SendCMD counterparts. See below:

Code: Select all

// Using raw uncompressed bitmap data, the CoProcessor is not needed for inflation and the data is 
// stored into RAM_G without the use of the FIFO / CoProcessor.
// This function uses only the Display List and not FIFO
void MakeScreen_Bitmap_DL(uint8_t *filename, uint16_t Xsize, uint16_t Ysize, uint16_t Xloc, uint16_t Yloc, uint8_t Reference)
{
  uint32_t BMPBaseAdd = RAM_G + 0x40000UL;                               // Hard-coded Address lacks panache
  
  Load_RAW(BMPBaseAdd, filename);                                        // Load a bitmap into RAM_G
  Log("after loadRAW \n"); 
  
  // Screen start
  /*wr32(RAM_DL + 0, CLEAR_COLOR_RGB(200,200,200));                        // Set the color for clearing to whitish
  wr32(RAM_DL + 4, CLEAR(1, 1, 1));                                      // clear screen*/

  Send_CMD(CMD_DLSTART);                                             // Start a new display list
  Send_CMD(CLEAR_COLOR_RGB(200,200,200));                            // Set the color for clearing to full white
  Send_CMD(CLEAR(1,1,1));                                            // clear screen 
  
  // Define the bitmap
  /*wr32(RAM_DL + 8, BITMAP_HANDLE(Reference));                            // handle for this bitmap
  wr32(RAM_DL + 12, BITMAP_SOURCE(BMPBaseAdd));                          // Starting address in GRAM
  wr32(RAM_DL + 16, BITMAP_LAYOUT(L1, 26, Ysize));              // format, stride, height 
  wr32(RAM_DL + 20, BITMAP_TRANSFORM_A(167)); //167 = 256/(302/208)             
  wr32(RAM_DL + 24, BITMAP_TRANSFORM_E(215));//215 = 256/(102/867)
  wr32(RAM_DL + 28, BITMAP_SIZE(NEAREST, BORDER, BORDER, 320, 102)); // define the holding area for the bitmap*/

  Send_CMD(BITMAP_HANDLE(Reference));                                // handle for this bitmap
  Send_CMD(BITMAP_SOURCE(BMPBaseAdd));                          // Starting address in GRAM  
  Send_CMD(BITMAP_LAYOUT(L1, 26, Ysize));                           // format, stride, height   
  Send_CMD(BITMAP_TRANSFORM_A(167));//167 = 256/(302/208)
  Send_CMD(BITMAP_TRANSFORM_E(215));//215 = 256/(102/867)
  Send_CMD(BITMAP_SIZE(NEAREST, BORDER, BORDER, 320, 102));
  
  // Place the bitmap
  /*wr32(RAM_DL + 32, BEGIN(BITMAPS));
  wr32(RAM_DL + 36, BITMAP_HANDLE(Reference));
  wr32(RAM_DL + 40, VERTEX2II(Xloc, Yloc, Reference, 0));                // Define the placement position of the previously defined holding area.                                                                          
  wr32(RAM_DL + 44, END());                                              // end placing bitmaps*/

  Send_CMD(BEGIN(BITMAPS));
  Send_CMD(BITMAP_HANDLE(Reference));
  Send_CMD(VERTEX2II(Xloc, Yloc, Reference, 0));                     // Define the placement position of the previously defined holding area.
  Send_CMD(END());                                                   // end placing bitmaps

  /*wr32(RAM_DL + 48, DISPLAY());                                          // End display list
  wr8(REG_DLSWAP + RAM_REG, DLSWAP_FRAME);                               // swap display lists*/

  Send_CMD(DISPLAY());                                               // End display list
  Send_CMD(CMD_SWAP);                                                // Activate this display list
  UpdateFIFO();                                                      // Trigger the CoProcessor to start processing the FIFO

  Log("Leave Bitmap DL\n");
}
You will have to develop your own function that converts the flash data and places it at a specific address in the EVE. Your LoadFileFromFlash should look fairly similar to our LoadRaw function.

Cheers,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

bobgardner
LCD!
Posts: 10
Joined: Thu May 09, 2019 11:48 am

Re: Make EVE2-29A look like a green crt display

Post by bobgardner »

Thanks for that reply. I spent a while over the holiday converting the wr32 style to the Send_CMD style, and I did notice that if we use BILINEAR instead of NEAREST it got rid of the lines that had scaled to 2 pixels when trying to scale it up. How in the heck did you get the equation for transform a and e? Not obvious at all.

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: Make EVE2-29A look like a green crt display

Post by Daniel Divino »

Hi Bob,

Yeah, I guess my comments in the code were pretty vague eh? It also looks like the resolution values listed in the calculations are wrong as well. I must have been daydreaming of the weekend when I wrote those comments haha.

The BITMAP_TRANSFORM registers are described in sections 4.12 to 4.17 of the FTDI FT81x programmers guide.

Bitmap transform registers A and E are used to control the bitmap's Horizontal and Vertical scaling.

Setting a BITMAP_TRANSFORM_A value of 256 will have the bitmap scaled as normal. Setting BITMAP_TRANSFORM_A to 128 will stretch the bitmap to double the width.

So, the calculations are as follows:

1. Calculate how much the image needs to be scaled in the horizontal axis in order for it to fill the display.
Display resolution = 320
Image resolution = 208

320/208 = 1.538461...

So in order for the image to fill the displays horizontal axis, it will have to be scaled 1.5x larger.

2. Determine the Transform_A value necessary to achieve the scaling.
256/1.538461.... = 166.4
Make sure to round up so that the image doesn't get cut off.


Then do the same with the vertical calculations and you should be good as gold!

Cheers,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

Post Reply