Blame view

principal.txt 13.3 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
52
53
54
55
  ; Nommage des adresses RAM utilisées
  
  .equ assocs = 0x0200 ; Association des modes aux heures
  .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
65
66
67
  .org 0x0002 ; INT0
      jmp valider
  
  .org 0x0004 ; INT1
      jmp retour
  
  .org 0x0006 ; INT2
ef1e877a   Geoffrey PREUD'HOMME   Les boutons fonct...
68
      jmp decrementer
733c078a   Geoffrey PREUD'HOMME   Configuration des...
69
70
  
  .org 0x0008 ; INT3
ef1e877a   Geoffrey PREUD'HOMME   Les boutons fonct...
71
      jmp incrementer
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
  
ba7e6936   Geoffrey PREUD'HOMME   Correction de que...
129
      ; Mercredi 12h34'56
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
130
      t2 <- 0b01001100
f121392c   Geoffrey PREUD'HOMME   Récupération code...
131
132
      t1 <- 34
      t0 <- 28
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
54877f0f   Geoffrey PREUD'HOMME   Correction du cod...
180
      d0 <- 0x63
10bf25f4   Geoffrey PREUD'HOMME   Correction du modulo
181
      d1 <- afficheur@ROM[compteur%10]
59a7fe2e   Geoffrey PREUD'HOMME   Correction des mo...
182
      temp <- compteur / 10 + 5
10bf25f4   Geoffrey PREUD'HOMME   Correction du modulo
183
      d2 <- afficheur@ROM[temp%10] | 0b10000000
59a7fe2e   Geoffrey PREUD'HOMME   Correction des mo...
184
185
      d3 <- 0x00
      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
215
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
      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
  
  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...
249
250
251
      ret
  
  ; Logique
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
252
253
  
  agir1s:
38c40966   Geoffrey PREUD'HOMME   Avancement divers
254
      ; Met à jour les registres de temps, active agir10s ou agirHeure si nécessaire
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
255
      inc t0
38c40966   Geoffrey PREUD'HOMME   Avancement divers
256
      si t0%10 != 0 saut ret ; Continue si on est sur un multiple de 10 secondes
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
257
      call agir10s
38c40966   Geoffrey PREUD'HOMME   Avancement divers
258
      si t0 < 60 saut ret ; Continue si on est sur un multiple de 60 secondes
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
259
260
261
262
263
264
265
266
267
268
      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
269
      call agirHeure
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
270
271
      ret
  
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
272
  agir10s:
dd9af113   Geoffrey PREUD'HOMME   Réorganisation de...
273
274
      ; Déclenche une conversion ADC
      ADCSRA <- 0b11011101
38c40966   Geoffrey PREUD'HOMME   Avancement divers
275
      ; Switche l'état de veille si veille il y a
dd9af113   Geoffrey PREUD'HOMME   Réorganisation de...
276
277
278
279
280
281
282
283
284
285
286
      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
287
288
      ret
  
38c40966   Geoffrey PREUD'HOMME   Avancement divers
289
  agirHeure:
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
290
      ; Recharge la température de référence
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
291
      temp <- (t2 / 0b00100000) * 24 + (t2 & 0b00011111)
38c40966   Geoffrey PREUD'HOMME   Avancement divers
292
293
      if assocs[temp] = 0x00 alors reference <- tempJour
      if assocs[temp] = 0x01 alors reference <- tempNuit
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
294
295
      ret
  
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
296
297
298
299
300
  ; Recadrage
  boundHeur:
      si compteur =  255 alors compteur <- 23
      si compteur >= 24  alors compteur <- 0
      ret
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
301
  
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
  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:
      si compteur < 5   alors compteur <- 5
      si compteur > 200 alors compteur <- 200
      ret
  
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
317
318
  ret:
      ret
e18f6847   Geoffrey PREUD'HOMME   Définition de com...
319
320
321
  reti:
      reti
  
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
322
323
324
325
326
327
328
329
330
  ; É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
331
332
      reti
  
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
333
  etatVeilleTemp:
ef1e877a   Geoffrey PREUD'HOMME   Les boutons fonct...
334
      etat <- 1
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
335
336
      compteur <- ADCH
      call afficherTemperature
1d126a93   Geoffrey PREUD'HOMME   Commencé l'interr...
337
338
339
340
      reti
  
  etatMenuAssoc:
      etat <- 2
58504c72   Taky Djeraba   Écriture du texte
341
342
343
344
      d3 <- 0x77
      d2 <- 0x5b
      d1 <- 0x5b
      d0 <- 0x5c
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
345
346
      reti
  
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
347
  etatMenuJours:
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
348
349
      ; Par défaut on prend le jour actuel
      compteur <- t2 / 0b00100000
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
350
351
352
  etatMenuJoursU:
      etat <- 3 + compteur
      call afficherJour
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
353
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
354
355
356
357
358
359
360
361
362
  
  etatMenuJoursR:
      compteur <- etat - 7 - 3
      jmp etatMenuJoursU
  
  etatMenuJoursC:
      call boundJour
      jmp etatMenuJoursU
  
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
363
  etatParaJours:
1d126a93   Geoffrey PREUD'HOMME   Commencé l'interr...
364
      etat <- etat + 7
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
365
      compteur <- t2 & 0b00011111
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
366
  etatParaJoursU:
54877f0f   Geoffrey PREUD'HOMME   Correction du cod...
367
      d3 <- afficheur@ROM[compteur/10]
10bf25f4   Geoffrey PREUD'HOMME   Correction du modulo
368
      d2 <- afficheur@ROM[compteur%10]
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
369
      d1 <- 0x00
a238970b   Geoffrey PREUD'HOMME   Sauvegarde en RAM...
370
371
372
373
374
      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
375
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
376
377
378
379
380
381
  
  etatParaJoursC:
      call boundHeur
      jmp etatParaJoursU
  
  etatParaJoursS: ; Switch
a238970b   Geoffrey PREUD'HOMME   Sauvegarde en RAM...
382
383
      temp <- (etat - 10) * 24 + compteur
      assocs[temp] <- (assocs[temp] + 1) & 0b00000001
38c40966   Geoffrey PREUD'HOMME   Avancement divers
384
      call agirHeure ; Au cas où on change l'heure en cours
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
385
386
387
388
      jmp etatParaJoursU
  
  etatMenuTJour:
      etat <- 17
58504c72   Taky Djeraba   Écriture du texte
389
390
391
392
      d3 <- 0x3c
      d2 <- 0x5c
      d1 <- 0x1c
      d0 <- 0x44
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
393
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
394
395
  
  etatParaTJour:
1d126a93   Geoffrey PREUD'HOMME   Commencé l'interr...
396
      etat <- 18
a238970b   Geoffrey PREUD'HOMME   Sauvegarde en RAM...
397
      compteur <- tempJour
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
398
399
  etatParaTJourU:
      call afficherTemperature
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
400
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
401
402
403
  
  etatParaTJourC:
      call boundTemperature
a238970b   Geoffrey PREUD'HOMME   Sauvegarde en RAM...
404
      tempJour <- compteur
38c40966   Geoffrey PREUD'HOMME   Avancement divers
405
      call agirHeure ; Au cas où on change le mode en cours
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
406
407
      jmp etatParaTJourU
  
968302e7   Geoffrey PREUD'HOMME   Améliorations div...
408
  etatMenuTNuit:
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
409
      etat <- 19
58504c72   Taky Djeraba   Écriture du texte
410
411
412
413
      d3 <- 0x54
      d2 <- 0x1c
      d1 <- 0x04
      d0 <- 0x4e
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
414
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
415
416
  
  etatParaTNuit:
1d126a93   Geoffrey PREUD'HOMME   Commencé l'interr...
417
      etat <- 20
a238970b   Geoffrey PREUD'HOMME   Sauvegarde en RAM...
418
      compteur <- tempNuit
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
419
420
  etatParaTNuitU:
      call afficherTemperature
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
421
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
422
423
424
  
  etatParaTNuitC:
      call boundTemperature
a238970b   Geoffrey PREUD'HOMME   Sauvegarde en RAM...
425
      tempNuit <- compteur
38c40966   Geoffrey PREUD'HOMME   Avancement divers
426
      call agirHeure ; Au cas où on change le mode en cours
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
427
428
429
430
      jmp etatParaTNuitU
  
  etatMenuHorloge:
      etat <- 21
6591a8e7   Geoffrey PREUD'HOMME   selaff directemen...
431
      d3 <- 0x76 ; "HORL"
58504c72   Taky Djeraba   Écriture du texte
432
433
434
      d2 <- 0x5c
      d1 <- 0x44
      d0 <- 0x0E
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
435
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
436
437
  
  etatMenuHJour:
1d126a93   Geoffrey PREUD'HOMME   Commencé l'interr...
438
      etat <- 22
6591a8e7   Geoffrey PREUD'HOMME   selaff directemen...
439
      d3 <- 0x3c ; "JOUR"
58504c72   Taky Djeraba   Écriture du texte
440
441
442
      d2 <- 0x5c
      d1 <- 0x1c
      d0 <- 0x44
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
443
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
444
445
446
  
  etatMenuHHeur:
      etat <- 23
6591a8e7   Geoffrey PREUD'HOMME   selaff directemen...
447
      d3 <- 0x76 ; "HEUR"
58504c72   Taky Djeraba   Écriture du texte
448
449
450
      d2 <- 0xcf
      d1 <- 0x1c
      d0 <- 0x44
0f97c980   Geoffrey PREUD'HOMME   Bouton valider
451
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
452
453
454
  
  etatMenuHMinu:
      etat <- 24
6591a8e7   Geoffrey PREUD'HOMME   selaff directemen...
455
      d3 <- 0x37 ; "MINU"
58504c72   Taky Djeraba   Écriture du texte
456
457
458
      d2 <- 0x04
      d1 <- 0x54
      d0 <- 0x1c
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
459
460
      reti
  
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
461
462
  etatParaHJour:
      etat <- 25
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
463
      compteur <- t2 / 0b00100000
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
464
      call afficherJour
c2a24067   Geoffrey PREUD'HOMME   Bouton retour
465
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
466
467
468
  
  etatParaHJourC:
      call boundJour
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
469
470
      t2 <- (compteur * 0b00100000) + (t2 & 0b00011111)
      call agirHeure
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
471
      call afficherJour
c2a24067   Geoffrey PREUD'HOMME   Bouton retour
472
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
473
474
475
  
  etatParaHHeur:
      etat <- 26
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
476
      compteur <- t2 & 0b00011111
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
477
      call afficherHeur
c2a24067   Geoffrey PREUD'HOMME   Bouton retour
478
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
479
480
481
  
  etatParaHHeurC:
      call boundHeur
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
482
483
      t2 <- (t2 & 0b11100000) + compteur
      call agirHeure
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
484
      call afficherHeur
c2a24067   Geoffrey PREUD'HOMME   Bouton retour
485
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
486
487
488
  
  etatParaHMinu:
      etat <- 27
968302e7   Geoffrey PREUD'HOMME   Améliorations div...
489
      compteur <- t1
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
490
      call afficherMinu
c2a24067   Geoffrey PREUD'HOMME   Bouton retour
491
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
492
493
494
  
  etatParaHMinuC:
      call boundMinu
968302e7   Geoffrey PREUD'HOMME   Améliorations div...
495
      t1 <- compteur
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
496
      call afficherMinu
c2a24067   Geoffrey PREUD'HOMME   Bouton retour
497
      reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
498
499
500
501
502
  
  ; Interruption boutons
  
  incrementer:
      inc compteur
54877f0f   Geoffrey PREUD'HOMME   Correction du cod...
503
504
      si etat =   0 saut etatVeilleTemp
      si etat =   1 saut etatVeilleHeur
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
      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...
523
524
      si etat =   0 saut etatVeilleTemp
      si etat =   1 saut etatVeilleHeur
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
      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...
545
      si etat <= 16 saut etatParaJoursS
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
546
547
548
549
550
551
      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
552
553
554
555
      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...
556
557
558
559
      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...
560
      si etat <=  1 saut reti
f629950c   Geoffrey PREUD'HOMME   Réorganisation de...
561
562
563
564
565
566
567
568
569
570
571
572
573
574
      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
575
576
  ; Interruption Watchdog
  watchdog:
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
577
      call agir1s
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
578
579
580
581
      reti
  
  ; Interruption ADC
  adc:
d47c1384   Geoffrey PREUD'HOMME   Finalisation du p...
582
      ADCSRA <- 0b11011101 ; DEBUG Lire la température continuellement
aadee417   Geoffrey PREUD'HOMME   Définition des états
583
584
585
586
      si ADCH > reference + 5 saut eteindreChaudiere
      si ADCH < reference - 5 saut allumerChaudiere
      reti
  allumerChaudiere:
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
587
      PORTG@IO <- 0xFF
aadee417   Geoffrey PREUD'HOMME   Définition des états
588
589
      reti
  eteindreChaudiere:
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
590
      PORTG@IO <- 0x00
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
591
592
593
594
      reti
  
  ; Interruption timer
  timer:
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
595
596
597
598
599
      ; Sauvegarde de l'état
      PUSH temp
      PUSH r16
      PUSH r17
  
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
600
      ; Affiche le digit suivant sur l'afficheur 7seg
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
601
602
603
604
605
606
607
608
609
610
611
612
      temp <- PORTC@IO
      lsr temp
      si temp < 0b00001111 alors temp <- 0b11110111
      PORTC@IO <- temp
      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
      if tt < 244 saut timerRestore
dd9af113   Geoffrey PREUD'HOMME   Réorganisation de...
613
      ;if tt < 10 saut timerRestore ; DEBUG Avancer le temps
9e20955c   Geoffrey PREUD'HOMME   Watchdog artificiel
614
615
616
617
618
619
620
621
622
      tt <- 0
      call agir1s
  
  timerRestore:
      ; Restoration de l'état
      POP r17
      POP r16
      POP temp
  
af2c171d   Geoffrey PREUD'HOMME   Rédaction du matin
623
      reti