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