avr: more work on fonts, added heap functions.
This commit is contained in:
@@ -5,7 +5,9 @@
|
||||
<extradist>
|
||||
defs.asm
|
||||
font8x8.asm
|
||||
font6x8.asm
|
||||
font1.asm
|
||||
font2.asm
|
||||
</extradist>
|
||||
|
||||
</gwbuild>
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AVR_MODULES_FONT_DEFS
|
||||
#define AVR_MODULES_FONT_DEFS
|
||||
|
||||
|
||||
.equ FONT_OFFS_RENDERFN_LOW = 0
|
||||
@@ -18,3 +20,7 @@
|
||||
.equ FONT_OFFS_NUMCHARS = 7
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ font1_8x8:
|
||||
.db 128, 0 ; needed buffer size
|
||||
.db 8, 8 ; width, height of chars
|
||||
.db 32, 64 ; first char, num of chars in font
|
||||
; data
|
||||
; data (8x8_horizontal_LSB_2)
|
||||
.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
|
||||
|
||||
179
avr/modules/lcd2/font/font2.asm
Normal file
179
avr/modules/lcd2/font/font2.asm
Normal file
@@ -0,0 +1,179 @@
|
||||
; ***************************************************************************
|
||||
; 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
|
||||
|
||||
|
||||
|
||||
font2_6x8:
|
||||
; header
|
||||
.dw font6x8MonoRenderCharacter ; renderFn
|
||||
.db 96, 0 ; needed buffer size
|
||||
.db 6, 8 ; width, height of chars
|
||||
.db 32, 65 ; first char, num of chars in font
|
||||
; data (6x8_horizontal_LSB_2)
|
||||
font:
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x20
|
||||
.db 0x08,0x1C,0x1C,0x08,0x08,0x00,0x08,0x00, ; 0x21
|
||||
.db 0x36,0x36,0x12,0x00,0x00,0x00,0x00,0x00, ; 0x22
|
||||
.db 0x00,0x14,0x3E,0x14,0x14,0x3E,0x14,0x00, ; 0x23
|
||||
.db 0x04,0x1C,0x02,0x0C,0x10,0x0E,0x08,0x00, ; 0x24
|
||||
.db 0x26,0x26,0x10,0x08,0x04,0x32,0x32,0x00, ; 0x25
|
||||
.db 0x04,0x0A,0x0A,0x04,0x2A,0x12,0x2C,0x00, ; 0x26
|
||||
.db 0x0C,0x0C,0x04,0x00,0x00,0x00,0x00,0x00, ; 0x27
|
||||
.db 0x08,0x04,0x04,0x04,0x04,0x04,0x08,0x00, ; 0x28
|
||||
.db 0x04,0x08,0x08,0x08,0x08,0x08,0x04,0x00, ; 0x29
|
||||
.db 0x00,0x14,0x1C,0x3E,0x1C,0x14,0x00,0x00, ; 0x2A
|
||||
.db 0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00, ; 0x2B
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x04, ; 0x2C
|
||||
.db 0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x00, ; 0x2D
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00, ; 0x2E
|
||||
.db 0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00, ; 0x2F
|
||||
.db 0x1C,0x22,0x32,0x2A,0x26,0x22,0x1C,0x00, ; 0x30
|
||||
.db 0x08,0x0C,0x08,0x08,0x08,0x08,0x1C,0x00, ; 0x31
|
||||
.db 0x1C,0x22,0x20,0x18,0x04,0x02,0x3E,0x00, ; 0x32
|
||||
.db 0x1C,0x22,0x20,0x1C,0x20,0x22,0x1C,0x00, ; 0x33
|
||||
.db 0x10,0x18,0x14,0x12,0x3E,0x10,0x10,0x00, ; 0x34
|
||||
.db 0x3E,0x02,0x02,0x1E,0x20,0x22,0x1C,0x00, ; 0x35
|
||||
.db 0x18,0x04,0x02,0x1E,0x22,0x22,0x1C,0x00, ; 0x36
|
||||
.db 0x3E,0x20,0x10,0x08,0x04,0x04,0x04,0x00, ; 0x37
|
||||
.db 0x1C,0x22,0x22,0x1C,0x22,0x22,0x1C,0x00, ; 0x38
|
||||
.db 0x1C,0x22,0x22,0x3C,0x20,0x10,0x0C,0x00, ; 0x39
|
||||
.db 0x00,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x00, ; 0x3A
|
||||
.db 0x00,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x04, ; 0x3B
|
||||
.db 0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x00, ; 0x3C
|
||||
.db 0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00, ; 0x3D
|
||||
.db 0x04,0x08,0x10,0x20,0x10,0x08,0x04,0x00, ; 0x3E
|
||||
.db 0x1C,0x22,0x20,0x18,0x08,0x00,0x08,0x00, ; 0x3F
|
||||
.db 0x1C,0x22,0x3A,0x2A,0x3A,0x02,0x1C,0x00, ; 0x40
|
||||
.db 0x1C,0x22,0x22,0x22,0x3E,0x22,0x22,0x00, ; 0x41
|
||||
.db 0x1E,0x22,0x22,0x1E,0x22,0x22,0x1E,0x00, ; 0x42
|
||||
.db 0x1C,0x22,0x02,0x02,0x02,0x22,0x1C,0x00, ; 0x43
|
||||
.db 0x1E,0x22,0x22,0x22,0x22,0x22,0x1E,0x00, ; 0x44
|
||||
.db 0x3E,0x02,0x02,0x1E,0x02,0x02,0x3E,0x00, ; 0x45
|
||||
.db 0x3E,0x02,0x02,0x1E,0x02,0x02,0x02,0x00, ; 0x46
|
||||
.db 0x1C,0x22,0x02,0x3A,0x22,0x22,0x3C,0x00, ; 0x47
|
||||
.db 0x22,0x22,0x22,0x3E,0x22,0x22,0x22,0x00, ; 0x48
|
||||
.db 0x1C,0x08,0x08,0x08,0x08,0x08,0x1C,0x00, ; 0x49
|
||||
.db 0x20,0x20,0x20,0x20,0x22,0x22,0x1C,0x00, ; 0x4A
|
||||
.db 0x22,0x12,0x0A,0x06,0x0A,0x12,0x22,0x00, ; 0x4B
|
||||
.db 0x02,0x02,0x02,0x02,0x02,0x02,0x3E,0x00, ; 0x4C
|
||||
.db 0x22,0x36,0x2A,0x22,0x22,0x22,0x22,0x00, ; 0x4D
|
||||
.db 0x22,0x26,0x2A,0x32,0x22,0x22,0x22,0x00, ; 0x4E
|
||||
.db 0x1C,0x22,0x22,0x22,0x22,0x22,0x1C,0x00, ; 0x4F
|
||||
.db 0x1E,0x22,0x22,0x1E,0x02,0x02,0x02,0x00, ; 0x50
|
||||
.db 0x1C,0x22,0x22,0x22,0x2A,0x12,0x2C,0x00, ; 0x51
|
||||
.db 0x1E,0x22,0x22,0x1E,0x12,0x22,0x22,0x00, ; 0x52
|
||||
.db 0x1C,0x22,0x02,0x1C,0x20,0x22,0x1C,0x00, ; 0x53
|
||||
.db 0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x00, ; 0x54
|
||||
.db 0x22,0x22,0x22,0x22,0x22,0x22,0x1C,0x00, ; 0x55
|
||||
.db 0x22,0x22,0x22,0x22,0x22,0x14,0x08,0x00, ; 0x56
|
||||
.db 0x22,0x22,0x2A,0x2A,0x2A,0x2A,0x14,0x00, ; 0x57
|
||||
.db 0x22,0x22,0x14,0x08,0x14,0x22,0x22,0x00, ; 0x58
|
||||
.db 0x22,0x22,0x22,0x14,0x08,0x08,0x08,0x00, ; 0x59
|
||||
.db 0x1E,0x10,0x08,0x04,0x02,0x02,0x1E,0x00, ; 0x5A
|
||||
.db 0x1C,0x04,0x04,0x04,0x04,0x04,0x1C,0x00, ; 0x5B
|
||||
.db 0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00, ; 0x5C
|
||||
.db 0x1C,0x10,0x10,0x10,0x10,0x10,0x1C,0x00, ; 0x5D
|
||||
.db 0x08,0x14,0x22,0x00,0x00,0x00,0x00,0x00, ; 0x5E
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F, ; 0x5F
|
||||
.db 0x0C,0x0C,0x08,0x00,0x00,0x00,0x00,0x00, ; 0x60
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x20
|
||||
.db 0x20,0x70,0x70,0x20,0x20,0x00,0x20,0x00, ; 0x21
|
||||
.db 0xD8,0xD8,0x48,0x00,0x00,0x00,0x00,0x00, ; 0x22
|
||||
.db 0x00,0x50,0xF8,0x50,0x50,0xF8,0x50,0x00, ; 0x23
|
||||
.db 0x10,0x70,0x08,0x30,0x40,0x38,0x20,0x00, ; 0x24
|
||||
.db 0x98,0x98,0x40,0x20,0x10,0xC8,0xC8,0x00, ; 0x25
|
||||
.db 0x10,0x28,0x28,0x10,0xA8,0x48,0xB0,0x00, ; 0x26
|
||||
.db 0x30,0x30,0x10,0x00,0x00,0x00,0x00,0x00, ; 0x27
|
||||
.db 0x20,0x10,0x10,0x10,0x10,0x10,0x20,0x00, ; 0x28
|
||||
.db 0x10,0x20,0x20,0x20,0x20,0x20,0x10,0x00, ; 0x29
|
||||
.db 0x00,0x50,0x70,0xF8,0x70,0x50,0x00,0x00, ; 0x2A
|
||||
.db 0x00,0x20,0x20,0xF8,0x20,0x20,0x00,0x00, ; 0x2B
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x10, ; 0x2C
|
||||
.db 0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00, ; 0x2D
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00, ; 0x2E
|
||||
.db 0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00, ; 0x2F
|
||||
.db 0x70,0x88,0xC8,0xA8,0x98,0x88,0x70,0x00, ; 0x30
|
||||
.db 0x20,0x30,0x20,0x20,0x20,0x20,0x70,0x00, ; 0x31
|
||||
.db 0x70,0x88,0x80,0x60,0x10,0x08,0xF8,0x00, ; 0x32
|
||||
.db 0x70,0x88,0x80,0x70,0x80,0x88,0x70,0x00, ; 0x33
|
||||
.db 0x40,0x60,0x50,0x48,0xF8,0x40,0x40,0x00, ; 0x34
|
||||
.db 0xF8,0x08,0x08,0x78,0x80,0x88,0x70,0x00, ; 0x35
|
||||
.db 0x60,0x10,0x08,0x78,0x88,0x88,0x70,0x00, ; 0x36
|
||||
.db 0xF8,0x80,0x40,0x20,0x10,0x10,0x10,0x00, ; 0x37
|
||||
.db 0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x00, ; 0x38
|
||||
.db 0x70,0x88,0x88,0xF0,0x80,0x40,0x30,0x00, ; 0x39
|
||||
.db 0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x00, ; 0x3A
|
||||
.db 0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x10, ; 0x3B
|
||||
.db 0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x00, ; 0x3C
|
||||
.db 0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00, ; 0x3D
|
||||
.db 0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x00, ; 0x3E
|
||||
.db 0x70,0x88,0x80,0x60,0x20,0x00,0x20,0x00, ; 0x3F
|
||||
.db 0x70,0x88,0xE8,0xA8,0xE8,0x08,0x70,0x00, ; 0x40
|
||||
.db 0x70,0x88,0x88,0x88,0xF8,0x88,0x88,0x00, ; 0x41
|
||||
.db 0x78,0x88,0x88,0x78,0x88,0x88,0x78,0x00, ; 0x42
|
||||
.db 0x70,0x88,0x08,0x08,0x08,0x88,0x70,0x00, ; 0x43
|
||||
.db 0x78,0x88,0x88,0x88,0x88,0x88,0x78,0x00, ; 0x44
|
||||
.db 0xF8,0x08,0x08,0x78,0x08,0x08,0xF8,0x00, ; 0x45
|
||||
.db 0xF8,0x08,0x08,0x78,0x08,0x08,0x08,0x00, ; 0x46
|
||||
.db 0x70,0x88,0x08,0xE8,0x88,0x88,0xF0,0x00, ; 0x47
|
||||
.db 0x88,0x88,0x88,0xF8,0x88,0x88,0x88,0x00, ; 0x48
|
||||
.db 0x70,0x20,0x20,0x20,0x20,0x20,0x70,0x00, ; 0x49
|
||||
.db 0x80,0x80,0x80,0x80,0x88,0x88,0x70,0x00, ; 0x4A
|
||||
.db 0x88,0x48,0x28,0x18,0x28,0x48,0x88,0x00, ; 0x4B
|
||||
.db 0x08,0x08,0x08,0x08,0x08,0x08,0xF8,0x00, ; 0x4C
|
||||
.db 0x88,0xD8,0xA8,0x88,0x88,0x88,0x88,0x00, ; 0x4D
|
||||
.db 0x88,0x98,0xA8,0xC8,0x88,0x88,0x88,0x00, ; 0x4E
|
||||
.db 0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00, ; 0x4F
|
||||
.db 0x78,0x88,0x88,0x78,0x08,0x08,0x08,0x00, ; 0x50
|
||||
.db 0x70,0x88,0x88,0x88,0xA8,0x48,0xB0,0x00, ; 0x51
|
||||
.db 0x78,0x88,0x88,0x78,0x48,0x88,0x88,0x00, ; 0x52
|
||||
.db 0x70,0x88,0x08,0x70,0x80,0x88,0x70,0x00, ; 0x53
|
||||
.db 0xF8,0x20,0x20,0x20,0x20,0x20,0x20,0x00, ; 0x54
|
||||
.db 0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00, ; 0x55
|
||||
.db 0x88,0x88,0x88,0x88,0x88,0x50,0x20,0x00, ; 0x56
|
||||
.db 0x88,0x88,0xA8,0xA8,0xA8,0xA8,0x50,0x00, ; 0x57
|
||||
.db 0x88,0x88,0x50,0x20,0x50,0x88,0x88,0x00, ; 0x58
|
||||
.db 0x88,0x88,0x88,0x50,0x20,0x20,0x20,0x00, ; 0x59
|
||||
.db 0x78,0x40,0x20,0x10,0x08,0x08,0x78,0x00, ; 0x5A
|
||||
.db 0x70,0x10,0x10,0x10,0x10,0x10,0x70,0x00, ; 0x5B
|
||||
.db 0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00, ; 0x5C
|
||||
.db 0x70,0x40,0x40,0x40,0x40,0x40,0x70,0x00, ; 0x5D
|
||||
.db 0x20,0x50,0x88,0x00,0x00,0x00,0x00,0x00, ; 0x5E
|
||||
.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC, ; 0x5F
|
||||
.db 0x30,0x30,0x20,0x00,0x00,0x00,0x00,0x00, ; 0x60
|
||||
#endif
|
||||
|
||||
|
||||
96
avr/modules/lcd2/font/font6x8.asm
Normal file
96
avr/modules/lcd2/font/font6x8.asm
Normal file
@@ -0,0 +1,96 @@
|
||||
; ***************************************************************************
|
||||
; 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 font6x8RenderCharacter
|
||||
|
||||
; @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 r16, r17, r24, r25, x
|
||||
|
||||
font6x8MonoRenderCharacter:
|
||||
push zl
|
||||
push zh
|
||||
adiw zh:zl, FONT_OFFS_WIDTH
|
||||
lpm r18, Z+ ; char width in pixels
|
||||
lpm r19, Z ; char height in pixels
|
||||
sbiw zh:zl, FONT_OFFS_WIDTH+1
|
||||
rcall font6x8GetCharPosInFont ; (r16, r17, r24, r25, z)
|
||||
mov r25, r19 ; height in pixels
|
||||
font6x8MonoRenderCharacter_loop1:
|
||||
mov r24, r18 ; width in pixels
|
||||
lpm r17, Z+
|
||||
font6x8MonoRenderCharacter_loop2:
|
||||
lsr r17
|
||||
brcs font6x8MonoRenderCharacter_writeForeground
|
||||
st X+, r0
|
||||
st X+, r1
|
||||
rjmp font6x8MonoRenderCharacter_loop2end
|
||||
font6x8MonoRenderCharacter_writeForeground:
|
||||
st X+, r2
|
||||
st X+, r3
|
||||
font6x8MonoRenderCharacter_loop2end:
|
||||
dec r24
|
||||
brne font6x8MonoRenderCharacter_loop2
|
||||
dec r25
|
||||
brne font6x8MonoRenderCharacter_loop1
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine font6x8GetCharPosInFont (same as font8x8GetCharPosInFont!)
|
||||
|
||||
; @param R16 character to write
|
||||
; @param Z pointer to font
|
||||
; @return Z pointer to begin of char data
|
||||
; @clobbers r16, r17, r24, r25, z
|
||||
|
||||
font6x8GetCharPosInFont:
|
||||
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 font6x8GetCharPosInFont_ret
|
||||
cp r16, r25
|
||||
brcc font6x8GetCharPosInFont_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
|
||||
font6x8GetCharPosInFont_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
@@ -57,3 +57,5 @@
|
||||
.equ WIN_OFFS_REL_X_HIGH = 11
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -97,8 +97,8 @@ ILI9341_Init:
|
||||
mov r7, r16
|
||||
|
||||
; set font pos
|
||||
ldi zl, LOW(font1_8x8*2)
|
||||
ldi zh, HIGH(font1_8x8*2)
|
||||
ldi zl, LOW(font2_6x8*2)
|
||||
ldi zh, HIGH(font2_6x8*2)
|
||||
|
||||
; set buffer pos
|
||||
; ldi xl, LOW(ILI9341_buffer)
|
||||
@@ -423,6 +423,6 @@ helloWorld: .db "Hello World", 0
|
||||
|
||||
|
||||
|
||||
.include "modules/lcd2/font/font1.asm"
|
||||
.include "modules/lcd2/font/font2.asm"
|
||||
|
||||
|
||||
|
||||
18
avr/modules/lcd2/win/widget.asm
Normal file
18
avr/modules/lcd2/win/widget.asm
Normal file
@@ -0,0 +1,18 @@
|
||||
; ***************************************************************************
|
||||
; 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. *
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine WID_Widget_new @global
|
||||
|
||||
|
||||
WID_Widget_new:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user