ili9341: added routine to write a char in double height/width.
This commit is contained in:
@@ -105,8 +105,7 @@ ILI9341_Init:
|
||||
|
||||
; set character
|
||||
ldi r16, 65
|
||||
|
||||
rcall ili9341_WriteCharacterAt
|
||||
rcall ili9341_WriteCharacterX2At
|
||||
|
||||
sec
|
||||
ret
|
||||
@@ -360,9 +359,27 @@ ili9341SetAddressWindow:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ili9341_WriteStringX1At
|
||||
|
||||
; @param R16 character to write
|
||||
; @param r19:r18 X pos
|
||||
; @param r21:r20 Y pos
|
||||
; @param R01:R00 background color
|
||||
; @param R03:R02 foreground color
|
||||
; @param Z pointer to font
|
||||
; @param Y pointer to RAM to store data to
|
||||
; @clobbers
|
||||
|
||||
ili9341_WriteStringX1At:
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ili9341_WriteCharacterAt
|
||||
; @routine ili9341_WriteCharacterX1At
|
||||
|
||||
; @param R16 character to write
|
||||
; @param r19:r18 X pos
|
||||
@@ -373,13 +390,14 @@ ili9341SetAddressWindow:
|
||||
; @param Y pointer to RAM to store data to
|
||||
; @clobbers
|
||||
|
||||
ili9341_WriteCharacterAt:
|
||||
ili9341_WriteCharacterX1At:
|
||||
push xl
|
||||
push xh
|
||||
rcall ili9341WriteCharacterFromFont8x8 ; (r17, r24, r25, x, z)
|
||||
rcall ili9341WriteCharacterFromFont8x8x1 ; (r17, r24, r25, x, z)
|
||||
pop xh
|
||||
pop xl
|
||||
ldi r17, 7
|
||||
|
||||
; calc X1
|
||||
mov r22, r18
|
||||
mov r23, r19
|
||||
@@ -398,12 +416,12 @@ ili9341_WriteCharacterAt:
|
||||
ldi r16, ILI9341_CMD_RAMWR ; start writing ro RAM
|
||||
rcall ili9341SendCommand
|
||||
ldi r17, 64 ; 8x8
|
||||
ili9341_WriteCharacterAt_loop:
|
||||
ili9341_WriteCharacterX1At_loop:
|
||||
ld r18, X+
|
||||
ld r19, X+
|
||||
rcall ili9341Send16BitData
|
||||
dec r17
|
||||
brne ili9341_WriteCharacterAt_loop
|
||||
brne ili9341_WriteCharacterX1At_loop
|
||||
rcall ili9341EndSpi
|
||||
ret
|
||||
; @end
|
||||
@@ -411,7 +429,57 @@ ili9341_WriteCharacterAt_loop:
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ili9341WriteCharacterFromFont8x8
|
||||
; @routine ili9341_WriteCharacterX2At
|
||||
|
||||
; @param R16 character to write
|
||||
; @param r19:r18 X pos
|
||||
; @param r21:r20 Y pos
|
||||
; @param R01:R00 background color
|
||||
; @param R03:R02 foreground color
|
||||
; @param X pointer to font
|
||||
; @param Y pointer to RAM to store data to
|
||||
; @clobbers
|
||||
|
||||
ili9341_WriteCharacterX2At:
|
||||
push xl
|
||||
push xh
|
||||
rcall ili9341WriteCharacterFromFont8x8x2 ; (r17, r24, r25, x, z)
|
||||
pop xh
|
||||
pop xl
|
||||
ldi r17, 15
|
||||
|
||||
; calc X1
|
||||
mov r22, r18
|
||||
mov r23, r19
|
||||
add r22, r17
|
||||
adc r23, r17
|
||||
sub r23, r17
|
||||
; calc Y1
|
||||
mov r24, r20
|
||||
mov r25, r21
|
||||
add r24, r17
|
||||
adc r25, r17
|
||||
sub r25, r17
|
||||
|
||||
rcall ili9341BeginSpi ; (r16, r17)
|
||||
rcall ili9341SetAddressWindow ; (R16)
|
||||
ldi r16, ILI9341_CMD_RAMWR ; start writing ro RAM
|
||||
rcall ili9341SendCommand
|
||||
ldi r17, 0 ; 256 bytes
|
||||
ili9341_WriteCharacterX2At_loop:
|
||||
ld r18, X+
|
||||
ld r19, X+
|
||||
rcall ili9341Send16BitData
|
||||
dec r17
|
||||
brne ili9341_WriteCharacterX2At_loop
|
||||
rcall ili9341EndSpi
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ili9341WriteCharacterFromFont8x8x1
|
||||
|
||||
; @param R16 character to write
|
||||
; @param R01:R00 background color
|
||||
@@ -420,18 +488,97 @@ ili9341_WriteCharacterAt_loop:
|
||||
; @param X pointer to RAM to store data to
|
||||
; @clobbers r17, r24, r25, x, z
|
||||
|
||||
ili9341WriteCharacterFromFont8x8:
|
||||
ili9341WriteCharacterFromFont8x8x1:
|
||||
rcall ili9341GetCharPosInFont8x8 ; (r17, r24, r25, z)
|
||||
ldi r25, 8 ; 8 bytes
|
||||
ili9341WriteCharacterFromFont8x8x1_loop1:
|
||||
ldi r24, 8 ; 8 bits
|
||||
lpm r17, Z+
|
||||
ili9341WriteCharacterFromFont8x8x1_loop2:
|
||||
lsr r17
|
||||
brcs ili9341WriteCharacterFromFont8x8x1_writeForeground
|
||||
st X+, r0
|
||||
st X+, r1
|
||||
rjmp ili9341WriteCharacterFromFont8x8x1_loop2end
|
||||
ili9341WriteCharacterFromFont8x8x1_writeForeground:
|
||||
st X+, r2
|
||||
st X+, r3
|
||||
ili9341WriteCharacterFromFont8x8x1_loop2end:
|
||||
dec r24
|
||||
brne ili9341WriteCharacterFromFont8x8x1_loop2
|
||||
dec r25
|
||||
brne ili9341WriteCharacterFromFont8x8x1_loop1
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ili9341WriteCharacterFromFont8x8x2
|
||||
|
||||
; @param R16 character to write
|
||||
; @param R01:R00 background color
|
||||
; @param R03:R02 foreground color
|
||||
; @param Z pointer to font
|
||||
; @param X pointer to RAM to store data to
|
||||
; @clobbers r17, r22, r23, r24, r25, x, z
|
||||
|
||||
ili9341WriteCharacterFromFont8x8x2:
|
||||
rcall ili9341GetCharPosInFont8x8 ; (r17, r24, r25, z)
|
||||
ldi r25, 8 ; 8 bytes
|
||||
ili9341WriteCharacterFromFont8x8x2_loop1:
|
||||
ldi r24, 8 ; 8 bits
|
||||
lpm r17, Z+
|
||||
ili9341WriteCharacterFromFont8x8x2_loop2:
|
||||
lsr r17
|
||||
brcs ili9341WriteCharacterFromFont8x8x2_writeForeground
|
||||
mov r22, r0
|
||||
mov r23, r1
|
||||
rjmp ili9341WriteCharacterFromFont8x8x2_loop2end
|
||||
ili9341WriteCharacterFromFont8x8x2_writeForeground:
|
||||
mov r22, r2
|
||||
mov r23, r3
|
||||
ili9341WriteCharacterFromFont8x8x2_loop2end:
|
||||
st X+, r22
|
||||
st X+, r23
|
||||
st X+, r22
|
||||
st X+, r23
|
||||
adiw xh:xl, 28 ; move to next row (8*4)-4
|
||||
st X+, r22
|
||||
st X+, r23
|
||||
st X+, r22
|
||||
st X+, r23
|
||||
sbiw xh:xl, 32 ; move back to previous row
|
||||
dec r24
|
||||
brne ili9341WriteCharacterFromFont8x8x2_loop2
|
||||
adiw xh:xl, 32 ; skip next line (we already wrote it)
|
||||
dec r25
|
||||
brne ili9341WriteCharacterFromFont8x8x2_loop1
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ili9341GetCharPosInFont8x8
|
||||
|
||||
; @param R16 character to write
|
||||
; @param Z pointer to font
|
||||
; @return Z pointer to begin of char data
|
||||
; @clobbers r17, r24, r25, z
|
||||
|
||||
ili9341GetCharPosInFont8x8:
|
||||
mov r24, r16
|
||||
lpm r17, Z+ ; first char num
|
||||
sub r24, r17
|
||||
brcc ili9341WriteCharacterFromFont8x8_firstValueOkay
|
||||
clr r24 ; use first char
|
||||
adiw zh:zl, 1
|
||||
rjmp ili9341WriteCharacterFromFont8x8_transform ; skip next test
|
||||
ili9341WriteCharacterFromFont8x8_firstValueOkay:
|
||||
brcc ili9341GetCharPosInFont8x8_firstValueOkay
|
||||
adiw zh:zl, 1 ; use first char
|
||||
ret
|
||||
ili9341GetCharPosInFont8x8_firstValueOkay:
|
||||
lpm r17, Z+
|
||||
cp r24, r17
|
||||
brcc ili9341WriteCharacterFromFont8x8_transform ; use first char
|
||||
brcs ili9341WriteCharacterFromFont8x8_gotPos
|
||||
ret
|
||||
ili9341WriteCharacterFromFont8x8_gotPos:
|
||||
clr r25
|
||||
lsl r24 ; R16x8
|
||||
@@ -442,25 +589,6 @@ ili9341WriteCharacterFromFont8x8_gotPos:
|
||||
rol r25
|
||||
add zl, r24
|
||||
adc zh, r25
|
||||
ili9341WriteCharacterFromFont8x8_transform:
|
||||
ldi r25, 8 ; 8 bytes
|
||||
ili9341WriteCharacterFromFont8x8_loop1:
|
||||
ldi r24, 8 ; 8 bits
|
||||
lpm r17, Z+
|
||||
ili9341WriteCharacterFromFont8x8_loop2:
|
||||
lsr r17
|
||||
brcs ili9341WriteCharacterFromFont8x8_writeForeground
|
||||
st X+, r0
|
||||
st X+, r1
|
||||
rjmp ili9341WriteCharacterFromFont8x8_loop2end
|
||||
ili9341WriteCharacterFromFont8x8_writeForeground:
|
||||
st X+, r2
|
||||
st X+, r3
|
||||
ili9341WriteCharacterFromFont8x8_loop2end:
|
||||
dec r24
|
||||
brne ili9341WriteCharacterFromFont8x8_loop2
|
||||
dec r25
|
||||
brne ili9341WriteCharacterFromFont8x8_loop1
|
||||
ret
|
||||
; @end
|
||||
|
||||
@@ -716,6 +844,9 @@ ili9341InitCommands:
|
||||
.db 0xff, 0xff
|
||||
|
||||
|
||||
helloWorld: .db "Hello World", 0
|
||||
|
||||
|
||||
|
||||
.include "modules/lcd2/ili9341/font1.asm"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user