Rev 1748 | Rev 1749 | ||
---|---|---|---|
1 | #include "main.h" |
1 | #include "main.h" |
2 | |
2 | |
3 | #case |
3 | #case |
4 | |
4 | |
5 | #define REVERS 2 // 2*256 ms = 0,5 s |
5 | #define REVERS 3 // 2*256 ms = 0,75 s |
6 | #define GO 117 // 117*256 ms = 30 s |
6 | #define GO 117 // 117*256 ms = 30 s |
7 | #define GO_ZALUZIE 5 // 5*256 ms = 1,25 s |
7 | #define GO_ZALUZIE 6 // cca 1,5 s |
8 | #define RECEIVE 12 // 3 s |
8 | #define RECEIVE 10 // cca 2,6 s |
9 | |
9 | |
10 | #define S105A PIN_A0 |
10 | #define S105A PIN_A0 |
11 | #define R110NU PIN_A1 |
11 | #define R110NU PIN_A1 |
12 | #define R110ND PIN_A2 |
12 | #define R110ND PIN_A2 |
13 | #define S104A PIN_A3 |
13 | #define S104A PIN_A3 |
14 | #define R104VU PIN_A4 |
14 | #define R104VU PIN_A4 |
15 | #define R104VD PIN_A5 |
15 | #define R104VD PIN_A5 |
16 | #define R104JU PIN_A6 |
16 | #define R104JU PIN_A6 |
17 | #define R104JD PIN_A7 |
17 | #define R104JD PIN_A7 |
18 | |
18 | |
19 | #define S103J PIN_B0 |
19 | #define S103J PIN_B0 |
20 | #define R103VU PIN_B1 |
20 | #define R103VU PIN_B1 |
21 | #define R103VD PIN_B2 |
21 | #define R103VD PIN_B2 |
22 | #define S106A PIN_B3 |
22 | #define S106A PIN_B3 |
23 | #define S107A PIN_B4 |
23 | #define S107A PIN_B4 |
24 | #define S109A PIN_B5 |
24 | #define S109A PIN_B5 |
25 | |
25 | |
26 | //#define OS101 PIN_C0 |
26 | //#define OS101 PIN_C0 |
27 | //#define OS105B PIN_C1 |
27 | //#define OS105B PIN_C1 |
28 | //#define OS105C PIN_C2 |
28 | //#define OS105C PIN_C2 |
29 | //#define PIN_C3 31763 |
29 | //#define PIN_C3 31763 |
30 | //#define PIN_C4 31764 |
30 | //#define PIN_C4 31764 |
31 | //#define PIN_C5 31765 |
31 | //#define PIN_C5 31765 |
32 | |
32 | |
33 | //#define PIN_C6 31766 //TX |
33 | //#define PIN_C6 31766 //TX |
34 | //#define PIN_C7 31767 //RX |
34 | //#define PIN_C7 31767 //RX |
35 | |
35 | |
36 | //#define S101A PIN_F0 |
36 | //#define S101A PIN_F0 |
37 | #define S105Z PIN_F1 |
37 | #define S105Z PIN_F1 |
38 | #define S102A PIN_F2 |
38 | #define S102A PIN_F2 |
39 | #define S110N PIN_F3 |
39 | #define S110N PIN_F3 |
40 | #define S108A PIN_F4 |
40 | #define S108A PIN_F4 |
41 | #define S201A PIN_F5 |
41 | #define S201A PIN_F5 |
42 | #define S110J PIN_F6 |
42 | #define S110J PIN_F6 |
43 | |
43 | |
44 | /* |
44 | /* |
45 | #define PIN_E0 31776 |
45 | #define PIN_E0 31776 |
46 | #define PIN_E1 31777 |
46 | #define PIN_E1 31777 |
47 | #define PIN_E2 31778 |
47 | #define PIN_E2 31778 |
48 | #define PIN_E3 31779 |
48 | #define PIN_E3 31779 |
49 | #define PIN_E4 31780 |
49 | #define PIN_E4 31780 |
50 | #define PIN_E5 31781 |
50 | #define PIN_E5 31781 |
51 | #define PIN_E6 31782 |
51 | #define PIN_E6 31782 |
52 | #define PIN_E7 31783 |
52 | #define PIN_E7 31783 |
53 | |
53 | |
54 | #define PIN_F0 31784 |
54 | #define PIN_F0 31784 |
55 | #define PIN_F1 31785 |
55 | #define PIN_F1 31785 |
56 | #define PIN_F2 31786 |
56 | #define PIN_F2 31786 |
57 | #define PIN_F3 31787 |
57 | #define PIN_F3 31787 |
58 | #define PIN_F4 31788 |
58 | #define PIN_F4 31788 |
59 | #define PIN_F5 31789 |
59 | #define PIN_F5 31789 |
60 | #define PIN_F6 31790 |
60 | #define PIN_F6 31790 |
61 | #define PIN_F7 31791 |
61 | #define PIN_F7 31791 |
62 | |
62 | |
63 | #define PIN_G0 31792 |
63 | #define PIN_G0 31792 |
64 | #define PIN_G1 31793 |
64 | #define PIN_G1 31793 |
65 | #define PIN_G2 31794 |
65 | #define PIN_G2 31794 |
66 | #define PIN_G3 31795 |
66 | #define PIN_G3 31795 |
67 | #define PIN_G4 31796 |
67 | #define PIN_G4 31796 |
68 | #define PIN_G5 31797 |
68 | #define PIN_G5 31797 |
69 | |
69 | |
70 | #define PIN_H0 31800 |
70 | #define PIN_H0 31800 |
71 | #define PIN_H1 31801 |
71 | #define PIN_H1 31801 |
72 | #define PIN_H2 31802 |
72 | #define PIN_H2 31802 |
73 | #define PIN_H3 31803 |
73 | #define PIN_H3 31803 |
74 | #define PIN_H4 31804 |
74 | #define PIN_H4 31804 |
75 | #define PIN_H5 31805 |
75 | #define PIN_H5 31805 |
76 | #define PIN_H6 31806 |
76 | #define PIN_H6 31806 |
77 | #define PIN_H7 31807 |
77 | #define PIN_H7 31807 |
78 | |
78 | |
79 | #define PIN_J0 31808 |
79 | #define PIN_J0 31808 |
80 | #define PIN_J1 31809 |
80 | #define PIN_J1 31809 |
81 | #define PIN_J2 31810 |
81 | #define PIN_J2 31810 |
82 | #define PIN_J3 31811 |
82 | #define PIN_J3 31811 |
83 | #define PIN_J4 31812 |
83 | #define PIN_J4 31812 |
84 | #define PIN_J5 31813 |
84 | #define PIN_J5 31813 |
85 | #define PIN_J6 31814 |
85 | #define PIN_J6 31814 |
86 | #define PIN_J7 31815 |
86 | #define PIN_J7 31815 |
87 | */ |
87 | */ |
88 | |
88 | |
89 | #bit CREN = 0xFAB.4 // USART enable register |
89 | #bit CREN = 0xFAB.4 // USART enable register |
90 | |
90 | |
91 | #define LED1 PIN_J7 |
91 | #define LED1 PIN_J7 |
92 | #define LED2 PIN_J6 |
92 | #define LED2 PIN_J6 |
93 | |
93 | |
94 | #define ON(port) output_low(port); |
94 | #define ON(port) output_low(port); |
95 | #define OFF(port) output_high(port); |
95 | #define OFF(port) output_high(port); |
96 | |
96 | |
97 | typedef enum {GO_UP, GO_DOWN, REVERS_UP, REVERS_DOWN, STOP} state; |
97 | typedef enum {GO_UP, GO_DOWN, REVERS_UP, REVERS_DOWN, STOP} state; |
98 | |
98 | |
99 | state r103V, r110N, r104V, r104J; // Stavy rolet |
99 | state r103V, r110N, r104V, r104J; // Stavy rolet |
100 | int8 tr103V, tr110N, tr104V, tr104J; // Casovace rolet |
100 | int8 tr103V, tr110N, tr104V, tr104J; // Casovace rolet |
101 | int8 timer; // Casovac komunikace |
101 | int8 timer; // Casovac komunikace |
102 | |
102 | |
103 | #int_TIMER0 |
103 | #int_TIMER0 |
104 | void TIMER0_isr(void) |
104 | void TIMER0_isr(void) |
105 | { |
105 | { |
106 | if(tr103V>0) tr103V--; |
106 | if(tr103V>0) tr103V--; |
107 | if(tr110N>0) tr110N--; |
107 | if(tr110N>0) tr110N--; |
108 | if(tr104V>0) tr104V--; |
108 | if(tr104V>0) tr104V--; |
109 | if(tr104J>0) tr104J--; |
109 | if(tr104J>0) tr104J--; |
110 | if(timer>0) timer--; |
110 | if(timer>0) timer--; |
111 | output_toggle(LED2); |
111 | output_toggle(LED2); |
112 | } |
112 | } |
113 | |
113 | |
114 | void up(state *status, int8 *timer) // Zmena stavu rolety smer nahoru |
114 | void up(state *status, int8 *timer) // Zmena stavu rolety smer nahoru |
115 | { |
115 | { |
116 | switch (*status) |
116 | switch (*status) |
117 | { |
117 | { |
118 | case STOP: |
118 | case STOP: |
119 | case GO_DOWN: |
119 | case GO_DOWN: |
120 | *status=REVERS_UP; |
120 | *status=REVERS_UP; |
121 | *timer=REVERS; |
121 | *timer=REVERS; |
122 | break; |
122 | break; |
123 | case REVERS_UP: |
123 | case REVERS_UP: |
124 | case GO_UP: |
124 | case GO_UP: |
125 | *status=STOP; |
125 | *status=STOP; |
126 | *timer=0; |
126 | *timer=0; |
127 | break; |
127 | break; |
128 | } |
128 | } |
129 | } |
129 | } |
130 | |
130 | |
131 | void down(state *status, int8 *timer) // Zmena stavu rolety smer dolu |
131 | void down(state *status, int8 *timer) // Zmena stavu rolety smer dolu |
132 | { |
132 | { |
133 | switch (*status) |
133 | switch (*status) |
134 | { |
134 | { |
135 | case STOP: |
135 | case STOP: |
136 | case GO_UP: |
136 | case GO_UP: |
137 | *status=REVERS_DOWN; |
137 | *status=REVERS_DOWN; |
138 | *timer=REVERS; |
138 | *timer=REVERS; |
139 | break; |
139 | break; |
140 | case REVERS_DOWN: |
140 | case REVERS_DOWN: |
141 | case GO_DOWN: |
141 | case GO_DOWN: |
142 | *status=STOP; |
142 | *status=STOP; |
143 | *timer=0; |
143 | *timer=0; |
144 | break; |
144 | break; |
145 | } |
145 | } |
146 | } |
146 | } |
147 | |
147 | |
148 | #define run(x) { \ |
148 | #define run(x) { \ |
149 | switch(r##x) \ |
149 | switch(r##x) \ |
150 | { \ |
150 | { \ |
151 | case STOP: \ |
151 | case STOP: \ |
152 | OFF(R##x##U); \ |
152 | OFF(R##x##U); \ |
153 | OFF(R##x##D); \ |
153 | OFF(R##x##D); \ |
154 | break; \ |
154 | break; \ |
155 | case GO_UP: \ |
155 | case GO_UP: \ |
156 | ON(R##x##U); \ |
156 | ON(R##x##U); \ |
157 | OFF(R##x##D); \ |
157 | OFF(R##x##D); \ |
158 | if(tr##x==0) {r##x=STOP;} \ |
158 | if(tr##x==0) {r##x=STOP;} \ |
159 | break; \ |
159 | break; \ |
160 | case GO_DOWN: \ |
160 | case GO_DOWN: \ |
161 | OFF(R##x##U); \ |
161 | OFF(R##x##U); \ |
162 | ON(R##x##D); \ |
162 | ON(R##x##D); \ |
163 | if(tr##x==0) {r##x=STOP;} \ |
163 | if(tr##x==0) {r##x=STOP;} \ |
164 | break; \ |
164 | break; \ |
165 | case REVERS_UP: \ |
165 | case REVERS_UP: \ |
166 | OFF(R##x##U); \ |
166 | OFF(R##x##U); \ |
167 | OFF(R##x##D); \ |
167 | OFF(R##x##D); \ |
168 | if(tr##x==0) {r##x=GO_UP; tr##x=GO;} \ |
168 | if(tr##x==0) {r##x=GO_UP; tr##x=GO;} \ |
169 | break; \ |
169 | break; \ |
170 | case REVERS_DOWN: \ |
170 | case REVERS_DOWN: \ |
171 | OFF(R##x##U); \ |
171 | OFF(R##x##U); \ |
172 | OFF(R##x##D); \ |
172 | OFF(R##x##D); \ |
173 | if(tr##x==0) {r##x=GO_DOWN; tr##x=GO;} \ |
173 | if(tr##x==0) {r##x=GO_DOWN; tr##x=GO;} \ |
174 | break; \ |
174 | break; \ |
175 | } \ |
175 | } \ |
176 | } |
176 | } |
177 | |
177 | |
178 | void main() |
178 | void main() |
179 | { |
179 | { |
180 | char buf[10]; |
180 | char buf[10]; |
181 | |
181 | |
182 | setup_adc_ports(NO_ANALOGS|VSS_VDD); |
182 | setup_adc_ports(NO_ANALOGS|VSS_VDD); |
183 | setup_adc(ADC_CLOCK_DIV_2); |
183 | setup_adc(ADC_CLOCK_DIV_2); |
184 | setup_psp(PSP_DISABLED); |
184 | setup_psp(PSP_DISABLED); |
185 | setup_spi(SPI_SS_DISABLED); |
185 | setup_spi(SPI_SS_DISABLED); |
186 | setup_wdt(WDT_OFF); |
186 | setup_wdt(WDT_OFF); |
187 | setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
187 | setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
188 | setup_timer_1(T1_DISABLED); |
188 | setup_timer_1(T1_DISABLED); |
189 | setup_timer_2(T2_DISABLED,0,1); |
189 | setup_timer_2(T2_DISABLED,0,1); |
190 | setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
190 | setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
191 | setup_ccp1(CCP_OFF); |
191 | setup_ccp1(CCP_OFF); |
192 | setup_comparator(NC_NC_NC_NC); |
192 | setup_comparator(NC_NC_NC_NC); |
193 | setup_vref(FALSE); |
193 | setup_vref(FALSE); |
194 | |
194 | |
195 | OFF(S105A); // Vsechno zhasni a zastav |
195 | OFF(S105A); // Vsechno zhasni a zastav |
196 | OFF(R110NU); |
196 | OFF(R110NU); |
197 | OFF(R110ND); |
197 | OFF(R110ND); |
198 | OFF(S104A); |
198 | OFF(S104A); |
199 | OFF(R104VU); |
199 | OFF(R104VU); |
200 | OFF(R104VD); |
200 | OFF(R104VD); |
201 | OFF(R104JU); |
201 | OFF(R104JU); |
202 | OFF(R104JD); |
202 | OFF(R104JD); |
203 | OFF(S103J); |
203 | OFF(S103J); |
204 | OFF(R103VU); |
204 | OFF(R103VU); |
205 | OFF(R103VD); |
205 | OFF(R103VD); |
206 | OFF(S106A); |
206 | OFF(S106A); |
207 | OFF(S107A); |
207 | OFF(S107A); |
208 | OFF(S109A); |
208 | OFF(S109A); |
209 | OFF(S105Z); |
209 | OFF(S105Z); |
210 | OFF(S102A); |
210 | OFF(S102A); |
211 | OFF(S110N); |
211 | OFF(S110N); |
212 | OFF(S108A); |
212 | OFF(S108A); |
213 | OFF(S201A); |
213 | OFF(S201A); |
214 | OFF(S110J); |
214 | OFF(S110J); |
215 | |
215 | |
216 | r103V=STOP; // Rolety jsou zastaveny |
216 | r103V=STOP; // Rolety jsou zastaveny |
217 | r110N=STOP; |
217 | r110N=STOP; |
218 | r104V=STOP; |
218 | r104V=STOP; |
219 | r104J=STOP; |
219 | r104J=STOP; |
- | 220 | tr103V=0; |
|
- | 221 | tr110N=0; |
|
- | 222 | tr104V=0; |
|
- | 223 | tr104J=0; |
|
220 | |
224 | |
221 | output_high(LED1); // Indikace restartu |
225 | output_high(LED1); // Indikace restartu |
222 | delay_ms(100); |
226 | delay_ms(100); |
223 | output_low(LED1); |
227 | output_low(LED1); |
224 | delay_ms(30); |
228 | delay_ms(30); |
225 | output_high(LED1); |
229 | output_high(LED1); |
226 | restart_wdt(); |
230 | restart_wdt(); |
227 | delay_ms(100); |
231 | delay_ms(100); |
228 | output_low(LED1); |
232 | output_low(LED1); |
229 | delay_ms(30); |
233 | delay_ms(30); |
230 | output_high(LED1); |
234 | output_high(LED1); |
231 | restart_wdt(); |
235 | restart_wdt(); |
232 | |
236 | |
233 | enable_interrupts(INT_TIMER0); |
237 | enable_interrupts(INT_TIMER0); |
234 | enable_interrupts(GLOBAL); |
238 | enable_interrupts(GLOBAL); |
235 | |
239 | |
236 | CREN=0; CREN=1; // Reinitialise USART |
240 | CREN=0; CREN=1; // Reinitialise USART |
237 | |
241 | |
238 | while(TRUE) |
242 | while(TRUE) |
239 | { |
243 | { |
240 | |
244 | |
241 | if(kbhit()) // Chce po nas nekdo neco? |
245 | if(kbhit()) // Chce po nas nekdo neco? |
242 | { |
246 | { |
243 | buf[0]=getc(); |
247 | buf[0]=getc(); |
244 | if((buf[0]=='S')||(buf[0]=='R')) // Jinym znakem nesmi zacinat prikaz |
248 | if((buf[0]=='S')||(buf[0]=='R')) // Jinym znakem nesmi zacinat prikaz |
245 | { |
249 | { |
246 | int8 n=0; // Ukazatel do prijimaciho bufferu |
250 | int8 n=0; // Ukazatel do prijimaciho bufferu |
247 | timer=RECEIVE; // Timeout pro prijem znaku |
251 | timer=RECEIVE; // Timeout pro prijem znaku |
248 | |
252 | |
249 | do |
253 | do |
250 | { |
254 | { |
251 | if(kbhit()) // Je dalsi znak? |
255 | if(kbhit()) // Je dalsi znak? |
252 | { |
256 | { |
253 | n++; |
257 | n++; |
254 | buf[n]=getc(); |
258 | buf[n]=getc(); |
255 | } |
259 | } |
256 | } while ((buf[n]!='\r')&&(timer>0)&&(n<7)); |
260 | } while ((buf[n]!='\r')&&(timer>0)&&(n<7)); |
257 | |
261 | |
258 | if (timer==0) { CREN=0; CREN=1; } // Reinitialise USART |
262 | if (timer==0) { CREN=0; CREN=1; } // Reinitialise USART |
259 | |
263 | |
260 | output_toggle(LED1); // Ukonceni prijimani prikazu |
264 | output_toggle(LED1); // Ukonceni prijimani prikazu |
261 | |
265 | |
262 | if((timer>0)) |
266 | if((timer>0)) |
263 | { |
267 | { |
264 | |
268 | |
265 | if((buf[0]=='S')&&(n>=4)) // Zmena stavu svetla |
269 | if((buf[0]=='S')&&(n>=4)) // Zmena stavu svetla |
266 | { |
270 | { |
267 | if(buf[1]=='1') |
271 | if(buf[1]=='1') |
268 | { |
272 | { |
269 | switch(buf[2]) |
273 | switch(buf[2]) |
270 | { |
274 | { |
271 | case '2': |
275 | case '2': |
272 | output_toggle(S102A); |
276 | output_toggle(S102A); |
273 | break; |
277 | break; |
274 | case '3': |
278 | case '3': |
275 | output_toggle(S103J); |
279 | output_toggle(S103J); |
276 | break; |
280 | break; |
277 | case '4': |
281 | case '4': |
278 | output_toggle(S104A); |
282 | output_toggle(S104A); |
279 | break; |
283 | break; |
280 | case '5': |
284 | case '5': |
281 | if(buf[3]=='A') {output_toggle(S105A);} |
285 | if(buf[3]=='A') {output_toggle(S105A);} |
282 | if(buf[3]=='Z') {output_toggle(S105Z);} |
286 | if(buf[3]=='Z') {output_toggle(S105Z);} |
283 | break; |
287 | break; |
284 | case '6': |
288 | case '6': |
285 | output_toggle(S106A); |
289 | output_toggle(S106A); |
286 | break; |
290 | break; |
287 | case '7': |
291 | case '7': |
288 | output_toggle(S107A); |
292 | output_toggle(S107A); |
289 | break; |
293 | break; |
290 | case '8': |
294 | case '8': |
291 | output_toggle(S108A); |
295 | output_toggle(S108A); |
292 | break; |
296 | break; |
293 | case '9': |
297 | case '9': |
294 | output_toggle(S109A); |
298 | output_toggle(S109A); |
295 | break; |
299 | break; |
296 | case 'a': |
300 | case 'a': |
297 | output_toggle(S110J); |
301 | output_toggle(S110J); |
298 | output_toggle(S110N); |
302 | output_toggle(S110N); |
299 | break; |
303 | break; |
300 | } |
304 | } |
301 | } |
305 | } |
302 | } |
306 | } |
303 | |
307 | |
304 | if((buf[0]=='R')&&(n>=5)) // Zmena stavu rolety |
308 | if((buf[0]=='R')&&(n>=5)) // Zmena stavu rolety |
305 | { |
309 | { |
306 | if(buf[1]=='1') |
310 | if(buf[1]=='1') |
307 | { |
311 | { |
308 | switch(buf[2]) |
312 | switch(buf[2]) |
309 | { |
313 | { |
310 | case '3': |
314 | case '3': |
311 | if(buf[4]=='U') {up(&r103V,&tr103V);} else {down(&r103V,&tr103V);} |
315 | if(buf[4]=='U') {up(&r103V,&tr103V);} else {down(&r103V,&tr103V);} |
312 | break; |
316 | break; |
313 | case '4': |
317 | case '4': |
314 | if(buf[3]=='V') if((buf[4]=='U')) {up(&r104V,&tr104V);} else {down(&r104V,&tr104V);} |
318 | if(buf[3]=='V') if((buf[4]=='U')) {up(&r104V,&tr104V);} else {down(&r104V,&tr104V);} |
315 | if(buf[3]=='J') if((buf[4]=='U')) {up(&r104J,&tr104J);} else {down(&r104J,&tr104J);} |
319 | if(buf[3]=='J') if((buf[4]=='U')) {up(&r104J,&tr104J);} else {down(&r104J,&tr104J);} |
316 | break; |
320 | break; |
317 | case 'a': |
321 | case 'a': |
318 | if((buf[4]=='U')) {up(&r110N,&tr110N);} else {down(&r110N,&tr110N);} |
322 | if((buf[4]=='U')) {up(&r110N,&tr110N);} else {down(&r110N,&tr110N);} |
319 | break; |
323 | break; |
320 | } |
324 | } |
321 | } |
325 | } |
322 | } |
326 | } |
323 | |
327 | |
324 | } |
328 | } |
325 | } |
329 | } |
326 | } |
330 | } |
327 | |
331 | |
328 | run(103V); // Rizeni rolet za behu |
332 | run(103V); // Rizeni rolet za behu |
329 | run(104V); |
333 | run(104V); |
330 | run(104J); |
334 | run(104J); |
331 | |
335 | |
332 | switch(r110N) // Zaluzie ma specielni rizeni |
336 | switch(r110N) // Zaluzie ma specielni rizeni |
333 | { |
337 | { |
334 | case STOP: |
338 | case STOP: |
335 | OFF(R110NU); |
339 | OFF(R110NU); |
336 | OFF(R110ND); |
340 | OFF(R110ND); |
337 | break; |
341 | break; |
338 | case GO_UP: |
342 | case GO_UP: |
339 | ON(R110NU); |
343 | ON(R110NU); |
340 | OFF(R110ND); |
344 | OFF(R110ND); |
341 | if(tr110N==0) {r110N=STOP;} |
345 | if(tr110N==0) {r110N=STOP;} |
342 | break; |
346 | break; |
343 | case GO_DOWN: |
347 | case GO_DOWN: |
344 | OFF(R110NU); |
348 | OFF(R110NU); |
345 | ON(R110ND); |
349 | ON(R110ND); |
346 | if(tr110N==0) {r110N=STOP;} |
350 | if(tr110N==0) {r110N=STOP;} |
347 | break; |
351 | break; |
348 | case REVERS_UP: |
352 | case REVERS_UP: |
349 | OFF(R110NU); |
353 | OFF(R110NU); |
350 | OFF(R110ND); |
354 | OFF(R110ND); |
351 | if(tr110N==0) {r110N=GO_UP; tr110N=GO_ZALUZIE;} |
355 | if(tr110N==0) {r110N=GO_UP; tr110N=GO_ZALUZIE;} // Nahoru pouze kratce na otevreni zaluzie |
352 | break; |
356 | break; |
353 | case REVERS_DOWN: |
357 | case REVERS_DOWN: |
354 | OFF(R110NU); |
358 | OFF(R110NU); |
355 | OFF(R110ND); |
359 | OFF(R110ND); |
356 | if(tr110N==0) {r110N=GO_DOWN; tr110N=GO_ZALUZIE;} |
360 | if(tr110N==0) {r110N=GO_DOWN; tr110N=2*GO_ZALUZIE;} // Dolu jede dele, aby se najelo na koncak a zatemnilo. |
357 | break; |
361 | break; |
358 | } |
362 | } |
359 | /* |
363 | /* |
360 | switch(r110A) |
364 | switch(r110A) |
361 | { |
365 | { |
362 | case GO_UP: |
366 | case GO_UP: |
363 | printf("U"); |
367 | printf("U"); |
364 | break; |
368 | break; |
365 | case GO_DOWN: |
369 | case GO_DOWN: |
366 | printf("D"); |
370 | printf("D"); |
367 | break; |
371 | break; |
368 | case REVERS_UP: |
372 | case REVERS_UP: |
369 | printf("R"); |
373 | printf("R"); |
370 | break; |
374 | break; |
371 | case REVERS_DOWN: |
375 | case REVERS_DOWN: |
372 | printf("E"); |
376 | printf("E"); |
373 | break; |
377 | break; |
374 | case STOP: |
378 | case STOP: |
375 | printf("S"); |
379 | printf("S"); |
376 | break; |
380 | break; |
377 | } |
381 | } |
378 | */ |
382 | */ |
379 | restart_wdt(); |
383 | restart_wdt(); |
380 | } |
384 | } |
381 | } |
385 | } |