145,7 → 145,7 |
if(timer_revers>0) timer_revers--; |
if(timer_start>0) timer_start--; |
if(timer_run_zaluzie>0) timer_run_zaluzie--; |
//!!!output_toggle(LED2); |
output_toggle(LED2); |
} |
|
void stop_all() // Zastav vsechny rolety |
152,9 → 152,9 |
{ |
int8 n; |
|
for(n=0; n<18; n++) rol[n]=STOP; |
output_a(0xFF); |
output_f(0xFF); |
for(n=0; n<18; n++) rol[n]=STOP; |
} |
|
void run_all() // Spust rolety |
182,11 → 182,26 |
} |
} |
|
void stop(int8 roleta) // Spust konkretni roletu |
{ |
switch (roleta) |
{ |
case R103V: OFF(OR103V); break; |
case R110N: OFF(OR110N); break; |
case R104V: OFF(OR104V); break; |
case R104J: OFF(OR104J); break; |
case R207V: OFF(OR207V); break; |
case R202J: OFF(OR202J); break; |
case R204Z: OFF(OR204Z); break; |
} |
} |
|
void up(int8 roleta) // Pozadavek, aby roleta jela nahoru |
{ |
if (rol[roleta]==RUN) |
{ |
rol[roleta]=STOP; // Roleta jela, tak zastav |
stop(roleta); |
} |
else |
{ |
198,7 → 213,7 |
} |
if (relay==RUN_UP) |
{ |
run(R207V); // Jede se spravnym smerem, tak jenom pust roletu |
run(roleta); // Jede se spravnym smerem, tak jenom pust roletu |
} |
|
rol[roleta]=RUN; // Roleta stala, tak ji pust |
212,6 → 227,7 |
if (rol[roleta]==RUN) |
{ |
rol[roleta]=STOP; // Roleta jela, tak zastav |
stop(roleta); |
} |
else |
{ |
223,7 → 239,7 |
} |
if (relay==RUN_DOWN) |
{ |
run(R207V); // Jede se spravnym smerem, tak jenom pust roletu |
run(roleta); // Jede se spravnym smerem, tak jenom pust roletu |
} |
|
rol[roleta]=RUN; // Roleta stala, tak ji pust |
300,7 → 316,7 |
timer_run_zaluzie=0; |
zakmity=0; |
|
enable_interrupts(INT_TIMER0); |
enable_interrupts(INT_TIMER0); // Spust casovani |
enable_interrupts(GLOBAL); |
|
CREN=0; CREN=1; // Reinitialise USART |
379,14 → 395,46 |
switch(buf[2]) |
{ |
case '3': |
//!!! if(buf[4]=='U') {up(&r103V,&tr103V);} else {down(&r103V,&tr103V);} |
if(buf[4]=='U') {up(R103V);} else {down(R103V);} |
break; |
case '4': |
//!!! if(buf[3]=='V') if((buf[4]=='U')) |
//!!! if(buf[3]=='J') if((buf[4]=='U')) {up(&r104J,&tr104J);} else {down(&r104J,&tr104J);} |
if(buf[3]=='V') if((buf[4]=='U')) {up(R104V);} else {down(R104V);} |
if(buf[3]=='J') if((buf[4]=='U')) {up(R104J);} else {down(R104J);} |
break; |
case 'a': |
//!!! if((buf[4]=='U')) {up(&r110N,&tr110N);} else {down(&r110N,&tr110N);} |
if((buf[4]=='U')) |
{//up(R110N); |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
{ |
relay=REVERS_UP; // Reverzuj |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
stop_all(); // Vsechno zastav |
} |
if (relay==RUN_UP) |
{ |
run(R110N); // Jede se spravnym smerem, tak jenom pust roletu |
} |
|
rol[R110N]=RUN; // Roleta stala, tak ji pust |
timer_run=T_GO; // Natahni bezpecnostni casovac |
} |
else |
{//down(R110N); |
if ((relay==UP)||(relay==RUN_UP)||(relay==RUN_UP_WAITING)) // Rele je prepnuto na druhou stranu! |
{ |
relay=REVERS_DOWN; // Reverzuj |
timer_revers=T_REVERS; // Natahni casovac na vybiti kondenzatoru a reverz motoru |
stop_all(); // Vsechno zastav |
} |
if (relay==RUN_DOWN) |
{ |
run(R110N); // Jede se spravnym smerem, tak jenom pust roletu |
} |
|
rol[R110N]=RUN; // Roleta stala, tak ji pust |
timer_run=T_GO; // Natahni bezpecnostni casovac |
} |
timer_run_zaluzie=T_GO_ZALUZIE; |
break; |
} |
} |
396,8 → 444,6 |
} |
} |
|
//!!! switch(r110N) // Zaluzie ma specielni rizeni |
|
// mistni vypinace z 2. n.p. |
if (0==zakmity) |
{ |
410,59 → 456,6 |
if(s204AJ!=IS204AJ) {s204AJ=IS204AJ; output_toggle(OS204A); zakmity=ZAKMIT;} |
if(s202AN!=IS202AN) {s202AN=IS202AN; output_toggle(OS202A); zakmity=ZAKMIT;} |
|
if(r207VU!=IR207VU) // Zmenil se stav vypinace |
{ |
r207VU=IR207VU; // Poznamenej soucasny stav vypinace |
|
if (rol[R207V]==RUN) |
{ |
rol[R207V]=STOP; // Roleta jela, tak zastav |
OFF(OR207V); |
} |
else |
{ |
if ((relay==DOWN)||(relay==RUN_DOWN)) // Rele je prepnuto na druhou stranu! |
{ |
relay=REVERS_UP; // Reverzuj |
timer_revers=T_REVERS; |
stop_all(); // Vsechno zastav |
} |
if (relay==RUN_UP) |
{ |
ON(OR207V); // Jede se spravnym smerem, tak jenom pust roletu |
} |
rol[R207V]=RUN; // Poznamenej, ze se jede, a natahni bezpecnostni casovac |
timer_run=T_GO; |
} |
zakmity=ZAKMIT; |
} |
if(r207VD!=IR207VD) |
{ |
r207VD=IR207VD; |
|
if (rol[R207V]==RUN) |
{ |
rol[R207V]=STOP; |
OFF(OR207V); |
} |
else |
{ |
if ((relay==UP)||(relay==RUN_UP)||(relay==RUN_UP_WAITING)) |
{ |
relay=REVERS_DOWN; |
timer_revers=T_REVERS; |
stop_all(); |
} |
if (relay==RUN_DOWN) |
{ |
ON(OR207V); |
} |
rol[R207V]=RUN; |
timer_run=T_GO; |
} |
zakmity=ZAKMIT; |
} |
|
if(r207VU!=IR207VU) {r207VU=IR207VU; up(R207V); zakmity=ZAKMIT;} |
if(r207VD!=IR207VD) {r207VD=IR207VD; down(R207V); zakmity=ZAKMIT;} |
if(r202NU!=IR202NU) {r202NU=IR202NU; up(R202J); zakmity=ZAKMIT;} |
527,5 → 520,8 |
} |
break; |
} |
|
// Zaluzie ma kratsi beh |
if ((timer_run_zaluzie==0)&&(rol[R110N]==RUN)) {rol[R110N]=STOP; OFF(OR110N);} |
} |
} |