shows a pictogram for a sensor and changes background color according to values received from a given sensor.
151 lines
3.7 KiB
NASM
151 lines
3.7 KiB
NASM
; ***************************************************************************
|
|
; 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_IMAGEVIEW_ASM
|
|
#define AQH_AVR_GUI2_IMAGEVIEW_ASM
|
|
|
|
|
|
; ***************************************************************************
|
|
; defines
|
|
|
|
; IMGVIEW in flash
|
|
.equ IMGVIEW_OFFS_IMGVIEW = WIDGET_SIZE
|
|
.equ IMGVIEW_OFFS_RESSOURCEID_LO = IMGVIEW_OFFS_IMGVIEW+0
|
|
.equ IMGVIEW_OFFS_RESSOURCEID_HI = IMGVIEW_OFFS_IMGVIEW+1
|
|
.equ IMGVIEW_SIZE = IMGVIEW_OFFS_IMGVIEW+2
|
|
|
|
|
|
; SDRAM data for IMGVIEW
|
|
.equ IMGVIEW_SD_OFFS_IMGVIEW = WIDGET_SD_SIZE
|
|
.equ IMGVIEW_SD_OFFS_BGCOL_LO = IMGVIEW_SD_OFFS_IMGVIEW+0
|
|
.equ IMGVIEW_SD_OFFS_BGCOL_HI = IMGVIEW_SD_OFFS_IMGVIEW+1
|
|
.equ IMGVIEW_SD_SIZE = IMGVIEW_SD_OFFS_IMGVIEW+2
|
|
|
|
|
|
; signals
|
|
.equ IMGVIEW_SIGNAL_SETBGCOL = WIDGET_SIGNAL_NEXTFREE+0
|
|
.equ IMGVIEW_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
|
|
|
|
ImageView_OnCreate:
|
|
bigcall Widget_OnCreate
|
|
bigcall Widget_GetSdramPtr ; (none)
|
|
ldi r16, LOW(STYLE_WIN_BACKGROUND)
|
|
ldi r17, HIGH(STYLE_WIN_BACKGROUND)
|
|
std Y+IMGVIEW_SD_OFFS_BGCOL_LO, r16
|
|
std Y+IMGVIEW_SD_OFFS_BGCOL_HI, r17
|
|
sec
|
|
ret
|
|
; @end
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; @routine ImageView_OnSetBgCol @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
|
|
|
|
ImageView_OnSetBgCol:
|
|
bigcall OBJ_IsObject ; (none)
|
|
brcc ImageView_OnSetBgCol_ret
|
|
push zl
|
|
push zh
|
|
rcall Widget_GetSdramPtr ; (none)
|
|
std Y+IMGVIEW_SD_OFFS_BGCOL_LO, xl
|
|
std Y+IMGVIEW_SD_OFFS_BGCOL_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
|
|
ImageView_OnSetBgCol_ret:
|
|
sec
|
|
ret
|
|
; @end
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; @routine Widget_OnDraw @global
|
|
;
|
|
; @param Z byte address of widget object (for LPM!)
|
|
; @return CFLAG set if signal handled
|
|
; @clobbers any, !Z
|
|
|
|
ImageView_OnDraw:
|
|
bigcall Widget_GetSdramPtr ; (none)
|
|
ldd r16, Y+WIDGET_SD_OFFS_FLAGS
|
|
andi r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
|
breq ImageView_OnDraw_ret
|
|
|
|
; rcall Widget_Clear
|
|
|
|
push zl
|
|
push zh
|
|
; get ressource id
|
|
adiw zh:zl, IMGVIEW_OFFS_RESSOURCEID_LO
|
|
lpm r16, Z+
|
|
lpm r17, Z
|
|
sbiw zh:zl, IMGVIEW_OFFS_RESSOURCEID_LO+1
|
|
; get ressource
|
|
ldi zl, LOW(RESSOURCE_ADDR*2)
|
|
ldi zh, HIGH(RESSOURCE_ADDR*2)
|
|
bigcall RES_GetRessource
|
|
mov r12, zl
|
|
mov r13, zh
|
|
pop zh
|
|
pop zl
|
|
brcc ImageView_OnDraw_done
|
|
|
|
; get background color
|
|
ldd r0, Y+IMGVIEW_SD_OFFS_BGCOL_LO
|
|
ldd r1, Y+IMGVIEW_SD_OFFS_BGCOL_HI
|
|
|
|
; draw at 0/0
|
|
clr r4 ; X
|
|
clr r5
|
|
clr r6 ; Y
|
|
clr r7
|
|
|
|
bigcall Widget_DrawImage
|
|
|
|
ImageView_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
|
|
|
|
ImageView_OnDraw_ret:
|
|
sec
|
|
ret
|
|
; @end
|
|
|
|
|
|
|
|
#endif
|
|
|