avr: added ValueLabel.
This commit is contained in:
177
avr/modules/lcd2/gui2/valuelabel.asm
Normal file
177
avr/modules/lcd2/gui2/valuelabel.asm
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; 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_VALUELABEL_ASM
|
||||||
|
#define AQH_AVR_GUI2_VALUELABEL_ASM
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; defines
|
||||||
|
|
||||||
|
; IMGVIEW in flash
|
||||||
|
.equ VLABEL_OFFS_VLABEL = WIDGET_SIZE
|
||||||
|
.equ VLABEL_OFFS_POSTKOMMADIGITS = VLABEL_OFFS_VLABEL+0
|
||||||
|
.equ VLABEL_OFFS_RESERVED = VLABEL_OFFS_VLABEL+1
|
||||||
|
.equ VLABEL_SIZE = VLABEL_OFFS_VLABEL+2
|
||||||
|
|
||||||
|
|
||||||
|
; SDRAM data for IMGVIEW
|
||||||
|
.equ VLABEL_SD_OFFS_VLABEL = WIDGET_SD_SIZE
|
||||||
|
.equ VLABEL_SD_OFFS_VALUE_LO = VLABEL_SD_OFFS_VLABEL+0
|
||||||
|
.equ VLABEL_SD_OFFS_VALUE_HI = VLABEL_SD_OFFS_VLABEL+1
|
||||||
|
.equ VLABEL_SD_SIZE = VLABEL_SD_OFFS_VLABEL+2
|
||||||
|
|
||||||
|
|
||||||
|
; signals
|
||||||
|
.equ VLABEL_SIGNAL_SETVALUE = WIDGET_SIGNAL_NEXTFREE+0
|
||||||
|
.equ VLABEL_SIGNAL_NEXTFREE = WIDGET_SIGNAL_NEXTFREE+1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; code
|
||||||
|
|
||||||
|
.cseg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ImageView_OnCreate @global
|
||||||
|
;
|
||||||
|
; @param Z byte address of widget object (for LPM!)
|
||||||
|
; @return CFLAG set if signal handled
|
||||||
|
; @clobbers any, !Z
|
||||||
|
|
||||||
|
ValueLabel_OnCreate:
|
||||||
|
bigcall Widget_OnCreate
|
||||||
|
bigcall Widget_GetSdramPtr ; (none)
|
||||||
|
clr r16
|
||||||
|
std Y+VLABEL_SD_OFFS_VALUE_LO, r16
|
||||||
|
std Y+VLABEL_SD_OFFS_VALUE_HI, r16
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ValueLabel_OnSetValue @global
|
||||||
|
;
|
||||||
|
; @param Z byte address of widget object (for LPM!)
|
||||||
|
; @param X new value for background color
|
||||||
|
; @return CFLAG set if signal handled
|
||||||
|
; @clobbers r17
|
||||||
|
|
||||||
|
ValueLabel_OnSetValue:
|
||||||
|
bigcall OBJ_IsObject ; (none)
|
||||||
|
brcc ValueLabel_OnSetValue_ret
|
||||||
|
push zl
|
||||||
|
push zh
|
||||||
|
rcall Widget_GetSdramPtr ; (none)
|
||||||
|
std Y+VLABEL_SD_OFFS_VALUE_LO, xl
|
||||||
|
std Y+VLABEL_SD_OFFS_VALUE_HI, xh
|
||||||
|
ldd r17, Y+WIDGET_SD_OFFS_FLAGS
|
||||||
|
ori r17, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||||
|
std Y+WIDGET_SD_OFFS_FLAGS, r17
|
||||||
|
pop zh
|
||||||
|
pop zl
|
||||||
|
ValueLabel_OnSetValue_ret:
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ValueLabel_OnDraw @global
|
||||||
|
;
|
||||||
|
; @param Z byte address of widget object (for LPM!)
|
||||||
|
; @return CFLAG set if signal handled
|
||||||
|
; @clobbers any, !Z
|
||||||
|
|
||||||
|
ValueLabel_OnDraw:
|
||||||
|
bigcall Widget_GetSdramPtr ; (none)
|
||||||
|
ldd r16, Y+WIDGET_SD_OFFS_FLAGS
|
||||||
|
andi r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||||
|
breq ValueLabel_OnDraw_ret
|
||||||
|
|
||||||
|
adiw zh:zl, WIDGET_OFFS_OPTS_LO ; get OPTS low
|
||||||
|
lpm r14, Z
|
||||||
|
sbiw zh:zl, WIDGET_OFFS_OPTS_LO
|
||||||
|
|
||||||
|
bigcall Widget_Clear
|
||||||
|
rcall valueLabelWriteValue
|
||||||
|
|
||||||
|
mov r16, r14
|
||||||
|
andi r16, (1<<WIDGETS_OPTSLO_BORDER_BIT)
|
||||||
|
breq ValueLabel_OnDraw_done
|
||||||
|
ldi r16, LOW(STYLE_BUTTON_COL_BORDER)
|
||||||
|
mov r2, r16
|
||||||
|
ldi r16, HIGH(STYLE_BUTTON_COL_BORDER)
|
||||||
|
mov r3, r16
|
||||||
|
bigcall Widget_DrawBorder
|
||||||
|
|
||||||
|
ValueLabel_OnDraw_done:
|
||||||
|
bigcall Widget_GetSdramPtr ; (none)
|
||||||
|
ldd r16, Y+WIDGET_SD_OFFS_FLAGS
|
||||||
|
cbr r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||||
|
std Y+WIDGET_SD_OFFS_FLAGS, r16
|
||||||
|
|
||||||
|
ValueLabel_OnDraw_ret:
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine valueLabelWriteValue
|
||||||
|
;
|
||||||
|
; @param Z byte address of object (for LPM!)
|
||||||
|
; @param R14 opts low
|
||||||
|
; @clobbers any, !Z
|
||||||
|
|
||||||
|
valueLabelWriteValue:
|
||||||
|
push zl
|
||||||
|
push zh
|
||||||
|
bigcall Widget_GetSdramPtr ; (none)
|
||||||
|
ldd r20, Y+VLABEL_SD_OFFS_VALUE_LO
|
||||||
|
ldd r21, Y+VLABEL_SD_OFFS_VALUE_HI
|
||||||
|
adiw zh:zl, VLABEL_OFFS_POSTKOMMADIGITS
|
||||||
|
lpm r24, Z
|
||||||
|
sbiw zh:zl, VLABEL_OFFS_POSTKOMMADIGITS
|
||||||
|
rcall IntToAscii ; X=pointer to text
|
||||||
|
clr r4 ; X
|
||||||
|
clr r5
|
||||||
|
clr r6 ; Y
|
||||||
|
clr r7
|
||||||
|
mov r16, r14
|
||||||
|
andi r16, (1<<WIDGETS_OPTSLO_BORDER_BIT)
|
||||||
|
breq valueLabelWriteValue_draw
|
||||||
|
ldi r16, 2
|
||||||
|
clr r17
|
||||||
|
add r4, r16 ; x+=2
|
||||||
|
adc r5, r17
|
||||||
|
add r6, r16 ; y+=2
|
||||||
|
adc r7, r17
|
||||||
|
valueLabelWriteValue_draw:
|
||||||
|
bigcall Widget_DrawTextSDRAM
|
||||||
|
pop zh
|
||||||
|
pop zl
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
Reference in New Issue
Block a user