NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
AM18XX SitaraWare Graphics
The software found on this site is available for download, but is no longer being actively developed and maintained. This wiki is in maintenance mode and the software is supported on Sitara E2E forum
|IMPORTANT - The content of this page is due to change quite frequently and thus the quality and accuracy are not guaranteed until this message has been removed. For suggestion/recommendation, please send mail to your local FAE.|
- 1 AM18XX SitaraWare Graphics
- 1.1 SitaraWare Graphics Library
- 1.2 Raster DAL based raw example
- 1.3 Graphics Library based Example Applications
- 1.4 Porting StellarisWare graphics application to SitaraWare
- 1.5 pnmtoc Tool
AM18XX SitaraWare Graphics
AM18XX is integrated with a LCD controller which can be configured in TFT mode to interface with TFT/Raster graphics panels. The LCD controller provides various options like different bits-per-pixel (BPP), configuration for different display horizontal (pixel-per-line) and vertical (lines-per-panel) dimensions, internal and dedicated DMA for increased throughput/FPS, configurable pixel clock etc. For more details on AM18XX LCD controller please refer to the LCD Controller user's guide. SitaraWare delivers graphics examples based on raster device abstraction layer (DAL) APIs which can be used as reference and/or adapted for user's requirements. There are two types of examples presented:
- Raster DAL API based, raw example which just uses static/predefined images for display on the panel
- Graphics Library based, advanced examples which uses graphic library calls for dynamic modification of images for display on the panel
SitaraWare Graphics Library
The graphics library from StellatisWare is integrated with Sitaraware. The off-screen LCD support is added for 16 bpp LCD. The graphics lib supports drawing various shapes like vertical, horizontal & slanting lines, filled and empty circle and rectangle, push button, check box, radio button, list box, slider, drawing image and it also supports drawing strings in various fonts. Currently it supports 153 different fonts.
It also supports widget tree data structure, where all the widgets like push button, radio button, check box, list box, slider can be added. If touch screen is integrated, the coordinates can be sent as a message to the tree. Based on the coordinates the message will be sent to the corresponding button. The button can be configured to call the user specific handler function when the button is touched. For the graphics library API reference, refer Stellaris Graphics Library User's Guide from here. While referring the document, the following points are to be noted from SitaraWare context,
- The discussion on tool chain support has to be ignored at this point in time.
- In addition to the Off-screen buffer display drivers provided in 1 bit-per-pixel (BPP) format, 4 BPP format and 8 BPP format, SitaraWare supports 16BPP format also.
Raster DAL based raw example
Raster DAL based raw example, configures the LCD in raster mode, with DMA configured to work in double frame buffer mode. The example displays a static banner image on the panel.
To configure the Raster LCD controller, the following sequence can be used.
- Raster needs to be first brought out of local reset by enabling the module inthe Power Sleep Controller by using PSCModuleControl().
- Pin multiplexing registers to enable LCD raster pin and a standard configuration is provided as part of the function LCDPinMuxSetup() in platform directory.
- Configure the rate at which pixel data should be out put by configuring pixel clock frequency done by invoking RasterClkConfig() API.
- Configuring the DMA for single or double frame buffer ,busrst size for DMA data transfer etc is done by invoking RasterDMAConfig() API.
- Configuring Panel type(TFT or STN) ,color display or monochrome etc is done invoking RasterModeConfig()API.
- Configure the frame buffer data order from least to most significant byte RasterLSBDataOrderSelect();
- Disable Nibble mode if 16 or 12 bits per pixel are used by invoking RasterNibbleModeDisable()
- Configure the polarity of various timing parameters (for example frame clock , pixel clock, line clock etc.) used by raster by invoking RasterTiming2Configure()
- Configure the Horizontal timing parameters of the raster by invoking RasterHparamConfig() API.
- Configure the vertical timing parameters of the raster invoking RasterVparamConfigure()API.
- Configure the required amount of FIFO delay by invoking RasterFIOFDMADelayConfig()
- Configure the base address register with base address of the array which contain pixels of the image to be displayed and ceiling address register with end address of the same array using API RasterDMAFBConfig()
- Enable the Raster by inovking RasterEnable().
Execucting The Example Application
Before executing the raster lcd program make sure that raster LCD is hooked on to the board. When program runs the image will be displayed on lcd hooked on to board . Pixels of the image to be displayed is taken in an array.
- Modules used in this example
The example application works in double frame buffer mode. The ISR handles only End-Of-frame interrupt. The frame buffer registers are updated in each End-of-frame interrupt.
Graphics Library based Example Applications
The graphics library example application, demonstrate how graphics library APIs can be used to easily draw/paint/write on the off screen LCD panel. It provides examples which show the ease of use in displaying dynamic content on the LCD panel.
- The modules used in the example applications are
- Graphics Library - for dynamic content/image modifications
- Raster DAL - for LCD display
- I2C - for touch detection
- Since the examples use the raster DAL for display on the panel, the programming, in addition to LCD initialization, consists of
- Initializing a 16 BPP off-screen image buffer by calling the API GrOffScreen16BPPInit()
- Initializing the drawing context by calling the API GrContextInit()
This application provides a demonstration of the capabilities of the Graphics Library. A series of panels show different features of the library. For each panel, the bottom provides a forward and back button (when appropriate), along with a brief description of the contents of the panel.
- The first panel provides some introductory text and basic instructions for operation of the application.
- The second panel shows the available drawing primitives: lines, circles, rectangles, strings, and images.
- The third panel shows the canvas widget, which provides a general drawing surface within the widget hierarchy. A text, image, and application-drawn canvas are displayed.
- The fourth panel shows the check box widget, which provides a means of toggling the state of an item. Four check boxes are provided, with each having a red LED to the right. The state of the LED tracks the state of the check box via an application callback.
- The fifth panel shows the container widget, which provides a grouping construct typically used for radio buttons. Containers with a title, a centered title, and no title are displayed.
- The sixth panel shows the push button widget. Two columns of push buttons are provided. Each push button has a red LED to its left, which is toggled via an application callback each time the push button is pressed.
- The seventh panel shows the radio button widget. Two groups of radio buttons are displayed, the first using text and the second using images for the selection value. Each radio button has a red LED to its right, which tracks the selection state of the radio buttons via an application callback. Only one radio button from each group can be selected at a time, though the radio buttons in each group operate independently.
- The eighth and final panel shows the slider widget. Six sliders constructed using the various supported style options are shown. The slider value callback is used to update two widgets to reflect the values reported by sliders. A canvas widget near the top right of the display tracks the value of the red and green image-based slider to its left and the text of the grey slider on the left side of the panel is update to show its own value. The slider on the right is configured as an indicator which tracks the state of the upper slider and ignores user input
On loading the graphics example binary on to the target, the banner page is displayed and on touching anywhere on the LCD the first slide is shown. other slides can be navigated with the previous and next button at the bottom of the LCD
Maze Game Application
The Maze game is ported from StellarisWare(Quickstart Application of EK-LM3S2965). A game in which a blob-like character tries to find its way out of a maze. The character starts in the middle of the maze and must find the exit, which will always be located at one of the four corners of the maze. Once the exit to the maze is located, the character is placed into the middle of a new maze and must find the exit to that maze; this repeats endlessly. The Graphics library is used to display the all the elements(maze, player, stars, score) in the game.
- Executing The Example Application
The game is started by pressing the select button on the right side of the LCD. During game play, the select button will fire a bullet in the direction the character is currently facing, and the navigation push buttons on the left side of the LCD will cause the character to walk in the corresponding direction.
Populating the maze are a hundred spinning stars that mindlessly attack the character. Contact with one of these stars results in the game ending, but the stars go away when shot.
Score is accumulated for shooting the stars and for finding the exit to the maze. The game lasts for only one character, and the score is displayed on the virtual UART at 115,200, 8-N-1 during game play and will be displayed on the screen at the end of the game.
The application also contains a screen saver. The screen saver will only become active if two minutes have passed without the user action while waiting to start the game (that is, it will never come on during game play). Qix-style bouncing lines are drawn on the display by the screen saver.
After two minutes of running the screen saver, the display will be turned off and the user LED will blink. Either mode of screen saver (bouncing lines or blank display) will be exited by touching the touch screen on LCD. The select button will then need to be pressed again to start the game.
Porting StellarisWare graphics application to SitaraWare
Please refer here to know more on the various aspects to be considered while porting StellarisWare graphics application to SitaraWare.
This section explains how to convert an image to C structure definition that can be passed to the GrImageDraw() function. This involves two steps,
- Convert image (jpg, bmp, jpeg etc...) to .pnm format using Imagemagick tool, which can be downloaded from here
convert.exe file.bmp -colors 65536 file.pnm
This command converts a bmp image to pnm file with maximum of 65536 colors.
- pnmtoc (convert pnm file to C array). The tool is run from the command line, and its usage is as follows:
pnmtoc [-c] file.pnm > file.c
Where the arguments mean:
-c Specifies that the image should be compressed. Compression is bypassed if it would result in a larger C array.
file.ppm Specifies the input image file.
This pnmtoc tool is located in /tools/pnmtoc/ (pnmtoc.exe - to be used in windows command prompt, pnmtoc - to be used in linux)
The resulting C image array definition is written to standard output. The output should be redirected into a file so that it can then be used by the application.This will result in an array called g_pucImage that contains the image data from file.ppm. If file.ppm contains only two colors, the 1 BPP image format is used; if it contains 16 or less colors, the 4 BPP image format is used; if it contains 256 or less colors, the 8 BPP image format used; if it contains more than 256 colors the 16 BPP image format used; and if it contains more than 65536 colors an error is generated.