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