; ***************************************************************************
; copyright   : (C) 2024 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.   *
; ***************************************************************************


; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; This file contains timer handlers for the address protocol
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;


; ***************************************************************************
; code

.cseg



CPRO_Screen:
  in r15, SREG ; debug
  push r15
    cli

    ldi r16, 0
    rcall LCD_Fill

    ldi r18, 0
    ldi r19, 0
    rcall LCD_SetCursor
    ldi zl, LOW(cproScreenText_title)
    ldi zh, HIGH(cproScreenText_title)
    rcall LCD_PrintFromFlash

    ldi r18, 0
    ldi r19, 2
    rcall LCD_SetCursor
    ldi zl, LOW(cproScreenText_uid)
    ldi zh, HIGH(cproScreenText_uid)
    rcall LCD_PrintFromFlash
    push xh                           ; 1-4: UID
      push xl
        rcall Utils_ReadUid           ; (R16, X)
      pop xl
    pop xh
    push r18
      push r19
        mov r18, r20
        mov r19, r21
        rcall LCD_PrintHexWord
      pop r19
    pop r18
    rcall LCD_PrintHexWord

    ldi r18, 0
    ldi r19, 3
    rcall LCD_SetCursor
    ldi zl, LOW(cproScreenText_addr)
    ldi zh, HIGH(cproScreenText_addr)
    rcall LCD_PrintFromFlash
    lds r16, com2Address
    rcall LCD_PrintHexByte
    ldi r16, 32
    rcall LCD_PrintChar
    lds r16, cproMode
    rcall LCD_PrintHexByte
    ldi r16, 32
    rcall LCD_PrintChar
    lds r16, cproAddrRangeBegin
    rcall LCD_PrintHexByte

    ldi r18, 0
    ldi r19, 4
    rcall LCD_SetCursor
    ldi zl, LOW(cproScreenText_bitmap)
    ldi zh, HIGH(cproScreenText_bitmap)
    rcall LCD_PrintFromFlash
    lds r16, cproUsedAddresses
    rcall LCD_PrintHexByte
    lds r16, cproUsedAddresses+1
    rcall LCD_PrintHexByte
    lds r16, cproUsedAddresses+2
    rcall LCD_PrintHexByte
    lds r16, cproUsedAddresses+3
    rcall LCD_PrintHexByte

  pop r15
  out SREG, r15
  ret


cproScreenText_title:  .db "CPRO Screen", 0
cproScreenText_uid:    .db "UID    : ", 0
cproScreenText_addr:   .db "Address: ", 0
cproScreenText_bitmap: .db "BITMAP : ", 0

  