This section covers GLCD devices that use the ILI9340 graphics controller. The ILI9340 is a TFT LCD Single Chip Driver with 240RGBx320 Resolution and 262K colors.
GCBASIC supports 65K-color mode operations.
The GCBASIC constants shown below control the configuration of the ILI9340 controller. GCBASIC supports SPI hardware and software connectivity - this is shown in the tables below.
To use the ILI9340 driver simply include the following in your user code. This will initialise the driver.
#include <glcd.h> #DEFINE GLCD_TYPE GLCD_TYPE_ILI9340 'Pin mappings for ILI9340 - these MUST be specified #define GLCD_DC porta.0 'example port setting #define GLCD_CS porta.1 'example port setting #define GLCD_RESET porta.2 'example port setting #define GLCD_DI porta.3 'example port setting #define GLCD_DO porta.4 'example port setting
The GCBASIC constants for the interface to the controller are shown in the table below.
Constants | Controls | Options |
---|---|---|
|
|
|
|
Specifies the output pin that is connected to Data/Command IO pin on the GLCD. |
Required |
|
Specifies the output pin that is connected to Chip Select (CS) on the GLCD. |
Required |
|
Specifies the output pin that is connected to Reset pin on the GLCD. |
Required |
|
Specifies the output pin that is connected to Data In (GLCD out) pin on the GLCD. |
Required |
|
Specifies the output pin that is connected to Data Out (GLCD in) pin on the GLCD. |
Required |
|
Specifies the output pin that is connected to Clock (CLK) pin on the GLCD. #define GLCD_SCK porta.5 'example port setting |
Required |
|
User can specify the hardware SPI mode. Must be one of MasterSlow, Master, Masterfast |
Optional. Defaults to Masterfast when chipMhz is less than 64mhz |
The GCBASIC constants for control display characteristics are shown in the table below.
Constants | Controls | Default |
---|---|---|
|
The width parameter of the GLCD |
|
|
The height parameter of the GLCD |
|
|
Specifies the font width of the GCBASIC font set. |
|
The GCBASIC commands supported for this GLCD are shown in the table below. Always review the appropiate library for the latest full set of supported commands.
Command | Purpose | Example |
---|---|---|
|
Clear screen of GLCD |
|
|
Print string of characters on GLCD using GCB font set |
|
|
Print character on GLCD using GCB font set |
|
|
Print characters on GLCD using GCB font set |
|
|
Draw a box on the GLCD to a specific size |
|
|
Draw a box on the GLCD to a specific size that is filled with the foreground colour. |
|
|
Draw a line on the GLCD to a specific length that is filled with the specific attribute. |
|
|
Set a pixel on the GLCD at a specific position that is set with the specific attribute. |
|
|
Set a byte value to the controller, see the datasheet for usage. |
|
|
Read a byte value from the controller, see the datasheet for usage. |
|
|
Rotate the display |
|
|
Specify color as a parameter for many GLCD commands |
Color constants for this device are shown in the list below. Any color can be defined using a valid hexidecimal word value between 0x0000 to 0xFFFF. |
ILI9340_BLACK 'hexidecimal value 0x0000 ILI9340_RED 'hexidecimal value 0xF800 ILI9340_GREEN 'hexidecimal value 0x07E0 ILI9340_BLUE 'hexidecimal value 0x001F ILI9340_WHITE 'hexidecimal value 0xFFFF ILI9340_PURPLE 'hexidecimal value 0xF11F ILI9340_YELLOW 'hexidecimal value 0xFFE0 ILI9340_CYAN 'hexidecimal value 0x07FF ILI9340_D_GRAY 'hexidecimal value 0x528A ILI9340_L_GRAY 'hexidecimal value 0x7997 ILI9340_SILVER 'hexidecimal value 0xC618 ILI9340_MAROON 'hexidecimal value 0x8000 ILI9340_OLIVE 'hexidecimal value 0x8400 ILI9340_LIME 'hexidecimal value 0x07E0 ILI9340_AQUA 'hexidecimal value 0x07FF ILI9340_TEAL 'hexidecimal value 0x0410 ILI9340_NAVY 'hexidecimal value 0x0010 ILI9340_FUCHSIA 'hexidecimal value 0xF81F
For a ILI9340 datasheet, please refer here.
This example shows how to drive a ILI9340 based Graphic LCD module with the built in commands of GCBASIC.
Example:
;Chip Settings #chip 16F1937,32 #config MCLRE_ON 'microcontroller specific configuration #include <glcd.h> 'Defines for ILI9340 #define GLCD_TYPE GLCD_TYPE_ILI9340 'Pin mappings for ILI9340 #define GLCD_DC porta.0 #define GLCD_CS porta.1 #define GLCD_RESET porta.2 #define GLCD_DI porta.3 #define GLCD_DO porta.4 #define GLCD_SCK porta.5 GLCDPrint(0, 0, "Test of the ILI9340 Device") end
For more help, see GLCDCLS, GLCDDrawChar, GLCDPrint, GLCDReadByte, GLCDWriteByte or Pset
Supported in <GLCD.H>