Line 31... |
Line 31... |
31 |
#use fast_io(G) |
31 |
#use fast_io(G) |
32 |
|
32 |
|
33 |
#define T_REVERS 2 // 2*256 ms = 0,5 s; pred prepnutim rele (zastaveni motoru a vybiti kondenzatoru) |
33 |
#define T_REVERS 2 // 2*256 ms = 0,5 s; pred prepnutim rele (zastaveni motoru a vybiti kondenzatoru) |
34 |
#define T_START 1 // 1*256 ms = 0,3 s; po prepnuti rele do sepnuti triaku |
34 |
#define T_START 1 // 1*256 ms = 0,3 s; po prepnuti rele do sepnuti triaku |
35 |
#define T_GO 117 // 117*256 ms = 30 s; max. beh rolety |
35 |
#define T_GO 117 // 117*256 ms = 30 s; max. beh rolety |
36 |
#define T_GO_ZALUZIE 6 // cca 1,5 s; beh zaluzie (pouze na preklopeni lamel) |
36 |
#define T_GO_ZALUZIE 2500/256 // cca 2 s; beh zaluzie (pouze na preklopeni lamel) |
37 |
#define T_RECEIVE 10 // cca 2,6 s |
37 |
#define T_RECEIVE 10 // cca 2,6 s |
- |
|
38 |
#define TIMEOUT_SPAJZ 255 // Timeout svetlo spajz cca minuta |
38 |
#define ZAKMIT 2000 // pocet pruchodu hlavni smyckou pred opetovnou detekci prepnuti vypinace |
39 |
#define ZAKMIT 2000 // pocet pruchodu hlavni smyckou pred opetovnou detekci prepnuti vypinace |
39 |
|
40 |
|
40 |
#define OR106Z PIN_A0 // t1 Roleta trucovna zapad |
41 |
//!!! STUDENAK na triaku spolecny vyvod !!! #define O PIN_A0 // t1 |
41 |
#define OR110N PIN_A1 // t2 Zaluzie koupelna dole sever |
42 |
#define OR110N PIN_A1 // t2 Zaluzie koupelna dole sever |
42 |
#define OR104V PIN_A2 // t3 Roleta lab vychod |
43 |
#define OR104V PIN_A2 // t3 Roleta lab vychod |
43 |
#define OR104J PIN_A3 // t4 Roleta lab jih |
44 |
#define OR104J PIN_A3 // t4 Roleta lab jih |
44 |
#define OR103V PIN_A4 // t5 Roleta loznice |
45 |
#define OR103V PIN_A4 // t5 Roleta loznice |
45 |
#define OR202J PIN_A5 // t6 Roleta Kaklik |
46 |
#define OR202J PIN_A5 // t6 Roleta Kaklik |
46 |
#define OR204Z PIN_A6 // t7 Roleta radiomistnost |
47 |
#define OR204Z PIN_A6 // t7 Roleta radiomistnost |
47 |
#define OR207V PIN_A7 // t8 Roleta klubovna |
48 |
#define OR207V PIN_A7 // t8 Roleta klubovna |
48 |
|
49 |
|
49 |
#define OR208V PIN_F0 // t1 Roleta Zizala vychod |
50 |
#define OR208V PIN_F0 // t1 Roleta Zizala vychod |
50 |
#define OR208J PIN_F1 // t2 Roleta Zizala jih |
51 |
#define OR208J PIN_F1 // t2 Roleta Zizala jih |
51 |
//??? #define OR107 PIN_F2 // t3 |
52 |
//??? #define OR107 PIN_F2 // t3 Roleta satna |
52 |
//??? #define OR107 PIN_F3 // t4 |
53 |
#define OR106J PIN_F3 // t4 Roleta trucovna jih |
53 |
#define OR201Z PIN_F4 // t5 Roleta chodba nahore |
54 |
#define OR201Z PIN_F4 // t5 Roleta chodba nahore |
54 |
#define OR205N PIN_F5 // t6 Roleta puda |
55 |
#define OR205N PIN_F5 // t6 Roleta puda |
55 |
//??? #define OR105 PIN_F6 // t7 Roleta kuchyn |
56 |
//??? #define OR105 PIN_F6 // t7 Roleta kuchyn |
56 |
//#define O... PIN_F7 // t8 |
57 |
#define OR106Z PIN_F7 // t8 Roleta trucovna zapad |
57 |
|
58 |
|
58 |
|
59 |
|
59 |
#define OS103J PIN_B0 // t1 Svetla loznice |
60 |
#define OS103J PIN_B0 // t1 Svetla loznice |
60 |
#define OS105Z PIN_B1 // t2 Svetlo kuchyn nad lavici |
61 |
#define OS105Z PIN_B1 // t2 Svetlo kuchyn nad lavici |
61 |
#define OS110N PIN_B2 // t3 Svetlo koupelna dole zachod a sprhca |
62 |
#define OS110N PIN_B2 // t3 Svetlo koupelna dole zachod a sprhca |
Line 81... |
Line 82... |
81 |
#define OS203A PIN_E6 // t7 Svetlo Kaklik koupelna |
82 |
#define OS203A PIN_E6 // t7 Svetlo Kaklik koupelna |
82 |
#define RE PIN_E7 // t8 Rele pro rizeni smeru rolet |
83 |
#define RE PIN_E7 // t8 Rele pro rizeni smeru rolet |
83 |
|
84 |
|
84 |
//#define O.... PIN_G0 // t8 |
85 |
//#define O.... PIN_G0 // t8 |
85 |
//#define O.... PIN_G1 // t7 |
86 |
//#define O.... PIN_G1 // t7 |
86 |
//#define O.... PIN_G2 // t6 |
87 |
#define OS108A PIN_G2 // t6 Svetlo spajz |
87 |
#define OS208A PIN_G3 // t5 Svetlo Zizala stred |
88 |
#define OS208A PIN_G3 // t5 Svetlo Zizala stred |
88 |
#define OS100A PIN_G4 // t4 Svetlo prujezd venku |
89 |
#define OS100A PIN_G4 // t4 Svetlo prujezd venku |
89 |
|
90 |
|
90 |
//#define I.... input(PIN_D0) // A |
91 |
//#define I.... input(PIN_D0) // A |
91 |
#define IS201AZ input(PIN_D1) // B Vypinac chodba 2.n.p. zapad u Kaklika |
92 |
#define IS201AZ input(PIN_D1) // B Vypinac chodba 2.n.p. zapad u Kaklika |
Line 101... |
Line 102... |
101 |
#define IR202NU input(PIN_J2) // C Vypinac roleta Kaklik nahoru u dveri |
102 |
#define IR202NU input(PIN_J2) // C Vypinac roleta Kaklik nahoru u dveri |
102 |
#define IS205A input(PIN_J3) // D Vypinac svetlo puda |
103 |
#define IS205A input(PIN_J3) // D Vypinac svetlo puda |
103 |
#define IS204AJ input(PIN_J4) // E Vypinac svetlo radiomistnost u dveri na chodbu |
104 |
#define IS204AJ input(PIN_J4) // E Vypinac svetlo radiomistnost u dveri na chodbu |
104 |
#define IR204ZD input(PIN_J5) // F Vypinac roleta radiomistnost dolu |
105 |
#define IR204ZD input(PIN_J5) // F Vypinac roleta radiomistnost dolu |
105 |
#define IR204ZU input(PIN_J6) // G Vypinac roleta radiomistnost nahoru |
106 |
#define IR204ZU input(PIN_J6) // G Vypinac roleta radiomistnost nahoru |
106 |
//#define I.... input(PIN_J7) // H |
107 |
#define IS108A input(PIN_J7) // H Mikrospinac spajz |
107 |
|
108 |
|
108 |
#define IS208AN input(PIN_H0) // A Vypinac svetlo stred Zizala u dveri na chodbu //POZOR! Jsou prohozeny rolety J a V a smery U a D |
109 |
#define IS208AN input(PIN_H0) // A Vypinac svetlo stred Zizala u dveri na chodbu //POZOR! Jsou prohozeny rolety J a V a smery U a D |
109 |
#define IR208JD input(PIN_H1) // B Vypinac roleta vychod Zizala nahoru u dveri |
110 |
#define IR208JD input(PIN_H1) // B Vypinac roleta vychod Zizala nahoru u dveri |
110 |
#define IR208JU input(PIN_H2) // C Vypinac roleta vychod Zizala dolu u dveri |
111 |
#define IR208JU input(PIN_H2) // C Vypinac roleta vychod Zizala dolu u dveri |
111 |
#define IR208VD input(PIN_H3) // D Vypinac roleta jih Zizala nahoru u dveri |
112 |
#define IR208VD input(PIN_H3) // D Vypinac roleta jih Zizala nahoru u dveri |
Line 153... |
Line 154... |
153 |
#define R207V 4 |
154 |
#define R207V 4 |
154 |
#define R202J 5 |
155 |
#define R202J 5 |
155 |
#define R204Z 6 |
156 |
#define R204Z 6 |
156 |
#define R208V 7 |
157 |
#define R208V 7 |
157 |
#define R208J 8 |
158 |
#define R208J 8 |
- |
|
159 |
#define R106J 9 |
- |
|
160 |
#define R106Z 10 |
158 |
|
161 |
|
159 |
typedef enum {UP, DOWN, REVERS_UP, REVERS_DOWN, RUN_UP, RUN_DOWN, RUN_UP_WAITING} relay_state; |
162 |
typedef enum {UP, DOWN, REVERS_UP, REVERS_DOWN, RUN_UP, RUN_DOWN, RUN_UP_WAITING} relay_state; |
160 |
relay_state relay; // Stavy rele |
163 |
relay_state relay; // Stavy rele |
161 |
|
164 |
|
162 |
int8 timer_run; // Bezpecnostni casovac behu rolety |
165 |
int8 timer_run; // Bezpecnostni casovac behu rolety |
163 |
int8 timer_run_zaluzie; // Casovac zaluzie na preklopeni lamel |
166 |
int8 timer_run_zaluzie; // Casovac zaluzie na preklopeni lamel |
164 |
int8 timer_revers; // Prodleva na vybiti kondenzatoru pa zastaveni rolety pred prepnutim rele |
167 |
int8 timer_revers; // Prodleva na vybiti kondenzatoru pa zastaveni rolety pred prepnutim rele |
165 |
int8 timer_start; // Prodleva na prepnuti rele pred startem rolety |
168 |
int8 timer_start; // Prodleva na prepnuti rele pred startem rolety |
166 |
int8 timer; // Casovac komunikace |
169 |
int8 timer; // Casovac komunikace |
- |
|
170 |
int8 tS108; // Casovac svetlo spajz |
167 |
|
171 |
|
168 |
#int_TIMER0 |
172 |
#int_TIMER0 |
169 |
void TIMER0_isr(void) |
173 |
void TIMER0_isr(void) |
170 |
{ |
174 |
{ |
171 |
if(timer>0) timer--; |
175 |
if(timer>0) timer--; |
- |
|
176 |
if(tS108>0) tS108--; |
172 |
if(timer_run>0) timer_run--; |
177 |
if(timer_run>0) timer_run--; |
173 |
if(timer_revers>0) timer_revers--; |
178 |
if(timer_revers>0) timer_revers--; |
174 |
if(timer_start>0) timer_start--; |
179 |
if(timer_start>0) timer_start--; |
175 |
if(timer_run_zaluzie>0) timer_run_zaluzie--; |
180 |
if(timer_run_zaluzie>0) timer_run_zaluzie--; |
176 |
output_toggle(LED2); |
181 |
output_toggle(LED2); |
Line 194... |
Line 199... |
194 |
if (rol[R207V]==RUN) ON(OR207V); |
199 |
if (rol[R207V]==RUN) ON(OR207V); |
195 |
if (rol[R202J]==RUN) ON(OR202J); |
200 |
if (rol[R202J]==RUN) ON(OR202J); |
196 |
if (rol[R204Z]==RUN) ON(OR204Z); |
201 |
if (rol[R204Z]==RUN) ON(OR204Z); |
197 |
if (rol[R208V]==RUN) ON(OR208V); |
202 |
if (rol[R208V]==RUN) ON(OR208V); |
198 |
if (rol[R208J]==RUN) ON(OR208J); |
203 |
if (rol[R208J]==RUN) ON(OR208J); |
- |
|
204 |
if (rol[R106J]==RUN) ON(OR106J); |
- |
|
205 |
if (rol[R106Z]==RUN) ON(OR106Z); |
199 |
} |
206 |
} |
200 |
|
207 |
|
201 |
void run(int8 roleta) // Spust konkretni roletu |
208 |
void run(int8 roleta) // Spust konkretni roletu |
202 |
{ |
209 |
{ |
203 |
switch (roleta) |
210 |
switch (roleta) |
Line 209... |
Line 216... |
209 |
case R207V: ON(OR207V); break; |
216 |
case R207V: ON(OR207V); break; |
210 |
case R202J: ON(OR202J); break; |
217 |
case R202J: ON(OR202J); break; |
211 |
case R204Z: ON(OR204Z); break; |
218 |
case R204Z: ON(OR204Z); break; |
212 |
case R208V: ON(OR208V); break; |
219 |
case R208V: ON(OR208V); break; |
213 |
case R208J: ON(OR208J); break; |
220 |
case R208J: ON(OR208J); break; |
- |
|
221 |
case R106J: ON(OR106J); break; |
- |
|
222 |
case R106Z: ON(OR106Z); break; |
214 |
} |
223 |
} |
215 |
} |
224 |
} |
216 |
|
225 |
|
217 |
void stop(int8 roleta) // Spust konkretni roletu |
226 |
void stop(int8 roleta) // Spust konkretni roletu |
218 |
{ |
227 |
{ |
Line 225... |
Line 234... |
225 |
case R207V: OFF(OR207V); break; |
234 |
case R207V: OFF(OR207V); break; |
226 |
case R202J: OFF(OR202J); break; |
235 |
case R202J: OFF(OR202J); break; |
227 |
case R204Z: OFF(OR204Z); break; |
236 |
case R204Z: OFF(OR204Z); break; |
228 |
case R208V: OFF(OR208V); break; |
237 |
case R208V: OFF(OR208V); break; |
229 |
case R208J: OFF(OR208J); break; |
238 |
case R208J: OFF(OR208J); break; |
- |
|
239 |
case R106J: OFF(OR106J); break; |
- |
|
240 |
case R106Z: OFF(OR106Z); break; |
230 |
} |
241 |
} |
231 |
} |
242 |
} |
232 |
|
243 |
|
233 |
void up(int8 roleta) // Pozadavek, aby roleta jela nahoru |
244 |
void up(int8 roleta) // Pozadavek, aby roleta jela nahoru |
234 |
{ |
245 |
{ |
Line 442... |
Line 453... |
442 |
break; |
453 |
break; |
443 |
case '4': |
454 |
case '4': |
444 |
if(buf[3]=='V') if((buf[4]=='U')) {up(R104V);} else {down(R104V);} |
455 |
if(buf[3]=='V') if((buf[4]=='U')) {up(R104V);} else {down(R104V);} |
445 |
if(buf[3]=='J') if((buf[4]=='U')) {up(R104J);} else {down(R104J);} |
456 |
if(buf[3]=='J') if((buf[4]=='U')) {up(R104J);} else {down(R104J);} |
446 |
break; |
457 |
break; |
- |
|
458 |
case '6': |
- |
|
459 |
if(buf[3]=='J') if((buf[4]=='U')) {up(R106J);} else {down(R106J);} |
- |
|
460 |
if(buf[3]=='Z') if((buf[4]=='U')) {up(R106Z);} else {down(R106Z);} |
- |
|
461 |
break; |
447 |
case 'a': |
462 |
case 'a': |
448 |
if((buf[4]=='U')) |
463 |
if((buf[4]=='U')) |
449 |
{//up(R110N); |
464 |
{//up(R110N); |
450 |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
465 |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
451 |
{ |
466 |
{ |
Line 513... |
Line 528... |
513 |
|
528 |
|
514 |
if(ispec!=Ispec) {ispec=Ispec; output_toggle(OS100A); zakmity=ZAKMIT;} |
529 |
if(ispec!=Ispec) {ispec=Ispec; output_toggle(OS100A); zakmity=ZAKMIT;} |
515 |
} |
530 |
} |
516 |
else zakmity--; |
531 |
else zakmity--; |
517 |
|
532 |
|
- |
|
533 |
// Spajz mikrospinac i svetlo |
- |
|
534 |
if(IS108A) {output_high(OS108A); tS108=TIMEOUT_SPAJZ;} |
- |
|
535 |
if((!IS108A)&&(tS108>0)) {output_low(OS108A);} else {output_high(OS108A);} |
- |
|
536 |
|
518 |
switch (relay) |
537 |
switch (relay) |
519 |
{ |
538 |
{ |
520 |
case UP: |
539 |
case UP: |
521 |
if (timer_start==0) // Rele prepnuto, muzeme sepnout triaky |
540 |
if (timer_start==0) // Rele prepnuto, muzeme sepnout triaky |
522 |
{ |
541 |
{ |