Line 23... |
Line 23... |
23 |
#define REVERS 3 // 2*256 ms = 0,75 s |
23 |
#define REVERS 3 // 2*256 ms = 0,75 s |
24 |
#define GO 117 // 117*256 ms = 30 s |
24 |
#define GO 117 // 117*256 ms = 30 s |
25 |
#define GO_ZALUZIE 6 // cca 1,5 s |
25 |
#define GO_ZALUZIE 6 // cca 1,5 s |
26 |
#define RECEIVE 10 // cca 2,6 s |
26 |
#define RECEIVE 10 // cca 2,6 s |
27 |
|
27 |
|
28 |
#define OR110NU PIN_A0 //* t1 Zaluzie koupelna dole |
28 |
#define OR110NU PIN_A0 // t1 Zaluzie koupelna dole |
29 |
#define OR110ND PIN_A1 //* t2 |
29 |
#define OR110ND PIN_A1 // t2 |
30 |
#define OR207VU PIN_A2 // t3 Roleta klubovna |
30 |
#define OR207VU PIN_A2 // t3 Roleta klubovna |
31 |
#define OR207VD PIN_A3 // t4 |
31 |
#define OR207VD PIN_A3 // t4 |
32 |
#define OR103VU PIN_A4 // t5 Roleta loznice |
32 |
#define OR103VU PIN_A4 // t5 Roleta loznice |
33 |
#define OR103VD PIN_A5 // t6 |
33 |
#define OR103VD PIN_A5 // t6 |
34 |
//#define OR104VU PIN_A4 // Roleta laborator vychod |
- |
|
35 |
//#define OR104VD PIN_A5 |
- |
|
36 |
#define OR104JU PIN_A6 // t7 Roleta laborator jih |
34 |
#define OR104JU PIN_A6 // t7 Roleta laborator jih |
37 |
#define OR104JD PIN_A7 // t8 |
35 |
#define OR104JD PIN_A7 // t8 |
38 |
|
36 |
|
39 |
#define OS103J PIN_B0 // t1 Svetla loznice |
37 |
#define OS103J PIN_B0 // t1 Svetla loznice |
40 |
#define OS105Z PIN_B1 // t2 Svetlo kuchyn nad lavici |
38 |
#define OS105Z PIN_B1 // t2 Svetlo kuchyn nad lavici |
41 |
#define OS110N PIN_B2 // t3 Svetlo koupelna dole zachod |
39 |
#define OS110N PIN_B2 // t3 Svetlo koupelna dole zachod a sprhca |
42 |
#define OS106A PIN_B3 // t4 Svetlo trucovna stred |
40 |
#define OS106A PIN_B3 // t4 Svetlo trucovna stred |
43 |
#define OS107A PIN_B4 // t5 Svetlo satna |
41 |
#define OS107A PIN_B4 // t5 Svetlo satna |
44 |
#define OS109A PIN_B5 // t6 Svetlo technologicka mistnost |
42 |
#define OS109A PIN_B5 // t6 Svetlo technologicka mistnost |
45 |
//#define OS110J PIN_B6 // t7 Svetlo koupelna dole sprcha |
43 |
#define OS205A PIN_B6 // t7 Svetlo puda |
46 |
//#define O... PIN_B7 // t8 |
44 |
#define OS204A PIN_B7 // t8 Svetlo radiomistnost |
47 |
|
45 |
|
48 |
//#define OS105C PIN_C2 |
46 |
//#define OS105C PIN_C2 |
49 |
//#define PIN_C3 31763 |
47 |
//#define PIN_C3 31763 |
50 |
//#define PIN_C4 31764 |
48 |
//#define PIN_C4 31764 |
51 |
//#define PIN_C5 31765 |
49 |
//#define PIN_C5 31765 |
52 |
//#define PIN_C6 31766 //TX |
50 |
//#define PIN_C6 31766 //TX |
53 |
//#define PIN_C7 31767 //RX |
51 |
//#define PIN_C7 31767 //RX |
54 |
|
52 |
|
55 |
#define OR104VU PIN_F0 // t1 Roleta laborator vychod |
53 |
#define OR104VU PIN_F0 // t1 Roleta laborator vychod |
56 |
#define OR104VD PIN_F1 // t2 |
54 |
#define OR104VD PIN_F1 // t2 |
57 |
//#define O... PIN_F2 // t3 |
55 |
#define OR202JU PIN_F2 // t3 Roleta Kaklik |
58 |
//#define O... PIN_F3 // t4 |
56 |
#define OR202JD PIN_F3 // t4 |
59 |
//#define O... PIN_F4 // t5 |
57 |
#define OR204ZU PIN_F4 // t5 Roleta radiomistnost |
60 |
//#define O... PIN_F5 // t6 |
58 |
#define OR204ZD PIN_F5 // t6 |
61 |
//#define O... PIN_F6 // t7 |
59 |
//#define O... PIN_F6 // t7 |
62 |
//#define O... PIN_F7 // t8 |
60 |
//#define O... PIN_F7 // t8 |
63 |
|
61 |
|
64 |
//#define I.... input(PIN_D0) // A |
- |
|
65 |
#define IS201AZ input(PIN_D1) // B Vypinac chodba 2.n.p. zapad u Kaklika |
- |
|
66 |
#define IS207AJ input(PIN_D2) // C Vypinac klubovna |
- |
|
67 |
#define IR207VD input(PIN_D3) // D Vypinac roleta klubovna dolu |
- |
|
68 |
#define IR207VU input(PIN_D4) // E Vypinac roleta klubovna nahoru |
- |
|
69 |
#define IS201AV input(PIN_D5) // F Vypinac chodba 2.n.p. vychod |
- |
|
70 |
#define IS209AJ input(PIN_D6) // G Vypinac koupelna Zizala |
- |
|
71 |
#define IS203AJ input(PIN_D7) // H Vypinac koupelna Kaklik |
- |
|
72 |
|
- |
|
73 |
#define OS102A PIN_E0 // t1 Svetlo chodba |
62 |
#define OS102A PIN_E0 // t1 Svetlo chodba |
74 |
#define OS105A PIN_E1 //* t2 Svetlo kuchyne stred |
63 |
#define OS105A PIN_E1 // t2 Svetlo kuchyne stred |
75 |
#define OS207A PIN_E2 // t3 Svetlo klubovna |
64 |
#define OS207A PIN_E2 // t3 Svetlo klubovna |
76 |
#define OS104A PIN_E3 //* t4 Svetlo laborator |
65 |
#define OS104A PIN_E3 // t4 Svetlo laborator |
77 |
//#define O... PIN_E4 // t5 |
66 |
#define OS202A PIN_E4 // t5 Svetlo Kaklik stred |
78 |
#define OS209A PIN_E5 // t6 Svetlo Zizala koupelna |
67 |
#define OS209A PIN_E5 // t6 Svetlo Zizala koupelna |
79 |
#define OS203A PIN_E6 // t7 Svetlo Kaklik koupelna |
68 |
#define OS203A PIN_E6 // t7 Svetlo Kaklik koupelna |
80 |
//#define O... PIN_E7 // t8 |
69 |
//#define O... PIN_E7 // t8 |
81 |
|
70 |
|
- |
|
71 |
//#define I.... input(PIN_D0) // A |
- |
|
72 |
#define IS201AZ input(PIN_D1) // B Vypinac chodba 2.n.p. zapad u Kaklika |
- |
|
73 |
#define IS207AJ input(PIN_D2) // C Vypinac klubovna |
- |
|
74 |
#define IR207VD input(PIN_D3) // D Vypinac roleta klubovna dolu |
- |
|
75 |
#define IR207VU input(PIN_D4) // E Vypinac roleta klubovna nahoru |
- |
|
76 |
#define IS201AV input(PIN_D5) // F Vypinac chodba 2.n.p. vychod |
- |
|
77 |
#define IS209AJ input(PIN_D6) // G Vypinac koupelna Zizala |
- |
|
78 |
#define IS203AJ input(PIN_D7) // H Vypinac koupelna Kaklik |
- |
|
79 |
|
- |
|
80 |
#define IS202AN input(PIN_J0) // A Vypinac svetlo Kaklik stred u dveri na chodbu |
- |
|
81 |
#define IR202ND input(PIN_J1) // B Vypinac roleta Kaklik dolu u dveri |
- |
|
82 |
#define IR202NU input(PIN_J2) // C Vypinac roleta Kaklik nahoru u dveri |
- |
|
83 |
#define IS205A input(PIN_J3) // D Vypinac svetlo puda |
- |
|
84 |
#define IS204AJ input(PIN_J4) // E Vypinac svetlo radiomistnost u dveri na chodbu |
- |
|
85 |
#define IR204ZD input(PIN_J5) // F Vypinac roleta radiomistnost dolu |
- |
|
86 |
#define IR204ZU input(PIN_J6) // G Vypinac roleta radiomistnost nahoru |
- |
|
87 |
//#define I.... input(PIN_J7) // H |
- |
|
88 |
|
82 |
int1 s201AV; |
89 |
int1 s201AV; |
83 |
int1 s201AZ; |
90 |
int1 s201AZ; |
84 |
int1 s207AJ; |
91 |
int1 s207AJ; |
85 |
int1 s203AJ; |
92 |
int1 s203AJ; |
86 |
int1 s209AJ; |
93 |
int1 s209AJ; |
87 |
int1 r207VU; |
94 |
int1 r207VU; |
88 |
int1 r207VD; |
95 |
int1 r207VD; |
- |
|
96 |
int1 s202AN; |
- |
|
97 |
int1 r202ND; |
- |
|
98 |
int1 r202NU; |
- |
|
99 |
int1 s205A; |
- |
|
100 |
int1 s204AJ; |
- |
|
101 |
int1 r204ZD; |
- |
|
102 |
int1 r204ZU; |
89 |
|
103 |
|
90 |
#bit CREN = 0xFAB.4 // USART enable register |
104 |
#bit CREN = 0xFAB.4 // USART enable register |
91 |
|
105 |
|
92 |
#define LED1 PIN_C0 |
106 |
#define LED1 PIN_C0 |
93 |
#define LED2 PIN_C1 |
107 |
#define LED2 PIN_C1 |
Line 95... |
Line 109... |
95 |
#define ON(port) output_low(port); |
109 |
#define ON(port) output_low(port); |
96 |
#define OFF(port) output_high(port); |
110 |
#define OFF(port) output_high(port); |
97 |
|
111 |
|
98 |
typedef enum {GO_UP, GO_DOWN, REVERS_UP, REVERS_DOWN, STOP} state; |
112 |
typedef enum {GO_UP, GO_DOWN, REVERS_UP, REVERS_DOWN, STOP} state; |
99 |
|
113 |
|
100 |
state r103V, r110N, r104V, r104J, r207V; // Stavy rolet |
114 |
state r103V, r110N, r104V, r104J, r207V, r202J, r204Z; // Stavy rolet |
101 |
int8 tr103V, tr110N, tr104V, tr104J, tr207V; // Casovace rolet |
115 |
int8 tr103V, tr110N, tr104V, tr104J, tr207V, tr202J, tr204Z; // Casovace rolet |
102 |
int8 timer; // Casovac komunikace |
116 |
int8 timer; // Casovac komunikace |
103 |
|
117 |
|
104 |
#int_TIMER0 |
118 |
#int_TIMER0 |
105 |
void TIMER0_isr(void) |
119 |
void TIMER0_isr(void) |
106 |
{ |
120 |
{ |
107 |
if(tr103V>0) tr103V--; |
121 |
if(tr103V>0) tr103V--; |
108 |
if(tr110N>0) tr110N--; |
122 |
if(tr110N>0) tr110N--; |
109 |
if(tr104V>0) tr104V--; |
123 |
if(tr104V>0) tr104V--; |
110 |
if(tr104J>0) tr104J--; |
124 |
if(tr104J>0) tr104J--; |
111 |
if(tr207V>0) tr207V--; |
125 |
if(tr207V>0) tr207V--; |
- |
|
126 |
if(tr202J>0) tr202J--; |
- |
|
127 |
if(tr204Z>0) tr204Z--; |
112 |
if(timer>0) timer--; |
128 |
if(timer>0) timer--; |
113 |
output_toggle(LED2); |
129 |
output_toggle(LED2); |
114 |
} |
130 |
} |
115 |
|
131 |
|
116 |
void up(state *status, int8 *timer) // Zmena stavu rolety smer nahoru |
132 |
void up(state *status, int8 *timer) // Zmena stavu rolety smer nahoru |
Line 202... |
Line 218... |
202 |
r103V=STOP; // Rolety jsou zastaveny |
218 |
r103V=STOP; // Rolety jsou zastaveny |
203 |
r110N=STOP; |
219 |
r110N=STOP; |
204 |
r104V=STOP; |
220 |
r104V=STOP; |
205 |
r104J=STOP; |
221 |
r104J=STOP; |
206 |
r207V=STOP; |
222 |
r207V=STOP; |
- |
|
223 |
r202J=STOP; |
- |
|
224 |
r204Z=STOP; |
207 |
tr103V=0; |
225 |
tr103V=0; |
208 |
tr110N=0; |
226 |
tr110N=0; |
209 |
tr104V=0; |
227 |
tr104V=0; |
210 |
tr104J=0; |
228 |
tr104J=0; |
211 |
tr207V=0; |
229 |
tr207V=0; |
- |
|
230 |
tr202J=0; |
- |
|
231 |
tr204Z=0; |
212 |
|
232 |
|
213 |
{ |
233 |
{ |
214 |
int n; |
234 |
int n; |
215 |
|
235 |
|
216 |
for(n=0;n<10;n++) |
236 |
for(n=0;n<10;n++) |
Line 228... |
Line 248... |
228 |
s207AJ=IS207AJ; |
248 |
s207AJ=IS207AJ; |
229 |
s203AJ=IS203AJ; |
249 |
s203AJ=IS203AJ; |
230 |
s209AJ=IS209AJ; |
250 |
s209AJ=IS209AJ; |
231 |
r207VU=IR207VU; |
251 |
r207VU=IR207VU; |
232 |
r207VD=IR207VD; |
252 |
r207VD=IR207VD; |
- |
|
253 |
s202AN=IS202AN; |
- |
|
254 |
r202ND=IR202ND; |
- |
|
255 |
r202NU=IR202NU; |
- |
|
256 |
s205A=IS205A; |
- |
|
257 |
s204AJ=IS204AJ; |
- |
|
258 |
r204ZD=IR204ZD; |
- |
|
259 |
r204ZU=IR204ZU; |
233 |
|
260 |
|
234 |
CREN=0; CREN=1; // Reinitialise USART |
261 |
CREN=0; CREN=1; // Reinitialise USART |
235 |
|
262 |
|
236 |
enable_interrupts(INT_TIMER0); |
263 |
enable_interrupts(INT_TIMER0); |
237 |
enable_interrupts(GLOBAL); |
264 |
enable_interrupts(GLOBAL); |
Line 328... |
Line 355... |
328 |
|
355 |
|
329 |
run(103V); // Rizeni rolet za behu |
356 |
run(103V); // Rizeni rolet za behu |
330 |
// run(104V); |
357 |
// run(104V); |
331 |
run(104J); |
358 |
run(104J); |
332 |
run(207V); |
359 |
run(207V); |
- |
|
360 |
run(202J); |
- |
|
361 |
run(204Z); |
333 |
|
362 |
|
334 |
switch(r110N) // Zaluzie ma specielni rizeni |
363 |
switch(r110N) // Zaluzie ma specielni rizeni |
335 |
{ |
364 |
{ |
336 |
case STOP: |
365 |
case STOP: |
337 |
OFF(OR110NU); |
366 |
OFF(OR110NU); |
Line 363... |
Line 392... |
363 |
if(s201AV!=IS201AV) {s201AV=IS201AV; output_toggle(OS102A); delay_ms(100); continue;} |
392 |
if(s201AV!=IS201AV) {s201AV=IS201AV; output_toggle(OS102A); delay_ms(100); continue;} |
364 |
if(s201AZ!=IS201AZ) {s201AZ=IS201AZ; output_toggle(OS102A); delay_ms(100); continue;} |
393 |
if(s201AZ!=IS201AZ) {s201AZ=IS201AZ; output_toggle(OS102A); delay_ms(100); continue;} |
365 |
if(s207AJ!=IS207AJ) {s207AJ=IS207AJ; output_toggle(OS207A); delay_ms(100); continue;} |
394 |
if(s207AJ!=IS207AJ) {s207AJ=IS207AJ; output_toggle(OS207A); delay_ms(100); continue;} |
366 |
if(s203AJ!=IS203AJ) {s203AJ=IS203AJ; output_toggle(OS203A); delay_ms(100); continue;} |
395 |
if(s203AJ!=IS203AJ) {s203AJ=IS203AJ; output_toggle(OS203A); delay_ms(100); continue;} |
367 |
if(s209AJ!=IS209AJ) {s209AJ=IS209AJ; output_toggle(OS209A); delay_ms(100); continue;} |
396 |
if(s209AJ!=IS209AJ) {s209AJ=IS209AJ; output_toggle(OS209A); delay_ms(100); continue;} |
- |
|
397 |
if(s205A!=IS205A) {s205A=IS205A; output_toggle(OS205A); delay_ms(100); continue;} |
- |
|
398 |
if(s204AJ!=IS204AJ) {s204AJ=IS204AJ; output_toggle(OS204A); delay_ms(100); continue;} |
- |
|
399 |
if(s202AN!=IS202AN) {s202AN=IS202AN; output_toggle(OS202A); delay_ms(100); continue;} |
368 |
|
400 |
|
369 |
if(r207VU!=IR207VU) {r207VU=IR207VU; up(&r207V,&tr207V); delay_ms(100); continue;} |
401 |
if(r207VU!=IR207VU) {r207VU=IR207VU; up(&r207V,&tr207V); delay_ms(100); continue;} |
370 |
if(r207VD!=IR207VD) {r207VD=IR207VD; down(&r207V,&tr207V); delay_ms(100); continue;} |
402 |
if(r207VD!=IR207VD) {r207VD=IR207VD; down(&r207V,&tr207V); delay_ms(100); continue;} |
- |
|
403 |
if(r202NU!=IR202NU) {r202NU=IR202NU; up(&r202J,&tr202J); delay_ms(100); continue;} |
- |
|
404 |
if(r202ND!=IR202ND) {r202ND=IR202ND; down(&r202J,&tr202J); delay_ms(100); continue;} |
- |
|
405 |
if(r204ZU!=IR204ZU) {r204ZU=IR204ZU; up(&r204Z,&tr204Z); delay_ms(100); continue;} |
- |
|
406 |
if(r204ZD!=IR204ZD) {r204ZD=IR204ZD; down(&r204Z,&tr204Z); delay_ms(100); continue;} |
371 |
|
407 |
|
372 |
restart_wdt(); |
408 |
restart_wdt(); |
373 |
} |
409 |
} |
374 |
} |
410 |
} |