more generalisation of font code.
This commit is contained in:
@@ -156,10 +156,13 @@
|
||||
.include "modules/lcd2/ili9341/defs.asm"
|
||||
.include "modules/lcd2/ili9341/main.asm"
|
||||
.include "modules/lcd2/ili9341/io_spi.asm"
|
||||
.include "modules/lcd2/ili9341/font8x8.asm"
|
||||
.include "modules/lcd2/ili9341/text.asm"
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_FONT_8X8
|
||||
.include "modules/lcd2/font/defs.asm"
|
||||
.include "modules/lcd2/font/font8x8.asm"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef APPS_MOTION
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#define MODULES_UART_HW
|
||||
#define MODULES_SPI_HW
|
||||
#define MODULES_ILI9341
|
||||
#define MODULES_FONT_8X8
|
||||
;#define MODULES_UART_BITBANG
|
||||
;#define MODULES_TWI_MASTER
|
||||
;#define MODULES_LCD
|
||||
@@ -202,7 +203,7 @@ onEveryLoop:
|
||||
.include "devices/all/hw_m8515.asm"
|
||||
.include "devices/all/includes.asm"
|
||||
|
||||
;.include "common/debug.asm"
|
||||
.include "common/debug.asm"
|
||||
|
||||
|
||||
|
||||
|
||||
13
avr/modules/lcd2/font/0BUILD
Normal file
13
avr/modules/lcd2/font/0BUILD
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml?>
|
||||
|
||||
<gwbuild>
|
||||
|
||||
<extradist>
|
||||
defs.asm
|
||||
font8x8.asm
|
||||
font1.asm
|
||||
</extradist>
|
||||
|
||||
</gwbuild>
|
||||
|
||||
|
||||
20
avr/modules/lcd2/font/defs.asm
Normal file
20
avr/modules/lcd2/font/defs.asm
Normal file
@@ -0,0 +1,20 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
|
||||
.equ FONT_OFFS_RENDERFN_LOW = 0
|
||||
.equ FONT_OFFS_RENDERFN_HI = 1
|
||||
.equ FONT_OFFS_DATASIZE = 2 ; one byte used, one byte reserved
|
||||
.equ FONT_OFFS_WIDTH = 4
|
||||
.equ FONT_OFFS_HEIGHT = 5
|
||||
.equ FONT_OFFS_FIRSTCHAR = 6
|
||||
.equ FONT_OFFS_NUMCHARS = 7
|
||||
|
||||
|
||||
100
avr/modules/lcd2/font/font1.asm
Normal file
100
avr/modules/lcd2/font/font1.asm
Normal file
@@ -0,0 +1,100 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; This is a font from the project LCD_fonts at
|
||||
; https://github.com/basti79/LCD-fonts.git
|
||||
; which in turn is based on a post by Benedikt K. in a forum post on
|
||||
; https://www.mikrocontroller.net/topic/54860
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
font1_8x8:
|
||||
; header
|
||||
rjmp font8x8MonoRenderCharacter ; renderFn
|
||||
.db 128, 0 ; needed buffer size
|
||||
.db 8, 8 ; width, height of chars
|
||||
.db 32, 64 ; first char, num of chars in font
|
||||
; data
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x20
|
||||
.db 0x0C,0x1E,0x1E,0x0C,0x0C,0x00,0x0C,0x00, ; 0x21
|
||||
.db 0x36,0x36,0x36,0x00,0x00,0x00,0x00,0x00, ; 0x22
|
||||
.db 0x36,0x36,0x7F,0x36,0x7F,0x36,0x36,0x00, ; 0x23
|
||||
.db 0x0C,0x3E,0x03,0x1E,0x30,0x1F,0x0C,0x00, ; 0x24
|
||||
.db 0x00,0x63,0x33,0x18,0x0C,0x66,0x63,0x00, ; 0x25
|
||||
.db 0x1C,0x36,0x1C,0x6E,0x3B,0x33,0x6E,0x00, ; 0x26
|
||||
.db 0x06,0x06,0x03,0x00,0x00,0x00,0x00,0x00, ; 0x27
|
||||
.db 0x18,0x0C,0x06,0x06,0x06,0x0C,0x18,0x00, ; 0x28
|
||||
.db 0x06,0x0C,0x18,0x18,0x18,0x0C,0x06,0x00, ; 0x29
|
||||
.db 0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00, ; 0x2A
|
||||
.db 0x00,0x0C,0x0C,0x3F,0x0C,0x0C,0x00,0x00, ; 0x2B
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x0E,0x0C,0x06, ; 0x2C
|
||||
.db 0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00, ; 0x2D
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00, ; 0x2E
|
||||
.db 0x60,0x30,0x18,0x0C,0x06,0x03,0x01,0x00, ; 0x2F
|
||||
.db 0x1E,0x33,0x3B,0x3F,0x37,0x33,0x1E,0x00, ; 0x30
|
||||
.db 0x0C,0x0F,0x0C,0x0C,0x0C,0x0C,0x3F,0x00, ; 0x31
|
||||
.db 0x1E,0x33,0x30,0x1C,0x06,0x33,0x3F,0x00, ; 0x32
|
||||
.db 0x1E,0x33,0x30,0x1C,0x30,0x33,0x1E,0x00, ; 0x33
|
||||
.db 0x38,0x3C,0x36,0x33,0x7F,0x30,0x30,0x00, ; 0x34
|
||||
.db 0x3F,0x03,0x1F,0x30,0x30,0x33,0x1E,0x00, ; 0x35
|
||||
.db 0x1C,0x06,0x03,0x1F,0x33,0x33,0x1E,0x00, ; 0x36
|
||||
.db 0x3F,0x33,0x30,0x18,0x0C,0x06,0x06,0x00, ; 0x37
|
||||
.db 0x1E,0x33,0x33,0x1E,0x33,0x33,0x1E,0x00, ; 0x38
|
||||
.db 0x1E,0x33,0x33,0x3E,0x30,0x18,0x0E,0x00, ; 0x39
|
||||
.db 0x00,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x00, ; 0x3A
|
||||
.db 0x00,0x00,0x0C,0x0C,0x00,0x0E,0x0C,0x06, ; 0x3B
|
||||
.db 0x18,0x0C,0x06,0x03,0x06,0x0C,0x18,0x00, ; 0x3C
|
||||
.db 0x00,0x00,0x3F,0x00,0x3F,0x00,0x00,0x00, ; 0x3D
|
||||
.db 0x06,0x0C,0x18,0x30,0x18,0x0C,0x06,0x00, ; 0x3E
|
||||
.db 0x1E,0x33,0x30,0x18,0x0C,0x00,0x0C,0x00, ; 0x3F
|
||||
.db 0x3E,0x63,0x7B,0x7B,0x7B,0x03,0x1E,0x00, ; 0x40
|
||||
.db 0x0C,0x1E,0x33,0x33,0x3F,0x33,0x33,0x00, ; 0x41
|
||||
.db 0x3F,0x66,0x66,0x3E,0x66,0x66,0x3F,0x00, ; 0x42
|
||||
.db 0x3C,0x66,0x03,0x03,0x03,0x66,0x3C,0x00, ; 0x43
|
||||
.db 0x3F,0x36,0x66,0x66,0x66,0x36,0x3F,0x00, ; 0x44
|
||||
.db 0x7F,0x46,0x16,0x1E,0x16,0x46,0x7F,0x00, ; 0x45
|
||||
.db 0x7F,0x46,0x16,0x1E,0x16,0x06,0x0F,0x00, ; 0x46
|
||||
.db 0x3C,0x66,0x03,0x03,0x73,0x66,0x7C,0x00, ; 0x47
|
||||
.db 0x33,0x33,0x33,0x3F,0x33,0x33,0x33,0x00, ; 0x48
|
||||
.db 0x1E,0x0C,0x0C,0x0C,0x0C,0x0C,0x1E,0x00, ; 0x49
|
||||
.db 0x78,0x30,0x30,0x30,0x33,0x33,0x1E,0x00, ; 0x4A
|
||||
.db 0x67,0x66,0x36,0x1E,0x36,0x66,0x67,0x00, ; 0x4B
|
||||
.db 0x0F,0x06,0x06,0x06,0x46,0x66,0x7F,0x00, ; 0x4C
|
||||
.db 0x63,0x77,0x7F,0x6B,0x63,0x63,0x63,0x00, ; 0x4D
|
||||
.db 0x63,0x67,0x6F,0x7B,0x73,0x63,0x63,0x00, ; 0x4E
|
||||
.db 0x1C,0x36,0x63,0x63,0x63,0x36,0x1C,0x00, ; 0x4F
|
||||
.db 0x3F,0x66,0x66,0x3E,0x06,0x06,0x0F,0x00, ; 0x50
|
||||
.db 0x1E,0x33,0x33,0x33,0x3B,0x1E,0x38,0x00, ; 0x51
|
||||
.db 0x3F,0x66,0x66,0x3E,0x1E,0x36,0x67,0x00, ; 0x52
|
||||
.db 0x1E,0x33,0x07,0x1C,0x38,0x33,0x1E,0x00, ; 0x53
|
||||
.db 0x3F,0x2D,0x0C,0x0C,0x0C,0x0C,0x1E,0x00, ; 0x54
|
||||
.db 0x33,0x33,0x33,0x33,0x33,0x33,0x3F,0x00, ; 0x55
|
||||
.db 0x33,0x33,0x33,0x33,0x33,0x1E,0x0C,0x00, ; 0x56
|
||||
.db 0x63,0x63,0x63,0x6B,0x7F,0x77,0x63,0x00, ; 0x57
|
||||
.db 0x63,0x63,0x36,0x1C,0x36,0x63,0x63,0x00, ; 0x58
|
||||
.db 0x33,0x33,0x33,0x1E,0x0C,0x0C,0x1E,0x00, ; 0x59
|
||||
.db 0x7F,0x33,0x19,0x0C,0x46,0x63,0x7F,0x00, ; 0x5A
|
||||
.db 0x1E,0x06,0x06,0x06,0x06,0x06,0x1E,0x00, ; 0x5B
|
||||
.db 0x03,0x06,0x0C,0x18,0x30,0x60,0x40,0x00, ; 0x5C
|
||||
.db 0x1E,0x18,0x18,0x18,0x18,0x18,0x1E,0x00, ; 0x5D
|
||||
.db 0x08,0x1C,0x36,0x63,0x00,0x00,0x00,0x00, ; 0x5E
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF ; 0x5F
|
||||
|
||||
|
||||
|
||||
97
avr/modules/lcd2/font/font8x8.asm
Normal file
97
avr/modules/lcd2/font/font8x8.asm
Normal file
@@ -0,0 +1,97 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine font8x8RenderCharacter
|
||||
|
||||
; @param R16 character to write
|
||||
; @param R1:R0 background color
|
||||
; @param R3:R2 foreground color
|
||||
; @param Z pointer to font
|
||||
; @param X pointer to RAM to store data to
|
||||
; @param r18 char width in pixel
|
||||
; @param r19 char height in pixel
|
||||
; @clobbers r17, r24, r25, x
|
||||
|
||||
font8x8MonoRenderCharacter:
|
||||
push zl
|
||||
push zh
|
||||
lsl zl
|
||||
rol zh
|
||||
|
||||
rcall font8x8GetCharPosInFont8x8 ; (r17, r24, r25, z)
|
||||
ldi r25, 8 ; 8 bytes
|
||||
font8x8MonoRenderCharacter_loop1:
|
||||
ldi r24, 8 ; 8 bits
|
||||
lpm r17, Z+
|
||||
font8x8MonoRenderCharacter_loop2:
|
||||
lsr r17
|
||||
brcs font8x8MonoRenderCharacter_writeForeground
|
||||
st X+, r0
|
||||
st X+, r1
|
||||
rjmp font8x8MonoRenderCharacter_loop2end
|
||||
font8x8MonoRenderCharacter_writeForeground:
|
||||
st X+, r2
|
||||
st X+, r3
|
||||
font8x8MonoRenderCharacter_loop2end:
|
||||
dec r24
|
||||
brne font8x8MonoRenderCharacter_loop2
|
||||
dec r25
|
||||
brne font8x8MonoRenderCharacter_loop1
|
||||
ldi r18, 8
|
||||
ldi r19, 8
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine font8x8GetCharPosInFont8x8
|
||||
|
||||
; @param R16 character to write
|
||||
; @param Z pointer to font
|
||||
; @return Z pointer to begin of char data
|
||||
; @clobbers r17, r24, r25, z
|
||||
|
||||
font8x8GetCharPosInFont8x8:
|
||||
mov r24, r16
|
||||
adiw zh:zl, FONT_OFFS_FIRSTCHAR
|
||||
lpm r24, Z+ ; first char num
|
||||
lpm r25, Z+ ; num of chars
|
||||
sub r16, r24
|
||||
brcs font8x8GetCharPosInFont8x8_ret
|
||||
cp r16, r25
|
||||
brcc font8x8GetCharPosInFont8x8_ret
|
||||
mov r24, r16
|
||||
clr r25
|
||||
lsl r24 ; x2
|
||||
rol r25
|
||||
lsl r24 ; x4
|
||||
rol r25
|
||||
lsl r24 ; x8
|
||||
rol r25
|
||||
add zl, r24
|
||||
adc zh, r25
|
||||
font8x8GetCharPosInFont8x8_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
|
||||
|
||||
|
||||
font8x8:
|
||||
.db 32, 64
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x20
|
||||
.db 0x0C,0x1E,0x1E,0x0C,0x0C,0x00,0x0C,0x00, ; 0x21
|
||||
.db 0x36,0x36,0x36,0x00,0x00,0x00,0x00,0x00, ; 0x22
|
||||
.db 0x36,0x36,0x7F,0x36,0x7F,0x36,0x36,0x00, ; 0x23
|
||||
.db 0x0C,0x3E,0x03,0x1E,0x30,0x1F,0x0C,0x00, ; 0x24
|
||||
.db 0x00,0x63,0x33,0x18,0x0C,0x66,0x63,0x00, ; 0x25
|
||||
.db 0x1C,0x36,0x1C,0x6E,0x3B,0x33,0x6E,0x00, ; 0x26
|
||||
.db 0x06,0x06,0x03,0x00,0x00,0x00,0x00,0x00, ; 0x27
|
||||
.db 0x18,0x0C,0x06,0x06,0x06,0x0C,0x18,0x00, ; 0x28
|
||||
.db 0x06,0x0C,0x18,0x18,0x18,0x0C,0x06,0x00, ; 0x29
|
||||
.db 0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00, ; 0x2A
|
||||
.db 0x00,0x0C,0x0C,0x3F,0x0C,0x0C,0x00,0x00, ; 0x2B
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x0E,0x0C,0x06, ; 0x2C
|
||||
.db 0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00, ; 0x2D
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00, ; 0x2E
|
||||
.db 0x60,0x30,0x18,0x0C,0x06,0x03,0x01,0x00, ; 0x2F
|
||||
.db 0x1E,0x33,0x3B,0x3F,0x37,0x33,0x1E,0x00, ; 0x30
|
||||
.db 0x0C,0x0F,0x0C,0x0C,0x0C,0x0C,0x3F,0x00, ; 0x31
|
||||
.db 0x1E,0x33,0x30,0x1C,0x06,0x33,0x3F,0x00, ; 0x32
|
||||
.db 0x1E,0x33,0x30,0x1C,0x30,0x33,0x1E,0x00, ; 0x33
|
||||
.db 0x38,0x3C,0x36,0x33,0x7F,0x30,0x30,0x00, ; 0x34
|
||||
.db 0x3F,0x03,0x1F,0x30,0x30,0x33,0x1E,0x00, ; 0x35
|
||||
.db 0x1C,0x06,0x03,0x1F,0x33,0x33,0x1E,0x00, ; 0x36
|
||||
.db 0x3F,0x33,0x30,0x18,0x0C,0x06,0x06,0x00, ; 0x37
|
||||
.db 0x1E,0x33,0x33,0x1E,0x33,0x33,0x1E,0x00, ; 0x38
|
||||
.db 0x1E,0x33,0x33,0x3E,0x30,0x18,0x0E,0x00, ; 0x39
|
||||
.db 0x00,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x00, ; 0x3A
|
||||
.db 0x00,0x00,0x0C,0x0C,0x00,0x0E,0x0C,0x06, ; 0x3B
|
||||
.db 0x18,0x0C,0x06,0x03,0x06,0x0C,0x18,0x00, ; 0x3C
|
||||
.db 0x00,0x00,0x3F,0x00,0x3F,0x00,0x00,0x00, ; 0x3D
|
||||
.db 0x06,0x0C,0x18,0x30,0x18,0x0C,0x06,0x00, ; 0x3E
|
||||
.db 0x1E,0x33,0x30,0x18,0x0C,0x00,0x0C,0x00, ; 0x3F
|
||||
.db 0x3E,0x63,0x7B,0x7B,0x7B,0x03,0x1E,0x00, ; 0x40
|
||||
.db 0x0C,0x1E,0x33,0x33,0x3F,0x33,0x33,0x00, ; 0x41
|
||||
.db 0x3F,0x66,0x66,0x3E,0x66,0x66,0x3F,0x00, ; 0x42
|
||||
.db 0x3C,0x66,0x03,0x03,0x03,0x66,0x3C,0x00, ; 0x43
|
||||
.db 0x3F,0x36,0x66,0x66,0x66,0x36,0x3F,0x00, ; 0x44
|
||||
.db 0x7F,0x46,0x16,0x1E,0x16,0x46,0x7F,0x00, ; 0x45
|
||||
.db 0x7F,0x46,0x16,0x1E,0x16,0x06,0x0F,0x00, ; 0x46
|
||||
.db 0x3C,0x66,0x03,0x03,0x73,0x66,0x7C,0x00, ; 0x47
|
||||
.db 0x33,0x33,0x33,0x3F,0x33,0x33,0x33,0x00, ; 0x48
|
||||
.db 0x1E,0x0C,0x0C,0x0C,0x0C,0x0C,0x1E,0x00, ; 0x49
|
||||
.db 0x78,0x30,0x30,0x30,0x33,0x33,0x1E,0x00, ; 0x4A
|
||||
.db 0x67,0x66,0x36,0x1E,0x36,0x66,0x67,0x00, ; 0x4B
|
||||
.db 0x0F,0x06,0x06,0x06,0x46,0x66,0x7F,0x00, ; 0x4C
|
||||
.db 0x63,0x77,0x7F,0x6B,0x63,0x63,0x63,0x00, ; 0x4D
|
||||
.db 0x63,0x67,0x6F,0x7B,0x73,0x63,0x63,0x00, ; 0x4E
|
||||
.db 0x1C,0x36,0x63,0x63,0x63,0x36,0x1C,0x00, ; 0x4F
|
||||
.db 0x3F,0x66,0x66,0x3E,0x06,0x06,0x0F,0x00, ; 0x50
|
||||
.db 0x1E,0x33,0x33,0x33,0x3B,0x1E,0x38,0x00, ; 0x51
|
||||
.db 0x3F,0x66,0x66,0x3E,0x1E,0x36,0x67,0x00, ; 0x52
|
||||
.db 0x1E,0x33,0x07,0x1C,0x38,0x33,0x1E,0x00, ; 0x53
|
||||
.db 0x3F,0x2D,0x0C,0x0C,0x0C,0x0C,0x1E,0x00, ; 0x54
|
||||
.db 0x33,0x33,0x33,0x33,0x33,0x33,0x3F,0x00, ; 0x55
|
||||
.db 0x33,0x33,0x33,0x33,0x33,0x1E,0x0C,0x00, ; 0x56
|
||||
.db 0x63,0x63,0x63,0x6B,0x7F,0x77,0x63,0x00, ; 0x57
|
||||
.db 0x63,0x63,0x36,0x1C,0x36,0x63,0x63,0x00, ; 0x58
|
||||
.db 0x33,0x33,0x33,0x1E,0x0C,0x0C,0x1E,0x00, ; 0x59
|
||||
.db 0x7F,0x33,0x19,0x0C,0x46,0x63,0x7F,0x00, ; 0x5A
|
||||
.db 0x1E,0x06,0x06,0x06,0x06,0x06,0x1E,0x00, ; 0x5B
|
||||
.db 0x03,0x06,0x0C,0x18,0x30,0x60,0x40,0x00, ; 0x5C
|
||||
.db 0x1E,0x18,0x18,0x18,0x18,0x18,0x1E,0x00, ; 0x5D
|
||||
.db 0x08,0x1C,0x36,0x63,0x00,0x00,0x00,0x00, ; 0x5E
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF ; 0x5F
|
||||
|
||||
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ili9341WriteCharacterFromFont8x8
|
||||
|
||||
; @param R16 character to write
|
||||
; @param R1:R0 background color
|
||||
; @param R3:R2 foreground color
|
||||
; @param Z pointer to font
|
||||
; @param X pointer to RAM to store data to
|
||||
; @clobbers r17, r24, r25, x, z
|
||||
|
||||
ili9341WriteCharacterFromFont8x8:
|
||||
rcall ili9341GetCharPosInFont8x8 ; (r17, r24, r25, z)
|
||||
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
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @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 ili9341GetCharPosInFont8x8_firstValueOkay
|
||||
adiw zh:zl, 1 ; use first char
|
||||
ret
|
||||
ili9341GetCharPosInFont8x8_firstValueOkay:
|
||||
lpm r17, Z+
|
||||
cp r24, r17
|
||||
brcs ili9341WriteCharacterFromFont8x8_gotPos
|
||||
ret
|
||||
ili9341WriteCharacterFromFont8x8_gotPos:
|
||||
clr r25
|
||||
lsl r24 ; R16x8
|
||||
rol r25
|
||||
lsl r24
|
||||
rol r25
|
||||
lsl r24
|
||||
rol r25
|
||||
add zl, r24
|
||||
adc zh, r25
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
@@ -97,8 +97,8 @@ ILI9341_Init:
|
||||
mov r7, r16
|
||||
|
||||
; set font pos
|
||||
ldi zl, LOW(font8x8*2)
|
||||
ldi zh, HIGH(font8x8*2)
|
||||
ldi zl, LOW(font1_8x8)
|
||||
ldi zh, HIGH(font1_8x8)
|
||||
|
||||
; set buffer pos
|
||||
; ldi xl, LOW(ILI9341_buffer)
|
||||
@@ -113,22 +113,22 @@ ILI9341_Init:
|
||||
|
||||
; set character
|
||||
ldi r16, 'A'
|
||||
rcall ili9341PrintChar
|
||||
rcall ili9341_WriteCharacterX4At
|
||||
|
||||
ldi r16, 'Q'
|
||||
rcall ili9341PrintChar
|
||||
rcall ili9341_WriteCharacterX4At
|
||||
|
||||
ldi r16, 'H'
|
||||
rcall ili9341PrintChar
|
||||
rcall ili9341_WriteCharacterX4At
|
||||
|
||||
ldi r16, 'O'
|
||||
rcall ili9341PrintChar
|
||||
rcall ili9341_WriteCharacterX4At
|
||||
|
||||
ldi r16, 'M'
|
||||
rcall ili9341PrintChar
|
||||
rcall ili9341_WriteCharacterX4At
|
||||
|
||||
ldi r16, 'E'
|
||||
rcall ili9341PrintChar
|
||||
rcall ili9341_WriteCharacterX4At
|
||||
|
||||
sec
|
||||
ret
|
||||
@@ -136,16 +136,6 @@ ILI9341_Init:
|
||||
|
||||
|
||||
|
||||
ili9341PrintChar:
|
||||
push zl
|
||||
push zh
|
||||
rcall ili9341_WriteCharacterX4At
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ILI9341_Fini @global
|
||||
|
||||
@@ -749,6 +739,6 @@ helloWorld: .db "Hello World", 0
|
||||
|
||||
|
||||
|
||||
.include "modules/lcd2/ili9341/font1.asm"
|
||||
.include "modules/lcd2/font/font1.asm"
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
; @param r7:r6 Y
|
||||
; @param r1:r0 background color
|
||||
; @param r3:r2 foreground color
|
||||
; @param Z pointer to font
|
||||
; @param Z pointer to font (word address!)
|
||||
; @param X pointer to RAM to store data to
|
||||
; @return r5:r4 new X (advanced by character width)
|
||||
; @clobbers r16 (r17, r20, r21, r22, r23, r24, r25, X)
|
||||
@@ -31,10 +31,9 @@
|
||||
ili9341_WriteCharacterX1At:
|
||||
rcall ili9341PrepareCharFromFont ; (r16, r17, r24, r25, z)
|
||||
rcall ili9341BitBlit ; (r16, r17, r20, r21, r22, r23, r24, r25, X)
|
||||
ldi r16, 8
|
||||
add r4, r16
|
||||
adc r5, r16
|
||||
sub r5, r16
|
||||
; advance X (add char width to X)
|
||||
add r4, r8
|
||||
adc r5, r9
|
||||
ret
|
||||
; @end
|
||||
|
||||
@@ -49,7 +48,7 @@ ili9341_WriteCharacterX1At:
|
||||
; @param r7:r6 Y
|
||||
; @param r1:r0 background color
|
||||
; @param r3:r2 foreground color
|
||||
; @param Z pointer to font
|
||||
; @param Z pointer to font (word address!)
|
||||
; @param X pointer to RAM to store data to
|
||||
; @return r5:r4 new X (advanced by character width)
|
||||
; @clobbers r16 (r17, r18, r19, r20, r21, r22, r23, r24, r25, X)
|
||||
@@ -57,10 +56,11 @@ ili9341_WriteCharacterX1At:
|
||||
ili9341_WriteCharacterX2At:
|
||||
rcall ili9341PrepareCharFromFont ; (r16, r17, r24, r25, z)
|
||||
rcall ili9341BitBlitStretch2 ; (r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, X)
|
||||
ldi r16, 16
|
||||
add r4, r16
|
||||
adc r5, r16
|
||||
sub r5, r16
|
||||
; advance X (add double char width to X)
|
||||
lsl r8 ; Wx2
|
||||
rol r9
|
||||
add r4, r8 ; add to X
|
||||
adc r5, r9
|
||||
ret
|
||||
; @end
|
||||
|
||||
@@ -74,18 +74,21 @@ ili9341_WriteCharacterX2At:
|
||||
; @param r7:r6 Y
|
||||
; @param r1:r0 background color
|
||||
; @param r3:r2 foreground color
|
||||
; @param Z pointer to font
|
||||
; @param Z pointer to font (word address!)
|
||||
; @param X pointer to RAM to store data to
|
||||
; @return r5:r4 new X (advanced by character width)
|
||||
; @clobbers r16, r17, r18, r19, r24, r25, x, z
|
||||
|
||||
ili9341_WriteCharacterX4At:
|
||||
rcall ili9341PrepareCharFromFont ; (r16, r17, r24, r25, z)
|
||||
rcall ili9341BitBlitStretch4
|
||||
ldi r16, 32
|
||||
add r4, r16
|
||||
adc r5, r16
|
||||
sub r5, r16
|
||||
rcall ili9341BitBlitStretch4 ; (r16, r17, r20, r21, r22, r23, r24, r25, X)
|
||||
; advance X (add quad char width to X)
|
||||
lsl r8 ; Wx2
|
||||
rol r9
|
||||
lsl r8 ; Wx4
|
||||
rol r9
|
||||
add r4, r8 ; add to X
|
||||
adc r5, r9
|
||||
ret
|
||||
; @end
|
||||
|
||||
@@ -99,27 +102,37 @@ ili9341_WriteCharacterX4At:
|
||||
; @param R16 character to write
|
||||
; @param Z pointer to font
|
||||
; @param X pointer to RAM to store data to
|
||||
; @param r9:r8 character width in points
|
||||
; @param r11:r10 character height in points
|
||||
; @return r9:r8 character width in points
|
||||
; @return r11:r10 character height in points
|
||||
; @clobbers r16 (r17, r24, r25, z)
|
||||
|
||||
ili9341PrepareCharFromFont:
|
||||
; render character
|
||||
push xl
|
||||
push xh
|
||||
rcall ili9341WriteCharacterFromFont8x8 ; (r17, r24, r25, x, z)
|
||||
; call render function of the selected font (first word of font is jmp to render function)
|
||||
rcall ili9341JumpToFontRenderFn ; (r17, r24, r25, x, z)
|
||||
pop xh
|
||||
pop xl
|
||||
|
||||
; set width and height
|
||||
ldi r16, 8
|
||||
mov r8, r16
|
||||
; set src width and height
|
||||
mov r8, r18
|
||||
clr r9
|
||||
mov r10, r16
|
||||
mov r10, r19
|
||||
clr r11
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ili9341JumpToFontRenderFn
|
||||
;
|
||||
; helper function to call function at the beginning of the given font
|
||||
|
||||
ili9341JumpToFontRenderFn:
|
||||
ijmp
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user