#include "T6963C.h" #define RB0 PORTB.F0 #define RB1 PORTB.F1 #define RB2 PORTB.F2 #define RB3 PORTB.F3 #define RB4 PORTB.F4 #define RB5 PORTB.F5 #define RB6 PORTB.F6 /* * bitmap pictures stored in ROM */ extern const char mc[] ; extern const char einstein[] ; void main(void) { unsigned char panel ; // current panel unsigned int i ; // general purpose register unsigned char curs ; // cursor visibility unsigned int cposx, cposy ; // cursor x-y position ADPCFG = 0xFFFF; //PORTAA PORTA = 0; TRISA = 0xFFFF; //PORTAB PORTB = 0; TRISB = 0xFFFF; //PORTAC TRISC = 0x0000; PORTC = 0x0000; //PORTAD PORTD = 0x0000; TRISD = 0x0000; //PORTAF PORTF = 0; TRISF = 0b00000000; //PORTAG TRISG = 0X0000; PORTG = 0; delay_ms(200); //T6963C_Init_240x64(); T6963C_init(240, 64, 8, &PORTD, &PORTF, 0, 1, 3, 4) ; delay_ms(500); /* * enable both graphics and text display at the same time */ T6963C_graphics(1) ; T6963C_text(1) ; delay_ms(500); panel = 0 ; i = 0 ; curs = 0 ; cposx = cposy = 0 ; /* * text messages */ delay_ms(100); T6963C_write_text(" GLCD LIBRARY DEMO, WELCOME !", 0, 0, T6963C_ROM_MODE_XOR) ; T6963C_write_text(" EINSTEIN WOULD HAVE LIKED mC", 0, 7, T6963C_ROM_MODE_XOR) ; /* * cursor */ T6963C_cursor_height(8) ; // 8 pixel height T6963C_set_cursor(0, 0) ; // move cursor to top left T6963C_cursor(0) ; // cursor off /* * draw rectangles */ T6963C_rectangle(0, 0, 239, 63, T6963C_WHITE) ; T6963C_rectangle(20, 11, 219, 53, T6963C_WHITE) ; T6963C_rectangle(40, 21, 199, 43, T6963C_WHITE) ; T6963C_rectangle(60, 30, 179, 34, T6963C_WHITE) ; /* * draw a cross */ T6963C_line(0, 0, 239, 63, T6963C_WHITE) ; T6963C_line(0, 63, 239, 0, T6963C_WHITE) ; T6963C_write_text("TESTO DI PROVA", 1, 1, T6963C_ROM_MODE_XOR); delay_ms(200); /* * draw solid boxes */ T6963C_box(0, 0, 239, 8, T6963C_WHITE) ; T6963C_box(0, 55, 239, 63, T6963C_WHITE) ; /* * draw circles */ T6963C_circle(120, 32, 10, T6963C_WHITE) ; T6963C_circle(120, 32, 30, T6963C_WHITE) ; T6963C_circle(120, 32, 50, T6963C_WHITE) ; T6963C_circle(120, 32, 70, T6963C_WHITE) ; T6963C_circle(120, 32, 90, T6963C_WHITE) ; T6963C_circle(120, 32, 110, T6963C_WHITE) ; T6963C_circle(120, 32, 130, T6963C_WHITE) ; T6963C_sprite(60, 0, einstein, 120, 64) ; // draw a sprite T6963C_setGrPanel(1) ; // select other graphic panel T6963C_image(mc) ; // fill the graphic screen with a picture for(;;) { /* * if RB2 is pressed, toggle the display between graphic panel 0 and graphic 1 */ if(RB2) { panel++ ; panel &= 1 ; T6963C_displayGrPanel(panel) ; Delay_ms(300) ; } /* * if RB3 is pressed, display only graphic panel */ else if(RB3) { T6963C_graphics(1) ; T6963C_text(0) ; Delay_ms(300) ; } /* * if RB4 is pressed, display only text panel */ else if(RB4) { T6963C_graphics(0) ; T6963C_text(1) ; Delay_ms(300) ; } /* * if RB5 is pressed, display text and graphic panels */ else if(RB5) { T6963C_graphics(1) ; T6963C_text(1) ; Delay_ms(300) ; } /* * if RB6 is pressed, change cursor */ else if(RB6) { curs++ ; if(curs == 3) curs = 0 ; switch(curs) { case 0: // no cursor T6963C_cursor(0) ; break ; case 1: // blinking cursor T6963C_cursor(1) ; T6963C_cursor_blink(1) ; break ; case 2: // non blinking cursor T6963C_cursor(1) ; T6963C_cursor_blink(0) ; break ; } Delay_ms(300) ; } /* * move cursor, even if not visible */ cposx++ ; if(cposx == T6963C_txtCols) { cposx = 0 ; cposy++ ; if(cposy == T6963C_grHeight / T6963C_CHARACTER_HEIGHT) { cposy = 0 ; } } T6963C_set_cursor(cposx, cposy) ; Delay_ms(100) ; }