avr: started woring on hspinner.
This commit is contained in:
206
avr/modules/lcd2/gui/base/hspinner.asm
Normal file
206
avr/modules/lcd2/gui/base/hspinner.asm
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; 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_GUI_HSPINNER_ASM
|
||||||
|
#define AQH_AVR_GUI_HSPINNER_ASM
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; defines
|
||||||
|
|
||||||
|
.equ HSPINNER_OFFS_BEGIN = HLAYOUT_SIZE
|
||||||
|
.equ HSPINNER_OFFS_CURVALUE_LO = HSPINNER_OFFS_BEGIN+0
|
||||||
|
.equ HSPINNER_OFFS_CURVALUE_HI = HSPINNER_OFFS_BEGIN+1
|
||||||
|
.equ HSPINNER_OFFS_MINVALUE_LO = HSPINNER_OFFS_BEGIN+2
|
||||||
|
.equ HSPINNER_OFFS_MINVALUE_HI = HSPINNER_OFFS_BEGIN+3
|
||||||
|
.equ HSPINNER_OFFS_MAXVALUE_LO = HSPINNER_OFFS_BEGIN+4
|
||||||
|
.equ HSPINNER_OFFS_MAXVALUE_HI = HSPINNER_OFFS_BEGIN+5
|
||||||
|
.equ HSPINNER_OFFS_DIGITS = HSPINNER_OFFS_BEGIN+6
|
||||||
|
.equ HSPINNER_OFFS_FLAGS = HSPINNER_OFFS_BEGIN+7
|
||||||
|
.equ HSPINNER_SIZE = HSPINNER_OFFS_BEGIN+8
|
||||||
|
|
||||||
|
|
||||||
|
; signals
|
||||||
|
.equ HSPINNER_SIGNAL_LEFT = WIDGET_SIGNAL_NEXTFREE+0
|
||||||
|
.equ HSPINNER_SIGNAL_RIGHT = WIDGET_SIGNAL_NEXTFREE+1
|
||||||
|
.equ HSPINNER_SIGNAL_NEXTFREE = WIDGET_SIGNAL_NEXTFREE+2
|
||||||
|
|
||||||
|
|
||||||
|
; values
|
||||||
|
.equ HSPINNER_VALUE_MINVALUE = WIDGET_VALUE_NEXTFREE+0
|
||||||
|
.equ HSPINNER_VALUE_MAXVALUE = WIDGET_VALUE_NEXTFREE+1
|
||||||
|
.equ HSPINNER_VALUE_NEXTFREE = WIDGET_VALUE_NEXTFREE+2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; code
|
||||||
|
|
||||||
|
.cseg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine HSpinner_new @global
|
||||||
|
;
|
||||||
|
; @return CFLAG set of okay, cleared otherwise
|
||||||
|
; @return Y address of newly created object
|
||||||
|
; @param X parent widget
|
||||||
|
; @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 (including komma, if r20>0)
|
||||||
|
; @clobbers any
|
||||||
|
|
||||||
|
HSpinner_new:
|
||||||
|
ldi r24, LOW(HSPINNER_SIZE)
|
||||||
|
ldi r25, HIGH(HSPINNER_SIZE)
|
||||||
|
push r20
|
||||||
|
push r21
|
||||||
|
bigcall Object_Alloc ; (!r16, !r17, !X)
|
||||||
|
pop r21
|
||||||
|
pop r20
|
||||||
|
brcc HSpinner_new_ret
|
||||||
|
rcall HSpinner_Init ; (any, !Y)
|
||||||
|
sec
|
||||||
|
HSpinner_new_ret:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine HSpinner_Init @global
|
||||||
|
;
|
||||||
|
; @param Y address of widget
|
||||||
|
; @param X parent widget (if any)
|
||||||
|
; @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 (including komma, if r20>0)
|
||||||
|
; @clobbers any, !Y
|
||||||
|
|
||||||
|
HSpinner_Init:
|
||||||
|
; call base class
|
||||||
|
push r20
|
||||||
|
push r21
|
||||||
|
ldi r20, HLAYOUT_MODE_EXPAND
|
||||||
|
bigcall HLayout_Init
|
||||||
|
pop r21
|
||||||
|
pop r20
|
||||||
|
brcc HSpinner_Init_ret
|
||||||
|
|
||||||
|
; set values
|
||||||
|
std Y+HSPINNER_OFFS_DIGITS, r20
|
||||||
|
|
||||||
|
; set default signal map
|
||||||
|
ldi r16, LOW(HSpinner_DefaultSignalmap*2)
|
||||||
|
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
|
||||||
|
ldi r16, HIGH(HSpinner_DefaultSignalmap*2)
|
||||||
|
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
|
||||||
|
|
||||||
|
rcall hSpinnerCreateChildren ; (any, !Y)
|
||||||
|
HSpinner_Init_ret:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine hSpinnerCreateChildren
|
||||||
|
;
|
||||||
|
; @param Y spinner object
|
||||||
|
; @param r20 number of postkomma digits
|
||||||
|
; @param r21 total number of digits (including komma, if r20>0)
|
||||||
|
; @clobbers any, !Y
|
||||||
|
|
||||||
|
hSpinnerCreateChildren:
|
||||||
|
push yl
|
||||||
|
push yh
|
||||||
|
mov xl, yl ; parent
|
||||||
|
mov xh, yh
|
||||||
|
|
||||||
|
; create left button
|
||||||
|
push r20
|
||||||
|
push r21
|
||||||
|
ldi r16, 0 ; OPTS
|
||||||
|
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_CENTER<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||||
|
ldi r20, LOW(RESSOURCE_IMG_ARROWLEFT) ; image ressource
|
||||||
|
ldi r21, HIGH(RESSOURCE_IMG_ARROWLEFT)
|
||||||
|
ldi r22, HSPINNER_SIGNAL_LEFT ; selector
|
||||||
|
push xl
|
||||||
|
push xh
|
||||||
|
bigcall ImageButton_new
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
|
pop r21
|
||||||
|
pop r20
|
||||||
|
brcc hSpinnerCreateChildren_popRet
|
||||||
|
|
||||||
|
; create value label
|
||||||
|
ldi r16, 0 ; OPTS
|
||||||
|
ldi r17, (WIDGET_PACK_CENTER<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_CENTER<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||||
|
push xl
|
||||||
|
push xh
|
||||||
|
bigcall ValueLabel_new
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
|
brcc hSpinnerCreateChildren_popRet
|
||||||
|
|
||||||
|
; create right button
|
||||||
|
ldi r16, 0 ; OPTS
|
||||||
|
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_CENTER<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||||
|
ldi r20, LOW(RESSOURCE_IMG_ARROWRIGHT) ; image ressource
|
||||||
|
ldi r21, HIGH(RESSOURCE_IMG_ARROWRIGHT)
|
||||||
|
ldi r22, HSPINNER_SIGNAL_RIGHT ; selector
|
||||||
|
push xl
|
||||||
|
push xh
|
||||||
|
bigcall ImageButton_new
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
|
hSpinnerCreateChildren_popRet:
|
||||||
|
pop yh
|
||||||
|
pop yl
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; signal handlers
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; data in FLASH
|
||||||
|
|
||||||
|
HSpinner_DefaultSignalmap:
|
||||||
|
; header
|
||||||
|
.dw HLayout_DefaultSignalmap*2 ; next table to use
|
||||||
|
; entries
|
||||||
|
.db 0, 0, 0, 0 ; end of table
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user