Graphic Lcd Library
The mikroC PRO for ARM provides a library for operating Graphic Lcd 128x64 (with commonly used Samsung KS108/KS107 controller).
For creating a custom set of Glcd images use Glcd Bitmap Editor Tool.
Library Dependency Tree
External dependencies of Graphic Lcd Library
Stellaris
| The following variables must be defined in all projects using Graphic Lcd Library: | Description : | Example : |
|---|---|---|
extern sfr sbit GLCD_D0; |
Data 0 line. | sbit GLCD_D0 at GPIO_PORTA_DATA.B0; |
extern sfr sbit GLCD_D1; |
Data 1 line. | sbit GLCD_D1 at GPIO_PORTA_DATA.B1; |
extern sfr sbit GLCD_D2; |
Data 2 line. | sbit GLCD_D2 at GPIO_PORTA_DATA.B2; |
extern sfr sbit GLCD_D3; |
Data 3 line. | sbit GLCD_D3 at GPIO_PORTA_DATA.B3; |
extern sfr sbit GLCD_D4; |
Data 4 line. | sbit GLCD_D4 at GPIO_PORTA_DATA.B4; |
extern sfr sbit GLCD_D5; |
Data 5 line. | sbit GLCD_D5 at GPIO_PORTA_DATA.B5; |
extern sfr sbit GLCD_D6; |
Data 6 line. | sbit GLCD_D6 at GPIO_PORTA_DATA.B6; |
extern sfr sbit GLCD_D7; |
Data 7 line. | sbit GLCD_D7 at GPIO_PORTA_DATA.B7; |
extern sfr sbit GLCD_CS1; |
Chip Select 1 line. | sbit GLCD_CS1 at GPIO_PORTD_DATA.B0; |
extern sfr sbit GLCD_CS2; |
Chip Select 2 line. | sbit GLCD_CS2 at GPIO_PORTD_DATA.B1; |
extern sfr sbit GLCD_RS; |
Register select line. | sbit GLCD_RS at GPIO_PORTD_DATA.B2; |
extern sfr sbit GLCD_RW; |
Read/Write line. | sbit GLCD_RW at GPIO_PORTD_DATA.B3; |
extern sfr sbit GLCD_EN; |
Enable line. | sbit GLCD_EN at GPIO_PORTD_DATA.B4; |
extern sfr sbit GLCD_RST; |
Reset line. | sbit GLCD_RST at GPIO_PORTD_DATA.B5; |
extern sfr sbit GLCD_D0_Direction; |
Direction of the Data 0 pin. | sbit GLCD_D0_Direction at GPIO_PORTA_DIR.B0; |
extern sfr sbit GLCD_D1_Direction; |
Direction of the Data 1 pin. | sbit GLCD_D1_Direction at GPIO_PORTA_DIR.B1; |
extern sfr sbit GLCD_D2_Direction; |
Direction of the Data 2 pin. | sbit GLCD_D2_Direction at GPIO_PORTA_DIR.B2; |
extern sfr sbit GLCD_D3_Direction; |
Direction of the Data 3 pin. | sbit GLCD_D3_Direction at GPIO_PORTA_DIR.B3; |
extern sfr sbit GLCD_D4_Direction; |
Direction of the Data 4 pin. | sbit GLCD_D4_Direction at GPIO_PORTA_DIR.B4; |
extern sfr sbit GLCD_D5_Direction; |
Direction of the Data 5 pin. | sbit GLCD_D5_Direction at GPIO_PORTA_DIR.B5; |
extern sfr sbit GLCD_D6_Direction; |
Direction of the Data 6 pin. | sbit GLCD_D6_Direction at GPIO_PORTA_DIR.B6; |
extern sfr sbit GLCD_D7_Direction; |
Direction of the Data 7 pin. | sbit GLCD_D7_Direction at GPIO_PORTA_DIR.B6; |
extern sfr sbit GLCD_CS1_Direction; |
Direction of the Chip Select 1 pin. | sbit GLCD_CS1_Direction at GPIO_PORTD_DIR.B0; |
extern sfr sbit GLCD_CS2_Direction; |
Direction of the Chip Select 2 pin. | sbit GLCD_CS2_Direction at GPIO_PORTD_DIR.B1; |
extern sfr sbit GLCD_RS_Direction; |
Direction of the Register select pin. | sbit GLCD_RS_Direction at GPIO_PORTD_DIR.B2; |
extern sfr sbit GLCD_RW_Direction; |
Direction of the Read/Write pin. | sbit GLCD_RW_Direction at GPIO_PORTD_DIR.B3; |
extern sfr sbit GLCD_EN_Direction; |
Direction of the Enable pin. | sbit GLCD_EN_Direction at GPIO_PORTD_DIR.B4; |
extern sfr sbit GLCD_RST_Direction; |
Direction of the Reset pin. | sbit GLCD_RST_Direction at GPIO_PORTD_DIR.B5; |
STM32
| The following variables must be defined in all projects using Graphic Lcd Library: | Description : | Example : |
|---|---|---|
extern sfr unsigned long GLCD_DataPort_Input; |
Data input port. | unsigned long GLCD_DataPort_Input at GPIOE_IDR; |
extern sfr unsigned long GLCD_DataPort_Output; |
Data output port. | unsigned long GLCD_DataPort_Output at GPIOE_ODR; |
extern sfr sbit GLCD_CS1; |
Chip Select 1 line. | sbit GLCD_CS1 at GPIOE_ODR.B8; |
extern sfr sbit GLCD_CS2; |
Chip Select 2 line. | sbit GLCD_CS2 at GPIOE_ODR.B9; |
extern sfr sbit GLCD_RS; |
Register select line. | sbit GLCD_RS at GPIOE_ODR.B10; |
extern sfr sbit GLCD_RW; |
Read/Write line. | sbit GLCD_RW at GPIOE_ODR.B11; |
extern sfr sbit GLCD_EN; |
Enable line. | sbit GLCD_EN at GPIOE_ODR.B12; |
extern sfr sbit GLCD_RST; |
Reset line. | sbit GLCD_RST at GPIOE_ODR.B13; |
Library Routines
Basic routines:
Advanced routines:
- Glcd_Fill
- Glcd_Dot
- Glcd_Line
- Glcd_V_Line
- Glcd_H_Line
- Glcd_Rectangle
- Glcd_Rectangle_Round_Edges
- Glcd_Rectangle_Round_Edges_Fill
- Glcd_Box
- Glcd_Circle
- Glcd_Circle_Fill
- Glcd_Set_Font
- Glcd_Set_Font_Adv
- Glcd_Set_Ext_Font_Adv
- Glcd_Write_Char
- Glcd_Write_Char_Adv
- Glcd_Write_Text
- Glcd_Write_Text_Adv
- Glcd_Image
- Glcd_Ext_Image
- Glcd_PartialImage
- Glcd_Ext_PartialImage
Glcd_Init
| Prototype |
void Glcd_Init(); |
|---|---|
| Description |
Initializes the Glcd module. Each of the control lines are both port and pin configurable, while data lines must be on a single port (pins <0:7>). |
| Parameters |
None. |
| Returns |
Nothing. |
| Requires |
External dependencies of the library from the top of the page must be defined before using this function. |
| Example |
Stellaris// Glcd pinout settings sbit GLCD_D7 at GPIO_PORTA_DATA.B7; sbit GLCD_D6 at GPIO_PORTA_DATA.B6; sbit GLCD_D5 at GPIO_PORTA_DATA.B5; sbit GLCD_D4 at GPIO_PORTA_DATA.B4; sbit GLCD_D3 at GPIO_PORTA_DATA.B3; sbit GLCD_D2 at GPIO_PORTA_DATA.B2; sbit GLCD_D1 at GPIO_PORTA_DATA.B1; sbit GLCD_D0 at GPIO_PORTA_DATA.B0; sbit GLCD_D7_Direction at GPIO_PORTA_DIR.B7; sbit GLCD_D6_Direction at GPIO_PORTA_DIR.B6; sbit GLCD_D5_Direction at GPIO_PORTA_DIR.B5; sbit GLCD_D4_Direction at GPIO_PORTA_DIR.B4; sbit GLCD_D3_Direction at GPIO_PORTA_DIR.B3; sbit GLCD_D2_Direction at GPIO_PORTA_DIR.B2; sbit GLCD_D1_Direction at GPIO_PORTA_DIR.B1; sbit GLCD_D0_Direction at GPIO_PORTA_DIR.B0; sbit GLCD_CS1 at GPIO_PORTD_DATA.B0; sbit GLCD_CS2 at GPIO_PORTD_DATA.B1; sbit GLCD_RS at GPIO_PORTD_DATA.B2; sbit GLCD_RW at GPIO_PORTD_DATA.B3; sbit GLCD_EN at GPIO_PORTD_DATA.B4; sbit GLCD_RST at GPIO_PORTD_DATA.B5; sbit GLCD_CS1_Direction at GPIO_PORTD_DIR.B0; sbit GLCD_CS2_Direction at GPIO_PORTD_DIR.B1; sbit GLCD_RS_Direction at GPIO_PORTD_DIR.B2; sbit GLCD_RW_Direction at GPIO_PORTD_DIR.B3; sbit GLCD_EN_Direction at GPIO_PORTD_DIR.B4; sbit GLCD_RST_Direction at GPIO_PORTD_DIR.B5; ... Glcd_Init(); STM32// Glcd pinout settings unsigned long GLCD_DataPort_Input at GPIOE_IDR; unsigned long GLCD_DataPort_Output at GPIOE_ODR; sbit GLCD_CS1 at GPIOE_ODR.B8; sbit GLCD_CS2 at GPIOE_ODR.B9; sbit GLCD_RS at GPIOE_ODR.B10; sbit GLCD_RW at GPIOE_ODR.B11; sbit GLCD_EN at GPIOE_ODR.B12; sbit GLCD_RST at GPIOE_ODR.B13; ... Glcd_Init(); |
| Notes |
None. |
Glcd_Set_Side
| Prototype |
void Glcd_Set_Side(unsigned short x_pos); |
|---|---|
| Description |
Selects Glcd side. Refer to the Glcd datasheet for detailed explanation. |
| Parameters |
|
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
The following two lines are equivalent, and both of them select the left side of Glcd: Glcd_Select_Side(0); Glcd_Select_Side(10); |
| Notes |
For side, x axis and page layout explanation see schematic at the bottom of this page. |
Glcd_Set_X
| Prototype |
void Glcd_Set_X(unsigned short x_pos); |
|---|---|
| Description |
Sets x-axis position to |
| Parameters |
|
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
Glcd_Set_X(25); |
| Notes |
For side, x axis and page layout explanation see schematic at the bottom of this page. |
Glcd_Set_Page
| Prototype |
void Glcd_Set_Page(unsigned short page); |
|---|---|
| Description |
Selects page of the Glcd. |
| Parameters |
|
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
Glcd_Set_Page(5); |
| Notes |
For side, x axis and page layout explanation see schematic at the bottom of this page. |
Glcd_Read_Data
| Prototype |
unsigned short Glcd_Read_Data(); |
|---|---|
| Description |
Reads data from from the current location of Glcd memory and moves to the next location. |
| Parameters |
None. |
| Returns |
One byte from Glcd memory, formatted as a word (16-bit). |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. Glcd side, x-axis position and page should be set first. See functions Glcd_Set_Side, Glcd_Set_X, and Glcd_Set_Page. |
| Example |
unsigned int data_; ... Glcd_Read_Data(); data_ = Glcd_Read_Data(); |
| Notes |
This routine needs to be called twice; After the first call, data is placed in the buffer register. After the second call, data is passed from the buffer register to data lines. |
Glcd_Write_Data
| Prototype |
void Glcd_Write_Data(unsigned short data_); |
|---|---|
| Returns |
Nothing. |
| Description |
Writes one byte to the current location in Glcd memory and moves to the next location. Parameters :
|
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. Glcd side, x-axis position and page should be set first. See functions Glcd_Set_Side, Glcd_Set_X, and Glcd_Set_Page. |
| Example |
unsigned short data_; ... Glcd_Write_Data(data_); |
Glcd_Set_Ext_Buffer
| Prototype |
void Glcd_Set_Ext_Buffer(char* (*getExtDataPtr)(unsigned long offset, unsigned long count, unsigned long* num)); |
|---|---|
| Returns |
Nothing. |
| Description |
Function sets pointer to the user function which manipulates the external resource. Parameters :
|
| Requires |
Glcd module needs to be initialized. See the Glcd_Init routine. |
| Example |
char* ReadExternalBuffer(unsigned long offset, unsigned int count, unsigned int *num){
unsigned long start_sector;
unsigned int pos;
start_sector = Mmc_Get_File_Write_Sector() + offset/512;
pos = (unsigned long)offset%512;
if(start_sector == currentSector+1){
Mmc_Multi_Read_Buffer(EXT_BUFFER);
currentSector = start_sector;
}else
if(start_sector != currentSector){
Mmc_Multi_Read_Stop();
Mmc_Multi_Read_Start(start_sector);
Mmc_Multi_Read_Buffer(EXT_BUFFER);
currentSector = start_sector;
}
if(count>512-pos){
*num = 512-pos;
}
else
*num = count;
return EXT_BUFFER+pos;
}
Glcd_Set_Ext_Buffer(ReadExternalBuffer);
|
Glcd_Fill
| Prototype |
void Glcd_Fill(unsigned short pattern); |
|---|---|
| Description |
Fills Glcd memory with the byte To clear the Glcd screen, use To fill the screen completely, use |
| Parameters |
|
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
// Clear screen Glcd_Fill(0); |
| Notes |
None. |
Glcd_Dot
| Prototype |
void Glcd_Dot(unsigned short x_pos, unsigned short y_pos, unsigned short color); |
|---|---|
| Description |
Draws a dot on Glcd at coordinates ( |
| Parameters |
The parameter |
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
// Invert the dot in the upper left corner Glcd_Dot(0, 0, 2); |
| Notes |
For x and y axis layout explanation see schematic at the bottom of this page. |
Glcd_Line
| Prototype |
void Glcd_Line(int x_start, int y_start, int x_end, int y_end, unsigned short color); |
|---|---|
| Description |
Draws a line on Glcd. |
| Parameters |
The parameter |
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
// Draw a line between dots (0,0) and (20,30) Glcd_Line(0, 0, 20, 30, 1); |
| Notes |
None. |
Glcd_V_Line
| Prototype |
void Glcd_V_Line(unsigned short y_start, unsigned short y_end, unsigned short x_pos, unsigned short color); |
|---|---|
| Description |
Draws a vertical line on Glcd. |
| Parameters |
The parameter |
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
// Draw a vertical line between dots (10,5) and (10,25) Glcd_V_Line(5, 25, 10, 1); |
| Notes |
None. |
Glcd_H_Line
| Prototype |
void Glcd_H_Line(unsigned short x_start, unsigned short x_end, unsigned short y_pos, unsigned short color); |
|---|---|
| Description |
Draws a horizontal line on Glcd. |
| Parameters |
The parameter |
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
// Draw a horizontal line between dots (10,20) and (50,20) Glcd_H_Line(10, 50, 20, 1); |
| Notes |
None. |
Glcd_Rectangle
| Prototype |
void Glcd_Rectangle(unsigned short x_upper_left, unsigned short y_upper_left, unsigned short x_bottom_right, unsigned short y_bottom_right, unsigned short color); |
|---|---|
| Description |
Draws a rectangle on Glcd. |
| Parameters |
The parameter |
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
// Draw a rectangle between dots (5,5) and (40,40) Glcd_Rectangle(5, 5, 40, 40, 1); |
| Notes |
None. |
Glcd_Rectangle_Round_Edges
| Prototype |
void Glcd_Rectangle_Round_Edges(unsigned short x_upper_left, unsigned short y_upper_left, unsigned short x_bottom_right, unsigned short y_bottom_right, unsigned short round_radius, unsigned short color); |
|---|---|
| Description |
Draws a rounded edge rectangle on Glcd. |
| Parameters |
The parameter |
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
// Draw a rounded edge rectangle between dots (5,5) and (40,40) with the radius of 12 Glcd_Rectangle_Round_Edges(5, 5, 40, 40, 12, 1); |
| Notes |
None. |
Glcd_Rectangle_Round_Edges_Fill
| Prototype |
void Glcd_Rectangle_Round_Edges_Fill(unsigned short x_upper_left, unsigned short y_upper_left, unsigned short x_bottom_right, unsigned short y_bottom_right, unsigned short round_radius, unsigned short color); |
|---|---|
| Description |
Draws a filled rounded edge rectangle on Glcd. |
| Parameters |
The parameter |
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
// Draws a filled rounded edge rectangle between dots (5,5) and (40,40) with the radius of 12 Glcd_Rectangle_Round_Edges_Fill(5, 5, 40, 40, 12, 1); |
| Notes |
None. |
Glcd_Box
| Prototype |
void Glcd_Box(unsigned short x_upper_left, unsigned short y_upper_left, unsigned short x_bottom_right, unsigned short y_bottom_right, unsigned short color); |
|---|---|
| Description |
Draws a box on Glcd. Parameters : |
| Parameters |
The parameter |
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
// Draw a box between dots (5,15) and (20,40) Glcd_Box(5, 15, 20, 40, 1); |
| Notes |
None. |
Glcd_Circle
| Prototype |
void Glcd_Circle(int x_center, int y_center, int radius, unsigned short color); |
|---|---|
| Description |
Draws a circle on Glcd. |
| Parameters |
The parameter |
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
// Draw a circle with center in (50,50) and radius=10 Glcd_Circle(50, 50, 10, 1); |
| Notes |
None. |
Glcd_Circle_Fill
| Prototype |
void Glcd_Circle_Fill(int x_center, int y_center, int radius, unsigned short color); |
|---|---|
| Description |
Draws a filled circle on Glcd. |
| Parameters |
The parameter |
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
// Draws a filled circle with center in (50,50) and radius=10 Glcd_Circle_Fill(50, 50, 10, 1); |
| Notes |
None. |
Glcd_Set_Font
| Prototype |
void Glcd_Set_Font(const char *activeFont, unsigned short aFontWidth, unsigned short aFontHeight, unsigned int aFontOffs); |
|---|---|
| Description |
Sets font that will be used with Glcd_Write_Char and Glcd_Write_Text routines. |
| Parameters |
The user can use fonts given in the file “__Lib_GLCDFonts” file located in the Uses folder or create his own fonts. List of supported fonts:
For the sake of the backward compatibility, these fonts are supported also:
|
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
// Use the custom 5x7 font "myfont" which starts with space (32): Glcd_Set_Font(&myfont, 5, 7, 32); |
| Notes |
None. |
Glcd_Set_Font_Adv
| Prototype |
void Glcd_Set_Font_Adv(const char *activeFont, unsigned char font_color, char font_orientation); |
|---|---|
| Description |
Sets font that will be used with Glcd_Write_Char_Adv and Glcd_Write_Text_Adv routines. |
| Parameters |
|
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
Glcd_Set_Font_Adv(&myfont, 0, 0); |
| Notes |
None. |
Glcd_Set_Ext_Font_Adv
| Prototype |
void Glcd_Set_Ext_Font_Adv(unsigned long activeFont, unsigned int font_color, char font_orientation); |
|---|---|
| Description |
Sets font that will be used with Glcd_Write_Char_Adv and Glcd_Write_Text_Adv routines. Font is located in an external resource. |
| Parameters |
|
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
Glcd_Set_Ext_Font_Adv(173296, 5, 7, 32); |
| Notes |
None. |
Glcd_Write_Char
| Prototype |
void Glcd_Write_Char(unsigned short character, unsigned short x_pos, unsigned short page_num, unsigned short color); |
|---|---|
| Description |
Prints character on the Glcd. |
| Parameters |
The parameter |
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. Use Glcd_Set_Font to specify the font for display; if no font is specified, then default |
| Example |
// Write character 'C' on the position 10 inside the page 2:
Glcd_Write_Char('C', 10, 2, 1);
|
| Notes |
For x axis and page layout explanation see schematic at the bottom of this page. |
Glcd_Write_Char_Adv
| Prototype |
void Glcd_Write_Char_Adv(unsigned int c, unsigned int x, unsigned int y); |
|---|---|
| Returns |
Nothing. |
| Description |
Writes a char on the glcd at coordinates (x, y).
|
| Requires |
glcd module needs to be initialized. See the Glcd_Init routine. |
| Example |
Glcd_Write_Char_Adv('A',22,23);
|
Glcd_Write_Text
| Prototype |
void Glcd_Write_Text(char *text, unsigned short x_pos, unsigned short page_num, unsigned short color); |
|---|---|
| Description |
Prints text on Glcd. |
| Parameters |
The parameter |
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. Use Glcd_Set_Font to specify the font for display; if no font is specified, then default |
| Example |
// Write text "Hello world!" on the position 10 inside the page 2:
Glcd_Write_Text("Hello world!", 10, 2, 1);
|
| Notes |
For x axis and page layout explanation see schematic at the bottom of this page. |
Glcd_Write_Text_Adv
| Prototype |
void Glcd_Write_Text_Adv(unsigned char *text, unsigned int x, unsigned int y); |
|---|---|
| Returns |
Nothing. |
| Description |
Writes text on the glcd at coordinates (x, y). Parameters :
|
| Requires |
Glcd module needs to be initialized. See the Glcd_Init routine. |
| Example |
Glcd_Write_Text_Adv("GLCD LIBRARY DEMO, WELCOME !", 0, 0);
|
Glcd_Image
| Prototype |
void Glcd_Image(code const unsigned short *image); |
|---|---|
| Description |
Displays bitmap on Glcd. |
| Parameters |
|
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
// Draw image my_image on Glcd Glcd_Image(my_image); |
| Notes |
Use the mikroC PRO for ARM integrated Glcd Bitmap Editor, Tools > Glcd Bitmap Editor, to convert image to a constant array suitable for displaying on Glcd. |
Glcd_Ext_Image
| Prototype |
void Glcd_Ext_Image(unsigned long image); |
|---|---|
| Description |
Displays a bitmap from an external resource. |
| Parameters |
|
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
Glcd_Ext_Image(153608); |
| Notes |
Use the mikroC PRO for ARM integrated Glcd Bitmap Editor, Tools > Glcd Bitmap Editor, to convert image to a constant array suitable for displaying on Glcd. |
Glcd_PartialImage
| Prototype |
void Glcd_PartialImage(unsigned int x_left, unsigned int y_top, unsigned int width, unsigned int height, unsigned int picture_width, unsigned int picture_height, code const unsigned short * image); |
|---|---|
| Description |
Displays a partial area of the image on a desired location. |
| Parameters |
|
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
// Draws a 10x15 part of the image starting from the upper left corner on the coordinate (10,12). Original image size is 16x32. Glcd_PartialImage(10, 12, 10, 15, 16, 32, image); |
| Notes |
Use the mikroC PRO for ARM integrated Glcd Bitmap Editor, Tools > Glcd Bitmap Editor, to convert image to a constant array suitable for displaying on Glcd. |
Glcd_Ext_PartialImage
| Prototype |
void Glcd_Ext_PartialImage(unsigned int x_left, unsigned int y_top, unsigned int width, unsigned int height, unsigned int picture_width, unsigned int picture_height, unsigned long image); |
|---|---|
| Description |
Displays a partial area of the image, located on an external resource, on a desired location of the screen. |
| Parameters |
|
| Returns |
Nothing. |
| Requires |
Glcd needs to be initialized, see Glcd_Init routine. |
| Example |
Glcd_Ext_PartialImage(10, 12, 10, 15, 16, 32, 0); |
| Notes |
Use the mikroC PRO for ARM integrated Glcd Bitmap Editor, Tools > Glcd Bitmap Editor, to convert image to a constant array suitable for displaying on Glcd. |
Library Example
Stellaris
//Declarations------------------------------------------------------------------
const code char truck_bmp[1024];
//--------------------------------------------------------------end-declarations
// Glcd module connections
sbit GLCD_D7 at GPIO_PORTA_DATA.B7;
sbit GLCD_D6 at GPIO_PORTA_DATA.B6;
sbit GLCD_D5 at GPIO_PORTA_DATA.B5;
sbit GLCD_D4 at GPIO_PORTA_DATA.B4;
sbit GLCD_D3 at GPIO_PORTA_DATA.B3;
sbit GLCD_D2 at GPIO_PORTA_DATA.B2;
sbit GLCD_D1 at GPIO_PORTA_DATA.B1;
sbit GLCD_D0 at GPIO_PORTA_DATA.B0;
sbit GLCD_D7_Direction at GPIO_PORTA_DIR.B7;
sbit GLCD_D6_Direction at GPIO_PORTA_DIR.B6;
sbit GLCD_D5_Direction at GPIO_PORTA_DIR.B5;
sbit GLCD_D4_Direction at GPIO_PORTA_DIR.B4;
sbit GLCD_D3_Direction at GPIO_PORTA_DIR.B3;
sbit GLCD_D2_Direction at GPIO_PORTA_DIR.B2;
sbit GLCD_D1_Direction at GPIO_PORTA_DIR.B1;
sbit GLCD_D0_Direction at GPIO_PORTA_DIR.B0;
sbit GLCD_CS1 at GPIO_PORTD_DATA.B0;
sbit GLCD_CS2 at GPIO_PORTD_DATA.B1;
sbit GLCD_RS at GPIO_PORTD_DATA.B2;
sbit GLCD_RW at GPIO_PORTD_DATA.B3;
sbit GLCD_EN at GPIO_PORTD_DATA.B4;
sbit GLCD_RST at GPIO_PORTD_DATA.B5;
sbit GLCD_CS1_Direction at GPIO_PORTD_DIR.B0;
sbit GLCD_CS2_Direction at GPIO_PORTD_DIR.B1;
sbit GLCD_RS_Direction at GPIO_PORTD_DIR.B2;
sbit GLCD_RW_Direction at GPIO_PORTD_DIR.B3;
sbit GLCD_EN_Direction at GPIO_PORTD_DIR.B4;
sbit GLCD_RST_Direction at GPIO_PORTD_DIR.B5;
// End Glcd module connections
void delay2S(){ // 2 seconds delay function
Delay_ms(2000);
}
void main() {
char counter;
char *someText;
Glcd_Init(); // Initialize GLCD
Glcd_Fill(0x00); // Clear GLCD
while(1) {
Glcd_Image(truck_bmp); // Draw image
Delay2s(); Delay2s();
Glcd_fill(0x00); // Clear GLCD
Glcd_PartialImage(0,0,68,30,128,64,truck_bmp); // Partial image
Delay_ms(500);
Glcd_PartialImage(24,16,68,30,128,64,truck_bmp);
Delay_ms(500);
Glcd_PartialImage(56,34,68,30,128,64,truck_bmp);
Delay2s(); Delay2s();
Glcd_Fill(0x00); // Clear GLCD
Glcd_Box(62,40,124,56,1); // Draw box
Glcd_Rectangle(5,5,84,35,1); // Draw rectangle
Delay_ms(1000);
Glcd_Rectangle_Round_Edges(2,2,87,38,7,1);
Delay_ms(1000);
Glcd_Rectangle_Round_Edges_Fill(8,8,81,32,12,1);
Delay_ms(1000);
Glcd_Line(0, 0, 127, 63, 1); // Draw line
Delay2s();
for(counter = 5; counter < 60; counter+=5 ){ // Draw horizontal and vertical lines
Delay_ms(250);
Glcd_V_Line(2, 54, counter, 1);
Glcd_H_Line(2, 120, counter, 1);
}
Delay2s();
Glcd_Fill(0x00); // Clear Glcd
Glcd_Set_Font(Character8x7, 8, 7, 32); // Choose font, see __Lib_GLCDFonts.c in Uses folder
Glcd_Write_Text("mikroE", 5, 7, 2); // Write string
for (counter = 1; counter <= 10; counter++) // Draw circles
Glcd_Circle(63,32, 3*counter, 1);
Delay2s();
Glcd_Circle_Fill(63,32, 30, 1); // Draw circles
Delay2s();
Glcd_Box(12,20, 70,57, 2); // Draw box
Delay2s();
Glcd_Fill(0xFF); // Fill Glcd
Glcd_Set_Font(Font_Glcd_Character8x7, 8, 7, 32); // Change font
someText = "8x7 Font";
Glcd_Write_Text(someText, 5, 0, 2); // Write string
Delay2s();
Glcd_Set_Font(Font_Glcd_System3x5, 3, 5, 32); // Change font
someText = "3X5 CAPITALS ONLY";
Glcd_Write_Text(someText, 60, 2, 2); // Write string
Delay2s();
Glcd_Set_Font(Font_Glcd_5x7, 5, 7, 32); // Change font
someText = "5x7 Font";
Glcd_Write_Text(someText, 5, 4, 2); // Write string
Delay2s();
Glcd_Set_Font(Font_Glcd_System5x7, 5, 7, 32); // Change font
someText = "5x7 Font (v2)";
Glcd_Write_Text(someText, 50, 6, 2); // Write string
Delay2s();
}
}
STM32
//Declarations------------------------------------------------------------------
const code char truck_bmp[1024];
//--------------------------------------------------------------end-declarations
// Glcd module connections
unsigned long GLCD_DataPort_Input at GPIOE_IDR;
unsigned long GLCD_DataPort_Output at GPIOE_ODR;
sbit GLCD_CS1 at GPIOE_ODR.B10;
sbit GLCD_CS2 at GPIOE_ODR.B11;
sbit GLCD_RS at GPIOE_ODR.B12;
sbit GLCD_RW at GPIOE_ODR.B13;
sbit GLCD_EN at GPIOE_ODR.B15;
sbit GLCD_RST at GPIOE_ODR.B8;
// End Glcd module connections
void delay2S(){ // 2 seconds delay function
Delay_ms(2000);
}
void main() {
char counter;
char *someText;
Glcd_Init(); // Initialize GLCD
Glcd_Fill(0x00); // Clear GLCD
while(1) {
Glcd_Image(truck_bmp); // Draw image
Delay2s(); Delay2s();
Glcd_fill(0x00); // Clear GLCD
Glcd_PartialImage(0,0,68,30,128,64,truck_bmp); // Partial image
Delay_ms(500);
Glcd_PartialImage(24,16,68,30,128,64,truck_bmp);
Delay_ms(500);
Glcd_PartialImage(56,34,68,30,128,64,truck_bmp);
Delay2s(); Delay2s();
Glcd_Fill(0x00); // Clear GLCD
Glcd_Box(62,40,124,56,1); // Draw box
Glcd_Rectangle(5,5,84,35,1); // Draw rectangle
Delay_ms(1000);
Glcd_Rectangle_Round_Edges(2,2,87,38,7,1);
Delay_ms(1000);
Glcd_Rectangle_Round_Edges_Fill(8,8,81,32,12,1);
Delay_ms(1000);
Glcd_Line(0, 0, 127, 63, 1); // Draw line
Delay2s();
for(counter = 5; counter < 60; counter+=5 ){ // Draw horizontal and vertical lines
Delay_ms(250);
Glcd_V_Line(2, 54, counter, 1);
Glcd_H_Line(2, 120, counter, 1);
}
Delay2s();
Glcd_Fill(0x00); // Clear Glcd
Glcd_Set_Font(Character8x7, 8, 7, 32); // Choose font, see __Lib_GLCDFonts.c in Uses folder
Glcd_Write_Text("mikroE", 5, 7, 2); // Write string
for (counter = 1; counter <= 10; counter++) // Draw circles
Glcd_Circle(63,32, 3*counter, 1);
Delay2s();
Glcd_Circle_Fill(63,32, 30, 1); // Draw circles
Delay2s();
Glcd_Box(12,20, 70,57, 2); // Draw box
Delay2s();
Glcd_Fill(0xFF); // Fill Glcd
Glcd_Set_Font(Font_Glcd_Character8x7, 8, 7, 32); // Change font
someText = "8x7 Font";
Glcd_Write_Text(someText, 5, 0, 2); // Write string
Delay2s();
Glcd_Set_Font(Font_Glcd_System3x5, 3, 5, 32); // Change font
someText = "3X5 CAPITALS ONLY";
Glcd_Write_Text(someText, 60, 2, 2); // Write string
Delay2s();
Glcd_Set_Font(Font_Glcd_5x7, 5, 7, 32); // Change font
someText = "5x7 Font";
Glcd_Write_Text(someText, 5, 4, 2); // Write string
Delay2s();
Glcd_Set_Font(Font_Glcd_System5x7, 5, 7, 32); // Change font
someText = "5x7 Font (v2)";
Glcd_Write_Text(someText, 50, 6, 2); // Write string
Delay2s();
}
}
What do you think about this topic ? Send us feedback!




