avr: more work on c03 and gui.

This commit is contained in:
Martin Preuss
2026-04-27 23:30:49 +02:00
parent 3b7317bb0f
commit 8b17a63fa1
7 changed files with 126 additions and 44 deletions

View File

@@ -371,41 +371,7 @@ C03App_OnCmdBack:
; @clobbers any, !X
C03App_CreateButton:
push xl
push xh
push r20
push r21
push r22
ldi r20, BUTTON_MODE_NORMAL
bigcall Button_new
pop r22
pop r21
pop r20
brcc C03App_CreateButton_done
mov xl, yl
mov xh, yh
push xl ; Button
push xh
push r22
ldi r16, 0
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
bigcall ImageView_new
pop r22
pop yh ; pop button into Y
pop yl
brcc C03App_CreateButton_done
pop xh
pop xl
std Y+OBJECT_OFFS_TARGET_LO, xl
std Y+OBJECT_OFFS_TARGET_HI, xh
std Y+OBJECT_OFFS_SELECTOR, r22
rjmp C03App_CreateButton_ret
C03App_CreateButton_done:
pop xh
pop xl
C03App_CreateButton_ret:
ret
bigjmp ImageButton_new
; @end

View File

@@ -503,7 +503,7 @@ Debug_Style:
.include "common/eeprom_tlv.asm"
.include "common/divide.asm"
;.include "common/multiply.asm"
.include "common/multiply.asm"
.include "common/itoa.asm"
.include "common/ressource.asm"
@@ -518,6 +518,7 @@ GUI_MODULE_BEGIN:
.include "modules/lcd2/gui/base/label.asm"
.include "modules/lcd2/gui/base/button.asm"
.include "modules/lcd2/gui/base/imageview.asm"
.include "modules/lcd2/gui/base/imagebutton.asm"
.include "modules/lcd2/gui/base/valuelabel.asm"
.include "modules/lcd2/gui/base/checkbox.asm"
.include "modules/lcd2/gui/base/checkbutton.asm"

View File

@@ -237,7 +237,6 @@ netStatWinCreateLabel:
; @routine netStatWinCreateValueLabel
;
; @param X parent (content sub-window of main window)
; @param r21:r20 id of text ressource
; @return CFLAG set if created, cleared otherwise
; @return Y new object created
; @clobbers !X
@@ -248,7 +247,8 @@ netStatWinCreateValueLabel:
ldi r16, 0
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_CENTER<<WIDGET_PACK_VSELF0_BIT) | \
(WIDGET_PACK_END<<WIDGET_PACK_HCONTENT0_BIT) | (WIDGET_PACK_CENTER<<WIDGET_PACK_VCONTENT0_BIT)
clr r20
clr r20 ; postkomma digits
clr r21 ; total digits (variable)
bigcall ValueLabel_new
pop xh
pop xl

View File

@@ -291,6 +291,7 @@ sensorWatchCreateValueLabel:
push yh
ldd r16, Y+SENSORWATCH_OFFS_TYPE
rcall sensorWatchGetPostKommaDigits ; r20=postkomma digits
clr r21 ; variable size
mov xl, yl
mov xh, yh
ldi r16, 0

View File

@@ -0,0 +1,75 @@
; ***************************************************************************
; copyright : (C) 2026 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. *
; ***************************************************************************
#ifndef AQH_AVR_GUI2_IMAGEBUTTON_ASM
#define AQH_AVR_GUI2_IMAGEBUTTON_ASM
; ***************************************************************************
; code
.cseg
; ---------------------------------------------------------------------------
; @routine ImageButton_new
;
; @param X parent
; @param r16 value for OBJECT_OFFS_OPTS
; @param r17 value for WIDGET_OFFS_PACK
; @param r21:r20 img ressource
; @param r22 selector (target will be parent, can be overridden later)
; @return CFLAG set if new object created, cleared on error
; @return Y button created
; @clobbers any, !X
ImageButton_new:
push xl
push xh
push r20
push r21
push r22
ldi r20, BUTTON_MODE_NORMAL
bigcall Button_new
pop r22
pop r21
pop r20
brcc ImageButton_new_done
mov xl, yl
mov xh, yh
push xl ; Button
push xh
push r22
ldi r16, 0
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
bigcall ImageView_new
pop r22
pop yh ; pop button into Y
pop yl
brcc ImageButton_new_done
pop xh
pop xl
std Y+OBJECT_OFFS_TARGET_LO, xl
std Y+OBJECT_OFFS_TARGET_HI, xh
std Y+OBJECT_OFFS_SELECTOR, r22
rjmp ImageButton_new_ret
ImageButton_new_done:
pop xh
pop xl
ImageButton_new_ret:
ret
; @end
#endif

View File

@@ -18,7 +18,8 @@
.equ VLABEL_OFFS_VALUE_LO = VLABEL_OFFS_BEGIN+0
.equ VLABEL_OFFS_VALUE_HI = VLABEL_OFFS_BEGIN+1
.equ VLABEL_OFFS_POSTKOMMADIGITS = VLABEL_OFFS_BEGIN+2
.equ VLABEL_SIZE = VLABEL_OFFS_BEGIN+3
.equ VLABEL_OFFS_TOTALDIGITS = VLABEL_OFFS_BEGIN+3
.equ VLABEL_SIZE = VLABEL_OFFS_BEGIN+4
.equ VLABEL_VALUE = WIDGET_VALUE_NEXTFREE+0
@@ -42,13 +43,16 @@
; @param r16 value for OBJECT_OFFS_OPTS
; @param r17 value for WIDGET_OFFS_PACK
; @param r20 number of postkomma digits
; @param r21 total number of digits (0=variable)
; @clobbers any
ValueLabel_new:
push r20
push r21
ldi r24, LOW(VLABEL_SIZE)
ldi r25, HIGH(VLABEL_SIZE)
bigcall Object_Alloc ; (!r16, !r17, !X)
pop r21
pop r20
brcc ValueLabel_new_ret
rcall ValueLabel_Init ; (r16, r17, X)
@@ -67,16 +71,20 @@ ValueLabel_new_ret:
; @param r16 value for OBJECT_OFFS_OPTS
; @param r17 value for WIDGET_OFFS_PACK
; @param r20 number of postkomma digits
; @param r21 total number of digits (0=variable)
; @clobbers r16, r17, X
ValueLabel_Init:
push r20
push r21
; call base class
bigcall Widget_Init ; (r16, r17, X)
pop r21
pop r20
; setup valueLabel data
std Y+VLABEL_OFFS_POSTKOMMADIGITS, r20
std Y+VLABEL_OFFS_TOTALDIGITS, r21
; set default signal map
ldi r16, LOW(ValueLabel_DefaultSignalmap*2)
@@ -168,7 +176,14 @@ ValueLabel_OnDraw_ret:
; @clobbers any, !Y
ValueLabel_OnGetDefaultWidth:
ldd r17, Y+VLABEL_OFFS_TOTALDIGITS
tst r17
breq ValueLabel_OnGetDefaultWidth_calcRealSize
bigcall Widget_CalcFixedStringWidth
rjmp ValueLabel_OnGetDefaultWidth_done
ValueLabel_OnGetDefaultWidth_calcRealSize:
rcall valueLabelCalcTextWidth
ValueLabel_OnGetDefaultWidth_done:
mov r18, r12
mov r19, r13
bigcall Widget_AddOuterStyleBorders ; (r20, r21)

View File

@@ -1210,6 +1210,30 @@ Widget_CalcStringWidthSDRAM_done:
; ---------------------------------------------------------------------------
; @routine Widget_CalcFixedStringWidth
;
; @param Y address of widget
; @param r17 number of chars
; @return r13:r12 width of string
; @clobbers R16-R25
Widget_CalcFixedStringWidth:
push xl
rcall Widget_GetCharWidth ; r16=charWidth (none)
mov r20, r16
clr r21
mov r22, r17
clr r23
bigcall Utils_Mulu16x16_32 ; (TODO: implement Mulu8x8_16)
mov r12, r16
mov r13, r17
pop xl
ret
; @end
; ---------------------------------------------------------------------------
; @routine Widget_PackSelfX @global
;