Blame view

principal.txt 14.5 KB
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
1
2
3
4
5
  ; Équivalences
  
  .equ PINA = 0x00
  .equ DDRA = 0x01
  .equ PORTA = 0x02
54877f0f   Geoffrey PREUD'HOMME   Correction du cod...
6
7
8
  .equ PINC = 0x06
  .equ DDRC = 0x07
  .equ PORTC = 0x08
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
9
10
11
  .equ PING = 0x12
  .equ DDRG = 0x13
  .equ PORTG = 0x14
733c078a   Geoffrey PREUD'HOMME   Configuration des...
12
  
930282df   Geoffrey PREUD'HOMME   Afficheur numérique
13
14
  .equ WDTCSR = 0x60
  
f121392c   Geoffrey PREUD'HOMME   Récupération code...
15
16
17
18
  .equ TTCR0A = 0x24
  .equ TTCR0B = 0x25
  .equ TMSK0 = 0x6e
  
733c078a   Geoffrey PREUD'HOMME   Configuration des...
19
20
21
22
  .equ EIMSK = 0x3D
  .equ EICRA = 0x69
  .equ EICRB = 0x6A
  
6244f6c8   Geoffrey PREUD'HOMME   Initialisation ADC
23
24
25
26
27
  .equ ADMUX = 0x7C
  .equ ADCSRB = 0x7B
  .equ ADCSRA = 0x7A
  .equ ADCH = 0x79
  
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
28
29
30
31
32
  .equ SPH = 0x3E
  .equ SPL = 0x3D
  
  ; Nommage des registres utilisés
  
54877f0f   Geoffrey PREUD'HOMME   Correction du cod...
33
  .def etat = r12
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
34
35
  .def compteur = r6 ; Utilisé pour modifier des valeurs dans le menu
  
54877f0f   Geoffrey PREUD'HOMME   Correction du cod...
36
  .def reference = r13 ; Température de référence actuelle
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
37
  
f121392c   Geoffrey PREUD'HOMME   Récupération code...
38
39
40
41
  .def d3 = r2 ; Digit 3 (tout à gauche)
  .def d2 = r3 ; Digit 2
  .def d1 = r4 ; Digit 1
  .def d0 = r5 ; Digit 0 (tout à droite)
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
42
  
f121392c   Geoffrey PREUD'HOMME   Récupération code...
43
44
45
  .def t2 = r8 ; Jour (3 premiers bits) et Heure (5 derniers bits)
  .def t1 = r9 ; Minutes
  .def t0 = r10 ; Secondes / 2
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
46
  .def tt = r11 ; Watchdog artificiel
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
47
  
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
48
49
  .def temp = r7 ; Utilisé pour différentes choses mais très brièvement
  
a238970b   Geoffrey PREUD'HOMME   Sauvegarde en RAM...
50
51
  ; Nommage des adresses RAM utilisées
  
c7d4e505   Geoffrey PREUD'HOMME   Encore des avance...
52
  .equ assocs = 0x0200 ; Association des modes aux heures (tableau de taille 168 octets)
a238970b   Geoffrey PREUD'HOMME   Sauvegarde en RAM...
53
54
55
  .equ tempJour = 0x02a8 ; Température du mode jour
  .equ tempNuit = 0x02a9 ; Température du mode nuit
  
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
56
57
58
59
60
  ; Vecteurs d'interruptions
  
  .org 0x000 ; Vecteur RESET
      jmp debut
  
733c078a   Geoffrey PREUD'HOMME   Configuration des...
61
62
63
64
  .org 0x0002 ; INT0
      jmp valider
  
  .org 0x0004 ; INT1
ef1e877a   Geoffrey PREUD'HOMME   Les boutons fonct...
65
      jmp decrementer
704b0adc   thubert   Fritzing refait e...
66
67
68
      
  .org 0x0006 ; INT2
      jmp incrementer
733c078a   Geoffrey PREUD'HOMME   Configuration des...
69
70
  
  .org 0x0008 ; INT3
704b0adc   thubert   Fritzing refait e...
71
      jmp retour
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
72
  
aa2eef0b   Geoffrey PREUD'HOMME   Initialisation wa...
73
74
75
  .org 0x0018 ; Watchdog
      jmp watchdog
  
f121392c   Geoffrey PREUD'HOMME   Récupération code...
76
77
78
  .org 0x002E ; Timer
      jmp timer
  
aa2eef0b   Geoffrey PREUD'HOMME   Initialisation wa...
79
80
81
82
  .org 0x003A ; ADC
      jmp adc
  
  
930282df   Geoffrey PREUD'HOMME   Afficheur numérique
83
84
  .org 0x0080
  
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
85
86
  ; Tableaux de la mémoire du programme
  
58504c72   Taky Djeraba   Écriture du texte
87
  afficheur:
54877f0f   Geoffrey PREUD'HOMME   Correction du cod...
88
89
      .DB 0x3F, 0x30, 0x6D, 0x79, 0x72, 0x5B, 0x5F, 0x31, 0x7F, 0x7B
      ;      0,    1,    2,    3,    4,    5,    6,    7,    8,    9
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
90
91
92
93
94
  
  ; Programme
  
  debut:
  ; Configuration des composants
54877f0f   Geoffrey PREUD'HOMME   Correction du cod...
95
96
97
      ; Ports parallèles
      DDRA@IO <- 0xFF
      DDRC@IO <- 0xFF
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
98
      DDRG@IO <- 0xFF
733c078a   Geoffrey PREUD'HOMME   Configuration des...
99
  
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
100
101
102
103
      ; Barres de chargement
      PORTA@IO <- 0x40
      PORTC@IO <- 0x00
  
930282df   Geoffrey PREUD'HOMME   Afficheur numérique
104
      ; Watchdog
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
105
106
      ;WDTCSR <- 0b00010000
      ;WDTCSR <- 0b01000111
930282df   Geoffrey PREUD'HOMME   Afficheur numérique
107
  
f121392c   Geoffrey PREUD'HOMME   Récupération code...
108
      ; Timer
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
109
110
111
      TTCR0A@IO <- 0b00000000
      TTCR0B@IO <- 0b00000100 ; Timer toutes les 4ms
      TMSK0  <-    0b00000001
f121392c   Geoffrey PREUD'HOMME   Récupération code...
112
  
733c078a   Geoffrey PREUD'HOMME   Configuration des...
113
114
      ; Interruptions externes
      EIMSK <- 0b00001111
ef1e877a   Geoffrey PREUD'HOMME   Les boutons fonct...
115
      EICRA <- 0b10101010
733c078a   Geoffrey PREUD'HOMME   Configuration des...
116
117
118
      EICRB <- 0b00000000
  
      ; ADC
dd9af113   Geoffrey PREUD'HOMME   Réorganisation de...
119
120
121
      ADMUX  <- 0b01100000
      ADCSRB <- 0b00000010
      ADCSRA <- 0b11011110
f121392c   Geoffrey PREUD'HOMME   Récupération code...
122
  
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
123
124
125
126
127
  ; Initialisation des registre
      etat <- 0
      ; compteur initialisé quand on en aura besoin
      ; reference initialisé avec agirHeure
      ; d3, d2, d1, d0 initialisés avec afficherHorloge
f121392c   Geoffrey PREUD'HOMME   Récupération code...
128
  
f85fc947   Geoffrey PREUD'HOMME   Avancement sur le...
129
130
131
132
      ; Mardi 14h00'55
      t2 <- 0b00101110
      t1 <- 0
      t0 <- 55
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
133
      tt <- 0
f121392c   Geoffrey PREUD'HOMME   Récupération code...
134
  
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
      ; temp initialisé quand on en aura besoin
  
  ; Initialisation de la RAM
      ; Valeurs de démonstration : 7° - 27° (on jouerait plus sur du 17° - 21° en réalité)
      tempNuit <- 20
      tempJour <- 220
  
      ; Initialisation des associations
      compteur <- 0 ; Jour
  initJour:
      temp <- 0 ; Heure
  initHeure:
      assocs[compteur * 24 + temp] <- 0 ; Par défaut le mode jour
      si temp <= 7 alors assocs[compteur * 24 + temp] <- 1 ; Entre minuit et 7h le mode nuit
      inc temp
      if temp < 24 saut initHeure
      inc compteur
      if compteur < 7 saut initJour
  
  ; Logique de démarrage
f121392c   Geoffrey PREUD'HOMME   Récupération code...
155
      call afficherHorloge
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
156
157
158
159
      call agirHeure
  
      ; On active les interruptions une fois que tout est prêt
      sei
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
160
161
162
163
164
165
  
  boucle:
      sleep
      jmp boucle
  
  ; Fonctions
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
166
167
168
  
  ; Affichages
  afficherHorloge:
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
169
      ; Affiche l'heure actuelle
e18f6847   Geoffrey PREUD'HOMME   Définition de com...
170
171
      temp <- t2 & 0b00011111
      d3 <- 0x00
54877f0f   Geoffrey PREUD'HOMME   Correction du cod...
172
      si temp > 10 alors d3 <- afficheur@ROM[temp/10]
10bf25f4   Geoffrey PREUD'HOMME   Correction du modulo
173
      d2 <- afficheur@ROM[temp%10] | 0b10000000
59a7fe2e   Geoffrey PREUD'HOMME   Correction des mo...
174
      d1 <- afficheur@ROM[t1/10]
10bf25f4   Geoffrey PREUD'HOMME   Correction du modulo
175
      d0 <- afficheur@ROM[t1%10]
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
176
177
      ret
  
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
178
179
  afficherTemperature:
      ; Considère le registre compteur comme une température et l'affiche
f85fc947   Geoffrey PREUD'HOMME   Avancement sur le...
180
181
182
183
184
      d0 <- 0x63 ; Sigle degré
      d1 <- afficheur@ROM[compteur%10] ; Décimale
      temp <- compteur / 10 + 5 ; On stocke temporairement la partie entière pour simplifier
      d2 <- afficheur@ROM[temp%10] | 0b10000000 ; Chiffre des unités, auquel on ajoute le point
      d3 <- 0x00 ; On affiche le chiffre des dizaines si la température est > 10
59a7fe2e   Geoffrey PREUD'HOMME   Correction des mo...
185
      si temp > 10 alors d3 <- afficheur@ROM[temp/10]
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
186
187
      ret
  
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
188
189
  afficherHeur:
      ; Considère le registre compteur comme une heure et l'affiche
54877f0f   Geoffrey PREUD'HOMME   Correction du cod...
190
      d3 <- afficheur@ROM[compteur/10]
10bf25f4   Geoffrey PREUD'HOMME   Correction du modulo
191
      d2 <- afficheur@ROM[compteur%10] | 0b10000000
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
192
193
194
195
196
197
198
199
      d1 <- 0x00
      d0 <- 0x00
      ret
  
  afficherMinu:
      ; Considère le registre compteur comme une minute et l'affiche
      d3 <- 0x00
      d2 <- 0b10000000
54877f0f   Geoffrey PREUD'HOMME   Correction du cod...
200
      d1 <- afficheur@ROM[compteur/10]
10bf25f4   Geoffrey PREUD'HOMME   Correction du modulo
201
      d0 <- afficheur@ROM[compteur%10]
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
202
203
204
      ret
  
  afficherJour:
e18f6847   Geoffrey PREUD'HOMME   Définition de com...
205
      ; Considère le registre compteur comme un jour et l'affiche
46a92afb   Taky Djeraba   Affichage digits ...
206
207
208
209
210
211
212
213
214
      d1 <- 0x00;
      d0 <- 0x00;
      si compteur = 0 saut afficherLu
      si compteur = 1 saut afficherMa
      si compteur = 2 saut afficherMe
      si compteur = 3 saut afficherJe
      si compteur = 4 saut afficherVe
      si compteur = 5 saut afficherSa
      si compteur = 6 saut afficherDi
f85fc947   Geoffrey PREUD'HOMME   Avancement sur le...
215
      ret ; Ne devrait pas arriver, mais permet d'éviter les dégâts
46a92afb   Taky Djeraba   Affichage digits ...
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
  
  afficherLu:
      d3 <- 0x0E
      d2 <- 0x1c    
      ret
  
  afficherMa:
      d3 <- 0x37
      d2 <- 0x77    
      ret
  
  afficherMe:
      d3 <- 0x37
      d2 <- 0xcf    
      ret
  
  afficherJe:
      d3 <- 0x3c
      d2 <- 0xcf    
      ret
  
  afficherVe:
      d3 <- 0x1c
      d2 <- 0xcf    
      ret
  
  afficherSa:
      d3 <- 0x5b
      d2 <- 0x77    
      ret
  
  afficherDi:
      d3 <- 0xfc
      d2 <- 0x04    
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
250
251
252
      ret
  
  ; Logique
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
253
254
  
  agir1s:
38c40966   Geoffrey PREUD'HOMME   Avancement divers
255
      ; Met à jour les registres de temps, active agir10s ou agirHeure si nécessaire
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
256
      inc t0
38c40966   Geoffrey PREUD'HOMME   Avancement divers
257
      si t0%10 != 0 saut ret ; Continue si on est sur un multiple de 10 secondes
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
258
      call agir10s
38c40966   Geoffrey PREUD'HOMME   Avancement divers
259
      si t0 < 60 saut ret ; Continue si on est sur un multiple de 60 secondes
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
260
261
262
263
264
265
266
267
268
269
      t0 <- 0
      inc t1
      si t1 < 60 saut ret ; Continue si on est sur un multiple de 60 minutes
      t1 <- 0
      inc t2
      si t2 & 0b00011111 >= 7 saut agir1sHeur ; Continue si il est minuit
      t2 <- t2 + 0b00100000 ; Jour suivant
      t2 <- t2 & 0b11100000 ; Heure à minuit
      si t2 >= 0b11100000 alors t2 <- 0b00000000 ; Si on est dimanche soir, on revient à lundi matin
  agir1sHeur:
38c40966   Geoffrey PREUD'HOMME   Avancement divers
270
      call agirHeure
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
271
272
      ret
  
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
273
  agir10s:
dd9af113   Geoffrey PREUD'HOMME   Réorganisation de...
274
275
      ; Déclenche une conversion ADC
      ADCSRA <- 0b11011101
38c40966   Geoffrey PREUD'HOMME   Avancement divers
276
      ; Switche l'état de veille si veille il y a
dd9af113   Geoffrey PREUD'HOMME   Réorganisation de...
277
278
279
280
281
282
283
284
285
286
287
      si etat =   0 saut a10sVeilleTemp
      si etat =   1 saut a10sVeilleHeur
      ret
  a10sVeilleHeur:
      etat <- 0
      call afficherHorloge
      ret
  a10sVeilleTemp:
      etat <- 1
      compteur <- ADCH
      call afficherTemperature
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
288
289
      ret
  
38c40966   Geoffrey PREUD'HOMME   Avancement divers
290
  agirHeure:
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
291
      ; Recharge la température de référence
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
292
      temp <- (t2 / 0b00100000) * 24 + (t2 & 0b00011111)
c7d4e505   Geoffrey PREUD'HOMME   Encore des avance...
293
294
      ;       ↑ numéro du jour de la semaine
      ;                                ↑ heure actuelle
38c40966   Geoffrey PREUD'HOMME   Avancement divers
295
296
      if assocs[temp] = 0x00 alors reference <- tempJour
      if assocs[temp] = 0x01 alors reference <- tempNuit
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
297
298
      ret
  
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
299
300
301
302
303
  ; Recadrage
  boundHeur:
      si compteur =  255 alors compteur <- 23
      si compteur >= 24  alors compteur <- 0
      ret
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
304
  
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
305
306
307
308
309
310
311
312
313
314
315
  boundMinu:
      si compteur =  255 alors compteur <- 59
      si compteur >= 60  alors compteur <- 0
      ret
  
  boundJour:
      si compteur = 255 alors compteur <- 6
      si compteur >= 7  alors compteur <- 0
      ret
  
  boundTemperature:
f85fc947   Geoffrey PREUD'HOMME   Avancement sur le...
316
317
      si compteur < 5   alors compteur <- 250
      si compteur > 250 alors compteur <- 5
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
318
319
      ret
  
f85fc947   Geoffrey PREUD'HOMME   Avancement sur le...
320
  ; Puisque l'assembleur étendu ne supporte pas les retours conditionnels
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
321
322
  ret:
      ret
e18f6847   Geoffrey PREUD'HOMME   Définition de com...
323
324
325
  reti:
      reti
  
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
326
327
328
329
330
331
332
333
334
  ; États
  ; × : Arrivée à l'état par un niveau supérieur
  ; R : Arrivée à l'état par un niveau inférieur
  ; U : Mise à jour de l'affichage
  ; C : Changement de l'état
  
  etatVeilleHeur:
      etat <- 0
      call afficherHorloge
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
335
336
      reti
  
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
337
  etatVeilleTemp:
ef1e877a   Geoffrey PREUD'HOMME   Les boutons fonct...
338
      etat <- 1
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
339
340
      compteur <- ADCH
      call afficherTemperature
1d126a93   Geoffrey PREUD'HOMME   Commencé l'interr...
341
342
343
344
      reti
  
  etatMenuAssoc:
      etat <- 2
58504c72   Taky Djeraba   Écriture du texte
345
346
347
348
      d3 <- 0x77
      d2 <- 0x5b
      d1 <- 0x5b
      d0 <- 0x5c
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
349
350
      reti
  
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
351
  etatMenuJours:
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
352
353
      ; Par défaut on prend le jour actuel
      compteur <- t2 / 0b00100000
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
354
355
356
  etatMenuJoursU:
      etat <- 3 + compteur
      call afficherJour
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
357
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
358
359
360
361
362
363
364
365
366
  
  etatMenuJoursR:
      compteur <- etat - 7 - 3
      jmp etatMenuJoursU
  
  etatMenuJoursC:
      call boundJour
      jmp etatMenuJoursU
  
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
367
  etatParaJours:
1d126a93   Geoffrey PREUD'HOMME   Commencé l'interr...
368
      etat <- etat + 7
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
369
      compteur <- t2 & 0b00011111
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
370
  etatParaJoursU:
54877f0f   Geoffrey PREUD'HOMME   Correction du cod...
371
      d3 <- afficheur@ROM[compteur/10]
10bf25f4   Geoffrey PREUD'HOMME   Correction du modulo
372
      d2 <- afficheur@ROM[compteur%10]
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
373
      d1 <- 0x00
a238970b   Geoffrey PREUD'HOMME   Sauvegarde en RAM...
374
375
376
377
378
      temp <- (etat - 10) * 24 + compteur
      ; Si la RAM n'est pas initialisée à cet endroit, on préfère afficher un tiret
      d0 <- 0x40
      si assocs[temp] = 0b00000000 alors d0 <- 0x3c
      si assocs[temp] = 0b00000001 alors d0 <- 0x54
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
379
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
380
381
382
383
384
385
  
  etatParaJoursC:
      call boundHeur
      jmp etatParaJoursU
  
  etatParaJoursS: ; Switch
a238970b   Geoffrey PREUD'HOMME   Sauvegarde en RAM...
386
387
      temp <- (etat - 10) * 24 + compteur
      assocs[temp] <- (assocs[temp] + 1) & 0b00000001
38c40966   Geoffrey PREUD'HOMME   Avancement divers
388
      call agirHeure ; Au cas où on change l'heure en cours
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
389
390
      jmp etatParaJoursU
  
f85fc947   Geoffrey PREUD'HOMME   Avancement sur le...
391
392
393
394
  ; Appelé depuis l'état  2 après un appui sur le  bouton Incrémenter
  ;                      19                               Décrémenter
  ;                      18                               Valider
  ;                      18                               Retour
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
395
396
  etatMenuTJour:
      etat <- 17
f85fc947   Geoffrey PREUD'HOMME   Avancement sur le...
397
      d3 <- 0x3c ; "JOUR"
58504c72   Taky Djeraba   Écriture du texte
398
399
400
      d2 <- 0x5c
      d1 <- 0x1c
      d0 <- 0x44
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
401
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
402
  
f85fc947   Geoffrey PREUD'HOMME   Avancement sur le...
403
  ; Appelé depuis l'état 17 après un appui sur Valider
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
404
  etatParaTJour:
1d126a93   Geoffrey PREUD'HOMME   Commencé l'interr...
405
      etat <- 18
f85fc947   Geoffrey PREUD'HOMME   Avancement sur le...
406
      compteur <- tempJour ; Lecture depuis la RAM
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
407
408
  etatParaTJourU:
      call afficherTemperature
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
409
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
410
  
f85fc947   Geoffrey PREUD'HOMME   Avancement sur le...
411
  ; Appelé depuis l'état 18 après un appui sur Incrementer ou Decrementer
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
412
  etatParaTJourC:
f85fc947   Geoffrey PREUD'HOMME   Avancement sur le...
413
414
415
      call boundTemperature ; Remet la température dans les bornes
      tempJour <- compteur ; Écriture vers la RAM
      call agirHeure ; Au cas où on change le mode de l'heure actuelle, on recharge la température de référence
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
416
417
      jmp etatParaTJourU
  
968302e7   Geoffrey PREUD'HOMME   Améliorations div...
418
  etatMenuTNuit:
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
419
      etat <- 19
f85fc947   Geoffrey PREUD'HOMME   Avancement sur le...
420
      d3 <- 0x54 ; "NUIT"
58504c72   Taky Djeraba   Écriture du texte
421
422
423
      d2 <- 0x1c
      d1 <- 0x04
      d0 <- 0x4e
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
424
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
425
426
  
  etatParaTNuit:
1d126a93   Geoffrey PREUD'HOMME   Commencé l'interr...
427
      etat <- 20
a238970b   Geoffrey PREUD'HOMME   Sauvegarde en RAM...
428
      compteur <- tempNuit
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
429
430
  etatParaTNuitU:
      call afficherTemperature
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
431
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
432
433
434
  
  etatParaTNuitC:
      call boundTemperature
a238970b   Geoffrey PREUD'HOMME   Sauvegarde en RAM...
435
      tempNuit <- compteur
38c40966   Geoffrey PREUD'HOMME   Avancement divers
436
      call agirHeure ; Au cas où on change le mode en cours
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
437
438
439
440
      jmp etatParaTNuitU
  
  etatMenuHorloge:
      etat <- 21
6591a8e7   Geoffrey PREUD'HOMME   selaff directemen...
441
      d3 <- 0x76 ; "HORL"
58504c72   Taky Djeraba   Écriture du texte
442
443
444
      d2 <- 0x5c
      d1 <- 0x44
      d0 <- 0x0E
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
445
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
446
447
  
  etatMenuHJour:
1d126a93   Geoffrey PREUD'HOMME   Commencé l'interr...
448
      etat <- 22
6591a8e7   Geoffrey PREUD'HOMME   selaff directemen...
449
      d3 <- 0x3c ; "JOUR"
58504c72   Taky Djeraba   Écriture du texte
450
451
452
      d2 <- 0x5c
      d1 <- 0x1c
      d0 <- 0x44
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
453
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
454
455
456
  
  etatMenuHHeur:
      etat <- 23
6591a8e7   Geoffrey PREUD'HOMME   selaff directemen...
457
      d3 <- 0x76 ; "HEUR"
58504c72   Taky Djeraba   Écriture du texte
458
459
460
      d2 <- 0xcf
      d1 <- 0x1c
      d0 <- 0x44
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
461
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
462
463
464
  
  etatMenuHMinu:
      etat <- 24
6591a8e7   Geoffrey PREUD'HOMME   selaff directemen...
465
      d3 <- 0x37 ; "MINU"
58504c72   Taky Djeraba   Écriture du texte
466
467
468
      d2 <- 0x04
      d1 <- 0x54
      d0 <- 0x1c
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
469
470
      reti
  
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
471
472
  etatParaHJour:
      etat <- 25
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
473
      compteur <- t2 / 0b00100000
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
474
      call afficherJour
c2a24067   Geoffrey PREUD'HOMME   Bouton retour
475
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
476
477
478
  
  etatParaHJourC:
      call boundJour
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
479
480
      t2 <- (compteur * 0b00100000) + (t2 & 0b00011111)
      call agirHeure
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
481
      call afficherJour
c2a24067   Geoffrey PREUD'HOMME   Bouton retour
482
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
483
484
485
  
  etatParaHHeur:
      etat <- 26
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
486
      compteur <- t2 & 0b00011111
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
487
      call afficherHeur
c2a24067   Geoffrey PREUD'HOMME   Bouton retour
488
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
489
490
491
  
  etatParaHHeurC:
      call boundHeur
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
492
493
      t2 <- (t2 & 0b11100000) + compteur
      call agirHeure
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
494
      call afficherHeur
c2a24067   Geoffrey PREUD'HOMME   Bouton retour
495
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
496
497
498
  
  etatParaHMinu:
      etat <- 27
968302e7   Geoffrey PREUD'HOMME   Améliorations div...
499
      compteur <- t1
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
500
      call afficherMinu
c2a24067   Geoffrey PREUD'HOMME   Bouton retour
501
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
502
503
504
  
  etatParaHMinuC:
      call boundMinu
968302e7   Geoffrey PREUD'HOMME   Améliorations div...
505
      t1 <- compteur
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
506
      call afficherMinu
c2a24067   Geoffrey PREUD'HOMME   Bouton retour
507
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
508
509
510
511
512
  
  ; Interruption boutons
  
  incrementer:
      inc compteur
54877f0f   Geoffrey PREUD'HOMME   Correction du cod...
513
514
      si etat =   0 saut etatVeilleTemp
      si etat =   1 saut etatVeilleHeur
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
      si etat =   2 saut etatMenuTJour
      si etat <=  9 saut etatMenuJoursC
      si etat <= 16 saut etatParaJoursC
      si etat =  17 saut etatMenuTNuit
      si etat =  18 saut etatParaTJourC
      si etat =  19 saut etatMenuHorloge
      si etat =  20 saut etatParaTNuitC
      si etat =  21 saut etatMenuAssoc
      si etat =  22 saut etatMenuHHeur
      si etat =  23 saut etatMenuHMinu
      si etat =  24 saut etatMenuHJour
      si etat =  25 saut etatParaHJourC
      si etat =  26 saut etatParaHHeurC
      si etat =  27 saut etatParaHMinuC
      reti ; Ne devrait pas arriver, mais permet d'éviter les dégâts
  
  decrementer:
      dec compteur
54877f0f   Geoffrey PREUD'HOMME   Correction du cod...
533
534
      si etat =   0 saut etatVeilleTemp
      si etat =   1 saut etatVeilleHeur
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
      si etat =   2 saut etatMenuHorloge
      si etat <=  9 saut etatMenuJoursC
      si etat <= 16 saut etatParaJoursC
      si etat =  17 saut etatMenuAssoc
      si etat =  18 saut etatParaTJourC
      si etat =  19 saut etatMenuTJour
      si etat =  20 saut etatParaTNuitC
      si etat =  21 saut etatMenuTNuit
      si etat =  22 saut etatMenuHMinu
      si etat =  23 saut etatMenuHJour
      si etat =  24 saut etatMenuHHeur
      si etat =  25 saut etatParaHJourC
      si etat =  26 saut etatParaHHeurC
      si etat =  27 saut etatParaHMinuC
      reti ; Ne devrait pas arriver, mais permet d'éviter les dégâts
  
  valider:
      si etat <=  1 saut etatMenuAssoc
      si etat =   2 saut etatMenuJours
      si etat <=  9 saut etatParaJours
a238970b   Geoffrey PREUD'HOMME   Sauvegarde en RAM...
555
      si etat <= 16 saut etatParaJoursS
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
556
557
558
559
560
561
      si etat =  17 saut etatParaTJour
      si etat =  18 saut etatMenuTJour
      si etat =  19 saut etatParaTNuit
      si etat =  20 saut etatMenuTNuit
      si etat =  21 saut etatMenuHJour
      si etat =  22 saut etatParaHJour
38c40966   Geoffrey PREUD'HOMME   Avancement divers
562
563
564
565
      si etat =  23 saut etatParaHHeur
      si etat =  24 saut etatParaHMinu
      si etat =  25 saut etatMenuHJour
      si etat =  26 saut etatMenuHHeur
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
566
567
568
569
      si etat =  27 saut etatMenuHMinu
      reti ; Ne devrait pas arriver, mais permet d'éviter les dégâts
  
  retour:
e18f6847   Geoffrey PREUD'HOMME   Définition de com...
570
      si etat <=  1 saut reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
571
572
573
574
575
576
577
578
579
580
581
582
583
584
      si etat =   2 saut etatVeilleHeur
      si etat <=  9 saut etatMenuAssoc
      si etat <= 16 saut etatMenuJoursR
      si etat =  17 saut etatVeilleHeur
      si etat =  18 saut etatMenuTJour
      si etat =  19 saut etatVeilleHeur
      si etat =  20 saut etatMenuTNuit
      si etat =  21 saut etatVeilleHeur
      si etat <= 24 saut etatMenuHorloge
      si etat =  25 saut etatMenuHJour
      si etat =  26 saut etatMenuHHeur
      si etat =  27 saut etatMenuHMinu
      reti ; Ne devrait pas arriver, mais permet d'éviter les dégâts
  
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
585
586
  ; Interruption Watchdog
  watchdog:
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
587
      call agir1s
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
588
589
590
591
      reti
  
  ; Interruption ADC
  adc:
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
592
      ADCSRA <- 0b11011101 ; DEBUG Lire la température continuellement
aadee417   Geoffrey PREUD'HOMME   Définition des états
593
594
595
596
      si ADCH > reference + 5 saut eteindreChaudiere
      si ADCH < reference - 5 saut allumerChaudiere
      reti
  allumerChaudiere:
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
597
      PORTG@IO <- 0xFF
aadee417   Geoffrey PREUD'HOMME   Définition des états
598
599
      reti
  eteindreChaudiere:
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
600
      PORTG@IO <- 0x00
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
601
602
      reti
  
c7d4e505   Geoffrey PREUD'HOMME   Encore des avance...
603
  ; Interruption timer (~4 ms)
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
604
  timer:
c7d4e505   Geoffrey PREUD'HOMME   Encore des avance...
605
606
607
      ; Notre composant requiert d'envoyer 0 sur PC7-4
      ; afin d'activer le digit qui y est connecté
  
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
608
      ; Affiche le digit suivant sur l'afficheur 7seg
7b3d156a   Geoffrey PREUD'HOMME   Correction du pro...
609
      temp <- PORTC@IO ; On lit le port dans son état précédent
c7d4e505   Geoffrey PREUD'HOMME   Encore des avance...
610
611
      lsr temp ; On change de digit
      ; Il y a 4 digits et 8 bits, on doit donc boucler plus tôt
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
612
613
      si temp < 0b00001111 alors temp <- 0b11110111
      PORTC@IO <- temp
c7d4e505   Geoffrey PREUD'HOMME   Encore des avance...
614
      ; On envoie le registre correpspondant
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
615
616
617
618
619
620
621
      si temp = 0b11110111 alors PORTA@IO <- d3
      si temp = 0b01111011 alors PORTA@IO <- d2
      si temp = 0b00111101 alors PORTA@IO <- d1
      si temp = 0b00011110 alors PORTA@IO <- d0
  
      ; Watchdog artificiel
      inc tt
f85fc947   Geoffrey PREUD'HOMME   Avancement sur le...
622
623
      if tt < 244 saut reti
      ;if tt < 10 saut reti ; DEBUG Avancer le temps
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
624
625
626
      tt <- 0
      call agir1s
  
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
627
      reti