Home Resources

HOW TO: Use the external EEPROM to load images onto the 128x128 Colour GLCD

 

 

overview

 

Items used in this tutorial:

  • FlamingICE40
  • GLCD + RTC Combo Module
  • FI EEPROM
  • FI Comm.Key
  • 6V Power Supply

With the launch of FIDE 2.0, many new and powerful features were introduced to make embedded programming and integration a whole lot easier; one of the greatest features that came with it is the ability to flash the external EEPROM with the data generated by the GLCD tool.  Before we go on to explore this new feature, let’s get the hardware up.

 

HARDWARE CONFIGURATION

 

FI40_GLCD_CONFIG.png

 NOTE(1): To find out how to interface the FI Comm.Key to the FIDE and power up the FI40 Board, as well as setting up a new project in FIDE, please refer to the document ‘FlamingICE_GettingStarted’, a copy of this can be obtained from the download’s tab.

 NOTE(2): To find out how to use the GLCD tool, please refer to the application note for the tool. This can be obtained from the download’s tab.

 

For this tutorial, I’m using the following image (100x100)px.

exampleImg.png

After loading the image up in the GLCD tool (FIDE > Tools > GLCD), save it as a text file so that the tool can automatically generate the code data required for writing to the external EEPROM later on.

Now that the preparations are done, we can move on to programming the FI40 Board to display the image from the EEPROM.

Launch FIDE and enter the COM Port assigned to your FI Comm.Key. (Refer to Note 1)

Set up a new project in FIDE and save it before doing anything else.

 

LOADING UP THE External EEPROM

Open up the text file you just saved and copy everything to the clipboard.

Under ExEEPROMData1 (select the file from the project tree view), declare a 2 dimensional Integer array with parameters (100, 50).

Project_TreeView.png

NOTE: The colours are saved in 16bit word data, which is 2 bytes, so a 100x100 pixel with 1byte worth of data per pixel would be saved with 100 rows of 50 columns of 16bit word data.

 

CODE:

'CODE:Data1

Public IMAGE100(100, 50) As Integer

‘<paste the data from the text file here>

 

 

Power up the FI40 Board.

Compile the Data and Write to the EEPROM by clicking on the 2 respective icons on the tool bar as shown below.

EEPROM_tool.png

The data is now in the FI EEPROM. Now we need to write some codes to retrieve the data for display on the GLCD.

 

PROGRAMMING THE FI40

Under Module1;

Declare these (BX, BY) as public variables.

 

CODE:

 

Dim BX, BY As Integer

Dim I as Integer

 


Under the Main() Subroutine, initialize the GLCD and fill the background with the colour white (value = 255) using the following commands.

 

CODE:

 

OS.GLCD.Init()

OS.GLCD.Fill(255)

 

‘Set the starting location of the image (0, 0)

BX = 0

BY = 0

 

‘set the region to fill the image;

‘where the starting point is (0,0) and the ending point is (99,99)

OS.GLCD.SetRegion(BX, BX + 99, BY, BY + 99)

 

‘Read the first column to the Buffer. Note that the buffer is limited to 128 bytes.

OS.ExEEProm.ReadToBuffer(0, 100)

‘Fill the first line of the GLCD region with data from the buffer.

OS.GLCD.FillRegion(0, 100)

‘Continue to do this for the rest of the 49 columns.

For i = 1 To 49

    OS.ExEEProm.ReadToBuffer(i * 100, 100)

    OS.GLCD.FillRegion_Cont(0, 100)

Next

 

 

COMPILE_DOWNLOAD.png

Compile the project to check for any syntax errors. If there are none, proceed to download the project into the FI40 Board.

Congrats! The image should now show up on your GLCD.

 


download_sourceCode.png