1 |
/* |
1 |
/* |
2 |
Ovladani domu rozvadec 2. n.p. |
2 |
Ovladani domu rozvadec 2. n.p. |
3 |
|
3 |
|
4 |
Syntaxe prikazu: |
4 |
Syntaxe prikazu: |
5 |
|
5 |
|
6 |
<Roleta/Svetlo><#patro><#mistnost><Nord/Jih/Vychod/Zapad/A/B><Up/Down> |
6 |
<Roleta/Svetlo><#patro><#mistnost><Nord/Jih/Vychod/Zapad/A/B><Up/Down> |
7 |
R2aNU - roleta, 2. n.p., mistnost 10, sever, nahoru |
7 |
R2aNU - roleta, 2. n.p., mistnost 10, sever, nahoru |
8 |
S12A - svetlo, 1. n.p., mistnost 2, prostredni |
8 |
S12A - svetlo, 1. n.p., mistnost 2, prostredni |
9 |
|
9 |
|
10 |
Rozmisteni desek: |
10 |
Rozmisteni desek: |
11 |
|
11 |
|
12 |
[CAN] |
12 |
[CAN] |
13 |
[IN J] [IN D] |
13 |
[IN J] [IN D] |
14 |
[OUT A] [CPU] |
14 |
[OUT A] [CPU] |
15 |
|
15 |
|
16 |
[OUT F] [OUT B] [OUT E] |
16 |
[OUT F] [OUT B] [OUT E] |
17 |
|
17 |
|
18 |
*/ |
18 |
*/ |
19 |
#include "main.h" |
19 |
#include "main.h" |
20 |
|
20 |
|
21 |
#case |
21 |
#case |
22 |
|
22 |
|
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 |
|
- |
|
62 |
#define OS102A PIN_E0 // t1 Svetlo chodba |
- |
|
63 |
#define OS105A PIN_E1 // t2 Svetlo kuchyne stred |
- |
|
64 |
#define OS207A PIN_E2 // t3 Svetlo klubovna |
- |
|
65 |
#define OS104A PIN_E3 // t4 Svetlo laborator |
- |
|
66 |
#define OS202A PIN_E4 // t5 Svetlo Kaklik stred |
- |
|
67 |
#define OS209A PIN_E5 // t6 Svetlo Zizala koupelna |
- |
|
68 |
#define OS203A PIN_E6 // t7 Svetlo Kaklik koupelna |
- |
|
69 |
//#define O... PIN_E7 // t8 |
- |
|
70 |
|
64 |
//#define I.... input(PIN_D0) // A |
71 |
//#define I.... input(PIN_D0) // A |
65 |
#define IS201AZ input(PIN_D1) // B Vypinac chodba 2.n.p. zapad u Kaklika |
72 |
#define IS201AZ input(PIN_D1) // B Vypinac chodba 2.n.p. zapad u Kaklika |
66 |
#define IS207AJ input(PIN_D2) // C Vypinac klubovna |
73 |
#define IS207AJ input(PIN_D2) // C Vypinac klubovna |
67 |
#define IR207VD input(PIN_D3) // D Vypinac roleta klubovna dolu |
74 |
#define IR207VD input(PIN_D3) // D Vypinac roleta klubovna dolu |
68 |
#define IR207VU input(PIN_D4) // E Vypinac roleta klubovna nahoru |
75 |
#define IR207VU input(PIN_D4) // E Vypinac roleta klubovna nahoru |
69 |
#define IS201AV input(PIN_D5) // F Vypinac chodba 2.n.p. vychod |
76 |
#define IS201AV input(PIN_D5) // F Vypinac chodba 2.n.p. vychod |
70 |
#define IS209AJ input(PIN_D6) // G Vypinac koupelna Zizala |
77 |
#define IS209AJ input(PIN_D6) // G Vypinac koupelna Zizala |
71 |
#define IS203AJ input(PIN_D7) // H Vypinac koupelna Kaklik |
78 |
#define IS203AJ input(PIN_D7) // H Vypinac koupelna Kaklik |
72 |
|
79 |
|
73 |
#define OS102A PIN_E0 // t1 Svetlo chodba |
80 |
#define IS202AN input(PIN_J0) // A Vypinac svetlo Kaklik stred u dveri na chodbu |
74 |
#define OS105A PIN_E1 //* t2 Svetlo kuchyne stred |
81 |
#define IR202ND input(PIN_J1) // B Vypinac roleta Kaklik dolu u dveri |
75 |
#define OS207A PIN_E2 // t3 Svetlo klubovna |
82 |
#define IR202NU input(PIN_J2) // C Vypinac roleta Kaklik nahoru u dveri |
76 |
#define OS104A PIN_E3 //* t4 Svetlo laborator |
83 |
#define IS205A input(PIN_J3) // D Vypinac svetlo puda |
77 |
//#define O... PIN_E4 // t5 |
84 |
#define IS204AJ input(PIN_J4) // E Vypinac svetlo radiomistnost u dveri na chodbu |
78 |
#define OS209A PIN_E5 // t6 Svetlo Zizala koupelna |
85 |
#define IR204ZD input(PIN_J5) // F Vypinac roleta radiomistnost dolu |
79 |
#define OS203A PIN_E6 // t7 Svetlo Kaklik koupelna |
86 |
#define IR204ZU input(PIN_J6) // G Vypinac roleta radiomistnost nahoru |
80 |
//#define O... PIN_E7 // t8 |
87 |
//#define I.... input(PIN_J7) // H |
81 |
|
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 |
94 |
|
108 |
|
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 |
117 |
{ |
133 |
{ |
118 |
switch (*status) |
134 |
switch (*status) |
119 |
{ |
135 |
{ |
120 |
case STOP: |
136 |
case STOP: |
121 |
case GO_DOWN: |
137 |
case GO_DOWN: |
122 |
*status=REVERS_UP; |
138 |
*status=REVERS_UP; |
123 |
*timer=REVERS; |
139 |
*timer=REVERS; |
124 |
break; |
140 |
break; |
125 |
case REVERS_UP: |
141 |
case REVERS_UP: |
126 |
case GO_UP: |
142 |
case GO_UP: |
127 |
*status=STOP; |
143 |
*status=STOP; |
128 |
*timer=0; |
144 |
*timer=0; |
129 |
break; |
145 |
break; |
130 |
} |
146 |
} |
131 |
} |
147 |
} |
132 |
|
148 |
|
133 |
void down(state *status, int8 *timer) // Zmena stavu rolety smer dolu |
149 |
void down(state *status, int8 *timer) // Zmena stavu rolety smer dolu |
134 |
{ |
150 |
{ |
135 |
switch (*status) |
151 |
switch (*status) |
136 |
{ |
152 |
{ |
137 |
case STOP: |
153 |
case STOP: |
138 |
case GO_UP: |
154 |
case GO_UP: |
139 |
*status=REVERS_DOWN; |
155 |
*status=REVERS_DOWN; |
140 |
*timer=REVERS; |
156 |
*timer=REVERS; |
141 |
break; |
157 |
break; |
142 |
case REVERS_DOWN: |
158 |
case REVERS_DOWN: |
143 |
case GO_DOWN: |
159 |
case GO_DOWN: |
144 |
*status=STOP; |
160 |
*status=STOP; |
145 |
*timer=0; |
161 |
*timer=0; |
146 |
break; |
162 |
break; |
147 |
} |
163 |
} |
148 |
} |
164 |
} |
149 |
|
165 |
|
150 |
#define run(x) { \ |
166 |
#define run(x) { \ |
151 |
switch(r##x) \ |
167 |
switch(r##x) \ |
152 |
{ \ |
168 |
{ \ |
153 |
case STOP: \ |
169 |
case STOP: \ |
154 |
OFF(OR##x##U); \ |
170 |
OFF(OR##x##U); \ |
155 |
OFF(OR##x##D); \ |
171 |
OFF(OR##x##D); \ |
156 |
break; \ |
172 |
break; \ |
157 |
case GO_UP: \ |
173 |
case GO_UP: \ |
158 |
OFF(OR##x##D); \ |
174 |
OFF(OR##x##D); \ |
159 |
ON(OR##x##U); \ |
175 |
ON(OR##x##U); \ |
160 |
if(tr##x==0) {r##x=STOP;} \ |
176 |
if(tr##x==0) {r##x=STOP;} \ |
161 |
break; \ |
177 |
break; \ |
162 |
case GO_DOWN: \ |
178 |
case GO_DOWN: \ |
163 |
OFF(OR##x##U); \ |
179 |
OFF(OR##x##U); \ |
164 |
ON(OR##x##D); \ |
180 |
ON(OR##x##D); \ |
165 |
if(tr##x==0) {r##x=STOP;} \ |
181 |
if(tr##x==0) {r##x=STOP;} \ |
166 |
break; \ |
182 |
break; \ |
167 |
case REVERS_UP: \ |
183 |
case REVERS_UP: \ |
168 |
OFF(OR##x##U); \ |
184 |
OFF(OR##x##U); \ |
169 |
OFF(OR##x##D); \ |
185 |
OFF(OR##x##D); \ |
170 |
if(tr##x==0) {r##x=GO_UP; tr##x=GO;} \ |
186 |
if(tr##x==0) {r##x=GO_UP; tr##x=GO;} \ |
171 |
break; \ |
187 |
break; \ |
172 |
case REVERS_DOWN: \ |
188 |
case REVERS_DOWN: \ |
173 |
OFF(OR##x##U); \ |
189 |
OFF(OR##x##U); \ |
174 |
OFF(OR##x##D); \ |
190 |
OFF(OR##x##D); \ |
175 |
if(tr##x==0) {r##x=GO_DOWN; tr##x=GO;} \ |
191 |
if(tr##x==0) {r##x=GO_DOWN; tr##x=GO;} \ |
176 |
break; \ |
192 |
break; \ |
177 |
} \ |
193 |
} \ |
178 |
} |
194 |
} |
179 |
|
195 |
|
180 |
void main() |
196 |
void main() |
181 |
{ |
197 |
{ |
182 |
char buf[10]; |
198 |
char buf[10]; |
183 |
|
199 |
|
184 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
200 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
185 |
setup_adc(ADC_CLOCK_DIV_2); |
201 |
setup_adc(ADC_CLOCK_DIV_2); |
186 |
setup_psp(PSP_DISABLED); |
202 |
setup_psp(PSP_DISABLED); |
187 |
setup_spi(SPI_SS_DISABLED); |
203 |
setup_spi(SPI_SS_DISABLED); |
188 |
setup_wdt(WDT_OFF); |
204 |
setup_wdt(WDT_OFF); |
189 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
205 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
190 |
setup_timer_1(T1_DISABLED); |
206 |
setup_timer_1(T1_DISABLED); |
191 |
setup_timer_2(T2_DISABLED,0,1); |
207 |
setup_timer_2(T2_DISABLED,0,1); |
192 |
setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
208 |
setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
193 |
setup_ccp1(CCP_OFF); |
209 |
setup_ccp1(CCP_OFF); |
194 |
setup_comparator(NC_NC_NC_NC); |
210 |
setup_comparator(NC_NC_NC_NC); |
195 |
setup_vref(FALSE); |
211 |
setup_vref(FALSE); |
196 |
|
212 |
|
197 |
output_a(0xFF); // Vsechno zhasni a zastav |
213 |
output_a(0xFF); // Vsechno zhasni a zastav |
198 |
output_b(0xFF); |
214 |
output_b(0xFF); |
199 |
output_f(0xFF); |
215 |
output_f(0xFF); |
200 |
output_e(0xFF); |
216 |
output_e(0xFF); |
201 |
|
217 |
|
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++) |
217 |
{ |
237 |
{ |
218 |
output_low(LED1); // Indikace restartu (pockame na nabiti kondenzatoru ve vstupnich obvodech) |
238 |
output_low(LED1); // Indikace restartu (pockame na nabiti kondenzatoru ve vstupnich obvodech) |
219 |
delay_ms(100); |
239 |
delay_ms(100); |
220 |
output_high(LED1); |
240 |
output_high(LED1); |
221 |
delay_ms(100); |
241 |
delay_ms(100); |
222 |
restart_wdt(); |
242 |
restart_wdt(); |
223 |
} |
243 |
} |
224 |
} |
244 |
} |
225 |
|
245 |
|
226 |
s201AV=IS201AV; // Precteme vychozi stav vypinacu |
246 |
s201AV=IS201AV; // Precteme vychozi stav vypinacu |
227 |
s201AZ=IS201AZ; |
247 |
s201AZ=IS201AZ; |
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); |
238 |
|
265 |
|
239 |
while(TRUE) |
266 |
while(TRUE) |
240 |
{ |
267 |
{ |
241 |
|
268 |
|
242 |
if(kbhit()) // Chce po nas nekdo neco? |
269 |
if(kbhit()) // Chce po nas nekdo neco? |
243 |
{ |
270 |
{ |
244 |
buf[0]=getc(); |
271 |
buf[0]=getc(); |
245 |
if((buf[0]=='S')||(buf[0]=='R')) // Jinym znakem nesmi zacinat prikaz |
272 |
if((buf[0]=='S')||(buf[0]=='R')) // Jinym znakem nesmi zacinat prikaz |
246 |
{ |
273 |
{ |
247 |
int8 n=0; // Ukazatel do prijimaciho bufferu |
274 |
int8 n=0; // Ukazatel do prijimaciho bufferu |
248 |
timer=RECEIVE; // Timeout pro prijem znaku |
275 |
timer=RECEIVE; // Timeout pro prijem znaku |
249 |
|
276 |
|
250 |
do |
277 |
do |
251 |
{ |
278 |
{ |
252 |
if(kbhit()) // Je dalsi znak? |
279 |
if(kbhit()) // Je dalsi znak? |
253 |
{ |
280 |
{ |
254 |
n++; |
281 |
n++; |
255 |
buf[n]=getc(); |
282 |
buf[n]=getc(); |
256 |
} |
283 |
} |
257 |
} while ((buf[n]!='\r')&&(timer>0)&&(n<7)); |
284 |
} while ((buf[n]!='\r')&&(timer>0)&&(n<7)); |
258 |
|
285 |
|
259 |
if (timer==0) { CREN=0; CREN=1; } // Reinitialise USART |
286 |
if (timer==0) { CREN=0; CREN=1; } // Reinitialise USART |
260 |
|
287 |
|
261 |
output_toggle(LED1); // Ukonceni prijimani prikazu |
288 |
output_toggle(LED1); // Ukonceni prijimani prikazu |
262 |
|
289 |
|
263 |
if((timer>0)) |
290 |
if((timer>0)) |
264 |
{ |
291 |
{ |
265 |
|
292 |
|
266 |
if((buf[0]=='S')&&(n>=4)) // Zmena stavu svetla |
293 |
if((buf[0]=='S')&&(n>=4)) // Zmena stavu svetla |
267 |
{ |
294 |
{ |
268 |
if(buf[1]=='1') |
295 |
if(buf[1]=='1') |
269 |
{ |
296 |
{ |
270 |
switch(buf[2]) |
297 |
switch(buf[2]) |
271 |
{ |
298 |
{ |
272 |
case '2': |
299 |
case '2': |
273 |
output_toggle(OS102A); |
300 |
output_toggle(OS102A); |
274 |
break; |
301 |
break; |
275 |
case '3': |
302 |
case '3': |
276 |
output_toggle(OS103J); |
303 |
output_toggle(OS103J); |
277 |
break; |
304 |
break; |
278 |
case '4': |
305 |
case '4': |
279 |
output_toggle(OS104A); |
306 |
output_toggle(OS104A); |
280 |
break; |
307 |
break; |
281 |
case '5': |
308 |
case '5': |
282 |
if(buf[3]=='A') {output_toggle(OS105A);} |
309 |
if(buf[3]=='A') {output_toggle(OS105A);} |
283 |
if(buf[3]=='Z') {output_toggle(OS105Z);} |
310 |
if(buf[3]=='Z') {output_toggle(OS105Z);} |
284 |
break; |
311 |
break; |
285 |
case '6': |
312 |
case '6': |
286 |
output_toggle(OS106A); |
313 |
output_toggle(OS106A); |
287 |
break; |
314 |
break; |
288 |
case '7': |
315 |
case '7': |
289 |
output_toggle(OS107A); |
316 |
output_toggle(OS107A); |
290 |
break; |
317 |
break; |
291 |
case '8': |
318 |
case '8': |
292 |
// output_toggle(OS108A); |
319 |
// output_toggle(OS108A); |
293 |
break; |
320 |
break; |
294 |
case '9': |
321 |
case '9': |
295 |
output_toggle(OS109A); |
322 |
output_toggle(OS109A); |
296 |
break; |
323 |
break; |
297 |
case 'a': |
324 |
case 'a': |
298 |
// output_toggle(OS110J); |
325 |
// output_toggle(OS110J); |
299 |
output_toggle(OS110N); |
326 |
output_toggle(OS110N); |
300 |
break; |
327 |
break; |
301 |
} |
328 |
} |
302 |
} |
329 |
} |
303 |
} |
330 |
} |
304 |
|
331 |
|
305 |
if((buf[0]=='R')&&(n>=5)) // Zmena stavu rolety |
332 |
if((buf[0]=='R')&&(n>=5)) // Zmena stavu rolety |
306 |
{ |
333 |
{ |
307 |
if(buf[1]=='1') |
334 |
if(buf[1]=='1') |
308 |
{ |
335 |
{ |
309 |
switch(buf[2]) |
336 |
switch(buf[2]) |
310 |
{ |
337 |
{ |
311 |
case '3': |
338 |
case '3': |
312 |
if(buf[4]=='U') {up(&r103V,&tr103V);} else {down(&r103V,&tr103V);} |
339 |
if(buf[4]=='U') {up(&r103V,&tr103V);} else {down(&r103V,&tr103V);} |
313 |
break; |
340 |
break; |
314 |
case '4': |
341 |
case '4': |
315 |
if(buf[3]=='V') if((buf[4]=='U')) {up(&r104V,&tr104V);} else {down(&r104V,&tr104V);} |
342 |
if(buf[3]=='V') if((buf[4]=='U')) {up(&r104V,&tr104V);} else {down(&r104V,&tr104V);} |
316 |
if(buf[3]=='J') if((buf[4]=='U')) {up(&r104J,&tr104J);} else {down(&r104J,&tr104J);} |
343 |
if(buf[3]=='J') if((buf[4]=='U')) {up(&r104J,&tr104J);} else {down(&r104J,&tr104J);} |
317 |
break; |
344 |
break; |
318 |
case 'a': |
345 |
case 'a': |
319 |
if((buf[4]=='U')) {up(&r110N,&tr110N);} else {down(&r110N,&tr110N);} |
346 |
if((buf[4]=='U')) {up(&r110N,&tr110N);} else {down(&r110N,&tr110N);} |
320 |
break; |
347 |
break; |
321 |
} |
348 |
} |
322 |
} |
349 |
} |
323 |
} |
350 |
} |
324 |
|
351 |
|
325 |
} |
352 |
} |
326 |
} |
353 |
} |
327 |
} |
354 |
} |
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); |
338 |
OFF(OR110ND); |
367 |
OFF(OR110ND); |
339 |
break; |
368 |
break; |
340 |
case GO_UP: |
369 |
case GO_UP: |
341 |
OFF(OR110ND); |
370 |
OFF(OR110ND); |
342 |
ON(OR110NU); |
371 |
ON(OR110NU); |
343 |
if(tr110N==0) {r110N=STOP;} |
372 |
if(tr110N==0) {r110N=STOP;} |
344 |
break; |
373 |
break; |
345 |
case GO_DOWN: |
374 |
case GO_DOWN: |
346 |
OFF(OR110NU); |
375 |
OFF(OR110NU); |
347 |
ON(OR110ND); |
376 |
ON(OR110ND); |
348 |
if(tr110N==0) {r110N=STOP;} |
377 |
if(tr110N==0) {r110N=STOP;} |
349 |
break; |
378 |
break; |
350 |
case REVERS_UP: |
379 |
case REVERS_UP: |
351 |
OFF(OR110NU); |
380 |
OFF(OR110NU); |
352 |
OFF(OR110ND); |
381 |
OFF(OR110ND); |
353 |
if(tr110N==0) {r110N=GO_UP; tr110N=GO_ZALUZIE;} // Nahoru pouze kratce na otevreni zaluzie |
382 |
if(tr110N==0) {r110N=GO_UP; tr110N=GO_ZALUZIE;} // Nahoru pouze kratce na otevreni zaluzie |
354 |
break; |
383 |
break; |
355 |
case REVERS_DOWN: |
384 |
case REVERS_DOWN: |
356 |
OFF(OR110NU); |
385 |
OFF(OR110NU); |
357 |
OFF(OR110ND); |
386 |
OFF(OR110ND); |
358 |
if(tr110N==0) {r110N=GO_DOWN; tr110N=GO_ZALUZIE;} // Dolu take kratce pouze na zaklopeni zaluzie |
387 |
if(tr110N==0) {r110N=GO_DOWN; tr110N=GO_ZALUZIE;} // Dolu take kratce pouze na zaklopeni zaluzie |
359 |
break; |
388 |
break; |
360 |
} |
389 |
} |
361 |
|
390 |
|
362 |
// mistni vypinace z 2. n.p. |
391 |
// mistni vypinace z 2. n.p. |
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 |
} |