; ; uLCD test routine ; ; Prints my name Paul Chubb three times in the three font sizes. ; ; copyright 2006, singlespoon ministries. Released under GPL v2 ; symbol uLCD_wakeup_pause = 2000 ; ms to wait for uLCD on powerup symbol uLCD_high_pause = 1000 ; pause after raising outpin symbol uLCD_sync_pause = 1000 ; pause after sync. For some reason it doesn't ack the sync symbol uLCD_out_pin = 3 ; output pin connected to uLCD RX symbol uLCD_in_pin = 1 ; input pin connected to uLCD TX symbol uLCD_speed = T2400 ; serial comms speed designation eg T1200. Must be T???? symbol uLCD_str_start = 0xC6 ; start of string buffer symbol uLCD_str_start0 = 0xC5 symbol uLCD_str_end = 0xDA ; end - note max string size is 20char symbol uLCD_ack = 0x06 ; ack packet symbol uLCD_nack = 0x15 ; nack packet symbol uLCD_sync = 0x55 ; auto baud sync command symbol uLCD_clrscrn = 0x45 ; clear screen symbol uLCD_fnt_cmd = 0x46 ; font command symbol uLCD_fnt_sml = 0x00 ; small font size - 5x7 - xy: 20,15 symbol uLCD_fnt_med = 0x01 ; med font size - 8x8 - xy: 15,15 symbol uLCD_fnt_lge = 0x02 ; large font size - 8x12 - xy: 15,9 symbol uLCD_opq_cmd = 0x4f ; opaque text command symbol uLCD_opq_on = 0x00 ; small font size - 5x7 - xy: 20,15 symbol uLCD_opq_off = 0x01 ; med font size - 8x8 - xy: 15,15 symbol uLCD_lcd_cmd = 0x59 ; screen control command cmd, mode, setting symbol uLCD_lcd_cmd_bl = 0x00 ; backlight control symbol uLCD_lcd_cmd_bl_off = 0x00 ; backlight off symbol uLCD_lcd_cmd_bl_dm = 0x01 ; backlight dim symbol uLCD_lcd_cmd_bl_on = 0x02 ; backlight bright symbol uLCD_lcd_cmd_ds = 0x01 ; display control symbol uLCD_lcd_cmd_ds_off = 0x00 ; display off symbol uLCD_lcd_cmd_ds_on = 0x01 ; display on symbol uLCD_lcd_cmd_pwr = 0x03 ; power control symbol uLCD_lcd_cmd_pwr_off = 0x00; power off symbol uLCD_lcd_cmd_pwr_on = 0x01 ; power on main: ; startup the lcd gosub uLCD_Start ; store my name in the str buffer b11 = uLCD_str_start poke b11,"P" b11 = b11 + 1 poke b11,"a" b11 = b11 + 1 poke b11,"u" b11 = b11 + 1 poke b11,"l" b11 = b11 + 1 poke b11," " b11 = b11 + 1 poke b11,"C" b11 = b11 + 1 poke b11,"h" b11 = b11 + 1 poke b11,"u" b11 = b11 + 1 poke b11,"b" b11 = b11 + 1 poke b11,"b" ; print in three sizes for b4 = 0 to 2 ; set the font sizes b0 = uLCD_fnt_cmd b1 = b4 gosub uLCD_2char ; output the text b7 = 0 b8 = b4 gosub uLCD_txtout debug next b4 ; wait a bit so I can see it on the screen wait 5 ; shut the screen down b0 = uLCD_lcd_cmd b1 = uLCD_lcd_cmd_pwr b2 = uLCD_lcd_cmd_pwr_off gosub uLCD_3char ; stop everything end ;-------------------------------------------------------------- ; ; uLCD routines ; ;-------------------------------------------------------------- ; ; to productionize: ; ; 1) add colour table to either the eeprom or the pic data area ; 2) alter text output to lookup the table for the colour values ; 3) implement background colour or use uLCD_3char ; ; ;; uLCD_Start ;; ;; sends 'U' for sync and then falls through to uLCD_clrscr ;; uses: ;; in: ;; out ; uLCD_Start: ; setup the comms etc pause uLCD_wakeup_pause high uLCD_out_pin pause uLCD_high_pause ;sync the speed serout uLCD_out_pin, uLCD_speed,(uLCD_sync) serin uLCD_in_pin,uLCD_speed,b0 ; drop through to clrscr ; ;; uLCD_clrscr ;; ;; sends 'E' to clear the screen. Calls uLCD_outch ;; uses: ;; in: ;; out: b0 ; uLCD_clrscr: uLCD_retry_clrscr: serout uLCD_out_pin, uLCD_speed,(uLCD_clrscrn) serin uLCD_in_pin,uLCD_speed,b0 if b0 = uLCD_nack then uLCD_retry_clrscr return ; ;; uLCD_txtout ;; ;; write text in the text buffer at a specified location ;; ;; uses b0, b10 ;; in: b7 (xcoord), b8 (ycoord) (b9 reserved for colour table index) b11 (str end) ;; out: b0,b7 ;; ; uLCD_txtout: for b10 = uLCD_str_start to b11 uLCD_retry_txtout: peek b10,b0 high uLCD_out_pin serout uLCD_out_pin, uLCD_speed,("T",b0,b7,b8,0,0) serin uLCD_in_pin, uLCD_speed, b0 if b0 = uLCD_nack then uLCD_retry_txtout b7 = b7 + 1 next b10 ; low uLCD_out_pin return ; ;; uLCD_2char ;; ;; do a two char cmd. ;; ;; uses: ;; in b0, b1 ;; out: b0 ;; ; uLCD_2char: uLCD_retry_2char: serout uLCD_out_pin, uLCD_speed,(b0,b1) serin uLCD_in_pin, uLCD_speed, b0 if b0 = uLCD_nack then uLCD_retry_2char return ; ;; uLCD_3char ;; ;; do a two char cmd. ;; ;; uses: ;; in b0, b1, b2 ;; out: b0 ;; ; uLCD_3char: uLCD_retry_3char: serout uLCD_out_pin, uLCD_speed,(b0,b1,b2) serin uLCD_in_pin, uLCD_speed, b0 if b0 = uLCD_nack then uLCD_retry_3char return