texts inside labels now work.

This commit is contained in:
Martin Preuss
2026-01-13 00:00:19 +01:00
parent caa2a92722
commit edb8e7b859
4 changed files with 74 additions and 36 deletions

View File

@@ -254,9 +254,8 @@ test:
;.include "modules/lcd2/font/font4.asm" ;.include "modules/lcd2/font/font4.asm"
;.include "modules/lcd2/font/font12x16.asm" ;.include "modules/lcd2/font/font12x16.asm"
;.include "modules/lcd2/ili9341/font12x16.asm" .include "modules/lcd2/ili9341/font12x16.asm"
;.include "modules/lcd2/ili9341/font12x16_1.asm" .include "modules/lcd2/ili9341/font12x16_1.asm"
.equ ili9341Font12x16_1 = 0
;.include "modules/lcd2/ili9341/font12x20.asm" ;.include "modules/lcd2/ili9341/font12x20.asm"
;.include "modules/lcd2/ili9341/font12x20_1.asm" ;.include "modules/lcd2/ili9341/font12x20_1.asm"
@@ -268,6 +267,7 @@ test:
.include "modules/lcd2/gui2/style.asm" .include "modules/lcd2/gui2/style.asm"
.include "modules/lcd2/gui2/object.asm" .include "modules/lcd2/gui2/object.asm"
.include "modules/lcd2/gui2/widget.asm" .include "modules/lcd2/gui2/widget.asm"
.include "modules/lcd2/gui2/label.asm"
.include "modules/lcd2/gui2/guiapp.asm" .include "modules/lcd2/gui2/guiapp.asm"
.include "modules/lcd2/gui2/guicntrl.asm" .include "modules/lcd2/gui2/guicntrl.asm"

View File

@@ -28,6 +28,8 @@ testApp_ramdata:
testWin_ramdata: testWin_ramdata:
.byte WIDGET_SD_SIZE .byte WIDGET_SD_SIZE
testWinHeader_ramdata:
.byte WIDGET_SD_SIZE
; *************************************************************************** ; ***************************************************************************
@@ -72,7 +74,7 @@ testWin_flashdata:
; OBJECT ; OBJECT
.dw 0 ; next .dw 0 ; next
.dw 0 ; parent .dw 0 ; parent
.dw 0 ; first child .dw testWinHeader_flashdata*2 ; first child
.dw 0 ; target .dw 0 ; target
.dw 0 ; selector (ony lower 8 bits used) .dw 0 ; selector (ony lower 8 bits used)
.dw testWin_signalmap*2 ; signal map .dw testWin_signalmap*2 ; signal map
@@ -82,10 +84,9 @@ testWin_flashdata:
.dw 0 ; Y .dw 0 ; Y
.dw DISPLAY_WIDTH ; W .dw DISPLAY_WIDTH ; W
.dw DISPLAY_HEIGHT ; H .dw DISPLAY_HEIGHT ; H
.dw 0 ; front color .dw STYLE_WIN_FOREGROUND ; front color
.dw DISPLAY_COLOR_PURPLE ; back color .dw STYLE_WIN_BACKGROUND ; back color
; .dw STYLE_WIN_FONT*2 ; font .dw STYLE_WIN_FONT*2 ; font
.dw 0 ; font
.dw testWin_ramdata ; ptr to SDRAM .dw testWin_ramdata ; ptr to SDRAM
testWin_signalmap: testWin_signalmap:
.db 0, OBJECT_SIGNAL_CREATE, LOW(Widget_OnCreate), HIGH(Widget_OnCreate) .db 0, OBJECT_SIGNAL_CREATE, LOW(Widget_OnCreate), HIGH(Widget_OnCreate)
@@ -93,6 +94,35 @@ testWin_signalmap:
.db 0, 0, 0, 0 ; end of table .db 0, 0, 0, 0 ; end of table
testWinHeader_flashdata:
; OBJECT
.dw 0 ; next
.dw testWin_flashdata*2 ; parent
.dw 0 ; first child
.dw 0 ; target
.dw 0 ; selector (ony lower 8 bits used)
.dw testWinHeader_signalmap*2 ; signal map
; WIDGET
.db 0, 0 ; opts lo, hi
.dw 0 ; X
.dw 0 ; Y
.dw DISPLAY_WIDTH ; W
.dw STYLE_WIN_TITLE_HEIGHT ; H
.dw STYLE_WIN_TITLE_FOREGROUND ; front color
.dw STYLE_WIN_TITLE_BACKGROUND ; back color
.dw STYLE_WIN_FONT*2 ; font
.dw testWinHeader_ramdata ; ptr to SDRAM
; LABEL
.dw testWinHeader_text*2 ; text
testWinHeader_text:
.db "Test-Window", 0
testWinHeader_signalmap:
.db 0, OBJECT_SIGNAL_CREATE, LOW(Widget_OnCreate), HIGH(Widget_OnCreate)
.db 0, WIDGET_SIGNAL_DRAW, LOW(Label_OnDraw), HIGH(Label_OnDraw)
.db 0, 0, 0, 0 ; end of table

View File

@@ -42,7 +42,6 @@ Label_OnDraw:
andi r16, (1<<WIDGET_FLAGS_DIRTY_BIT) andi r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
breq Label_OnDraw_ret breq Label_OnDraw_ret
bigcall Widget_LoadDisplayRegs
adiw zh:zl, WIDGET_OFFS_OPTS_LO ; get OPTS low adiw zh:zl, WIDGET_OFFS_OPTS_LO ; get OPTS low
lpm r14, Z lpm r14, Z
sbiw zh:zl, WIDGET_OFFS_OPTS_LO sbiw zh:zl, WIDGET_OFFS_OPTS_LO
@@ -60,6 +59,7 @@ Label_OnDraw:
bigcall Widget_DrawBorder bigcall Widget_DrawBorder
Label_OnDraw_done: Label_OnDraw_done:
bigcall Widget_GetSdramPtr ; (none)
ldd r16, Y+WIDGET_SD_OFFS_FLAGS ldd r16, Y+WIDGET_SD_OFFS_FLAGS
cbr r16, (1<<WIDGET_FLAGS_DIRTY_BIT) cbr r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
std Y+WIDGET_SD_OFFS_FLAGS, r16 std Y+WIDGET_SD_OFFS_FLAGS, r16
@@ -77,14 +77,14 @@ Label_OnDraw_ret:
; @param Z byte address of object (for LPM!) ; @param Z byte address of object (for LPM!)
; @param R1:R0 background color ; @param R1:R0 background color
; @param R3:R2 foreground color ; @param R3:R2 foreground color
; @param R5:R4 X
; @param R7:R6 Y
; @param R9:R8 widget width
; @param R11:R10 widget height
; @param R14 opts low ; @param R14 opts low
; @clobbers any, !Z ; @clobbers any, !Z
labelWriteText: labelWriteText:
clr r4
clr r5
clr r6
clr r7
mov r16, r14 mov r16, r14
andi r16, (1<<WIDGETS_OPTSLO_BORDER_BIT) andi r16, (1<<WIDGETS_OPTSLO_BORDER_BIT)
breq labelWriteText_draw breq labelWriteText_draw

View File

@@ -508,7 +508,11 @@ Widget_FillRect:
; @clobbers any, !Z ; @clobbers any, !Z
Widget_DrawBorder: Widget_DrawBorder:
rcall Widget_LoadDisplayRegs clr r6
clr r7
clr r8
clr r9
rcall Widget_MakeAbsPos ; (R16, R17)
bigcall Display_DrawRect bigcall Display_DrawRect
ret ret
; @end ; @end
@@ -525,7 +529,6 @@ Widget_DrawBorder:
; @clobbers any, !Z ; @clobbers any, !Z
Widget_DrawTextFlash: Widget_DrawTextFlash:
rcall Widget_LoadDisplayRegs
rcall Widget_GetSdramPtr ; (none) rcall Widget_GetSdramPtr ; (none)
rcall Widget_SelectColors rcall Widget_SelectColors
rjmp Widget_DrawColoredTextFlash rjmp Widget_DrawColoredTextFlash
@@ -546,23 +549,24 @@ Widget_DrawTextFlash:
Widget_DrawColoredTextFlash: Widget_DrawColoredTextFlash:
rcall widgetCalcAbsPosAndBorders rcall widgetCalcAbsPosAndBorders
push zl
push zh
mov zl, r12
mov zh, r13
Widget_DrawColoredTextFlash_loop: Widget_DrawColoredTextFlash_loop:
push zl
push zh
mov zl, r12
mov zh, r13
lpm r16, Z lpm r16, Z
tst r16 pop zh
breq Widget_DrawColoredTextFlash_loopEnd pop zl
rcall widgetDrawChar tst r16
brcc Widget_DrawColoredTextFlash_loopEnd breq Widget_DrawColoredTextFlash_loopEnd
adiw zh:zl, 1 rcall widgetDrawChar
rjmp Widget_DrawColoredTextFlash_loop brcc Widget_DrawColoredTextFlash_loopEnd
ldi r16, 1
add r12, r16
adc r13, r12
sub r13, r12
rjmp Widget_DrawColoredTextFlash_loop
Widget_DrawColoredTextFlash_loopEnd: Widget_DrawColoredTextFlash_loopEnd:
mov r12, zl
mov r13, zh
pop zh
pop zl
ret ret
; @end ; @end
@@ -585,11 +589,11 @@ widgetCalcAbsPosAndBorders:
push zl push zl
push zh push zh
adiw zh:zl, WIDGET_OFFS_X_LO adiw zh:zl, WIDGET_OFFS_X_LO
lpm r16, Z+ lpm r16, Z+ ; widget X
lpm r17, Z+ lpm r17, Z+
add r4, r16 ; adjust X add r4, r16 ; adjust X
adc r5, r17 adc r5, r17
lpm r16, Z+ lpm r16, Z+ ; widget Y
lpm r17, Z+ lpm r17, Z+
add r6, r16 ; adjust Y add r6, r16 ; adjust Y
adc r7, r17 adc r7, r17
@@ -624,26 +628,29 @@ widgetDrawChar:
push zl push zl
push zh push zh
; save R16 (char to write) ; save R16 (char to write)
mov r12, r16 mov r14, r16
; get font to Z ; get font to Z
adiw zh:zl, WIDGET_OFFS_FONT_LO adiw zh:zl, WIDGET_OFFS_FONT_LO
lpm r18, Z+ lpm r18, Z+
lpm zh, Z lpm zh, Z
mov zl, r18 mov zl, r18
or r18, zh
clc
breq widgetDrawChar_done
; check whether the char fits inside window ; check whether the char fits inside window
bigcall FONT_GetCharWidth ; r16=char width bigcall FONT_GetCharWidth ; r16=char width
clr r17 clr r17
add r16, r4 ; char width+X add r16, r4 ; char width+X
adc r17, r5 adc r17, r5
sub r16, r8 ; check against window width sub r16, r8 ; check against window width
sbc r17, r9 sbc r17, r9
brcc widgetDrawChar_ret ; not fit, jmp brcc widgetDrawChar_done ; not fit, jmp
; actually draw char ; actually draw char
mov r16, r12 mov r16, r14
push r8 push r8
push r9 push r9
push r10 push r10
@@ -657,10 +664,11 @@ widgetDrawChar:
add r4, r18 ; increment X add r4, r18 ; increment X
adc r5, r16 adc r5, r16
sec ; write succeeded sec ; write succeeded
widgetDrawChar_ret: widgetDrawChar_done:
pop zh pop zh
pop zl pop zl
ret ret
; @end