19,11 → 19,18 |
#include "main.h" |
|
#case |
#use fast_io(A) // Aby se neztracely znaky pri cteni prikazu |
#use fast_io(B) |
#use fast_io(E) |
#use fast_io(F) |
#use fast_io(D) |
#use fast_io(J) |
|
#define REVERS 3 // 2*256 ms = 0,75 s |
#define REVERS 3 // 3*256 ms = 0,75 s |
#define GO 117 // 117*256 ms = 30 s |
#define GO_ZALUZIE 6 // cca 1,5 s |
#define RECEIVE 10 // cca 2,6 s |
#define ZAKMIT 250 // pocet pruchodu hlavni smyckou pred opetovnou detekci prepnuti vypinace |
|
#define OR110NU PIN_A0 // t1 Zaluzie koupelna dole |
#define OR110ND PIN_A1 // t2 |
50,6 → 57,15 |
//#define PIN_C6 31766 //TX |
//#define PIN_C7 31767 //RX |
|
#define OS102A PIN_E0 // t1 Svetlo chodba |
#define OS105A PIN_E1 // t2 Svetlo kuchyne stred |
#define OS207A PIN_E2 // t3 Svetlo klubovna |
#define OS104A PIN_E3 // t4 Svetlo laborator |
#define OS202A PIN_E4 // t5 Svetlo Kaklik stred |
#define OS209A PIN_E5 // t6 Svetlo Zizala koupelna |
#define OS203A PIN_E6 // t7 Svetlo Kaklik koupelna |
//#define O... PIN_E7 // t8 |
|
#define OR104VU PIN_F0 // t1 Roleta laborator vychod |
#define OR104VD PIN_F1 // t2 |
#define OR202JU PIN_F2 // t3 Roleta Kaklik |
59,15 → 75,6 |
//#define O... PIN_F6 // t7 |
//#define O... PIN_F7 // t8 |
|
#define OS102A PIN_E0 // t1 Svetlo chodba |
#define OS105A PIN_E1 // t2 Svetlo kuchyne stred |
#define OS207A PIN_E2 // t3 Svetlo klubovna |
#define OS104A PIN_E3 // t4 Svetlo laborator |
#define OS202A PIN_E4 // t5 Svetlo Kaklik stred |
#define OS209A PIN_E5 // t6 Svetlo Zizala koupelna |
#define OS203A PIN_E6 // t7 Svetlo Kaklik koupelna |
//#define O... PIN_E7 // t8 |
|
//#define I.... input(PIN_D0) // A |
#define IS201AZ input(PIN_D1) // B Vypinac chodba 2.n.p. zapad u Kaklika |
#define IS207AJ input(PIN_D2) // C Vypinac klubovna |
195,7 → 202,8 |
|
void main() |
{ |
char buf[10]; |
char buf[10]; // Buffer pro prijem prikazu |
unsigned int8 zakmity=0; // Osetreni zakmitu vypinacu |
|
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
setup_adc(ADC_CLOCK_DIV_2); |
202,7 → 210,7 |
setup_psp(PSP_DISABLED); |
setup_spi(SPI_SS_DISABLED); |
setup_wdt(WDT_OFF); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8); |
setup_timer_1(T1_DISABLED); |
setup_timer_2(T2_DISABLED,0,1); |
setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
209,6 → 217,13 |
setup_ccp1(CCP_OFF); |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
|
set_tris_a(0); // Vystupy |
set_tris_b(0); |
set_tris_e(0); |
set_tris_f(0); |
set_tris_d(0xFF); // Vstupy |
set_tris_j(0xFF); |
|
output_a(0xFF); // Vsechno zhasni a zastav |
output_b(0xFF); |
265,6 → 280,7 |
|
while(TRUE) |
{ |
restart_wdt(); |
|
if(kbhit()) // Chce po nas nekdo neco? |
{ |
389,22 → 405,24 |
} |
|
// mistni vypinace z 2. n.p. |
if(s201AV!=IS201AV) {s201AV=IS201AV; output_toggle(OS102A); delay_ms(100); continue;} |
if(s201AZ!=IS201AZ) {s201AZ=IS201AZ; output_toggle(OS102A); delay_ms(100); continue;} |
if(s207AJ!=IS207AJ) {s207AJ=IS207AJ; output_toggle(OS207A); delay_ms(100); continue;} |
if(s203AJ!=IS203AJ) {s203AJ=IS203AJ; output_toggle(OS203A); delay_ms(100); continue;} |
if(s209AJ!=IS209AJ) {s209AJ=IS209AJ; output_toggle(OS209A); delay_ms(100); continue;} |
if(s205A!=IS205A) {s205A=IS205A; output_toggle(OS205A); delay_ms(100); continue;} |
if(s204AJ!=IS204AJ) {s204AJ=IS204AJ; output_toggle(OS204A); delay_ms(100); continue;} |
if(s202AN!=IS202AN) {s202AN=IS202AN; output_toggle(OS202A); delay_ms(100); continue;} |
|
if(r207VU!=IR207VU) {r207VU=IR207VU; up(&r207V,&tr207V); delay_ms(100); continue;} |
if(r207VD!=IR207VD) {r207VD=IR207VD; down(&r207V,&tr207V); delay_ms(100); continue;} |
if(r202NU!=IR202NU) {r202NU=IR202NU; up(&r202J,&tr202J); delay_ms(100); continue;} |
if(r202ND!=IR202ND) {r202ND=IR202ND; down(&r202J,&tr202J); delay_ms(100); continue;} |
if(r204ZU!=IR204ZU) {r204ZU=IR204ZU; up(&r204Z,&tr204Z); delay_ms(100); continue;} |
if(r204ZD!=IR204ZD) {r204ZD=IR204ZD; down(&r204Z,&tr204Z); delay_ms(100); continue;} |
|
restart_wdt(); |
if (0==zakmity) |
{ |
if(s201AV!=IS201AV) {s201AV=IS201AV; output_toggle(OS102A); zakmity=ZAKMIT;} |
if(s201AZ!=IS201AZ) {s201AZ=IS201AZ; output_toggle(OS102A); zakmity=ZAKMIT;} |
if(s207AJ!=IS207AJ) {s207AJ=IS207AJ; output_toggle(OS207A); zakmity=ZAKMIT;} |
if(s203AJ!=IS203AJ) {s203AJ=IS203AJ; output_toggle(OS203A); zakmity=ZAKMIT;} |
if(s209AJ!=IS209AJ) {s209AJ=IS209AJ; output_toggle(OS209A); zakmity=ZAKMIT;} |
if(s205A!=IS205A) {s205A=IS205A; output_toggle(OS205A); zakmity=ZAKMIT;} |
if(s204AJ!=IS204AJ) {s204AJ=IS204AJ; output_toggle(OS204A); zakmity=ZAKMIT;} |
if(s202AN!=IS202AN) {s202AN=IS202AN; output_toggle(OS202A); zakmity=ZAKMIT;} |
|
if(r207VU!=IR207VU) {r207VU=IR207VU; up(&r207V,&tr207V); zakmity=ZAKMIT;} |
if(r207VD!=IR207VD) {r207VD=IR207VD; down(&r207V,&tr207V); zakmity=ZAKMIT;} |
if(r202NU!=IR202NU) {r202NU=IR202NU; up(&r202J,&tr202J); zakmity=ZAKMIT;} |
if(r202ND!=IR202ND) {r202ND=IR202ND; down(&r202J,&tr202J); zakmity=ZAKMIT;} |
if(r204ZU!=IR204ZU) {r204ZU=IR204ZU; up(&r204Z,&tr204Z); zakmity=ZAKMIT;} |
if(r204ZD!=IR204ZD) {r204ZD=IR204ZD; down(&r204Z,&tr204Z); zakmity=ZAKMIT;} |
} |
else zakmity--; |
} |
} |