program T6963C_240x128
include __Lib_T6963C_Consts
include einstein_bmp
include mikroe_bmp
' T6963C module connections
dim T6963C_dataPort as byte at PORTD ' DATA port
dim T6963C_ctrlwr as sbit at RC2_bit ' WR write signal
dim T6963C_ctrlrd as sbit at RC1_bit ' RD read signal
dim T6963C_ctrlcd as sbit at RC0_bit ' CD command/data signal
dim T6963C_ctrlrst as sbit at RC4_bit ' RST reset signal
dim T6963C_ctrlwr_Direction as sbit at TRISC2_bit ' WR write signal direction
dim T6963C_ctrlrd_Direction as sbit at TRISC1_bit ' RD read signal direction
dim T6963C_ctrlcd_Direction as sbit at TRISC0_bit ' CD command/data signal direction
dim T6963C_ctrlrst_Direction as sbit at TRISC4_bit ' RST reset signal direction
' Signals not used by library, they are set in main sub function
dim T6963C_ctrlce as sbit at RC3_bit ' CE signal
dim T6963C_ctrlfs as sbit at RC6_bit ' FS signal
dim T6963C_ctrlmd as sbit at RC5_bit ' MD signal
dim T6963C_ctrlce_Direction as sbit at TRISC3_bit ' CE signal direction
dim T6963C_ctrlfs_Direction as sbit at TRISC6_bit ' FS signal direction
dim T6963C_ctrlmd_Direction as sbit at TRISC5_bit ' MD signal direction
' End T6963C module connections
dim panel as byte ' current panel
i as word ' general purpose register
curs as byte ' cursor visibility
cposx,
cposy as word ' cursor x-y position
txtcols as byte ' number of text coloms
txt, txt1 as string[29]
main:
txt1 = " EINSTEIN WOULD HAVE LIKED mE"
txt = " GLCD LIBRARY DEMO, WELCOME !"
ANSEL = 0 ' Configure AN pins as digital I/O
ANSELH = 0
C1ON_bit = 0 ' Disable comparators
C2ON_bit = 0
TRISB0_bit = 1 ' Set RB0 as input
TRISB1_bit = 1 ' Set RB1 as input
TRISB2_bit = 1 ' Set RB2 as input
TRISB3_bit = 1 ' Set RB3 as input
TRISB4_bit = 1 ' Set RB4 as input
T6963C_ctrlce_Direction = 0
T6963C_ctrlce = 0 ' Enable T6963C
T6963C_ctrlfs_Direction = 0
T6963C_ctrlfs = 0 ' Font Select 8x8
T6963C_ctrlmd_Direction = 0
T6963C_ctrlmd = 0 ' Column number select
panel = 0
i = 0
curs = 0
cposx = 0
cposy = 0
' Initialize T6369C
T6963C_init(240, 128, 8)
' *
' * Enable both graphics and text display at the same time
' *
T6963C_graphics(1)
T6963C_text(1)
' *
' * Text messages
' *
T6963C_write_text(txt, 0, 0, T6963C_ROM_MODE_XOR)
T6963C_write_text(txt1, 0, 15, 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, 127, T6963C_WHITE)
T6963C_rectangle(20, 20, 219, 107, T6963C_WHITE)
T6963C_rectangle(40, 40, 199, 87, T6963C_WHITE)
T6963C_rectangle(60, 60, 179, 67, T6963C_WHITE)
' *
' * Draw a cross
' *
T6963C_line(0, 0, 239, 127, T6963C_WHITE)
T6963C_line(0, 127, 239, 0, T6963C_WHITE)
' *
' * Draw solid boxes
' *
T6963C_box(0, 0, 239, 8, T6963C_WHITE)
T6963C_box(0, 119, 239, 127, T6963C_WHITE)
' *
' * Draw circles
' *
T6963C_circle(120, 64, 10, T6963C_WHITE)
T6963C_circle(120, 64, 30, T6963C_WHITE)
T6963C_circle(120, 64, 50, T6963C_WHITE)
T6963C_circle(120, 64, 70, T6963C_WHITE)
T6963C_circle(120, 64, 90, T6963C_WHITE)
T6963C_circle(120, 64, 110, T6963C_WHITE)
T6963C_circle(120, 64, 130, T6963C_WHITE)
T6963C_sprite(76, 4, @einstein, 88, 119) ' Draw a sprite
T6963C_setGrPanel(1) ' Select other graphic panel
T6963C_sprite(0, 0, @mikroe_bmp, 240, 64) ' 240x128 can"t be stored in most of PIC16 MCUs
T6963C_sprite(0, 64, @mikroe_bmp, 240, 64) ' it is replaced with smaller picture 240x64
' Smaller picture is drawn two times
while TRUE ' Endless loop
'*
'* If PORTB_0 is pressed, toggle the display between graphic panel 0 and graphic 1
'*
if (RB0_bit <> 0) then
T6963C_graphics(1)
T6963C_text(0)
Delay_ms(300)
'*
'* If PORTB_1 is pressed, display only graphic panel
'*
else
if (RB1_bit <> 0) then
Inc(panel)
panel = panel and 1
T6963C_setPtr((T6963C_grMemSize + T6963C_txtMemSize) * panel, T6963C_GRAPHIC_HOME_ADDRESS_SET)
Delay_ms(300)
'*
'* If PORTB_2 is pressed, display only text panel
'*
else
if (RB2_bit <> 0) then
T6963C_graphics(0)
T6963C_text(1)
Delay_ms(300)
'*
'* If PORTB_3 is pressed, display text and graphic panels
'*
else
if (RB3_bit <> 0) then
T6963C_graphics(1)
T6963C_text(1)
Delay_ms(300)
'*
'* If PORTB_4 is pressed, change cursor
'*
else
if(RB4_bit <> 0) then
Inc(curs)
if (curs = 3) then
curs = 0
end if
select case curs
case 0
' no cursor
T6963C_cursor(0)
case 1
' blinking cursor
T6963C_cursor(1)
T6963C_cursor_blink(1)
case 2
' non blinking cursor
T6963C_cursor(1)
T6963C_cursor_blink(0)
end select 'case
Delay_ms(300)
end if
end if
end if
end if
end if
'*
'* Move cursor, even if not visible
'*
Inc(cposx)
if (cposx = T6963C_txtCols) then
cposx = 0
Inc(cposy)
if (cposy = T6963C_grHeight / T6963C_CHARACTER_HEIGHT) then
cposy = 0
end if
end if
T6963C_set_cursor(cposx, cposy)
Delay_ms(100)
wend
end.