📄 aqua ok.asm
字号:
movf MAX,W
call INCREMENTE
movf DONNEE,W
call LCDHEX
call RELACHE
goto boucle_regl
fin_regl
call RELACHE
movf ADRESSE,W ;ecriture
call DS1302
return
;****************************************************************************
; INCREMENTE == incremente DONNEE (en BCD), valeur max + 1 dans W
;****************************************************************************
INCREMENTE
movwf TEMP2
movf DONNEE,W
movwf TEMP1
incf TEMP1
movlw 0Fh
andwf TEMP1,W
sublw 0Ah
btfss STATUS,Z
goto fin_inc
movlw 0Ah
subwf TEMP1
movlw 10h
addwf TEMP1
fin_inc
movf TEMP1,W
movwf DONNEE
movf TEMP2,W
subwf DONNEE,W
btfsc STATUS,Z
clrf DONNEE
return
;****************************************************************************
; OUINON == menu OUI / NON, emplacement dans W, resultat dans DONNEE
; FF : OUI, 00 : NON
;****************************************************************************
OUINON
movwf TEMP2
non
movf TEMP2,W
call LCDSETADR
movlw 7Dh
call LCDSTR2
clrf DONNEE
non_att
clrwdt
btfsc PB,2
goto fin_ouinon
btfss PB,1
goto non_att
call RELACHE
oui
movf TEMP2,W
call LCDSETADR
movlw 79h
call LCDSTR2
movlw 0FFh
movwf DONNEE
oui_att
clrwdt
btfsc PB,2
goto fin_ouinon
btfss PB,1
goto oui_att
call RELACHE
goto non
fin_ouinon
call RELACHE
return
;****************************************************************************
; MENU_UTIL == menu utilisateur
;****************************************************************************
MENU_UTIL
movlw 01h ;clear display
call LCDCMD ;
movlw 20h
call LCDSTR2
movlw 40h
call LCDSETADR
movlw 31h
call LCDSTR2
menu_suite
clrwdt
btfss PB,2
goto menu_suite
clrw
call MENU
movf DONNEE,W
andlw 0FFh ;Commandes Manu ?
btfsc STATUS,Z
goto manu
movlw 01h ;reglages ?
subwf DONNEE,W
btfsc STATUS,Z
goto reglages
movlw 03h ;?propos ?
subwf DONNEE,W
btfsc STATUS,Z
goto apropos
return
manu
call MENU_MANU
return
reglages
movlw 06h
call MENU
call RELACHE
movlw 06h ;date / heure ?
subwf DONNEE,W
btfsc STATUS,Z
goto dateheure
movlw 07h ;eclairage blanc ?
subwf DONNEE,W
btfsc STATUS,Z
goto eclairage_blanc
movlw 08h ;eclairage bleu ?
subwf DONNEE,W
btfsc STATUS,Z
goto eclairage_bleu
movlw 09h ;reacteur ?
subwf DONNEE,W
btfsc STATUS,Z
goto reacteur
movlw 0Ah ;reacteur 2 ?
subwf DONNEE,W
btfsc STATUS,Z
goto reacteur2
movlw 0Bh ;remplissage ?
subwf DONNEE,W
btfsc STATUS,Z
goto remplissage
movlw 0Ch ;brassage ?
subwf DONNEE,W
btfsc STATUS,Z
goto brassage
movlw 0Dh ;heure remplissage
subwf DONNEE,W
btfsc STATUS,Z
goto heure_rempliss
movlw 0Eh ;temperature
subwf DONNEE,W
btfsc STATUS,Z
goto regle_temperature
movlw 0Fh ;reset ?
subwf DONNEE,W
btfsc STATUS,Z
goto reset
return
apropos
movlw 01h ;clear display
call LCDCMD ;
clrw
call LCDSTR2
movlw 40h
call LCDSETADR
movlw 0Fh
call LCDSTR2
apropos_att
clrwdt
btfss PB,2
goto apropos_att
call RELACHE
return
dateheure
movlw 01h ;clear display
call LCDCMD ;
movlw 02h
call LCDSETADR
movlw 58h
call LCDSTR
call REGLHEURE
return
eclairage_blanc
movlw 01h ;clear display
call LCDCMD ;
movlw 48h
call LCDSTR
movlw 40h
call LCDSETADR
movlw 81h ;debut
call LCDSTR2
movlw L_BLANCHE
call REGLE
movlw 01h ;clear display
call LCDCMD ;
movlw 48h
call LCDSTR
movlw 40h
call LCDSETADR
movlw 87h ;fin
call LCDSTR2
movlw L_BLANCHE + 2
call REGLE
return
eclairage_bleu
movlw 01h ;clear display
call LCDCMD ;
movlw 58h
call LCDSTR
movlw 40h
call LCDSETADR
movlw 81h ;debut
call LCDSTR2
movlw L_BLEUE
call REGLE
movlw 01h ;clear display
call LCDCMD ;
movlw 58h
call LCDSTR
movlw 40h
call LCDSETADR
movlw 87h ;fin
call LCDSTR2
movlw L_BLEUE + 2
call REGLE
return
reacteur
movlw REACTEUR
call REGLE2
return
reacteur2
movlw REACTEUR2
call REGLE2
return
remplissage
movlw REMPLISSAGE
call REGLE2
return
brassage
movlw 12h
call MENU
movlw 12h ;Pompe1
subwf DONNEE,W
btfss STATUS,Z
goto t_pompe2
movlw POMPE1
goto reglage_pompe
t_pompe2
movlw 13h ;Pompe2
subwf DONNEE,W
btfss STATUS,Z
goto t_pompe3
movlw POMPE2
goto reglage_pompe
t_pompe3
movlw 14h ;Pompe3
subwf DONNEE,W
btfss STATUS,Z
goto t_pompe4
movlw POMPE3
goto reglage_pompe
t_pompe4
movlw 15h ;Pompe4
subwf DONNEE,W
btfss STATUS,Z
return
movlw POMPE4
reglage_pompe
call REGLE_POMPE
goto brassage
heure_rempliss
movlw 01h ;clear display
call LCDCMD ;
movlw 0E6h
call LCDSTR
movlw 40h
call LCDSETADR
movlw 81h ;debut
call LCDSTR2
movlw H_REMPLISS
call REGLE
movlw 01h ;clear display
call LCDCMD ;
movlw 48h
call LCDSTR
movlw 40h
call LCDSETADR
movlw 87h ;fin
call LCDSTR2
movlw H_REMPLISS + 2
call REGLE
return
regle_temperature
movlw 01h ;clear display
call LCDCMD ;
movlw 0B1h
call LCDSTR
movlw " "
call LCDCHAR
movlw ":"
call LCDCHAR
movlw TEMP_VISEE + 2
call LIS_EEPROM2
movlw 4Ch
call LCDSETADR
movlw 0DFh ;"?
call LCDCHAR
movlw "C"
call LCDCHAR
att_regle_temp
clrwdt
movlw 4Ah
call LCDSETADR
movf DONNEE,W
call LCDDEC
btfsc PB,2
goto fin_regle_temp
btfss PB,1
goto att_regle_temp
call RELACHE
incf DONNEE
movlw d'30'
subwf DONNEE,W
btfss STATUS,Z
goto att_regle_temp
movlw d'15'
movwf DONNEE
goto att_regle_temp
fin_regle_temp
movlw TEMP_VISEE + 2
call ECRISEEPROM
decf DONNEE
movlw TEMP_VISEE
call ECRISEEPROM
movlw HYSTERESIS
movwf DONNEE
movlw TEMP_VISEE + 3
call ECRISEEPROM
movlw HYSTERESIS
sublw d'10'
movwf DONNEE
movlw TEMP_VISEE + 1
call ECRISEEPROM
return
reset
movlw 01h ;clear display
call LCDCMD ;
movlw 69h
call LCDSTR2
movlw 4Dh
call OUINON
btfss DONNEE,0
return
movlw 01h ;clear display
call LCDCMD ;
reset_fin
goto reset_fin
;****************************************************************************
; REGLE == reglage adresse EEPROM dans W
;****************************************************************************
REGLE
movwf TEMP4
movlw 4Bh
call LCDSETADR
movf TEMP4,W
call LISEEPROM
movf DONNEE,W
call LCDHEX
movlw ":"
call LCDCHAR
incf TEMP4,W
call LISEEPROM
movf DONNEE,W
call LCDHEX
movf TEMP4,W
call LISEEPROM
attente_regle
clrwdt
btfsc PB,1
goto incremente_heure
btfsc PB,2
goto fin_heure
goto attente_regle
incremente_heure
call RELACHE
movlw 24h
call INCREMENTE
movlw 4Bh
call LCDSETADR
movf DONNEE,W
call LCDHEX
goto attente_regle
fin_heure
call RELACHE
movf TEMP4,W
call ECRISEEPROM
incf TEMP4,W
call LISEEPROM
attente_regle2
clrwdt
btfsc PB,1
goto incremente_min
btfsc PB,2
goto fin_regle
goto attente_regle2
incremente_min
call RELACHE
movlw 60h
call INCREMENTE
movlw 4Eh
call LCDSETADR
movf DONNEE,W
call LCDHEX
goto attente_regle2
fin_regle
call RELACHE
incf TEMP4,W
call ECRISEEPROM
return
;****************************************************************************
; interruption
;****************************************************************************
INT
;****************** sauvegarde de W, STATUS **********************************
movwf W_TEMP
swapf STATUS,W
clrf STATUS
movwf STATUS_TEMP
;****************** sauvegarde de W, STATUS **********************************
btfsc INTCON,T0IF
goto Timer0
goto fin_int
Timer0
bcf STATUS,RP0
bcf STATUS,RP1
movf PB,F
btfsc STATUS,Z ;Aucun bouton appuy?
goto test_boutons
decfsz CPT_TIMER
goto fin_timer0
test_boutons ;non : on teste
swapf PORTB,W
andlw 07h
xorlw 07h
movwf PB
btfsc STATUS,Z ;un changement ?
goto fin_timer0
movlw TEMPS_REBOND
movwf CPT_TIMER
fin_timer0
bcf INTCON,T0IF
fin_int
;****************** restauration de W, STATUS *******************************
swapf STATUS_TEMP,W
movwf STATUS
swapf W_TEMP
swapf W_TEMP,W
;****************** restauration de W, STATUS *******************************
bsf INTCON,GIE
retfie
;****************************************************************************
; LIS_I2C == lecture des entrees sur le bus I2C et mise en marche des
; appareils en fonction
;****************************************************************************
LIS_I2C
movlw H_REMPLISS
call TEST_HEURE
movwf TEMP4
movlw b'01000011'
call PCF8574
movf TEMP4,F
btfsc STATUS,Z
goto pas_remplissage ;non
btfss DONNEE,BAC_HAUT
goto arret_remplissage
btfsc FLAGS,2 ;on est deja en train de remplir ?
goto test_osmo ;oui
clrf M_REAC
clrf H_REAC
clrf M_REMP ;init
bsf REMPREAC,0 ;de cycle
bcf REMPREAC,2
bsf FLAGS,2 ;remplissage
bsf SORTIES1,1
call ECRIS_I2C1
goto test_osmo
arret_remplissage
bcf FLAGS,2 ;stop remplissage
bcf SORTIES1,1
test_osmo
btfsc DONNEE,RES_BAS
bsf SORTIES1,2 ;osmoseur
btfss DONNEE,RES_HAUT
bcf SORTIES1,2 ;stop osmoseur
call ECRIS_I2C1
return
pas_remplissage
bcf FLAGS,2
goto test_osmo
;****************************************************************************
; LIS_HEURE : lis l'heure sans l'afficher (pour init)
;****************************************************************************
LIS_HEURE
movlw b'10000101' ;heures
call DS1302
movf DONNEE,W
movwf HEURES
movlw b'10000011' ;minutes
call DS1302
movf DONNEE,W
movwf MINUTES
return
;****************************************************************************
; AFF_HEURE : affiche l'heure
;****************************************************************************
AFF_HEURE
movlw 06h ;6 essais...
movwf TEMP5
movlw 0Bh
call LCDSETADR
essai_heure
decf TEMP5
btfsc STATUS,Z
return ;trop d'erreurs, on quitte
movlw b'10000101' ;heures
call DS1302
movf HEURES,W
subwf DONNEE,W
btfss STATUS,C
goto heure_erreur ;erreur si DONNEE < HEURES
affichage_heure
movf DONNEE,W
movwf HEURES
call LCDHEX
movlw ":"
call LCDCHAR
essai_minute
decf TEMP5
btfsc STATUS,Z
return ;trop d'erreurs, on quitte
movlw b'10000011' ;minutes
call DS1302
movf MINUTES,W
subwf DONNEE,W
btfss STATUS,C
goto minute_erreur ;erreur si DONNEE < MINUTES
affichage_minute
movf DONNEE,W
movwf MINUTES
call LCDHEX
return
heure_erreur
movf HEURES,W
btfsc STATUS,Z ;test si HEURES = 0
goto affichage_heure ;oui : pas de pb, on est pass?de 23 ?0
goto essai_heure ;non, il y a un pb, on recommence
minute_erreur
movf MINUTES,W
btfsc STATUS,Z ;test si MINUTES = 0
goto affichage_minute ;oui : pas de pb, on est pass?de 59 ?0
goto essai_minute ;non, il y a un pb, on recommence
;****************************************************************************
; ECRIS_I2C0 == ecriture sur le bus I2C (mise en marche des appareils)
;****************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -