
|
INFO - FAQ - CC2-Forum - CCPro-Forum |
|
Hello, I wrote this CCBasic example for the C-Control I v2.02 with Applicationboard 2.0. It will NOT work on the C-Control I V2.01. Greetings, H.J.W. '----------------------------------------------------------------------------------------------------' '******************************************************' '* WINDT SYSTEMS *' '* LCD Possibilities v1.6 for CCIUM2.02 with CCIAB2.0 *' '* 2006 / H.J.WINDT *' '******************************************************' '----------------------------------------------------------------------------------------------------' 'This software, with the C-Control I Unit M2.02 mounted on the C-Control I Application Board 2.0,' 'shows the possibilities of the APPLICATION BOARD LCD that are not supported in ccbasic2.0.' 'The possibilities include: reverse printing, 3 different cursors, cursor shifting, 'user defined characters and display on/ off.' 'User defined characters is the possibility to design your own 8 characters.' 'Feel free to use and share this software' '----------------------------------------------------------------------------------------------------' '**************** I/O PORTS ****************' '-----port 2 lcd connections-----' define lcd_port byteport[2] define db4 port[9] 'databus 4' define db5 port[10] 'databus 5' define db6 port[11] 'databus 6' define db7 port[12] 'databus 7' define rw port[13] '0 = write to lcd display / 1 = read from lcd display' define rs port[14] '0 = command / 1 = data' define en port[15] '1 to 0 = enable' define lcd_light_off port[16] '(off)0 = light on / (on)1 = light off' '*******************************************' '**************** A/D PORTS ****************' '*******************************************' '**************** D/A PORTS ****************' '*******************************************' '**************** VARIABLES ****************' define lcd_busy bit[1] define adr byte[2] 'lcd address code' define cmd byte[3] 'lcd command code' define dat byte[4] 'lcd data code' define loop byte[6] '*******************************************' '**************** CONSTANTS ****************' '*******************************************' '****************** SETUP ******************' gosub initialize_lcd beep 4,2,4: beep 4,2,4 '*******************************************' '***************** PROGRAM *****************' lcd_light_off = 0 #start print"#ON_LCD#"; print"#CLR#"; 'forward and reverse printing on lcd' gosub entry_mode_set_left_to_right 'print from left to right' print"#L101#"; print"Entry Mode LR"; gosub entry_mode_set_right_to_left 'print from right to left' print"#L216#"; print"Entry Mode RL"; gosub entry_mode_set_left_to_right 'print from left to right' pause 200 for loop = 0 to 3 'no cursor and 3 different cursors' print"#CLR#"; print"Cursor ";loop;" "; on loop gosub lcd_cursor_0, lcd_cursor_1, lcd_cursor_2, lcd_cursor_3 pause 200 next print"#CLR#"; print"Cursor Movement"; 'moving the cursor left and right' for loop = 1 to 15 pause 25 gosub lcd_cursor_shift_left 'shift the cursor left' next for loop = 1 to 15 pause 25 gosub lcd_cursor_shift_right 'shift the cursor right' next pause 25 gosub lcd_cursor_0 print"#CLR#"; print"Generated Chara."; 'printing 4 example generated characters on the lcd' print"#L205#"; put&h08 'antenna' print" "; put&h09 'heart' print" "; put&h0a 'happy' print" "; put&h0b 'window' pause 200 print"#CLR#"; print" DiSpLaY "; 'display off on off on ......' print"#L201#"; print" ON/OFF "; for loop = 1 to 10 pause 25 gosub display_off pause 25 gosub display_on_0 next print"#OFF#"; tog lcd_light_off goto start '*******************************************' '*************** SUBROUTINES ***************' #display_off 'lcd display OFF/ cursor OFF / understripe OFF' cmd = &b00001000:goto command_to_lcd #display_on_0 'lcd display ON and' #lcd_cursor_0 'cursor OFF / understripe OFF' cmd = &b00001100:goto command_to_lcd #display_on_1 'lcd display ON and' #lcd_cursor_1 'cursor BLINKS / understripe BLINKS' cmd = &b00001101:goto command_to_lcd #display_on_2 'lcd display ON and' #lcd_cursor_2 'cursor OFF / understripe ON' cmd = &b00001110:goto command_to_lcd #display_on_3 'lcd display ON and' #lcd_cursor_3 'cursor BLINKS / understripe ON' cmd = &b00001111:goto command_to_lcd #lcd_cursor_shift_left 'shifts cursor left without clearing character' cmd = &b00010000:goto command_to_lcd #lcd_cursor_shift_right 'shifts cursor right without clearing character' cmd = &b00010100:goto command_to_lcd #entry_mode_set_left_to_right 'sets printing to left to right ex. HELLO' cmd = &b00000110 goto command_to_lcd #entry_mode_set_right_to_left 'sets printing to right to left (backwards) ex. OLLEH' cmd = &b00000100 goto command_to_lcd #command_to_lcd gosub busy_flag_check_from_lcd deact db7:deact db6:deact db5:deact db4 lcd_port = (lcd_light_off * 128) or (cmd / 16) : pulse en 'HIGH NIBBLE command to lcd' lcd_port = (lcd_light_off * 128) or (cmd mod 16) : pulse en 'LOW NIBBLE command to lcd' return #data_to_DD_ram_lcd cmd = &b10000000 or adr : gosub command_to_lcd goto put_data_into_lcd #data_to_CG_ram_lcd cmd = &b01000000 or adr : gosub command_to_lcd #put_data_into_lcd gosub busy_flag_check_from_lcd deact db7:deact db6:deact db5:deact db4 lcd_port = &b00100000 or (lcd_light_off * 128) or (dat / 16) : pulse en 'HIGH NIBBLE data to lcd' lcd_port = &b00100000 or (lcd_light_off * 128) or (dat mod 16) : pulse en 'LOW NIBBLE data to lcd' return #data_from_DD_ram_lcd cmd = &b10000000 or adr : gosub command_to_lcd goto get_data_from_lcd #data_from_CG_ram_lcd cmd = &b01000000 or adr : gosub command_to_lcd #get_data_from_lcd deact db7 : deact db6 : deact db5 : deact db4:rw = 1:rs =1 : en = 1 dat = 0 dat = (abs(db7) * 128) or (abs(db6) * 64) or (abs(db5) * 32) or (abs(db4) * 16) 'HIGH NIBBLE data from lcd' pulse en dat = dat or (abs(db7) * 8) or (abs(db6) * 4) or (abs(db5) * 2) or (abs(db4) * 1) 'LOW NIBBLE data from lcd' en = 0 goto command_to_lcd #busy_flag_check_from_lcd deact db7 : deact db6 : deact db5 : deact db4:rw = 1:rs = 0:en = 1 lcd_busy = db7 pulse en if lcd_busy then goto busy_flag_check_from_lcd return '*******************************************' '******* INITIALIZATION SUBROUTINES ********' #initialize_lcd print"#ON_LCD#";"#INIT#";"#CLR#";"#OFF#"; 'initialize lcd display' #character_build 'generates characters in lcd ram from characterbuild table / 8 characters of 5 x 8 pixels' for adr = 0 to 63 'lcd display character generation (CG) address' looktab characterbuild, adr, dat 'lcd data for character generation' gosub data_to_CG_ram_lcd 'set character generation data in CG address' next return '*******************************************' '********* CALIBRATION SUBROUTINES *********' '*******************************************' '****************** DATA *******************' ' (CG dat adr) 000/XXXXX first 3 bits are not used/ last 5 bits are for character generation ' table characterbuild &b00010001 '(0) 000/1 1' character build data for antenna symbol/ read from DD-ram address &h08' &b00011111 '(1) 000/11111' *use put&h08*' &b00010101 '(2) 000/1 1 1' &b00000100 '(3) 000/ 1 ' &b00000100 '(4) 000/ 1 ' &b00000100 '(5) 000/ 1 ' &b00000100 '(6) 000/ 1 ' &b00000000 '(7) 000/ '-----------------------------------------' &b00000000 '(8) 000/ ' character build data for heart/ read from DD-ram address &h09' &b00000000 '(9) 000/ ' *use put&h09*' &b00001010 '(10) 000/ 1 1 ' &b00011111 '(11) 000/11111' &b00001110 '(12) 000/ 111 ' &b00000100 '(13) 000/ 1 ' &b00000000 '(14) 000/ ' &b00000000 '(15) 000/ '-----------------------------------------' &b00000000 '(16) 000/ ' character build data for happy/ read from DD-ram address &h0a' &b00000000 '(17) 000/ ' *use put&h0a*' &b00001010 '(18) 000/ 1 1 ' &b00000000 '(19) 000/ ' &b00000100 '(20) 000/ 1 ' &b00010001 '(21) 000/1 1' &b00001110 '(22) 000/ 111 ' &b00000000 '(23) 000/ '-----------------------------------------' &b00011111 '(24) 000/11111 character build data for window/ read from DD-ram address &h0b' &b00010101 '(25) 000/1 1 1' *use put&h0b*' &b00010101 '(26) 000/1 1 1' &b00011111 '(27) 000/11111' &b00010101 '(28) 000/1 1 1' &b00010101 '(29) 000/1 1 1' &b00011111 '(30) 000/11111' &b00011111 '(31) 000/11111'-----------------------------------------' &b00000000 '(32) 000/00000 empty place for character build data/ read from DD-ram address &h0c' &b00000000 '(33) 000/00000' *use put&h0c*' &b00000000 '(34) 000/00000' &b00000000 '(35) 000/00000' &b00000000 '(36) 000/00000' &b00000000 '(37) 000/00000' &b00000000 '(38) 000/00000' &b00000000 '(39) 000/00000 -----------------------------------------' &b00000000 '(40) 000/00000 empty place for character build data/ read from DD-ram address &h0d' &b00000000 '(41) 000/00000' *use put&h0d*' &b00000000 '(42) 000/00000' &b00000000 '(43) 000/00000' &b00000000 '(44) 000/00000' &b00000000 '(45) 000/00000' &b00000000 '(46) 000/00000' &b00000000 '(47) 000/00000 -----------------------------------------' &b00000000 '(48) 000/00000 empty place for character build data/ read from DD-ram address &h0e' &b00000000 '(49) 000/00000' *use put&h0e*' &b00000000 '(50) 000/00000' &b00000000 '(51) 000/00000' &b00000000 '(52) 000/00000' &b00000000 '(53) 000/00000' &b00000000 '(54) 000/00000' &b00000000 '(55) 000/00000 -----------------------------------------' &b00000000 '(56) 000/00000 empty place for character build data/ read from DD-ram address &h0f' &b00000000 '(57) 000/00000' *use put&h0f*' &b00000000 '(58) 000/00000' &b00000000 '(59) 000/00000' &b00000000 '(60) 000/00000' &b00000000 '(61) 000/00000' &b00000000 '(62) 000/00000' &b00000000 '(63) 000/00000 -----------------------------------------' tabend '*******************************************' '************* ERROR MESSAGES **************' '*******************************************' |
| Antwort schreiben |