PIC18 LaurTec Library
3.1.2
Open Source C Library for PIC18 Microcontrollers based on C18 - XC8 Compilers
|
Go to the source code of this file.
Macros | |
#define | GLCD_DATA_WRITE LATD |
#define | GLCD_DATA_READ PORTD |
#define | GLCD_DATA_DIRECTION TRISD |
#define | GLCD_D_I LATAbits.LATA3 |
#define | GLCD_R_W LATAbits.LATA4 |
#define | GLCD_E LATAbits.LATA5 |
#define | GLCD_CS1 LATEbits.LATE0 |
#define | GLCD_CS2 LATEbits.LATE1 |
#define | GLCD_RST LATEbits.LATE2 |
#define | GLCD_LED LATCbits.LATC1 |
#define | INPUT 0xFF |
#define | OUTPUT 0x00 |
#define | NUMBER_OF_PAGES 8 |
#define | X_RESOLUTION 128 |
#define | Y_RESOLUTION 64 |
#define | CONTROLLER_MAX_X 64 |
#define | ENABLE_FONT_5x7 |
#define | ENABLE_LOGO_1 |
#define | GLCD_FONT_WIDTH_5 5 |
#define | GLCD_FONT_HEIGTH_7 7 |
#define | GLCD_FONT_SPACE 1 |
#define | COMM_DISPLAY_ON 0b00111111 |
#define | COMM_DISPLAY_OFF 0b00111110 |
#define | COMM_PAGE_SELECT 0b10111000 |
#define | COMM_ADDRESS_SELECT 0b01000000 |
#define | COMM_START_LINE 0b11000000 |
#define | GLCD_BUSY_FLAG 0x80 |
#define | TURN_ON_LED_GLCD 0b00000001 |
#define | TURN_OFF_LED_GLCD 0b00000000 |
#define | TURN_ON_DISPLAY 0b00000001 |
#define | TURN_OFF_DISPLAY 0b00000000 |
#define | HIGH_GLCD 0b00000001 |
#define | LOW_GLCD 0b00000000 |
#define | ENABLE_GLCD 0b00000001 |
#define | DISABLE_GLCD 0b00000000 |
#define | ENABLE_RESET_GLCD 0b00000000 |
#define | DISABLE_RESET_GLCD 0b00000001 |
#define | GLCD_CHIP_SELECT_1 0x00 |
#define | GLCD_CHIP_SELECT_2 0x01 |
#define | FILLING_WHITE 0x00 |
#define | FILLING_BLACK 0xFF |
Functions | |
void | initialize_GLCD (void) |
void | clear_GLCD (unsigned char filling_color) |
void | backlight_GLCD (unsigned char backlight) |
void | set_display_GLCD (unsigned char display_status) |
void | set_vertical_offset_GLCD (unsigned char vertical_offset) |
void | plot_xy_GLCD (unsigned char x_pos, unsigned char y_pos, unsigned char filling_color) |
void | draw_horizontal_line_GLCD (unsigned char x_origin, unsigned char y_origin, unsigned char length, unsigned char filling_color) |
void | draw_vertical_line_GLCD (unsigned char x_origin, unsigned char y_origin, unsigned char length, unsigned char filling_color) |
void | draw_window_GLCD (unsigned char x_origin, unsigned char y_origin, unsigned char length, unsigned char height, unsigned char filling_color) |
void | draw_box_GLCD (unsigned char x_origin, unsigned char y_origin, unsigned char length, unsigned char height, unsigned char filling_color) |
void | draw_picture_GLCD (rom unsigned char *picture_table) |
void | write_char_GLCD (unsigned char x_pos, unsigned char y_pos, unsigned char character) |
void | write_string_GLCD (unsigned char x_pos, unsigned char y_pos, unsigned char *character_array) |
void | write_message_GLCD (unsigned char x_pos, unsigned char y_pos, const rom unsigned char *character) |
void | write_integer_GLCD (unsigned char x_pos, unsigned char y_pos, int value, char number_of_digits) |
void | set_font_GLCD (unsigned char width, unsigned char height) |
void | wait_busy_status_GLCD (void) |
unsigned char | get_controller_status_GLCD (void) |
void | write_command_GLCD (unsigned char command_to_send) |
void | set_page_GLCD (unsigned char controller_page) |
void | set_address_GLCD (unsigned char controller_address) |
void | write_data_GLCD (unsigned char data_to_send) |
unsigned char | read_data_GLCD (void) |
Variables | |
rom unsigned char | font_5x7 [96][5] |
rom unsigned char | logo_1 [] |
#define COMM_ADDRESS_SELECT 0b01000000 |
Definition at line 120 of file GLCD_KS0108B.h.
#define COMM_DISPLAY_OFF 0b00111110 |
Definition at line 116 of file GLCD_KS0108B.h.
#define COMM_DISPLAY_ON 0b00111111 |
Definition at line 115 of file GLCD_KS0108B.h.
#define COMM_PAGE_SELECT 0b10111000 |
Definition at line 118 of file GLCD_KS0108B.h.
#define COMM_START_LINE 0b11000000 |
Definition at line 122 of file GLCD_KS0108B.h.
#define CONTROLLER_MAX_X 64 |
Definition at line 90 of file GLCD_KS0108B.h.
#define DISABLE_GLCD 0b00000000 |
Definition at line 147 of file GLCD_KS0108B.h.
#define DISABLE_RESET_GLCD 0b00000001 |
Definition at line 150 of file GLCD_KS0108B.h.
#define ENABLE_FONT_5x7 |
Definition at line 97 of file GLCD_KS0108B.h.
#define ENABLE_GLCD 0b00000001 |
Definition at line 146 of file GLCD_KS0108B.h.
#define ENABLE_LOGO_1 |
Definition at line 99 of file GLCD_KS0108B.h.
#define ENABLE_RESET_GLCD 0b00000000 |
Definition at line 149 of file GLCD_KS0108B.h.
#define FILLING_BLACK 0xFF |
Definition at line 156 of file GLCD_KS0108B.h.
#define FILLING_WHITE 0x00 |
Definition at line 155 of file GLCD_KS0108B.h.
#define GLCD_BUSY_FLAG 0x80 |
Definition at line 129 of file GLCD_KS0108B.h.
#define GLCD_CHIP_SELECT_1 0x00 |
Definition at line 152 of file GLCD_KS0108B.h.
#define GLCD_CHIP_SELECT_2 0x01 |
Definition at line 153 of file GLCD_KS0108B.h.
#define GLCD_CS1 LATEbits.LATE0 |
Definition at line 74 of file GLCD_KS0108B.h.
#define GLCD_CS2 LATEbits.LATE1 |
Definition at line 75 of file GLCD_KS0108B.h.
#define GLCD_D_I LATAbits.LATA3 |
Definition at line 71 of file GLCD_KS0108B.h.
#define GLCD_DATA_DIRECTION TRISD |
Definition at line 69 of file GLCD_KS0108B.h.
#define GLCD_DATA_READ PORTD |
Definition at line 68 of file GLCD_KS0108B.h.
#define GLCD_DATA_WRITE LATD |
Definition at line 67 of file GLCD_KS0108B.h.
#define GLCD_E LATAbits.LATA5 |
Definition at line 73 of file GLCD_KS0108B.h.
#define GLCD_FONT_HEIGTH_7 7 |
Definition at line 106 of file GLCD_KS0108B.h.
#define GLCD_FONT_SPACE 1 |
Definition at line 108 of file GLCD_KS0108B.h.
#define GLCD_FONT_WIDTH_5 5 |
Definition at line 105 of file GLCD_KS0108B.h.
#define GLCD_LED LATCbits.LATC1 |
Definition at line 77 of file GLCD_KS0108B.h.
#define GLCD_R_W LATAbits.LATA4 |
Definition at line 72 of file GLCD_KS0108B.h.
#define GLCD_RST LATEbits.LATE2 |
Definition at line 76 of file GLCD_KS0108B.h.
#define HIGH_GLCD 0b00000001 |
Definition at line 143 of file GLCD_KS0108B.h.
#define INPUT 0xFF |
Definition at line 83 of file GLCD_KS0108B.h.
#define LOW_GLCD 0b00000000 |
Definition at line 144 of file GLCD_KS0108B.h.
#define NUMBER_OF_PAGES 8 |
Definition at line 86 of file GLCD_KS0108B.h.
#define OUTPUT 0x00 |
Definition at line 84 of file GLCD_KS0108B.h.
#define TURN_OFF_DISPLAY 0b00000000 |
Definition at line 141 of file GLCD_KS0108B.h.
#define TURN_OFF_LED_GLCD 0b00000000 |
Definition at line 138 of file GLCD_KS0108B.h.
#define TURN_ON_DISPLAY 0b00000001 |
Definition at line 140 of file GLCD_KS0108B.h.
#define TURN_ON_LED_GLCD 0b00000001 |
Definition at line 137 of file GLCD_KS0108B.h.
#define X_RESOLUTION 128 |
Definition at line 87 of file GLCD_KS0108B.h.
#define Y_RESOLUTION 64 |
Definition at line 88 of file GLCD_KS0108B.h.
void backlight_GLCD | ( | unsigned char | backlight | ) |
This function turns ON-OFF the GLCD back light.
backlight | Control the backlight LED. TURN_ON_LED : Backlight is ON TURN_OFF_LED : Backlight is OFF |
Definition at line 576 of file GLCD_KS0108B.c.
References GLCD_LED.
void clear_GLCD | ( | unsigned char | filling_color | ) |
This function clears the display either in black or white color.
filling_color | Filling color allows to set the display either on white or black color [FILLING_WHITE, FILLING_BLACK] |
Definition at line 231 of file GLCD_KS0108B.c.
References GLCD_CS1, GLCD_CS2, HIGH_GLCD, LOW_GLCD, NUMBER_OF_PAGES, set_address_GLCD(), set_page_GLCD(), write_data_GLCD(), and Y_RESOLUTION.
void draw_box_GLCD | ( | unsigned char | x_origin, |
unsigned char | y_origin, | ||
unsigned char | length, | ||
unsigned char | height, | ||
unsigned char | filling_color | ||
) |
This function plots a colored box either in black or white color. Origin and length and height can be set by the user.
x_origin | Box X origin [0..127] |
y_origin | Box Y origin [0..63] |
length | Box lenght. |
length | Box height. |
filling_color | Filling color allows to set the dot either on white or black color [FILLING_WHITE, FILLING_BLACK] |
Definition at line 403 of file GLCD_KS0108B.c.
References draw_vertical_line_GLCD().
void draw_horizontal_line_GLCD | ( | unsigned char | x_origin, |
unsigned char | y_origin, | ||
unsigned char | length, | ||
unsigned char | filling_color | ||
) |
This function plots an horizontal line either in black or white color. Origin and length can be set by the user.
x_origin | Line X origin [0..127]. |
y_origin | Line Y origin [0..63]. |
length | Line lenght [0..127]. |
filling_color | Filling color allows to set the dot either on white or black color [FILLING_WHITE, FILLING_BLACK] |
Definition at line 371 of file GLCD_KS0108B.c.
References plot_xy_GLCD().
void draw_picture_GLCD | ( | rom unsigned char * | picture_table | ) |
This function draws a picture with 128x64 resolution.
picture_table | Pointer to the table cointaining the picture (stored in flash). |
Definition at line 483 of file GLCD_KS0108B.c.
References draw_picture_GLCD(), GLCD_CS1, GLCD_CS2, HIGH_GLCD, LOW_GLCD, NUMBER_OF_PAGES, set_address_GLCD(), set_page_GLCD(), write_data_GLCD(), and Y_RESOLUTION.
void draw_vertical_line_GLCD | ( | unsigned char | x_origin, |
unsigned char | y_origin, | ||
unsigned char | length, | ||
unsigned char | filling_color | ||
) |
This function plots a vertical line either in black or white color. Origin and length can be set by the user.
x_origin | Line X origin [0..128]. |
y_origin | Line Y origin [0..63]. |
length | Line lenght [0..63]. |
filling_color | Filling color allows to set the dot either on white or black color [FILLING_WHITE, FILLING_BLACK] |
Definition at line 358 of file GLCD_KS0108B.c.
References plot_xy_GLCD().
void draw_window_GLCD | ( | unsigned char | x_origin, |
unsigned char | y_origin, | ||
unsigned char | length, | ||
unsigned char | height, | ||
unsigned char | filling_color | ||
) |
This function plots an empty window either with black or white color borders. Origin and length and height can be set by the user.
x_origin | Window X origin [0..127]. |
y_origin | Window Y origin [0..63]. |
length | Window lenght [0..127]. |
length | Window height [0..63]. |
filling_color | Filling color allows to set the dot either on white or black color [FILLING_WHITE, FILLING_BLACK] |
Definition at line 385 of file GLCD_KS0108B.c.
References draw_horizontal_line_GLCD(), and draw_vertical_line_GLCD().
unsigned char get_controller_status_GLCD | ( | void | ) |
This function gets the Controller Status, among which the status bit.
void |
Definition at line 71 of file GLCD_KS0108B.c.
References GLCD_D_I, GLCD_DATA_DIRECTION, GLCD_DATA_READ, GLCD_E, GLCD_R_W, HIGH_GLCD, INPUT, LOW_GLCD, and OUTPUT.
void initialize_GLCD | ( | void | ) |
GLCD Initialization. This function should be called before using the GLCD. Controller are initialized, backlight is set to OFF, Diplay is clreared and font is set.
void |
Definition at line 585 of file GLCD_KS0108B.c.
References backlight_GLCD(), clear_GLCD(), delay_ms(), FILLING_WHITE, GLCD_CS1, GLCD_CS2, GLCD_D_I, GLCD_DATA_DIRECTION, GLCD_E, GLCD_FONT_HEIGTH_7, GLCD_FONT_WIDTH_5, GLCD_LED, GLCD_R_W, GLCD_RST, HIGH_GLCD, LOW_GLCD, OUTPUT, set_display_GLCD(), set_font_GLCD(), set_vertical_offset_GLCD(), TURN_OFF_LED_GLCD, and TURN_ON_DISPLAY.
void plot_xy_GLCD | ( | unsigned char | x_pos, |
unsigned char | y_pos, | ||
unsigned char | filling_color | ||
) |
This function plots a single dot either in black or white color. Plot position is set accordingly to x,y.
x_pos | Position X [0..127]. |
y_pos | Position Y [0..63]. |
filling_color | Filling color allows to set the dot either on white or black color [FILLING_WHITE, FILLING_BLACK] |
Definition at line 306 of file GLCD_KS0108B.c.
References CONTROLLER_MAX_X, FILLING_BLACK, GLCD_CS1, GLCD_CS2, HIGH_GLCD, LOW_GLCD, read_data_GLCD(), set_address_GLCD(), set_page_GLCD(), write_data_GLCD(), and Y_RESOLUTION.
unsigned char read_data_GLCD | ( | void | ) |
This function reads a data byte from the controller. It is used to know the data byte value of a certain address before writing into it.
void |
Definition at line 276 of file GLCD_KS0108B.c.
References GLCD_D_I, GLCD_DATA_DIRECTION, GLCD_DATA_READ, GLCD_E, GLCD_R_W, HIGH_GLCD, INPUT, LOW_GLCD, and OUTPUT.
void set_address_GLCD | ( | unsigned char | controller_address | ) |
This function sets the controller address (0 to 63).
controller_address | Controller address [0..63]. |
Definition at line 165 of file GLCD_KS0108B.c.
References COMM_ADDRESS_SELECT, wait_busy_status_GLCD(), and write_command_GLCD().
void set_display_GLCD | ( | unsigned char | display_status | ) |
This function sets the display turning it ON or OFF.
display_status | Turn ON or OFF the display [TURN_ON_DISPLAY, TURN_OFF_DISPLAY] |
Definition at line 122 of file GLCD_KS0108B.c.
References COMM_DISPLAY_OFF, COMM_DISPLAY_ON, GLCD_CS1, GLCD_CS2, HIGH_GLCD, LOW_GLCD, wait_busy_status_GLCD(), and write_command_GLCD().
void set_font_GLCD | ( | unsigned char | width, |
unsigned char | height | ||
) |
This function sets the font. Currently only one font is supported so is not yet that important. The initialization function is calling it so there is no reason to call it till new fonts will be supported.
width | Font width. |
width | Font height. |
Definition at line 566 of file GLCD_KS0108B.c.
References font_height, and font_width.
void set_page_GLCD | ( | unsigned char | controller_page | ) |
This function sets the controller page (0 to NUMBER_OF_PAGES).
controller_page | Controller page [0..NUMBER_OF_PAGES]. |
Definition at line 154 of file GLCD_KS0108B.c.
References COMM_PAGE_SELECT, wait_busy_status_GLCD(), and write_command_GLCD().
void set_vertical_offset_GLCD | ( | unsigned char | vertical_offset | ) |
This function sets the vertical offset allowing a display shift.
vertical_offset | Vertical offset [0..63]. |
Definition at line 176 of file GLCD_KS0108B.c.
References COMM_START_LINE, GLCD_CS1, GLCD_CS2, HIGH_GLCD, LOW_GLCD, and write_command_GLCD().
void wait_busy_status_GLCD | ( | void | ) |
This function waits until the controller is not busy anylonger. It calls the private function get_controller_status_GLCD ().
void |
Definition at line 54 of file GLCD_KS0108B.c.
References get_controller_status_GLCD(), and GLCD_BUSY_FLAG.
void write_char_GLCD | ( | unsigned char | x_pos, |
unsigned char | y_pos, | ||
unsigned char | character | ||
) |
This function writes an ASCII character.
x_pos | Position X [0..127]. |
y_pos | Position Y [0..63]. |
character | ASCII character either as number (unsigned char) or character. Example: 97, 'a'. |
Definition at line 415 of file GLCD_KS0108B.c.
References FILLING_BLACK, FILLING_WHITE, font_5x7, font_height, font_width, and plot_xy_GLCD().
void write_command_GLCD | ( | unsigned char | command_to_send | ) |
This function writes a command to the controller. The available commands are GLCD command constants. For each command there is a dedicated function. The User should use these rather than sending commands.
command_to_send | Command to be sent to the Controller. |
Definition at line 95 of file GLCD_KS0108B.c.
References GLCD_D_I, GLCD_DATA_WRITE, GLCD_E, GLCD_R_W, HIGH_GLCD, and LOW_GLCD.
void write_data_GLCD | ( | unsigned char | data_to_send | ) |
This function writes a data byte to the controller.
data_to_send | Data byte to be sent out. |
Definition at line 201 of file GLCD_KS0108B.c.
References GLCD_D_I, GLCD_DATA_WRITE, GLCD_E, GLCD_R_W, HIGH_GLCD, and LOW_GLCD.
void write_integer_GLCD | ( | unsigned char | x_pos, |
unsigned char | y_pos, | ||
int | value, | ||
char | number_of_digits | ||
) |
This function writes variable that contains an integer number.
x_pos | Position X [0..127]. |
y_pos | Position Y [0..63]. |
value | Integer value to be written (either positive or negative) |
number_of_digits | The number is formatted with a fixed number of digits to ensure a constant string length. |
Definition at line 529 of file GLCD_KS0108B.c.
References write_string_GLCD().
void write_message_GLCD | ( | unsigned char | x_pos, |
unsigned char | y_pos, | ||
const rom unsigned char * | character | ||
) |
This function writes a constant string of char.
x_pos | Position X [0..127]. |
y_pos | Position Y [0..63]. |
character_array | Pointer to the array that contains the string (stored in flash). |
Definition at line 460 of file GLCD_KS0108B.c.
References font_width, GLCD_FONT_SPACE, write_char_GLCD(), and write_message_GLCD().
void write_string_GLCD | ( | unsigned char | x_pos, |
unsigned char | y_pos, | ||
unsigned char * | character_array | ||
) |
This function writes an entire string of char. The string must be terminated with /0.
x_pos | Position X [0..127]. |
y_pos | Position Y [0..63]. |
character_array | Pointer to the array that contains the string. |
Definition at line 443 of file GLCD_KS0108B.c.
References font_width, GLCD_FONT_SPACE, and write_char_GLCD().
rom unsigned char font_5x7[96][5] |
Definition at line 530 of file GLCD_KS0108B.h.
rom unsigned char logo_1[] |
Definition at line 644 of file GLCD_KS0108B.h.