; ***************************************************************************
; 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_AQHOME_D_LIGHT_CONNS_ASM
#define AQH_AVR_GUI2_AQHOME_D_LIGHT_CONNS_ASM


; ***************************************************************************
; defines


; widget
.equ DLGLIGHTCONNS_OFFS_BEGIN            = CDIALOG_SIZE
.equ DLGLIGHTCONNS_OFFS_SETTINGS_LO      = DLGLIGHTCONNS_OFFS_BEGIN+0
.equ DLGLIGHTCONNS_OFFS_SETTINGS_HI      = DLGLIGHTCONNS_OFFS_BEGIN+1
.equ DLGLIGHTCONNS_SIZE                  = DLGLIGHTCONNS_OFFS_BEGIN+2


; selectors
.equ DLGLIGHTCONNS_SEL_BTN_MOTION1       = DIALOG_SEL_NEXTFREE+0
.equ DLGLIGHTCONNS_SEL_ADDR_MOTION1      = DIALOG_SEL_NEXTFREE+1
.equ DLGLIGHTCONNS_SEL_VALUE_MOTION1     = DIALOG_SEL_NEXTFREE+2
.equ DLGLIGHTCONNS_SEL_DLG_MOTION1       = DIALOG_SEL_NEXTFREE+3
.equ DLGLIGHTCONNS_SEL_BTN_MOTION2       = DIALOG_SEL_NEXTFREE+4
.equ DLGLIGHTCONNS_SEL_ADDR_MOTION2      = DIALOG_SEL_NEXTFREE+5
.equ DLGLIGHTCONNS_SEL_VALUE_MOTION2     = DIALOG_SEL_NEXTFREE+6
.equ DLGLIGHTCONNS_SEL_DLG_MOTION2       = DIALOG_SEL_NEXTFREE+7
.equ DLGLIGHTCONNS_SEL_BTN_LIGHT         = DIALOG_SEL_NEXTFREE+8
.equ DLGLIGHTCONNS_SEL_ADDR_LIGHT        = DIALOG_SEL_NEXTFREE+9
.equ DLGLIGHTCONNS_SEL_VALUE_LIGHT       = DIALOG_SEL_NEXTFREE+10
.equ DLGLIGHTCONNS_SEL_DLG_LIGHT         = DIALOG_SEL_NEXTFREE+11
.equ DLGLIGHTCONNS_SEL_BTN_NEXTFREE      = DIALOG_SEL_NEXTFREE+12




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

.cseg

; ---------------------------------------------------------------------------
; @routine DlgLightConns_new @global
;
; @param  Y       pointer to GUIAPP
; @return CFLAG   set of okay, cleared otherwise
; @return Y       address of newly created object
; @param r21:r20  pointer to settings

DlgLightConns_new:
  bigcall GuiApp_GetRootWindow        ; r19:r18=root window (none)
  brcc DlgLightConns_new_ret
  mov xl, r18                         ; use root window as parent for main window
  mov xh, r19
  ldi r24, LOW(DLGLIGHTCONNS_SIZE)
  ldi r25, HIGH(DLGLIGHTCONNS_SIZE)
  push r20
    push r21
      bigcall Object_Alloc            ; Y=space (!r16, !r17, !X)
    pop r21
  pop r20
  brcc DlgLightConns_new_ret
  rcall DlgLightConns_Init
DlgLightConns_new_ret:
  ret
; @end



; ---------------------------------------------------------------------------
; @routine DlgLightConns_Init @global
;
; @param  Y       pointer to dialog
; @param  X       pointer to root window
; @return CFLAG set of okay, cleared otherwise
; @param r21:r20  pointer to settings
; @clobbers any, !Y

DlgLightConns_Init:
  push r20
    push r21
      ldi r16, (1<<DIALOG_OPTS_STDBTNS_BIT)                                                                ; OPTS
      ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
      ldi r20, LOW(RESSOURCE_TXT_LEDCONNECTIONS)
      ldi r21, HIGH(RESSOURCE_TXT_LEDCONNECTIONS)
      ldi r22, LOW(DlgLightConns_Config*2)
      ldi r23, HIGH(DlgLightConns_Config*2)
      bigcall CDialog_Init               ; Y=main window
    pop r21
  pop r20
  brcc DlgLightConns_Init_ret

  ; store data
  std Y+DLGLIGHTCONNS_OFFS_SETTINGS_LO, r20
  std Y+DLGLIGHTCONNS_OFFS_SETTINGS_HI, r21

  ; set default signal map
  ldi r16, LOW(DlgLightConns_DefaultSignalmap*2)
  std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
  ldi r16, HIGH(DlgLightConns_DefaultSignalmap*2)
  std Y+OBJECT_OFFS_SIGNALMAP_HI, r16

DlgLightConns_Init_ret:
  ret
; @end



; ---------------------------------------------------------------------------
; @routine DlgLightConns_toGui @global
;
; @param  Y       pointer to dialog

DlgLightConns_toGui:
  ldd zl, Y+DLGLIGHTCONNS_OFFS_SETTINGS_LO
  ldd zh, Y+DLGLIGHTCONNS_OFFS_SETTINGS_HI
  
  ; motion source 1
  ldd xl, Z+LIGHTSETTINGS_OFFS_SOURCE1_NODEADDR
  clr xh
  ldi r16, DLGLIGHTCONNS_SEL_ADDR_MOTION1
  bigcall CDialog_SetChildValue

  ldd xl, Z+LIGHTSETTINGS_OFFS_SOURCE1_VALUEID
  clr xh
  ldi r16, DLGLIGHTCONNS_SEL_VALUE_MOTION1
  bigcall CDialog_SetChildValue

  ; motion source 2
  ldd xl, Z+LIGHTSETTINGS_OFFS_SOURCE2_NODEADDR
  clr xh
  ldi r16, DLGLIGHTCONNS_SEL_ADDR_MOTION2
  bigcall CDialog_SetChildValue

  ldd xl, Z+LIGHTSETTINGS_OFFS_SOURCE2_VALUEID
  clr xh
  ldi r16, DLGLIGHTCONNS_SEL_VALUE_MOTION2
  bigcall CDialog_SetChildValue

  ; light source
  ldd xl, Z+LIGHTSETTINGS_OFFS_BSOURCE_NODEADDR
  clr xh
  ldi r16, DLGLIGHTCONNS_SEL_ADDR_LIGHT
  bigcall CDialog_SetChildValue

  ldd xl, Z+LIGHTSETTINGS_OFFS_BSOURCE_VALUEID
  clr xh
  ldi r16, DLGLIGHTCONNS_SEL_VALUE_LIGHT
  bigcall CDialog_SetChildValue
  
  ret
; @end



; ---------------------------------------------------------------------------
; @routine DlgLightConns_fromGui @global
;
; @param  Y       pointer to dialog

DlgLightConns_fromGui:
  ldd zl, Y+DLGLIGHTCONNS_OFFS_SETTINGS_LO
  ldd zh, Y+DLGLIGHTCONNS_OFFS_SETTINGS_HI
  
  ; motion source 1
  ldi r16, DLGLIGHTCONNS_SEL_ADDR_MOTION1
  rcall CDialog_GetChildValue
  std Z+LIGHTSETTINGS_OFFS_SOURCE1_NODEADDR, r18

  ldi r16, DLGLIGHTCONNS_SEL_VALUE_MOTION1
  rcall CDialog_GetChildValue
  std Z+LIGHTSETTINGS_OFFS_SOURCE1_VALUEID, r18

  ; motion source 2
  ldi r16, DLGLIGHTCONNS_SEL_ADDR_MOTION2
  rcall CDialog_GetChildValue
  std Z+LIGHTSETTINGS_OFFS_SOURCE2_NODEADDR, r18

  ldi r16, DLGLIGHTCONNS_SEL_VALUE_MOTION2
  rcall CDialog_GetChildValue
  std Z+LIGHTSETTINGS_OFFS_SOURCE2_VALUEID, r18

  ; light source
  ldi r16, DLGLIGHTCONNS_SEL_ADDR_LIGHT
  rcall CDialog_GetChildValue
  std Z+LIGHTSETTINGS_OFFS_BSOURCE_NODEADDR, r18

  ldi r16, DLGLIGHTCONNS_SEL_VALUE_LIGHT
  rcall CDialog_GetChildValue
  std Z+LIGHTSETTINGS_OFFS_BSOURCE_VALUEID, r18

  ret
; @end



; ***************************************************************************
; signal handlers


; ---------------------------------------------------------------------------
; @routine DlgLightConns_OnToGui @global
;
; @param  Y       pointer to dialog
; @return CFLAG set of okay, cleared otherwise
; @clobbers any, !Y

DlgLightConns_OnToGui:
  rcall DlgLightConns_toGui
  sec
  ret
; @end



; ---------------------------------------------------------------------------
; @routine DlgLightConns_OnFromGui @global
;
; @param  Y       pointer to dialog
; @return CFLAG set of okay, cleared otherwise
; @clobbers any, !Y

DlgLightConns_OnFromGui:
  rcall DlgLightConns_fromGui
  sec
  ret
; @end



; ---------------------------------------------------------------------------
; @routine DlgLightConns_OnCmdMotion1 @global
;
; @param Y pointer to dialog
; @clobbers any, !Y

DlgLightConns_OnCmdMotion1:
  push yl
    push yh
      ldd zl, Y+DLGLIGHTCONNS_OFFS_SETTINGS_LO
      ldd zh, Y+DLGLIGHTCONNS_OFFS_SETTINGS_HI
      bigcall Widget_GetApp                     ; R19:R18=gui
      mov yl, r18
      mov yh, r19
      ldi r20, LOW(RESSOURCE_TXT_LEDMOTIONSRC1)
      ldi r21, HIGH(RESSOURCE_TXT_LEDMOTIONSRC1)
      push zl
        push zh
          bigcall DlgNodeValueId_new
        pop zh
      pop zl

      ldi r16, DLGLIGHTCONNS_SEL_DLG_MOTION1
      std Y+OBJECT_OFFS_SELECTOR, r16
      ; set values
      ldd xl, Z+LIGHTSETTINGS_OFFS_SOURCE1_NODEADDR
      clr xh
      bigcall DlgNodeValueId_SetNodeAddr
      ldd xl, Z+LIGHTSETTINGS_OFFS_SOURCE1_VALUEID
      clr xh
      bigcall DlgNodeValueId_SetValueId

      mov xl, yl
      mov xh, yh
    pop yh
  pop yl

  rcall Dialog_EnterSubDialog

  sec
  ret
; @end



; ---------------------------------------------------------------------------
; @routine DlgLightConns_OnDlgEndMotion1 @global
;
; @param Y pointer to dialog
; @clobbers any, !Y

DlgLightConns_OnDlgEndMotion1:
  cpi xl, DIALOG_RESULT_OK
  brne DlgLightConns_OnDlgEndMotion1_leave

  ; get values
  ldd zl, Y+DLGLIGHTCONNS_OFFS_SETTINGS_LO
  ldd zh, Y+DLGLIGHTCONNS_OFFS_SETTINGS_HI
  push yl
    push yh
      ldd r16, Y+DIALOG_OFFS_CURRSUBDLG_LO
      ldd yh, Y+DIALOG_OFFS_CURRSUBDLG_HI
      mov yl, r16
      bigcall DlgNodeValueId_GetNodeAddr
      std Z+LIGHTSETTINGS_OFFS_SOURCE1_NODEADDR, r18
      bigcall DlgNodeValueId_GetValueId
      std Z+LIGHTSETTINGS_OFFS_SOURCE1_VALUEID, r18
    pop yh
  pop yl
  
DlgLightConns_OnDlgEndMotion1_leave:
  bigcall Dialog_LeaveSubDialog
  sec
  ret
; @end



; ---------------------------------------------------------------------------
; @routine DlgLightConns_OnCmdMotion2 @global
;
; @param Y pointer to dialog
; @clobbers any, !Y

DlgLightConns_OnCmdMotion2:
  push yl
    push yh
      ldd zl, Y+DLGLIGHTCONNS_OFFS_SETTINGS_LO
      ldd zh, Y+DLGLIGHTCONNS_OFFS_SETTINGS_HI
      bigcall Widget_GetApp                     ; R19:R18=gui
      mov yl, r18
      mov yh, r19
      ldi r20, LOW(RESSOURCE_TXT_LEDMOTIONSRC2)
      ldi r21, HIGH(RESSOURCE_TXT_LEDMOTIONSRC2)
      push zl
        push zh
          bigcall DlgNodeValueId_new
        pop zh
      pop zl

      ldi r16, DLGLIGHTCONNS_SEL_DLG_MOTION2
      std Y+OBJECT_OFFS_SELECTOR, r16
      ; set values
      ldd xl, Z+LIGHTSETTINGS_OFFS_SOURCE2_NODEADDR
      clr xh
      bigcall DlgNodeValueId_SetNodeAddr
      ldd xl, Z+LIGHTSETTINGS_OFFS_SOURCE2_VALUEID
      clr xh
      bigcall DlgNodeValueId_SetValueId

      mov xl, yl
      mov xh, yh
    pop yh
  pop yl

  rcall Dialog_EnterSubDialog

  sec
  ret
; @end



; ---------------------------------------------------------------------------
; @routine DlgLightConns_OnDlgEndMotion2 @global
;
; @param Y pointer to dialog
; @clobbers any, !Y

DlgLightConns_OnDlgEndMotion2:
  cpi xl, DIALOG_RESULT_OK
  brne DlgLightConns_OnDlgEndMotion2_leave

  ; get values
  ldd zl, Y+DLGLIGHTCONNS_OFFS_SETTINGS_LO
  ldd zh, Y+DLGLIGHTCONNS_OFFS_SETTINGS_HI
  push yl
    push yh
      ldd r16, Y+DIALOG_OFFS_CURRSUBDLG_LO
      ldd yh, Y+DIALOG_OFFS_CURRSUBDLG_HI
      mov yl, r16
      bigcall DlgNodeValueId_GetNodeAddr
      std Z+LIGHTSETTINGS_OFFS_SOURCE2_NODEADDR, r18
      bigcall DlgNodeValueId_GetValueId
      std Z+LIGHTSETTINGS_OFFS_SOURCE2_VALUEID, r18
    pop yh
  pop yl
  
DlgLightConns_OnDlgEndMotion2_leave:
  bigcall Dialog_LeaveSubDialog
  sec
  ret
; @end



; ---------------------------------------------------------------------------
; @routine DlgLightConns_OnCmdLight @global
;
; @param Y pointer to dialog
; @clobbers any, !Y

DlgLightConns_OnCmdLight:
  push yl
    push yh
      ldd zl, Y+DLGLIGHTCONNS_OFFS_SETTINGS_LO
      ldd zh, Y+DLGLIGHTCONNS_OFFS_SETTINGS_HI
      bigcall Widget_GetApp                     ; R19:R18=gui
      mov yl, r18
      mov yh, r19
      ldi r20, LOW(RESSOURCE_TXT_LEDBRIGHTNESSSRC)
      ldi r21, HIGH(RESSOURCE_TXT_LEDBRIGHTNESSSRC)
      push zl
        push zh
          bigcall DlgNodeValueId_new
        pop zh
      pop zl

      ldi r16, DLGLIGHTCONNS_SEL_DLG_LIGHT
      std Y+OBJECT_OFFS_SELECTOR, r16
      ; set values
      ldd xl, Z+LIGHTSETTINGS_OFFS_BSOURCE_NODEADDR
      clr xh
      bigcall DlgNodeValueId_SetNodeAddr
      ldd xl, Z+LIGHTSETTINGS_OFFS_BSOURCE_VALUEID
      clr xh
      bigcall DlgNodeValueId_SetValueId

      mov xl, yl
      mov xh, yh
    pop yh
  pop yl

  rcall Dialog_EnterSubDialog
  sec
  ret
; @end



; ---------------------------------------------------------------------------
; @routine DlgLightConns_OnDlgEndLight @global
;
; @param Y pointer to dialog
; @clobbers any, !Y

DlgLightConns_OnDlgEndLight:
  cpi xl, DIALOG_RESULT_OK
  brne DlgLightConns_OnDlgEndLight_leave

  ; get values
  ldd zl, Y+DLGLIGHTCONNS_OFFS_SETTINGS_LO
  ldd zh, Y+DLGLIGHTCONNS_OFFS_SETTINGS_HI
  push yl
    push yh
      ldd r16, Y+DIALOG_OFFS_CURRSUBDLG_LO
      ldd yh, Y+DIALOG_OFFS_CURRSUBDLG_HI
      mov yl, r16
      bigcall DlgNodeValueId_GetNodeAddr
      std Z+LIGHTSETTINGS_OFFS_BSOURCE_NODEADDR, r18
      bigcall DlgNodeValueId_GetValueId
      std Z+LIGHTSETTINGS_OFFS_BSOURCE_VALUEID, r18
    pop yh
  pop yl
  
DlgLightConns_OnDlgEndLight_leave:
  bigcall Dialog_LeaveSubDialog
  sec
  ret
; @end






; ***************************************************************************
; data in FLASH


DlgLightConns_Config:
  .db CWIDGETCFG_MAINWIDGET_TYPE_MLAYOUT, 0                 ; TYPE, FLAGS
  .dw 0                                                     ; STYLE
  .db 3, 0                                                  ; PARAM1, PARAM2
  

  ; header widget1
  .db CWIDGETCFG_WIDGET_TYPE_LABEL, 0                       ; TYPE, FLAGS
  .db 0, 0                                                  ; SELECTOR, RESERVED
  .db 0, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | \
         (WIDGET_PACK_CENTER<<WIDGET_PACK_VSELF0_BIT) | \
         (WIDGET_PACK_BEGIN<<WIDGET_PACK_HCONTENT0_BIT) | \
         (WIDGET_PACK_CENTER<<WIDGET_PACK_VCONTENT0_BIT)    ; OPTS, PACK
  .dw 0                                                     ; STYLE
  .dw RESSOURCE_TXT_TYPE                                    ; PARAM1, PARAM2
  .dw 0                                                     ; PARAM3, PARAM4
  .dw 0, 0                                                  ; MINVAL, MAXVAL

  ; header widget2
  .db CWIDGETCFG_WIDGET_TYPE_LABEL, 0                       ; TYPE, FLAGS
  .db 0, 0                                                  ; SELECTOR, RESERVED
  .db 0, (WIDGET_PACK_END<<WIDGET_PACK_HSELF0_BIT) | \
         (WIDGET_PACK_CENTER<<WIDGET_PACK_VSELF0_BIT) | \
         (WIDGET_PACK_BEGIN<<WIDGET_PACK_HCONTENT0_BIT) | \
         (WIDGET_PACK_CENTER<<WIDGET_PACK_VCONTENT0_BIT)    ; OPTS, PACK
  .dw 0                                                     ; STYLE
  .dw RESSOURCE_TXT_NODEADDR_S                              ; PARAM1, PARAM2
  .dw 0                                                     ; PARAM3, PARAM4
  .dw 0, 0                                                  ; MINVAL, MAXVAL

  ; header widget3
  .db CWIDGETCFG_WIDGET_TYPE_LABEL, 0                       ; TYPE, FLAGS
  .db 0, 0                                                  ; SELECTOR, RESERVED
  .db 0, (WIDGET_PACK_END<<WIDGET_PACK_HSELF0_BIT) | \
         (WIDGET_PACK_CENTER<<WIDGET_PACK_VSELF0_BIT) | \
         (WIDGET_PACK_BEGIN<<WIDGET_PACK_HCONTENT0_BIT) | \
         (WIDGET_PACK_CENTER<<WIDGET_PACK_VCONTENT0_BIT)    ; OPTS, PACK
  .dw 0                                                     ; STYLE
  .dw RESSOURCE_TXT_VALUEID_S                               ; PARAM1, PARAM2
  .dw 0                                                     ; PARAM3, PARAM4
  .dw 0, 0                                                  ; MINVAL, MAXVAL


  ; line1 widget1
  .db CWIDGETCFG_WIDGET_TYPE_TEXTBUTTON, 0                  ; TYPE, FLAGS
  .db DLGLIGHTCONNS_SEL_BTN_MOTION1, 0                      ; SELECTOR, RESERVED
  .db (1<<WIDGET_OPTS_BORDER_BIT), \
      (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | \
      (WIDGET_PACK_CENTER<<WIDGET_PACK_VSELF0_BIT) | \
      (WIDGET_PACK_BEGIN<<WIDGET_PACK_HCONTENT0_BIT) | \
      (WIDGET_PACK_CENTER<<WIDGET_PACK_VCONTENT0_BIT)       ; OPTS, PACK
  .dw (DefaultStyle_SpacyButton*2)                          ; STYLE
  .dw RESSOURCE_TXT_MOTIONSENSOR1_S                         ; PARAM1, PARAM2 (text ressource)
  .db 0, BUTTON_MODE_NORMAL                                 ; PARAM3, PARAM4
  .dw 0, 0                                                  ; MINVAL, MAXVAL

  ; line1 widget2
  .db CWIDGETCFG_WIDGET_TYPE_VALUELABEL, 0
  .db DLGLIGHTCONNS_SEL_ADDR_MOTION1, 0                     ; SELECTOR, RESERVED
  .db 0, \
      (WIDGET_PACK_END<<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)       ; OPTS, PACK
  .dw 0                                                     ; STYLE
  .db 0, 0                                                  ; PARAM1, PARAM2 (postkomma digits, total digits)
  .db 0, 0                                                  ; PARAM3, PARAM4
  .dw 0, 0                                                  ; MINVAL, MAXVAL

  ; line1 widget3
  .db CWIDGETCFG_WIDGET_TYPE_VALUELABEL, 0
  .db DLGLIGHTCONNS_SEL_VALUE_MOTION1, 0                    ; SELECTOR, RESERVED
  .db 0, \
      (WIDGET_PACK_END<<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)       ; OPTS, PACK
  .dw 0                                                     ; STYLE
  .db 0, 0                                                  ; PARAM1, PARAM2 (postkomma digits, total digits)
  .db 0, 0                                                  ; PARAM3, PARAM4
  .dw 0, 0                                                  ; MINVAL, MAXVAL


  ; line2 widget1
  .db CWIDGETCFG_WIDGET_TYPE_TEXTBUTTON, 0                  ; TYPE, FLAGS
  .db DLGLIGHTCONNS_SEL_BTN_MOTION2, 0                      ; SELECTOR, RESERVED
  .db (1<<WIDGET_OPTS_BORDER_BIT), \
      (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | \
      (WIDGET_PACK_CENTER<<WIDGET_PACK_VSELF0_BIT) | \
      (WIDGET_PACK_BEGIN<<WIDGET_PACK_HCONTENT0_BIT) | \
      (WIDGET_PACK_CENTER<<WIDGET_PACK_VCONTENT0_BIT)       ; OPTS, PACK
  .dw (DefaultStyle_SpacyButton*2)                          ; STYLE
  .dw RESSOURCE_TXT_MOTIONSENSOR2_S                         ; PARAM1, PARAM2 (text ressource)
  .db 0, BUTTON_MODE_NORMAL                                 ; PARAM3, PARAM4
  .dw 0, 0                                                  ; MINVAL, MAXVAL

  ; line2 widget2
  .db CWIDGETCFG_WIDGET_TYPE_VALUELABEL, 0
  .db DLGLIGHTCONNS_SEL_ADDR_MOTION2, 0                     ; SELECTOR, RESERVED
  .db 0, \
      (WIDGET_PACK_END<<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)       ; OPTS, PACK
  .dw 0                                                     ; STYLE
  .db 0, 0                                                  ; PARAM1, PARAM2 (postkomma digits, total digits)
  .db 0, 0                                                  ; PARAM3, PARAM4
  .dw 0, 0                                                  ; MINVAL, MAXVAL

  ; line2 widget3
  .db CWIDGETCFG_WIDGET_TYPE_VALUELABEL, 0
  .db DLGLIGHTCONNS_SEL_VALUE_MOTION2, 0                    ; SELECTOR, RESERVED
  .db 0, \
      (WIDGET_PACK_END<<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)       ; OPTS, PACK
  .dw 0                                                     ; STYLE
  .db 0, 0                                                  ; PARAM1, PARAM2 (postkomma digits, total digits)
  .db 0, 0                                                  ; PARAM3, PARAM4
  .dw 0, 0                                                  ; MINVAL, MAXVAL


  ; line3 widget1
  .db CWIDGETCFG_WIDGET_TYPE_TEXTBUTTON, 0                  ; TYPE, FLAGS
  .db DLGLIGHTCONNS_SEL_BTN_LIGHT, 0                      ; SELECTOR, RESERVED
  .db (1<<WIDGET_OPTS_BORDER_BIT), \
      (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | \
      (WIDGET_PACK_CENTER<<WIDGET_PACK_VSELF0_BIT) | \
      (WIDGET_PACK_BEGIN<<WIDGET_PACK_HCONTENT0_BIT) | \
      (WIDGET_PACK_CENTER<<WIDGET_PACK_VCONTENT0_BIT)       ; OPTS, PACK
  .dw (DefaultStyle_SpacyButton*2)                          ; STYLE
  .dw RESSOURCE_TXT_LIGHTSENSOR_S                           ; PARAM1, PARAM2 (text ressource)
  .db 0, BUTTON_MODE_NORMAL                                 ; PARAM3, PARAM4
  .dw 0, 0                                                  ; MINVAL, MAXVAL

  ; line3 widget2
  .db CWIDGETCFG_WIDGET_TYPE_VALUELABEL, 0
  .db DLGLIGHTCONNS_SEL_ADDR_LIGHT, 0                     ; SELECTOR, RESERVED
  .db 0, \
      (WIDGET_PACK_END<<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)       ; OPTS, PACK
  .dw 0                                                     ; STYLE
  .db 0, 0                                                  ; PARAM1, PARAM2 (postkomma digits, total digits)
  .db 0, 0                                                  ; PARAM3, PARAM4
  .dw 0, 0                                                  ; MINVAL, MAXVAL

  ; line3 widget3
  .db CWIDGETCFG_WIDGET_TYPE_VALUELABEL, 0
  .db DLGLIGHTCONNS_SEL_VALUE_LIGHT, 0                      ; SELECTOR, RESERVED
  .db 0, \
      (WIDGET_PACK_END<<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)       ; OPTS, PACK
  .dw 0                                                     ; STYLE
  .db 0, 0                                                  ; PARAM1, PARAM2 (postkomma digits, total digits)
  .db 0, 0                                                  ; PARAM3, PARAM4
  .dw 0, 0                                                  ; MINVAL, MAXVAL

  ; end of dialog configuration
  .dw 0





; signal map
DlgLightConns_DefaultSignalmap:
  ; header
  .dw CDialog_DefaultSignalmap*2  ; next table to use
  ; entries
  .db 0,                              DIALOG_SIGNAL_TOGUI,      LOW(DlgLightConns_OnToGui),         HIGH(DlgLightConns_OnToGui)
  .db 0,                              DIALOG_SIGNAL_FROMGUI,    LOW(DlgLightConns_OnFromGui),       HIGH(DlgLightConns_OnFromGui)
  .db DLGLIGHTCONNS_SEL_BTN_MOTION1,  WIDGET_SIGNAL_COMMAND,    LOW(DlgLightConns_OnCmdMotion1),    HIGH(DlgLightConns_OnCmdMotion1)
  .db DLGLIGHTCONNS_SEL_BTN_MOTION2,  WIDGET_SIGNAL_COMMAND,    LOW(DlgLightConns_OnCmdMotion2),    HIGH(DlgLightConns_OnCmdMotion2)
  .db DLGLIGHTCONNS_SEL_BTN_LIGHT,    WIDGET_SIGNAL_COMMAND,    LOW(DlgLightConns_OnCmdLight),      HIGH(DlgLightConns_OnCmdLight)
  .db DLGLIGHTCONNS_SEL_DLG_MOTION1,  WIDGET_SIGNAL_DIALOG_END, LOW(DlgLightConns_OnDlgEndMotion1), HIGH(DlgLightConns_OnDlgEndMotion1)
  .db DLGLIGHTCONNS_SEL_DLG_MOTION2,  WIDGET_SIGNAL_DIALOG_END, LOW(DlgLightConns_OnDlgEndMotion2), HIGH(DlgLightConns_OnDlgEndMotion2)
  .db DLGLIGHTCONNS_SEL_DLG_LIGHT,    WIDGET_SIGNAL_DIALOG_END, LOW(DlgLightConns_OnDlgEndLight),   HIGH(DlgLightConns_OnDlgEndLight)
  ; end of table
  .db 0, 0, 0, 0



#endif

