Line 17... |
Line 17... |
17 |
|
17 |
|
18 |
*/ |
18 |
*/ |
19 |
#include "main.h" |
19 |
#include "main.h" |
20 |
|
20 |
|
21 |
#case |
21 |
#case |
- |
|
22 |
#use fast_io(A) // Aby se neztracely znaky pri cteni prikazu |
- |
|
23 |
#use fast_io(B) |
- |
|
24 |
#use fast_io(E) |
- |
|
25 |
#use fast_io(F) |
- |
|
26 |
#use fast_io(D) |
- |
|
27 |
#use fast_io(J) |
22 |
|
28 |
|
23 |
#define REVERS 3 // 2*256 ms = 0,75 s |
29 |
#define REVERS 3 // 3*256 ms = 0,75 s |
24 |
#define GO 117 // 117*256 ms = 30 s |
30 |
#define GO 117 // 117*256 ms = 30 s |
25 |
#define GO_ZALUZIE 6 // cca 1,5 s |
31 |
#define GO_ZALUZIE 6 // cca 1,5 s |
26 |
#define RECEIVE 10 // cca 2,6 s |
32 |
#define RECEIVE 10 // cca 2,6 s |
- |
|
33 |
#define ZAKMIT 250 // pocet pruchodu hlavni smyckou pred opetovnou detekci prepnuti vypinace |
27 |
|
34 |
|
28 |
#define OR110NU PIN_A0 // t1 Zaluzie koupelna dole |
35 |
#define OR110NU PIN_A0 // t1 Zaluzie koupelna dole |
29 |
#define OR110ND PIN_A1 // t2 |
36 |
#define OR110ND PIN_A1 // t2 |
30 |
#define OR207VU PIN_A2 // t3 Roleta klubovna |
37 |
#define OR207VU PIN_A2 // t3 Roleta klubovna |
31 |
#define OR207VD PIN_A3 // t4 |
38 |
#define OR207VD PIN_A3 // t4 |
Line 48... |
Line 55... |
48 |
//#define PIN_C4 31764 |
55 |
//#define PIN_C4 31764 |
49 |
//#define PIN_C5 31765 |
56 |
//#define PIN_C5 31765 |
50 |
//#define PIN_C6 31766 //TX |
57 |
//#define PIN_C6 31766 //TX |
51 |
//#define PIN_C7 31767 //RX |
58 |
//#define PIN_C7 31767 //RX |
52 |
|
59 |
|
53 |
#define OR104VU PIN_F0 // t1 Roleta laborator vychod |
- |
|
54 |
#define OR104VD PIN_F1 // t2 |
- |
|
55 |
#define OR202JU PIN_F2 // t3 Roleta Kaklik |
- |
|
56 |
#define OR202JD PIN_F3 // t4 |
- |
|
57 |
#define OR204ZU PIN_F4 // t5 Roleta radiomistnost |
- |
|
58 |
#define OR204ZD PIN_F5 // t6 |
- |
|
59 |
//#define O... PIN_F6 // t7 |
- |
|
60 |
//#define O... PIN_F7 // t8 |
- |
|
61 |
|
- |
|
62 |
#define OS102A PIN_E0 // t1 Svetlo chodba |
60 |
#define OS102A PIN_E0 // t1 Svetlo chodba |
63 |
#define OS105A PIN_E1 // t2 Svetlo kuchyne stred |
61 |
#define OS105A PIN_E1 // t2 Svetlo kuchyne stred |
64 |
#define OS207A PIN_E2 // t3 Svetlo klubovna |
62 |
#define OS207A PIN_E2 // t3 Svetlo klubovna |
65 |
#define OS104A PIN_E3 // t4 Svetlo laborator |
63 |
#define OS104A PIN_E3 // t4 Svetlo laborator |
66 |
#define OS202A PIN_E4 // t5 Svetlo Kaklik stred |
64 |
#define OS202A PIN_E4 // t5 Svetlo Kaklik stred |
67 |
#define OS209A PIN_E5 // t6 Svetlo Zizala koupelna |
65 |
#define OS209A PIN_E5 // t6 Svetlo Zizala koupelna |
68 |
#define OS203A PIN_E6 // t7 Svetlo Kaklik koupelna |
66 |
#define OS203A PIN_E6 // t7 Svetlo Kaklik koupelna |
69 |
//#define O... PIN_E7 // t8 |
67 |
//#define O... PIN_E7 // t8 |
70 |
|
68 |
|
- |
|
69 |
#define OR104VU PIN_F0 // t1 Roleta laborator vychod |
- |
|
70 |
#define OR104VD PIN_F1 // t2 |
- |
|
71 |
#define OR202JU PIN_F2 // t3 Roleta Kaklik |
- |
|
72 |
#define OR202JD PIN_F3 // t4 |
- |
|
73 |
#define OR204ZU PIN_F4 // t5 Roleta radiomistnost |
- |
|
74 |
#define OR204ZD PIN_F5 // t6 |
- |
|
75 |
//#define O... PIN_F6 // t7 |
- |
|
76 |
//#define O... PIN_F7 // t8 |
- |
|
77 |
|
71 |
//#define I.... input(PIN_D0) // A |
78 |
//#define I.... input(PIN_D0) // A |
72 |
#define IS201AZ input(PIN_D1) // B Vypinac chodba 2.n.p. zapad u Kaklika |
79 |
#define IS201AZ input(PIN_D1) // B Vypinac chodba 2.n.p. zapad u Kaklika |
73 |
#define IS207AJ input(PIN_D2) // C Vypinac klubovna |
80 |
#define IS207AJ input(PIN_D2) // C Vypinac klubovna |
74 |
#define IR207VD input(PIN_D3) // D Vypinac roleta klubovna dolu |
81 |
#define IR207VD input(PIN_D3) // D Vypinac roleta klubovna dolu |
75 |
#define IR207VU input(PIN_D4) // E Vypinac roleta klubovna nahoru |
82 |
#define IR207VU input(PIN_D4) // E Vypinac roleta klubovna nahoru |
Line 193... |
Line 200... |
193 |
} \ |
200 |
} \ |
194 |
} |
201 |
} |
195 |
|
202 |
|
196 |
void main() |
203 |
void main() |
197 |
{ |
204 |
{ |
198 |
char buf[10]; |
205 |
char buf[10]; // Buffer pro prijem prikazu |
- |
|
206 |
unsigned int8 zakmity=0; // Osetreni zakmitu vypinacu |
199 |
|
207 |
|
200 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
208 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
201 |
setup_adc(ADC_CLOCK_DIV_2); |
209 |
setup_adc(ADC_CLOCK_DIV_2); |
202 |
setup_psp(PSP_DISABLED); |
210 |
setup_psp(PSP_DISABLED); |
203 |
setup_spi(SPI_SS_DISABLED); |
211 |
setup_spi(SPI_SS_DISABLED); |
204 |
setup_wdt(WDT_OFF); |
212 |
setup_wdt(WDT_OFF); |
205 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
213 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8); |
206 |
setup_timer_1(T1_DISABLED); |
214 |
setup_timer_1(T1_DISABLED); |
207 |
setup_timer_2(T2_DISABLED,0,1); |
215 |
setup_timer_2(T2_DISABLED,0,1); |
208 |
setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
216 |
setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
209 |
setup_ccp1(CCP_OFF); |
217 |
setup_ccp1(CCP_OFF); |
210 |
setup_comparator(NC_NC_NC_NC); |
218 |
setup_comparator(NC_NC_NC_NC); |
211 |
setup_vref(FALSE); |
219 |
setup_vref(FALSE); |
- |
|
220 |
|
- |
|
221 |
set_tris_a(0); // Vystupy |
- |
|
222 |
set_tris_b(0); |
- |
|
223 |
set_tris_e(0); |
- |
|
224 |
set_tris_f(0); |
- |
|
225 |
set_tris_d(0xFF); // Vstupy |
- |
|
226 |
set_tris_j(0xFF); |
212 |
|
227 |
|
213 |
output_a(0xFF); // Vsechno zhasni a zastav |
228 |
output_a(0xFF); // Vsechno zhasni a zastav |
214 |
output_b(0xFF); |
229 |
output_b(0xFF); |
215 |
output_f(0xFF); |
230 |
output_f(0xFF); |
216 |
output_e(0xFF); |
231 |
output_e(0xFF); |
Line 263... |
Line 278... |
263 |
enable_interrupts(INT_TIMER0); |
278 |
enable_interrupts(INT_TIMER0); |
264 |
enable_interrupts(GLOBAL); |
279 |
enable_interrupts(GLOBAL); |
265 |
|
280 |
|
266 |
while(TRUE) |
281 |
while(TRUE) |
267 |
{ |
282 |
{ |
- |
|
283 |
restart_wdt(); |
268 |
|
284 |
|
269 |
if(kbhit()) // Chce po nas nekdo neco? |
285 |
if(kbhit()) // Chce po nas nekdo neco? |
270 |
{ |
286 |
{ |
271 |
buf[0]=getc(); |
287 |
buf[0]=getc(); |
272 |
if((buf[0]=='S')||(buf[0]=='R')) // Jinym znakem nesmi zacinat prikaz |
288 |
if((buf[0]=='S')||(buf[0]=='R')) // Jinym znakem nesmi zacinat prikaz |
Line 387... |
Line 403... |
387 |
if(tr110N==0) {r110N=GO_DOWN; tr110N=GO_ZALUZIE;} // Dolu take kratce pouze na zaklopeni zaluzie |
403 |
if(tr110N==0) {r110N=GO_DOWN; tr110N=GO_ZALUZIE;} // Dolu take kratce pouze na zaklopeni zaluzie |
388 |
break; |
404 |
break; |
389 |
} |
405 |
} |
390 |
|
406 |
|
391 |
// mistni vypinace z 2. n.p. |
407 |
// mistni vypinace z 2. n.p. |
- |
|
408 |
if (0==zakmity) |
- |
|
409 |
{ |
392 |
if(s201AV!=IS201AV) {s201AV=IS201AV; output_toggle(OS102A); delay_ms(100); continue;} |
410 |
if(s201AV!=IS201AV) {s201AV=IS201AV; output_toggle(OS102A); zakmity=ZAKMIT;} |
393 |
if(s201AZ!=IS201AZ) {s201AZ=IS201AZ; output_toggle(OS102A); delay_ms(100); continue;} |
411 |
if(s201AZ!=IS201AZ) {s201AZ=IS201AZ; output_toggle(OS102A); zakmity=ZAKMIT;} |
394 |
if(s207AJ!=IS207AJ) {s207AJ=IS207AJ; output_toggle(OS207A); delay_ms(100); continue;} |
412 |
if(s207AJ!=IS207AJ) {s207AJ=IS207AJ; output_toggle(OS207A); zakmity=ZAKMIT;} |
395 |
if(s203AJ!=IS203AJ) {s203AJ=IS203AJ; output_toggle(OS203A); delay_ms(100); continue;} |
413 |
if(s203AJ!=IS203AJ) {s203AJ=IS203AJ; output_toggle(OS203A); zakmity=ZAKMIT;} |
396 |
if(s209AJ!=IS209AJ) {s209AJ=IS209AJ; output_toggle(OS209A); delay_ms(100); continue;} |
414 |
if(s209AJ!=IS209AJ) {s209AJ=IS209AJ; output_toggle(OS209A); zakmity=ZAKMIT;} |
397 |
if(s205A!=IS205A) {s205A=IS205A; output_toggle(OS205A); delay_ms(100); continue;} |
415 |
if(s205A!=IS205A) {s205A=IS205A; output_toggle(OS205A); zakmity=ZAKMIT;} |
398 |
if(s204AJ!=IS204AJ) {s204AJ=IS204AJ; output_toggle(OS204A); delay_ms(100); continue;} |
416 |
if(s204AJ!=IS204AJ) {s204AJ=IS204AJ; output_toggle(OS204A); zakmity=ZAKMIT;} |
399 |
if(s202AN!=IS202AN) {s202AN=IS202AN; output_toggle(OS202A); delay_ms(100); continue;} |
417 |
if(s202AN!=IS202AN) {s202AN=IS202AN; output_toggle(OS202A); zakmity=ZAKMIT;} |
400 |
|
418 |
|
401 |
if(r207VU!=IR207VU) {r207VU=IR207VU; up(&r207V,&tr207V); delay_ms(100); continue;} |
419 |
if(r207VU!=IR207VU) {r207VU=IR207VU; up(&r207V,&tr207V); zakmity=ZAKMIT;} |
402 |
if(r207VD!=IR207VD) {r207VD=IR207VD; down(&r207V,&tr207V); delay_ms(100); continue;} |
420 |
if(r207VD!=IR207VD) {r207VD=IR207VD; down(&r207V,&tr207V); zakmity=ZAKMIT;} |
403 |
if(r202NU!=IR202NU) {r202NU=IR202NU; up(&r202J,&tr202J); delay_ms(100); continue;} |
421 |
if(r202NU!=IR202NU) {r202NU=IR202NU; up(&r202J,&tr202J); zakmity=ZAKMIT;} |
404 |
if(r202ND!=IR202ND) {r202ND=IR202ND; down(&r202J,&tr202J); delay_ms(100); continue;} |
422 |
if(r202ND!=IR202ND) {r202ND=IR202ND; down(&r202J,&tr202J); zakmity=ZAKMIT;} |
405 |
if(r204ZU!=IR204ZU) {r204ZU=IR204ZU; up(&r204Z,&tr204Z); delay_ms(100); continue;} |
423 |
if(r204ZU!=IR204ZU) {r204ZU=IR204ZU; up(&r204Z,&tr204Z); zakmity=ZAKMIT;} |
406 |
if(r204ZD!=IR204ZD) {r204ZD=IR204ZD; down(&r204Z,&tr204Z); delay_ms(100); continue;} |
424 |
if(r204ZD!=IR204ZD) {r204ZD=IR204ZD; down(&r204Z,&tr204Z); zakmity=ZAKMIT;} |
407 |
|
425 |
} |
408 |
restart_wdt(); |
426 |
else zakmity--; |
409 |
} |
427 |
} |
410 |
} |
428 |
} |