Hi :)
According to my calculations, this code works first go in PBP without even testing it :D
If that’s found not to be the case, please let me know, and I’ll fix it.
This was written in C, and ported from there. It is NOT disassembled PBP code.
According to my calculations, this code works first go in PBP without even testing it :D
If that’s found not to be the case, please let me know, and I’ll fix it.
This was written in C, and ported from there. It is NOT disassembled PBP code.
Code:
'
'****************************************************************
'* *
'* PBP LCDOUT Replacement Functions *
'* Brek Martin (Art) 2019 *
'* *
'****************************************************************
'
'define your own LCD pin aliases here
'and set tris registers for output ports
'
arg var byte 'function arguments
nib var byte '
cnt var byte 'counter
worka var word 'work variables
workb var byte '
line var byte[16] 'string array
RS_PIN = 1 '
E_PIN = 1 '
pause 1000 'full second delay before talking to the LCD at all
'
'******************************************************************************
‘
gosub lcdinit
'
line[0] = 'H' 'set data
line[1] = 'e'
line[2] = 'l'
line[3] = 'l'
line[4] = 'o'
'
arg = $02 : gosub fsend_command_byte 'go to start of line 1 - Hex $80 is first line $02 home
for cnt = 0 to 4 'print line 1
arg = line[cnt] : gosub send_data_byte
next cnt
'
worka = 12345 'set data (this data is destroyed)
workb = 10000 '
'
arg = $C0 : gosub fsend_command_byte 'go to start of line 2
'
for cnt = 0 to 5
arg = worka / workb : gosub send_data_byte
worka = worka - workb
workb = workb / 10
next cnt
'
'******************************************************************************
'
' HD44780 lcd functions
'
lcdinit: 'module initialisation sequence for 4 bit interface
pause 16 ' must be more than 15ms
nib = %0011 : gosub send_nibble
pause 6 ' must be more than 4.1ms
nib = %0011 : gosub send_nibble
pause 3 ' must be more than 100us
nib = %0011 : gosub send_nibble
pause 6 ' must be more than 4.1ms
nib = %0010 : gosub send_nibble 'set 4 bit mode
'2x16 character LCD display settings
arg = %00101000 : gosub send_command_byte 'N=0 : 2 lines F=0 : 5x7 font
arg = %00001000 : gosub send_command_byte 'display: display off, cursor off, blink off
arg = %00000001 : gosub send_command_byte 'clear display
arg = %00000110 : gosub send_command_byte 'set entry mode
arg = %00001100 : gosub send_command_byte 'display: display on
return
'
'
send_nibble:
E_PIN = 0
portb = (portb & $FFF0) | (nib ^ $F)
pause 2
E_PIN = 1
pause 2 'enough time for slowest command
return
'
'
send_command_byte:
RS_PIN = 1
nib = arg >> 4 : gosub send_nibble
nib = arg & $F : gosub send_nibble
return
'
'
send_data_byte:
RS_PIN = 0
nib = arg >> 4 : gosub send_nibble
nib = arg & $F : gosub send_nibble
return
'
'
'******************************************************************************
'
'