LCD: moved address definition to main file.

This commit is contained in:
Martin Preuss
2023-01-30 01:02:04 +01:00
parent b4f16dd987
commit 89f403f602

View File

@@ -24,8 +24,6 @@
; ***************************************************************************
; defines
.equ LCD_TWI_ADDRESS = 0x3c
.equ LCD_WIDTH = 128
.equ LCD_HEIGHT = 64
@@ -86,6 +84,12 @@ LCD_Init:
ldi zh, HIGH(lcdHelloMsg)
rcall LCD_PrintFromFlash
; set cursor to next line here, sometimes this doesn't work correctly
; when called later. TODO: find out what goes wrong here...
ldi r18, 0
ldi r19, 2
rcall LCD_SetCursor
sec
ret
@@ -117,7 +121,7 @@ LCD_Fini:
; - R19: Y
; OUT:
; - CFLAG: set if okay, cleared otherwise
; REGS: r1, r2, r16 (R16, R17, R18, R22)
; REGS: r1, r2, r15, r16 (R16, R17, R18, R22)
LCD_SetCursor:
in r15, SREG
@@ -173,6 +177,7 @@ LCD_SetCursor_error:
LCD_Fill:
in r15, SREG
push r15
cli
mov r20, r16
@@ -204,11 +209,13 @@ LCD_Fill_loopX:
inc r21
cpi r21, LCD_PAGE_COUNT
brcs LCD_Fill_loopY
pop r15
out SREG, r15
sec
ret
LCD_Fill_error:
rcall twiStop
pop r15
out SREG, r15
clc
ret
@@ -228,6 +235,7 @@ LCD_Fill_error:
LCD_PrintFromFlash:
in r15, SREG
push r15
cli
lsl zl
rol zh
@@ -252,12 +260,14 @@ LCD_PrintFromFlash_loop:
rjmp LCD_PrintFromFlash_loop
LCD_PrintFromFlash_end:
rcall twiStop
pop r15
out SREG, r15
sec
ret
LCD_PrintFromFlash_error:
rcall twiStop
pop r15
out SREG, r15
clc
ret
@@ -302,7 +312,7 @@ LCD_PrintChar_error:
; ---------------------------------------------------------------------------
; LCD_PrintHexByte
;
; Convert a give byte into HEX and write it to the current position.
; Convert a given byte into HEX and write it to the current position.
;
; IN:
; - R16: byte to convert to hex
@@ -311,6 +321,7 @@ LCD_PrintChar_error:
LCD_PrintHexByte:
in r15, SREG
push r15
cli
mov r20, r16
rcall twiStart
@@ -324,11 +335,13 @@ LCD_PrintHexByte:
rcall lcdPrintHexByte
brcc LCD_PrintHexByte_error
rcall twiStop
pop r15
out SREG, r15
sec
ret
LCD_PrintHexByte_error:
rcall twiStop
pop r15
out SREG, r15
clc
ret
@@ -349,29 +362,33 @@ LCD_PrintHexByte_error:
LCD_PrintHexWord:
in r15, SREG
push r15
cli
push r18
push r19
rcall twiStart
ldi r16, (LCD_TWI_ADDRESS*2)
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_PrintHexWord_error
brcc LCD_PrintHexWord_errorPop
ldi r16, LCD_DATA_MODE
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_PrintHexWord_error
brcc LCD_PrintHexWord_errorPop
pop r19
pop r18
rcall lcdPrintHexWord
brcc LCD_PrintHexWord_error
brcc LCD_PrintHexWord_errorNoPop
rcall twiStop
pop r15
out SREG, r15
sec
ret
LCD_PrintHexWord_error:
LCD_PrintHexWord_errorPop:
rcall twiStop
pop r19
pop r18
LCD_PrintHexWord_errorNoPop:
pop r15
out SREG, r15
clc
ret