2080 |
kakl |
1 |
/* |
|
|
2 |
Ovladani domu rozvadec 2. n.p. |
|
|
3 |
|
|
|
4 |
Syntaxe prikazu: |
|
|
5 |
|
|
|
6 |
<Roleta/Svetlo><#patro><#mistnost><Nord/Jih/Vychod/Zapad/A/B><Up/Down> |
|
|
7 |
R2aNU - roleta, 2. n.p., mistnost 10, sever, nahoru |
|
|
8 |
S12A - svetlo, 1. n.p., mistnost 2, prostredni |
|
|
9 |
|
2081 |
kakl |
10 |
Rozmisteni desek: |
|
|
11 |
|
2494 |
kakl |
12 |
[IN D] |
|
|
13 |
[OUT E] |
|
|
14 |
[IN H] [IN J] |
|
|
15 |
[OUT B] |
|
|
16 |
[CPU] |
2081 |
kakl |
17 |
|
2494 |
kakl |
18 |
[OUT G] [CAN] [OUT A] [OUT F] |
2081 |
kakl |
19 |
|
2080 |
kakl |
20 |
*/ |
1746 |
kakl |
21 |
#include "main.h" |
|
|
22 |
|
|
|
23 |
#case |
2085 |
kakl |
24 |
#use fast_io(A) // Aby se neztracely znaky pri cteni prikazu |
|
|
25 |
#use fast_io(B) |
|
|
26 |
#use fast_io(E) |
|
|
27 |
#use fast_io(F) |
|
|
28 |
#use fast_io(D) |
|
|
29 |
#use fast_io(J) |
2494 |
kakl |
30 |
#use fast_io(H) |
|
|
31 |
#use fast_io(G) |
1746 |
kakl |
32 |
|
2494 |
kakl |
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 |
2231 |
kakl |
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) |
|
|
37 |
#define T_RECEIVE 10 // cca 2,6 s |
|
|
38 |
#define ZAKMIT 2000 // pocet pruchodu hlavni smyckou pred opetovnou detekci prepnuti vypinace |
1747 |
kakl |
39 |
|
2232 |
kakl |
40 |
#define OR106Z PIN_A0 // t1 Roleta trucovna zapad |
2231 |
kakl |
41 |
#define OR110N PIN_A1 // t2 Zaluzie koupelna dole sever |
|
|
42 |
#define OR104V PIN_A2 // t3 Roleta lab vychod |
|
|
43 |
#define OR104J PIN_A3 // t4 Roleta lab jih |
|
|
44 |
#define OR103V PIN_A4 // t5 Roleta loznice |
|
|
45 |
#define OR202J PIN_A5 // t6 Roleta Kaklik |
|
|
46 |
#define OR204Z PIN_A6 // t7 Roleta radiomistnost |
|
|
47 |
#define OR207V PIN_A7 // t8 Roleta klubovna |
1746 |
kakl |
48 |
|
2231 |
kakl |
49 |
#define OR208V PIN_F0 // t1 Roleta Zizala vychod |
|
|
50 |
#define OR208J PIN_F1 // t2 Roleta Zizala jih |
|
|
51 |
//??? #define OR107 PIN_F2 // t3 |
|
|
52 |
//??? #define OR107 PIN_F3 // t4 |
|
|
53 |
#define OR201Z PIN_F4 // t5 Roleta chodba nahore |
|
|
54 |
#define OR205N PIN_F5 // t6 Roleta puda |
|
|
55 |
//??? #define OR105 PIN_F6 // t7 Roleta kuchyn |
|
|
56 |
//#define O... PIN_F7 // t8 |
|
|
57 |
|
|
|
58 |
|
2080 |
kakl |
59 |
#define OS103J PIN_B0 // t1 Svetla loznice |
|
|
60 |
#define OS105Z PIN_B1 // t2 Svetlo kuchyn nad lavici |
2084 |
kakl |
61 |
#define OS110N PIN_B2 // t3 Svetlo koupelna dole zachod a sprhca |
2080 |
kakl |
62 |
#define OS106A PIN_B3 // t4 Svetlo trucovna stred |
|
|
63 |
#define OS107A PIN_B4 // t5 Svetlo satna |
|
|
64 |
#define OS109A PIN_B5 // t6 Svetlo technologicka mistnost |
2084 |
kakl |
65 |
#define OS205A PIN_B6 // t7 Svetlo puda |
|
|
66 |
#define OS204A PIN_B7 // t8 Svetlo radiomistnost |
1746 |
kakl |
67 |
|
|
|
68 |
//#define OS105C PIN_C2 |
|
|
69 |
//#define PIN_C3 31763 |
|
|
70 |
//#define PIN_C4 31764 |
|
|
71 |
//#define PIN_C5 31765 |
|
|
72 |
//#define PIN_C6 31766 //TX |
|
|
73 |
//#define PIN_C7 31767 //RX |
|
|
74 |
|
2085 |
kakl |
75 |
#define OS102A PIN_E0 // t1 Svetlo chodba |
|
|
76 |
#define OS105A PIN_E1 // t2 Svetlo kuchyne stred |
|
|
77 |
#define OS207A PIN_E2 // t3 Svetlo klubovna |
|
|
78 |
#define OS104A PIN_E3 // t4 Svetlo laborator |
|
|
79 |
#define OS202A PIN_E4 // t5 Svetlo Kaklik stred |
|
|
80 |
#define OS209A PIN_E5 // t6 Svetlo Zizala koupelna |
|
|
81 |
#define OS203A PIN_E6 // t7 Svetlo Kaklik koupelna |
2231 |
kakl |
82 |
#define RE PIN_E7 // t8 Rele pro rizeni smeru rolet |
2085 |
kakl |
83 |
|
2494 |
kakl |
84 |
//#define O.... PIN_G0 // t8 |
|
|
85 |
//#define O.... PIN_G1 // t7 |
|
|
86 |
//#define O.... PIN_G2 // t6 |
|
|
87 |
#define OS208A PIN_G3 // t5 Svetlo Zizala stred |
|
|
88 |
#define OS100A PIN_G4 // t4 Svetlo prujezd venku |
|
|
89 |
|
|
|
90 |
//#define I.... input(PIN_D0) // A |
2084 |
kakl |
91 |
#define IS201AZ input(PIN_D1) // B Vypinac chodba 2.n.p. zapad u Kaklika |
|
|
92 |
#define IS207AJ input(PIN_D2) // C Vypinac klubovna |
|
|
93 |
#define IR207VD input(PIN_D3) // D Vypinac roleta klubovna dolu |
|
|
94 |
#define IR207VU input(PIN_D4) // E Vypinac roleta klubovna nahoru |
|
|
95 |
#define IS201AV input(PIN_D5) // F Vypinac chodba 2.n.p. vychod |
|
|
96 |
#define IS209AJ input(PIN_D6) // G Vypinac koupelna Zizala |
|
|
97 |
#define IS203AJ input(PIN_D7) // H Vypinac koupelna Kaklik |
|
|
98 |
|
|
|
99 |
#define IS202AN input(PIN_J0) // A Vypinac svetlo Kaklik stred u dveri na chodbu |
|
|
100 |
#define IR202ND input(PIN_J1) // B Vypinac roleta Kaklik dolu u dveri |
|
|
101 |
#define IR202NU input(PIN_J2) // C Vypinac roleta Kaklik nahoru u dveri |
|
|
102 |
#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 IR204ZD input(PIN_J5) // F Vypinac roleta radiomistnost dolu |
|
|
105 |
#define IR204ZU input(PIN_J6) // G Vypinac roleta radiomistnost nahoru |
2494 |
kakl |
106 |
//#define I.... input(PIN_J7) // H |
2084 |
kakl |
107 |
|
2494 |
kakl |
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 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 IR208VD input(PIN_H3) // D Vypinac roleta jih Zizala nahoru u dveri |
|
|
112 |
#define IR208VU input(PIN_H4) // E Vypinac roleta jih Zizala dolu u dveri |
|
|
113 |
//#define I.... input(PIN_H5) // F |
|
|
114 |
//#define I.... input(PIN_H6) // G |
|
|
115 |
#define Ispec input(PIN_H7) // H specialni vypinac u rozvadece 2.n.p. |
|
|
116 |
|
|
|
117 |
|
2080 |
kakl |
118 |
int1 s201AV; |
|
|
119 |
int1 s201AZ; |
|
|
120 |
int1 s207AJ; |
|
|
121 |
int1 s203AJ; |
|
|
122 |
int1 s209AJ; |
|
|
123 |
int1 r207VU; |
|
|
124 |
int1 r207VD; |
2084 |
kakl |
125 |
int1 s202AN; |
|
|
126 |
int1 r202ND; |
|
|
127 |
int1 r202NU; |
|
|
128 |
int1 s205A; |
|
|
129 |
int1 s204AJ; |
|
|
130 |
int1 r204ZD; |
|
|
131 |
int1 r204ZU; |
2494 |
kakl |
132 |
int1 s208AN; |
|
|
133 |
int1 r208VU; |
|
|
134 |
int1 r208VD; |
|
|
135 |
int1 r208JU; |
|
|
136 |
int1 r208JD; |
|
|
137 |
int1 ispec; |
1746 |
kakl |
138 |
|
1747 |
kakl |
139 |
#bit CREN = 0xFAB.4 // USART enable register |
|
|
140 |
|
2494 |
kakl |
141 |
#define LED1 PIN_C0 // Vyvedeno na desku portu G |
|
|
142 |
#define LED2 PIN_C1 // Vyvedeno na desku portu G |
1746 |
kakl |
143 |
|
|
|
144 |
#define ON(port) output_low(port); |
|
|
145 |
#define OFF(port) output_high(port); |
|
|
146 |
|
2231 |
kakl |
147 |
typedef enum {RUN, STOP} roleta_state; |
|
|
148 |
roleta_state rol[18]; // Stavy rolet |
|
|
149 |
#define R103V 0 |
|
|
150 |
#define R110N 1 |
|
|
151 |
#define R104V 2 |
|
|
152 |
#define R104J 3 |
|
|
153 |
#define R207V 4 |
|
|
154 |
#define R202J 5 |
|
|
155 |
#define R204Z 6 |
2494 |
kakl |
156 |
#define R208V 7 |
|
|
157 |
#define R208J 8 |
1746 |
kakl |
158 |
|
2232 |
kakl |
159 |
typedef enum {UP, DOWN, REVERS_UP, REVERS_DOWN, RUN_UP, RUN_DOWN, RUN_UP_WAITING} relay_state; |
2231 |
kakl |
160 |
relay_state relay; // Stavy rele |
1747 |
kakl |
161 |
|
2231 |
kakl |
162 |
int8 timer_run; // Bezpecnostni casovac behu rolety |
|
|
163 |
int8 timer_run_zaluzie; // Casovac zaluzie na preklopeni lamel |
|
|
164 |
int8 timer_revers; // Prodleva na vybiti kondenzatoru pa zastaveni rolety pred prepnutim rele |
|
|
165 |
int8 timer_start; // Prodleva na prepnuti rele pred startem rolety |
|
|
166 |
int8 timer; // Casovac komunikace |
|
|
167 |
|
1747 |
kakl |
168 |
#int_TIMER0 |
|
|
169 |
void TIMER0_isr(void) |
|
|
170 |
{ |
1748 |
kakl |
171 |
if(timer>0) timer--; |
2231 |
kakl |
172 |
if(timer_run>0) timer_run--; |
|
|
173 |
if(timer_revers>0) timer_revers--; |
|
|
174 |
if(timer_start>0) timer_start--; |
|
|
175 |
if(timer_run_zaluzie>0) timer_run_zaluzie--; |
2233 |
kakl |
176 |
output_toggle(LED2); |
1747 |
kakl |
177 |
} |
|
|
178 |
|
2231 |
kakl |
179 |
void stop_all() // Zastav vsechny rolety |
|
|
180 |
{ |
|
|
181 |
int8 n; |
|
|
182 |
|
|
|
183 |
output_a(0xFF); |
|
|
184 |
output_f(0xFF); |
2233 |
kakl |
185 |
for(n=0; n<18; n++) rol[n]=STOP; |
2231 |
kakl |
186 |
} |
|
|
187 |
|
|
|
188 |
void run_all() // Spust rolety |
|
|
189 |
{ |
|
|
190 |
if (rol[R103V]==RUN) ON(OR103V); |
|
|
191 |
if (rol[R110N]==RUN) ON(OR110N); |
|
|
192 |
if (rol[R104V]==RUN) ON(OR104V); |
|
|
193 |
if (rol[R104J]==RUN) ON(OR104J); |
|
|
194 |
if (rol[R207V]==RUN) ON(OR207V); |
|
|
195 |
if (rol[R202J]==RUN) ON(OR202J); |
|
|
196 |
if (rol[R204Z]==RUN) ON(OR204Z); |
2494 |
kakl |
197 |
if (rol[R208V]==RUN) ON(OR208V); |
|
|
198 |
if (rol[R208J]==RUN) ON(OR208J); |
2231 |
kakl |
199 |
} |
|
|
200 |
|
2232 |
kakl |
201 |
void run(int8 roleta) // Spust konkretni roletu |
1747 |
kakl |
202 |
{ |
2232 |
kakl |
203 |
switch (roleta) |
1747 |
kakl |
204 |
{ |
2232 |
kakl |
205 |
case R103V: ON(OR103V); break; |
|
|
206 |
case R110N: ON(OR110N); break; |
|
|
207 |
case R104V: ON(OR104V); break; |
|
|
208 |
case R104J: ON(OR104J); break; |
|
|
209 |
case R207V: ON(OR207V); break; |
|
|
210 |
case R202J: ON(OR202J); break; |
|
|
211 |
case R204Z: ON(OR204Z); break; |
2494 |
kakl |
212 |
case R208V: ON(OR208V); break; |
|
|
213 |
case R208J: ON(OR208J); break; |
1747 |
kakl |
214 |
} |
|
|
215 |
} |
|
|
216 |
|
2233 |
kakl |
217 |
void stop(int8 roleta) // Spust konkretni roletu |
|
|
218 |
{ |
|
|
219 |
switch (roleta) |
|
|
220 |
{ |
|
|
221 |
case R103V: OFF(OR103V); break; |
|
|
222 |
case R110N: OFF(OR110N); break; |
|
|
223 |
case R104V: OFF(OR104V); break; |
|
|
224 |
case R104J: OFF(OR104J); break; |
|
|
225 |
case R207V: OFF(OR207V); break; |
|
|
226 |
case R202J: OFF(OR202J); break; |
|
|
227 |
case R204Z: OFF(OR204Z); break; |
2494 |
kakl |
228 |
case R208V: OFF(OR208V); break; |
|
|
229 |
case R208J: OFF(OR208J); break; |
2233 |
kakl |
230 |
} |
|
|
231 |
} |
|
|
232 |
|
2232 |
kakl |
233 |
void up(int8 roleta) // Pozadavek, aby roleta jela nahoru |
1747 |
kakl |
234 |
{ |
2232 |
kakl |
235 |
if (rol[roleta]==RUN) |
1747 |
kakl |
236 |
{ |
2232 |
kakl |
237 |
rol[roleta]=STOP; // Roleta jela, tak zastav |
2233 |
kakl |
238 |
stop(roleta); |
1747 |
kakl |
239 |
} |
2232 |
kakl |
240 |
else |
|
|
241 |
{ |
|
|
242 |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
|
|
243 |
{ |
|
|
244 |
relay=REVERS_UP; // Reverzuj |
|
|
245 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
|
|
246 |
stop_all(); // Vsechno zastav |
|
|
247 |
} |
|
|
248 |
if (relay==RUN_UP) |
|
|
249 |
{ |
2233 |
kakl |
250 |
run(roleta); // Jede se spravnym smerem, tak jenom pust roletu |
2232 |
kakl |
251 |
} |
|
|
252 |
|
|
|
253 |
rol[roleta]=RUN; // Roleta stala, tak ji pust |
|
|
254 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
|
|
255 |
} |
1747 |
kakl |
256 |
} |
|
|
257 |
|
|
|
258 |
|
2232 |
kakl |
259 |
void down(int8 roleta) // Pozadavek, aby roleta jela dolu |
|
|
260 |
{ |
|
|
261 |
if (rol[roleta]==RUN) |
|
|
262 |
{ |
|
|
263 |
rol[roleta]=STOP; // Roleta jela, tak zastav |
2233 |
kakl |
264 |
stop(roleta); |
2232 |
kakl |
265 |
} |
|
|
266 |
else |
|
|
267 |
{ |
|
|
268 |
if ((relay==UP)||(relay==RUN_UP)||(relay==RUN_UP_WAITING)) // Rele je prepnuto na druhou stranu! |
|
|
269 |
{ |
|
|
270 |
relay=REVERS_DOWN; // Reverzuj |
|
|
271 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
|
|
272 |
stop_all(); // Vsechno zastav |
|
|
273 |
} |
|
|
274 |
if (relay==RUN_DOWN) |
|
|
275 |
{ |
2233 |
kakl |
276 |
run(roleta); // Jede se spravnym smerem, tak jenom pust roletu |
2232 |
kakl |
277 |
} |
|
|
278 |
|
|
|
279 |
rol[roleta]=RUN; // Roleta stala, tak ji pust |
|
|
280 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
|
|
281 |
} |
|
|
282 |
} |
|
|
283 |
|
|
|
284 |
|
1746 |
kakl |
285 |
void main() |
|
|
286 |
{ |
2085 |
kakl |
287 |
char buf[10]; // Buffer pro prijem prikazu |
2153 |
kakl |
288 |
unsigned int16 zakmity=0; // Osetreni zakmitu vypinacu |
1746 |
kakl |
289 |
|
1748 |
kakl |
290 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
|
|
291 |
setup_adc(ADC_CLOCK_DIV_2); |
|
|
292 |
setup_psp(PSP_DISABLED); |
|
|
293 |
setup_spi(SPI_SS_DISABLED); |
|
|
294 |
setup_wdt(WDT_OFF); |
2085 |
kakl |
295 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8); |
1748 |
kakl |
296 |
setup_timer_1(T1_DISABLED); |
|
|
297 |
setup_timer_2(T2_DISABLED,0,1); |
|
|
298 |
setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
|
|
299 |
setup_ccp1(CCP_OFF); |
|
|
300 |
setup_comparator(NC_NC_NC_NC); |
|
|
301 |
setup_vref(FALSE); |
2085 |
kakl |
302 |
|
|
|
303 |
set_tris_a(0); // Vystupy |
|
|
304 |
set_tris_b(0); |
|
|
305 |
set_tris_e(0); |
|
|
306 |
set_tris_f(0); |
2494 |
kakl |
307 |
set_tris_g(0x20); |
2085 |
kakl |
308 |
set_tris_d(0xFF); // Vstupy |
|
|
309 |
set_tris_j(0xFF); |
2494 |
kakl |
310 |
set_tris_h(0xFF); |
1747 |
kakl |
311 |
|
2080 |
kakl |
312 |
output_a(0xFF); // Vsechno zhasni a zastav |
|
|
313 |
output_b(0xFF); |
|
|
314 |
output_f(0xFF); |
|
|
315 |
output_e(0xFF); |
2494 |
kakl |
316 |
output_g(0xFF); |
2231 |
kakl |
317 |
stop_all(); |
1747 |
kakl |
318 |
|
2232 |
kakl |
319 |
relay=RUN_UP_WAITING; // Rele je na zacatku vypnuto |
2231 |
kakl |
320 |
|
2081 |
kakl |
321 |
{ |
|
|
322 |
int n; |
|
|
323 |
|
|
|
324 |
for(n=0;n<10;n++) |
|
|
325 |
{ |
|
|
326 |
output_low(LED1); // Indikace restartu (pockame na nabiti kondenzatoru ve vstupnich obvodech) |
|
|
327 |
delay_ms(100); |
|
|
328 |
output_high(LED1); |
|
|
329 |
delay_ms(100); |
|
|
330 |
restart_wdt(); |
|
|
331 |
} |
|
|
332 |
} |
1746 |
kakl |
333 |
|
2080 |
kakl |
334 |
s201AV=IS201AV; // Precteme vychozi stav vypinacu |
|
|
335 |
s201AZ=IS201AZ; |
|
|
336 |
s207AJ=IS207AJ; |
|
|
337 |
s203AJ=IS203AJ; |
|
|
338 |
s209AJ=IS209AJ; |
|
|
339 |
r207VU=IR207VU; |
|
|
340 |
r207VD=IR207VD; |
2084 |
kakl |
341 |
s202AN=IS202AN; |
|
|
342 |
r202ND=IR202ND; |
|
|
343 |
r202NU=IR202NU; |
|
|
344 |
s205A=IS205A; |
|
|
345 |
s204AJ=IS204AJ; |
|
|
346 |
r204ZD=IR204ZD; |
|
|
347 |
r204ZU=IR204ZU; |
2494 |
kakl |
348 |
s208AN=IS208AN; |
|
|
349 |
r208VU=IR208VU; |
|
|
350 |
r208VD=IR208VD; |
|
|
351 |
r208JU=IR208JU; |
|
|
352 |
r208JD=IR208JD; |
|
|
353 |
ispec=Ispec; |
2232 |
kakl |
354 |
|
|
|
355 |
timer_run=0; // Zastav vsechny casovace |
|
|
356 |
timer=0; |
|
|
357 |
timer_revers=0; |
|
|
358 |
timer_start=0; |
|
|
359 |
timer_run_zaluzie=0; |
|
|
360 |
zakmity=0; |
|
|
361 |
|
2233 |
kakl |
362 |
enable_interrupts(INT_TIMER0); // Spust casovani |
1748 |
kakl |
363 |
enable_interrupts(GLOBAL); |
2081 |
kakl |
364 |
|
2232 |
kakl |
365 |
CREN=0; CREN=1; // Reinitialise USART |
|
|
366 |
|
1746 |
kakl |
367 |
while(TRUE) |
|
|
368 |
{ |
2085 |
kakl |
369 |
restart_wdt(); |
1748 |
kakl |
370 |
|
|
|
371 |
if(kbhit()) // Chce po nas nekdo neco? |
1746 |
kakl |
372 |
{ |
1748 |
kakl |
373 |
buf[0]=getc(); |
|
|
374 |
if((buf[0]=='S')||(buf[0]=='R')) // Jinym znakem nesmi zacinat prikaz |
1746 |
kakl |
375 |
{ |
1748 |
kakl |
376 |
int8 n=0; // Ukazatel do prijimaciho bufferu |
2231 |
kakl |
377 |
timer=T_RECEIVE; // Timeout pro prijem znaku |
1748 |
kakl |
378 |
|
|
|
379 |
do |
1746 |
kakl |
380 |
{ |
1748 |
kakl |
381 |
if(kbhit()) // Je dalsi znak? |
1747 |
kakl |
382 |
{ |
1748 |
kakl |
383 |
n++; |
|
|
384 |
buf[n]=getc(); |
1747 |
kakl |
385 |
} |
1748 |
kakl |
386 |
} while ((buf[n]!='\r')&&(timer>0)&&(n<7)); |
|
|
387 |
|
|
|
388 |
if (timer==0) { CREN=0; CREN=1; } // Reinitialise USART |
|
|
389 |
|
|
|
390 |
output_toggle(LED1); // Ukonceni prijimani prikazu |
|
|
391 |
|
|
|
392 |
if((timer>0)) |
1746 |
kakl |
393 |
{ |
1748 |
kakl |
394 |
|
|
|
395 |
if((buf[0]=='S')&&(n>=4)) // Zmena stavu svetla |
1747 |
kakl |
396 |
{ |
1748 |
kakl |
397 |
if(buf[1]=='1') |
|
|
398 |
{ |
|
|
399 |
switch(buf[2]) |
|
|
400 |
{ |
|
|
401 |
case '2': |
2080 |
kakl |
402 |
output_toggle(OS102A); |
1748 |
kakl |
403 |
break; |
|
|
404 |
case '3': |
2080 |
kakl |
405 |
output_toggle(OS103J); |
1748 |
kakl |
406 |
break; |
|
|
407 |
case '4': |
2080 |
kakl |
408 |
output_toggle(OS104A); |
1748 |
kakl |
409 |
break; |
|
|
410 |
case '5': |
2080 |
kakl |
411 |
if(buf[3]=='A') {output_toggle(OS105A);} |
|
|
412 |
if(buf[3]=='Z') {output_toggle(OS105Z);} |
1748 |
kakl |
413 |
break; |
|
|
414 |
case '6': |
2080 |
kakl |
415 |
output_toggle(OS106A); |
1748 |
kakl |
416 |
break; |
|
|
417 |
case '7': |
2080 |
kakl |
418 |
output_toggle(OS107A); |
1748 |
kakl |
419 |
break; |
|
|
420 |
case '8': |
2080 |
kakl |
421 |
// output_toggle(OS108A); |
1748 |
kakl |
422 |
break; |
|
|
423 |
case '9': |
2080 |
kakl |
424 |
output_toggle(OS109A); |
1748 |
kakl |
425 |
break; |
|
|
426 |
case 'a': |
2080 |
kakl |
427 |
// output_toggle(OS110J); |
|
|
428 |
output_toggle(OS110N); |
1748 |
kakl |
429 |
break; |
|
|
430 |
} |
|
|
431 |
} |
1747 |
kakl |
432 |
} |
1748 |
kakl |
433 |
|
|
|
434 |
if((buf[0]=='R')&&(n>=5)) // Zmena stavu rolety |
|
|
435 |
{ |
|
|
436 |
if(buf[1]=='1') |
|
|
437 |
{ |
|
|
438 |
switch(buf[2]) |
|
|
439 |
{ |
|
|
440 |
case '3': |
2233 |
kakl |
441 |
if(buf[4]=='U') {up(R103V);} else {down(R103V);} |
1748 |
kakl |
442 |
break; |
|
|
443 |
case '4': |
2233 |
kakl |
444 |
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);} |
1748 |
kakl |
446 |
break; |
|
|
447 |
case 'a': |
2233 |
kakl |
448 |
if((buf[4]=='U')) |
|
|
449 |
{//up(R110N); |
|
|
450 |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
|
|
451 |
{ |
|
|
452 |
relay=REVERS_UP; // Reverzuj |
|
|
453 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
|
|
454 |
stop_all(); // Vsechno zastav |
|
|
455 |
} |
|
|
456 |
if (relay==RUN_UP) |
|
|
457 |
{ |
|
|
458 |
run(R110N); // Jede se spravnym smerem, tak jenom pust roletu |
|
|
459 |
} |
|
|
460 |
|
|
|
461 |
rol[R110N]=RUN; // Roleta stala, tak ji pust |
|
|
462 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
|
|
463 |
} |
|
|
464 |
else |
|
|
465 |
{//down(R110N); |
|
|
466 |
if ((relay==UP)||(relay==RUN_UP)||(relay==RUN_UP_WAITING)) // Rele je prepnuto na druhou stranu! |
|
|
467 |
{ |
|
|
468 |
relay=REVERS_DOWN; // Reverzuj |
|
|
469 |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
|
|
470 |
stop_all(); // Vsechno zastav |
|
|
471 |
} |
|
|
472 |
if (relay==RUN_DOWN) |
|
|
473 |
{ |
|
|
474 |
run(R110N); // Jede se spravnym smerem, tak jenom pust roletu |
|
|
475 |
} |
|
|
476 |
|
|
|
477 |
rol[R110N]=RUN; // Roleta stala, tak ji pust |
|
|
478 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
|
|
479 |
} |
|
|
480 |
timer_run_zaluzie=T_GO_ZALUZIE; |
1748 |
kakl |
481 |
break; |
|
|
482 |
} |
|
|
483 |
} |
|
|
484 |
} |
|
|
485 |
|
1746 |
kakl |
486 |
} |
|
|
487 |
} |
|
|
488 |
} |
1748 |
kakl |
489 |
|
2080 |
kakl |
490 |
// mistni vypinace z 2. n.p. |
2085 |
kakl |
491 |
if (0==zakmity) |
|
|
492 |
{ |
|
|
493 |
if(s201AV!=IS201AV) {s201AV=IS201AV; output_toggle(OS102A); zakmity=ZAKMIT;} |
|
|
494 |
if(s201AZ!=IS201AZ) {s201AZ=IS201AZ; output_toggle(OS102A); zakmity=ZAKMIT;} |
|
|
495 |
if(s207AJ!=IS207AJ) {s207AJ=IS207AJ; output_toggle(OS207A); zakmity=ZAKMIT;} |
|
|
496 |
if(s203AJ!=IS203AJ) {s203AJ=IS203AJ; output_toggle(OS203A); zakmity=ZAKMIT;} |
|
|
497 |
if(s209AJ!=IS209AJ) {s209AJ=IS209AJ; output_toggle(OS209A); zakmity=ZAKMIT;} |
2233 |
kakl |
498 |
if(s205A!=IS205A) {s205A=IS205A; output_toggle(OS205A); zakmity=ZAKMIT;} |
2085 |
kakl |
499 |
if(s204AJ!=IS204AJ) {s204AJ=IS204AJ; output_toggle(OS204A); zakmity=ZAKMIT;} |
|
|
500 |
if(s202AN!=IS202AN) {s202AN=IS202AN; output_toggle(OS202A); zakmity=ZAKMIT;} |
2494 |
kakl |
501 |
if(s208AN!=IS208AN) {s208AN=IS208AN; output_toggle(OS208A); zakmity=ZAKMIT;} |
2085 |
kakl |
502 |
|
2232 |
kakl |
503 |
if(r207VU!=IR207VU) {r207VU=IR207VU; up(R207V); zakmity=ZAKMIT;} |
|
|
504 |
if(r207VD!=IR207VD) {r207VD=IR207VD; down(R207V); zakmity=ZAKMIT;} |
2233 |
kakl |
505 |
if(r202NU!=IR202NU) {r202NU=IR202NU; up(R202J); zakmity=ZAKMIT;} |
2232 |
kakl |
506 |
if(r202ND!=IR202ND) {r202ND=IR202ND; down(R202J); zakmity=ZAKMIT;} |
2233 |
kakl |
507 |
if(r204ZU!=IR204ZU) {r204ZU=IR204ZU; up(R204Z); zakmity=ZAKMIT;} |
2232 |
kakl |
508 |
if(r204ZD!=IR204ZD) {r204ZD=IR204ZD; down(R204Z); zakmity=ZAKMIT;} |
2494 |
kakl |
509 |
if(r208VU!=IR208VU) {r208VU=IR208VU; up(R208V); zakmity=ZAKMIT;} |
|
|
510 |
if(r208VD!=IR208VD) {r208VD=IR208VD; down(R208V); zakmity=ZAKMIT;} |
|
|
511 |
if(r208JU!=IR208JU) {r208JU=IR208JU; up(R208J); zakmity=ZAKMIT;} |
|
|
512 |
if(r208JD!=IR208JD) {r208JD=IR208JD; down(R208J); zakmity=ZAKMIT;} |
|
|
513 |
|
|
|
514 |
if(ispec!=Ispec) {ispec=Ispec; output_toggle(OS100A); zakmity=ZAKMIT;} |
2085 |
kakl |
515 |
} |
|
|
516 |
else zakmity--; |
2232 |
kakl |
517 |
|
|
|
518 |
switch (relay) |
|
|
519 |
{ |
|
|
520 |
case UP: |
|
|
521 |
if (timer_start==0) // Rele prepnuto, muzeme sepnout triaky |
|
|
522 |
{ |
|
|
523 |
relay=RUN_UP; // Zmen stav na "jede se" |
|
|
524 |
run_all(); // Sepni triaky u rolet, ktere maji jet |
|
|
525 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
|
|
526 |
} |
|
|
527 |
break; |
2231 |
kakl |
528 |
|
2232 |
kakl |
529 |
case DOWN: |
|
|
530 |
if (timer_start==0) // Rele prepnuto, muzeme sepnout triaky |
|
|
531 |
{ |
|
|
532 |
relay=RUN_DOWN; // Zmen stav na "jede se" |
|
|
533 |
run_all(); // Sepni triaky u rolet, ktere maji jet |
|
|
534 |
timer_run=T_GO; // Natahni bezpecnostni casovac |
|
|
535 |
} |
|
|
536 |
break; |
|
|
537 |
|
|
|
538 |
case RUN_UP: |
|
|
539 |
if (timer_run==0) // Vyprsel bezpecnostni casovac |
|
|
540 |
{ |
|
|
541 |
timer=RUN_UP_WAITING; |
|
|
542 |
stop_all(); // Vsechno zastav |
|
|
543 |
} |
|
|
544 |
break; |
|
|
545 |
|
|
|
546 |
case RUN_DOWN: |
|
|
547 |
if (timer_run==0) // Vyprsel bezpecnostni casovac |
|
|
548 |
{ |
|
|
549 |
relay=REVERS_UP; // Vsechno zastav a reverzuj pro prepnuti rele do klidove polohy bez energizace civky |
|
|
550 |
stop_all(); |
|
|
551 |
timer_revers=T_REVERS; |
|
|
552 |
} |
|
|
553 |
break; |
|
|
554 |
|
|
|
555 |
case REVERS_UP: |
|
|
556 |
if (timer_revers==0) // Uz se snad vybil kondenzator, muzeme reverzovat |
|
|
557 |
{ |
|
|
558 |
relay=UP; // Prepni rele |
|
|
559 |
OFF(RE); |
|
|
560 |
timer_start=T_START; // Pockej na prepnuti rele |
|
|
561 |
} |
|
|
562 |
break; |
|
|
563 |
|
|
|
564 |
case REVERS_DOWN: |
|
|
565 |
if (timer_revers==0) // Uz se snad vybil kondenzator, muzeme reverzovat |
|
|
566 |
{ |
|
|
567 |
relay=DOWN; // Prepni rele |
|
|
568 |
ON(RE); |
|
|
569 |
timer_start=T_START; // Pockej na prepnuti rele |
|
|
570 |
} |
|
|
571 |
break; |
|
|
572 |
} |
2233 |
kakl |
573 |
|
|
|
574 |
// Zaluzie ma kratsi beh |
|
|
575 |
if ((timer_run_zaluzie==0)&&(rol[R110N]==RUN)) {rol[R110N]=STOP; OFF(OR110N);} |
2231 |
kakl |
576 |
} |
1746 |
kakl |
577 |
} |