2023-12-08 22:56:35 +01:00
|
|
|
;********************************************************************************
|
|
|
|
; @module LCD-W164B
|
|
|
|
; @type driver
|
|
|
|
; @device ELECTRONIC ASSEMBLY - W164B-NLW
|
|
|
|
; @details
|
|
|
|
; The LCD must be connected to a W65C22N Interface Chip:
|
|
|
|
; - IO.RB0-7 -> LCD.D0-7 data lines
|
|
|
|
; - IO.RA5 -> LCD.RS register select
|
|
|
|
; - IO.RA6 -> LCD.R/W read/write
|
|
|
|
; - IO.RA7 -> LCD.E enable
|
|
|
|
;
|
|
|
|
; @requires IO: Base Address of IO Chip
|
|
|
|
; @depends IO-W65C22N
|
|
|
|
;********************************************************************************
|
|
|
|
.ifndef INCLUDE_LCD
|
|
|
|
INCLUDE_LCD = 1
|
|
|
|
|
|
|
|
.include "system/system.h65"
|
|
|
|
|
|
|
|
.scope lcd
|
|
|
|
LCD_IO = IO1
|
2023-12-16 02:41:19 +01:00
|
|
|
Import lcd,init,clear,print,print_char,set_position,set_custom_char
|
|
|
|
Import lcd,_cmd,_wait_nbusy,_write_ram,_read_ram
|
2023-12-08 22:56:35 +01:00
|
|
|
|
|
|
|
;********************************************************************************
|
2023-12-16 02:41:19 +01:00
|
|
|
; @macro Clear the screen and print a null-terminated string
|
2023-12-08 22:56:35 +01:00
|
|
|
; @param message: Address of the message
|
|
|
|
;********************************************************************************
|
|
|
|
.macro Print message
|
|
|
|
jsr lcd::clear
|
|
|
|
lda #<message
|
|
|
|
sta ARG0
|
|
|
|
lda #>message
|
|
|
|
sta ARG1
|
|
|
|
jsr lcd::print
|
|
|
|
.endmacro
|
|
|
|
|
2023-12-16 02:41:19 +01:00
|
|
|
|
|
|
|
;********************************************************************************
|
|
|
|
; @macro Print a null-terminated string
|
|
|
|
; @param message: Address of the message
|
|
|
|
;********************************************************************************
|
|
|
|
.macro PrintNC message
|
|
|
|
lda #<message
|
|
|
|
sta ARG0
|
|
|
|
lda #>message
|
|
|
|
sta ARG1
|
|
|
|
jsr lcd::print
|
|
|
|
.endmacro
|
|
|
|
|
2023-12-08 22:56:35 +01:00
|
|
|
; PIN MASKS
|
|
|
|
E = %10000000
|
|
|
|
RW = %01000000
|
|
|
|
RS = %00100000
|
|
|
|
|
2023-12-16 02:41:19 +01:00
|
|
|
RA_MASK = %11100000
|
|
|
|
|
2023-12-08 22:56:35 +01:00
|
|
|
; LCD Instructions (see datasheet for more)
|
|
|
|
CMD_CLEAR = %00000001 ; clear display
|
|
|
|
CMD_ENTRY_MODE = %00000110 ; auto-shift cursor
|
|
|
|
CMD_DISPLAY_ON = %00001111 ; everything on, with blinking cursor
|
2023-12-16 02:41:19 +01:00
|
|
|
CMD_SHIFT_CUR_LEFT = %00101000 ; shift the display to the left
|
|
|
|
CMD_SHIFT_DIS_LEFT = %00111000 ; shift the display to the left
|
|
|
|
CMD_SHIFT_DIS_RIGHT = %00110000 ; shift the display to the right
|
|
|
|
CMD_SHIFT_CUR_RIGHT = %00100000 ; shift the display to the right
|
2023-12-08 22:56:35 +01:00
|
|
|
CMD_FUNCTION_SET = %00111000 ; 8-bit, 4 lines, 5x7 font
|
2023-12-16 02:41:19 +01:00
|
|
|
CMD_SET_CG_ADDRESS = %01000000 ; or with the address
|
2023-12-08 22:56:35 +01:00
|
|
|
CMD_SET_ADDRESS = %10000000 ; or with the address
|
|
|
|
; LCD Constants
|
|
|
|
LINE1 = $00
|
|
|
|
LINE2 = $40
|
|
|
|
LINE3 = $10
|
|
|
|
LINE4 = $50
|
|
|
|
|
|
|
|
.endscope
|
|
|
|
.endif ; guard
|