?? fireplace.src
字號:
remote_sound_judge:
cp sound_status,#01H
jr eq,remote_sound_judge1
call sound_close
jr remote_lamp_judge
remote_sound_judge1:
call sound_open
remote_lamp_judge:
cp lamp_status,#01H
jr eq,remote_lamp_judge1
call lamp_close
jr remote_fire_control_end
remote_lamp_judge1:
call lamp_open
remote_fire_control_end:
ld beep_flag,#01h
ld remote_value,#00h
ret
;*********************************************************************************
remote_fire_inc:
cp fire_value,#0ah
jr z,remote_fire_inc_end
tm fire_status,#01H
jr z,remote_fire_inc_end ;fire off ,exit
inc fire_value ;fire+
cp fire_value,#01H
jr ult,remote_fire_min
cp fire_value,#0AH
jr ugt,remote_fire_max
jr remote_fire_inc1
remote_fire_min:
ld fire_value,#01H
jr remote_fire_inc1
remote_fire_max:
ld fire_value,#0AH
remote_fire_inc1:
ld I2C_data,fire_value
ld I2C_dress,#fire_value_dress
call WR_24C02
ld beep_flag,#01h
remote_fire_inc_end:
;ld remote_again,#00 ;#00h
ld remote_value,#01h
ret
;**********************************************************************************
remote_fire_dec:
cp fire_value,#01H
jr z,remote_fire_dec_end
tm fire_status,#01H
jr z,remote_fire_dec_end ;fire off ,exit
dec fire_value ;fire-
cp fire_value,#01H
jr ult,remote_fire_min_1
cp fire_value,#0AH
jr ugt,remote_fire_max_2
jr remote_fire_dec1
remote_fire_min_1:
ld fire_value,#01H
jr remote_fire_dec1
remote_fire_max_2:
ld fire_value,#0AH
remote_fire_dec1:
ld I2C_data,fire_value
ld I2C_dress,#fire_value_dress
call WR_24C02
ld beep_flag,#01h
remote_fire_dec_end:
;ld remote_again,#00 ;#00h
ld remote_value,#02h
ret
;**********************************************************************************
remote_temp_control:
tm temp_status,#01H
jr z,remote_temp_on ;if temp_status=0=off jump to temp on
remote_temp_off: ;if temp_status=1=on to temp off
ld temp_status,#00H
call temp_ad_off
jr remote_temp_control1
remote_temp_on:
ld temp_status,#01H
remote_temp_control1:
ld beep_flag,#01h
remote_temp_control_end:
ld remote_value,#00h
ret
;**********************************************************************************
remote_temp_inc:
cp temp_value,#0ah
jr z,remote_temp_inc_end
tm temp_status,#01H
jr z,remote_temp_inc_end ;temp off ,exit
inc temp_value ;temp+
cp temp_value,#01H
jr ult,remote_temp_min
cp temp_value,#0AH
jr ugt,remote_temp_max
jr remote_temp_inc1
remote_temp_min:
ld temp_value,#01H
jr remote_temp_inc1
remote_temp_max:
ld temp_value,#0AH
remote_temp_inc1:
ld I2C_data,temp_value
ld I2C_dress,#temp_value_dress
call WR_24C02
ld beep_flag,#01h
remote_temp_inc_end:
;ld remote_again,#00 ;#00h
ld remote_value,#03h
ret
;**********************************************************************************
remote_temp_dec:
cp temp_value,#01H
jr z,remote_temp_dec_end
tm temp_status,#01H
jr z,remote_temp_dec_end ;temp off ,exit
dec temp_value ;temp-
cp temp_value,#01H
jr ult,remote_temp_min_1
cp temp_value,#0AH
jr ugt,remote_temp_max_2
jr remote_temp_dec1
remote_temp_min_1:
ld temp_value,#01H
jr remote_temp_dec1
remote_temp_max_2:
ld temp_value,#0AH
remote_temp_dec1:
ld I2C_data,temp_value
ld I2C_dress,#temp_value_dress
call WR_24C02
ld beep_flag,#01h
remote_temp_dec_end:
;ld remote_again,#00 ;#00h
ld remote_value,#04h
ret
;**********************************************************************************
remote_sound_control:
tm fire_status,#01H
jr z,remote_sound_control_end
tm sound_status,#01H
jr z,remote_sound_on ;if sound_status=0=off jump to sound on
remote_sound_off: ;if sound_status=1=on to sound off
ld sound_status,#00H
call sound_close
jr remote_sound_control1
remote_sound_on:
ld sound_status,#01H
call sound_open
remote_sound_control1:
ld I2C_data,sound_status
ld I2C_dress,#sound_status_dress
call WR_24C02
ld beep_flag,#01h
remote_sound_control_end:
ld remote_value,#00h
ret
;***********************************************************************************
remote_lamp_control:
tm fire_status,#01H
jr z,remote_lamp_control_end
tm lamp_status,#01H
jr nz,remote_lamp_off ;if lamp_status=0=off jump to lamp on
remote_lamp_on:
ld lamp_status,#01H
call lamp_open
jr remote_lamp_control1
remote_lamp_off: ;if lamp_status=1=on to lamp off
ld lamp_status,#00H
call lamp_close
remote_lamp_control1:
ld I2C_data,lamp_status
ld I2C_dress,#lamp_status_dress
call WR_24C02
ld beep_flag,#01h
remote_lamp_control_end:
ld remote_value,#00h
ret
;***********************************************************************************
;*******************************************************************
counter_check:
;ld key_first_delay,01h
tm common_flag,#01h
jp z,counter_check_end
inc AD_convert_time1
cp AD_convert_time1,#200
jr ult,counter_check0
ld AD_convert_time1,#00
ld AD_convert_time,#01h
counter_check0:
tm key_hold_down,#01H ;key hold counter 120us*10*255=306ms
jr z,counter_check1
inc key_press_time1
cp key_press_time1,#100
jr ult,counter_check1
ld key_press_time1,#100
inc key_press_time2
cp key_press_time2,#250
jr ult,counter_check1
ld key_press_time2,#250
inc key_press_time
cp key_press_time,#255 ;255 #150
jr ult,counter_check1
ld key_press_time,#100 ;#0
ld key_hold_flag,#01h
counter_check1:
tm fire_status,#01H ;motor counter 120us*10*30=32ms
jr z,counter_check2
inc motor_delay_time
cp motor_delay_time,motor_value
jr ult,counter_check2
or p2,#01000000B
cp motor_delay_time,#50 ;30
jr ult,counter_check2
and p2,#10111111B ;motor=p2.6
ld motor_delay_time,#0
counter_check2:
tm beep_flag,#01h ;beep counter 10*80=800
jr z,counter_check3
inc beep_counter
cp beep_counter,#73 ;14
jr ult,counter_check3
ld beep_flag,#00h ;int 800 disenble beep
ld beep_counter,#0
;or p0,#01000000B ;set p0.6
and p0,#10111111B ;clear p0.6
counter_check3:
tm fire_status,#01h
jr nz,counter_check3_1
tm temp_status,#01h
jr z,counter_check4
counter_check3_1:
tm led_display_flag,#01H ;if time=14.4s led off, else led on
jr z,counter_check4 ;120us*10*120*100=14.4s
inc led_15s_time1
cp led_15s_time1,#120
jr ult,counter_check4
ld led_15s_time1,#0
inc led_15s_time2
cp led_15s_time2,#100 ;21
jr ult,counter_check4
ld led_15s_time2,#0
ld led_display_flag,#00H
counter_check4:
tm temp_sensor,#01H
jr nz,remote_repeat_program
inc not_sensor_counter1
cp not_sensor_counter1,#100
jr ult,remote_repeat_program
ld not_sensor_counter1,#0
inc not_sensor_counter2
cp not_sensor_counter2,#15
jr ult,remote_repeat_program
ld not_sensor_counter2,#0
ld beep_flag,#01h
remote_repeat_program:
tm remote_repeat_start,#01h
jr z,cleat_common_flag
inc remote_repeat_time
cp remote_repeat_time,#120 ;120
jr ult,cleat_common_flag
ld remote_again,#00h
ld remote_repeat_time,#0
ld remote_repeat_start,#00h
cleat_common_flag:
ld common_flag,#00h
counter_check_end:
ret
;***********************led scan************************************
;********************************************************************
led_scan:
tm led_display_flag,#01H ;if time=15s led off, else led on
jp z,led_scan_end
led_temp:
tm temp_status,#01H
jr z,led_temp1
ld r2,#0fh
ld r3,temp_value
ldc r0,@rr2 ;of00h
jr led_temp2
led_temp1:
ld r0,#0ffh
led_temp2:
or p1,#02H
or p2,#03H ;Q1 Q2 Q3 off
ld serial_data,r0 ;temp on
call serial_out
and p1,#11111101B ;Q2 on p1.1
call delay20ms
tm temp_status,#01H
jr z,led_temp3
ld r2,#0fh
ld r3,temp_value
ldc r0,#10h[rr2] ;0f10h
jr led_temp4
led_temp3:
ld r0,#0ffh
led_temp4:
or p1,#02H
or p2,#03H ;Q1 Q2 Q3 off
ld serial_data,r0 ;temp on
call serial_out
and p2,#11111110B ;Q3 on p2.0
call delay20ms
led_fire:
tm fire_status,#01H
jr z,led_fire1
ld r2,#0fh
ld r3,fire_value
ldc r0,@rr2 ;of00h
jr led_fire2
led_fire1:
ld r0,#0ffh
led_fire2:
or p1,#02H
or p2,#03H ;Q1 Q2 Q3 off
ld serial_data,r0 ;temp on
call serial_out
and p2,#11111101B ;Q1 on p2.1
call delay20ms
tm fire_status,#01H
jr z,led_fire3
ld r2,#0fh
ld r3,fire_value
ldc r0,#20h[rr2] ;0f20h
jr led_fire4
led_fire3:
ld r0,#0ffh
led_fire4:
or p1,#02H
or p2,#03H ;Q1 Q2 Q3 off
ld serial_data,r0 ;temp on
call serial_out
and p2,#11111110B ;Q3 on p2.0
call delay20ms
led_scan_end:
or p1,#02H
or p2,#03H ;Q1 Q2 Q3 off
ret
;*******************************************************************
;******************serial out subroutine****************************
serial_out:
ld r5,#08 ;n=8
ld r4,serial_data
serial_out_loop:
and p2,#11110111B ;clk=0
rrc r4
jr c,set_data_1
;and p1,#0feh ;p1.0->data in
and p2,#11111011B ;p2.2->data in
jp judge_164_end
set_data_1:
;or p1,#01h
or p2,#00000100B
judge_164_end:
nop
or p2,#00001000B ;clk=1
nop
dec r5 ;serial_number-1=0?
jp nz,serial_out_loop ;if serial_number=0 end, else again
ret
;***************************************************************************
;**************************scan_key subroutine******************************
key_scan:
; ld serial_clk_0,#0f7H ;74ls164 clk=P2.3 clk=0
; ld serial_clk_1,#08H ;clk=1
or p1,#02H
or p2,#03H ;Q1 Q2 Q3 off
key_first_scan:
ld serial_data,#00H
call serial_out ;serial out 00
tm p0,#01H ;test P0.0=0 ?
jr z, key_operation1 ;if P0.0=0 to key_operation
ld key_hold_flag,#00H ;no key clear key_first_flag
ld key_press_time,#00H ;no key clear key_press_time
ld key_press_time1,#00H
ld key_press_time2,#00H
ld key_press_down,#00H ;no key press down
ld key_hold_down,#00H ; already press
ld key_release,#00H ;key realease
ld key_hold_flag,#01h
;ld key_first_delay,00h
key_scan_end:
ret
key_operation1:
call delay20ms
;tm key_first_delay,01h
;jr z,key_operation1_end
ld serial_data,#00H
call serial_out ;serial out 00
tm p0,#01H ;test P0.0=0 ?
jr z, key_value_judge ;if P0.0=0 to key_operation
; jp key_scan_end
key_operation1_end:
ret
;************************************************************
key_validate:
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -