/Designs/dum/SW/2patra/1np/main.c
3,8 → 3,8
#case
 
#define S105A1 input(PIN_A0)
#define R105A1U input(PIN_A1)
#define R105A1D input(PIN_A2)
#define R110A1U input(PIN_A1)
#define R110A1D input(PIN_A2)
#define S104A1 input(PIN_A3)
#define R104A1U input(PIN_A4)
#define R104A1D input(PIN_A5)
89,8 → 89,8
#define LED2 PIN_J6
 
int1 s105A1;
int1 r105A1U;
int1 r105A1D;
int1 r110A1U;
int1 r110A1D;
int1 s104A1;
int1 r104A1U;
int1 r104A1D;
113,6 → 113,13
int1 s110A1;
int1 s108A1;
 
#define send(s) \
{\
printf("%s\r\n",#s);\
output_toggle(LED1);\
delay_ms(100);\
}
 
void main()
{
 
130,8 → 137,8
setup_vref(FALSE);
 
s105A1=S105A1;
r105A1U=R105A1U;
r105A1D=R105A1D;
r110A1U=R110A1U;
r110A1D=R110A1D;
s104A1=S104A1;
r104A1U=R104A1U;
r104A1D=R104A1D;
156,37 → 163,34
 
while(TRUE)
{
if(s105A1!=S105A1) {s105A1=S105A1; printf("S15A");}
if(r105A1U!=R105A1U) {r105A1U=R105A1U; printf("R15AU");}
if(r105A1D!=R105A1D) {r105A1D=R105A1D; printf("R15AD");}
if(s105A1!=S105A1) {s105A1=S105A1; send(S15A);}
if(r110A1U!=R110A1U) {r110A1U=R110A1U; send(R1aAU);}
if(r110A1D!=R110A1D) {r110A1D=R110A1D; send(R1aAD);}
if(!S105B1) {output_low(OS105B);} else {output_high(OS105B);}
if(!S105C1) {output_low(OS105C);} else {output_high(OS105C);}
if(s105D1!=S105D1) {s105D1=S105D1; printf("S15D");}
if(s105D1!=S105D1) {s105D1=S105D1; send(S15D);}
if(s104A1!=S104A1) {s104A1=S104A1; printf("S14A");}
if(r104A1U!=R104A1U) {r104A1U=R104A1U; printf("R14AU");}
if(r104A1D!=R104A1D) {r104A1D=R104A1D; printf("R14AD");}
if(r104B1U!=R104B1U) {r104B1U=R104B1U; printf("R14BU");}
if(r104B1D!=R104B1D) {r104B1D=R104B1D; printf("R14BD");}
if(s104A1!=S104A1) {s104A1=S104A1; send(S14A);}
if(r104A1U!=R104A1U) {r104A1U=R104A1U; send(R14AU);}
if(r104A1D!=R104A1D) {r104A1D=R104A1D; send(R14AD);}
if(r104B1U!=R104B1U) {r104B1U=R104B1U; send(R14BU);}
if(r104B1D!=R104B1D) {r104B1D=R104B1D; send(R14BD);}
if(s103A1!=S103A1) {s103A1=S103A1; printf("S13A");}
if(s103A2!=S103A2) {s103A2=S103A2; printf("S13A");}
if(s103A3!=S103A3) {s103A3=S103A3; printf("S13A");}
if(r103A1U!=R103A1U) {r103A1U=R103A1U; printf("R13AU");}
if(r103A1D!=R103A1D) {r103A1D=R103A1D; printf("R13AD");}
if(s103A1!=S103A1) {s103A1=S103A1; send(S13A);}
if(s103A2!=S103A2) {s103A2=S103A2; send(S13A);}
if(s103A3!=S103A3) {s103A3=S103A3; send(S13A);}
if(r103A1U!=R103A1U) {r103A1U=R103A1U; send(R13AU);}
if(r103A1D!=R103A1D) {r103A1D=R103A1D; send(R13AD);}
if(s106A1!=S106A1) {s106A1=S106A1; printf("S16A");}
if(s107A2!=S107A2) {s107A2=S107A2; printf("S17A");}
if(s109A1!=S109A1) {s109A1=S109A1; printf("S19A");}
if(s106A1!=S106A1) {s106A1=S106A1; send(S16A);}
if(s107A2!=S107A2) {s107A2=S107A2; send(S17A);}
if(s109A1!=S109A1) {s109A1=S109A1; send(S19A);}
if(s101A1!=S101A1) {s101A1=S101A1; printf("S11A");}
if(s101A2!=S101A2) {s101A2=S101A2; printf("S11A");}
if(s101A1!=S101A1) {s101A1=S101A1; send(S11A);}
if(s101A2!=S101A2) {s101A2=S101A2; send(S11A);}
if(s102A1!=S102A1) {s102A1=S102A1; printf("S12A");}
if(s110A1!=S110A1) {s110A1=S110A1; printf("S1aA");}
if(s108A1!=S108A1) {s108A1=S108A1; printf("S18A");}
 
output_toggle(LED1);
delay_ms(100);
if(s102A1!=S102A1) {s102A1=S102A1; send(S12A);}
if(s110A1!=S110A1) {s110A1=S110A1; send(S1aA);}
if(s108A1!=S108A1) {s108A1=S108A1; send(S18A);}
}
}
/Designs/dum/SW/2patra/1np/main.pjt
23,7 → 23,7
1=main.c
2=main.h
3=..\..\..\..\..\..\..\..\..\Program Files\PICC\Devices\18F8310.h
4=..\..\simple\main.c
4=
5=
6=..\..\..\..\..\Modules\PIC\PIC18F8xTQ8001A\SW\PIC18F8310\blik.h
7=..\..\..\..\..\Modules\PIC\PIC18F8xTQ8001A\SW\PIC18F8310\blik.c
/Designs/dum/SW/2patra/2np/main.c
2,9 → 2,13
 
#case
 
#define REVERS 2 // 2*256 ms = 0,5 s
#define GO 117 // 117*256 ms = 30 s
#define GO_ZALUZIE 5 // 5*256 ms = 1,25 s
 
#define S105A PIN_A0
#define R105AU PIN_A1
#define R105AD PIN_A2
#define R110AU PIN_A1
#define R110AD PIN_A2
#define S104A PIN_A3
#define R104AU PIN_A4
#define R104AD PIN_A5
81,14 → 85,93
#define PIN_J7 31815
*/
 
#define LED1 PIN_J7
#bit CREN = 0xFAB.4 // USART enable register
 
#define LED1 PIN_J7
#define LED2 PIN_J6
 
#define ON(port) output_low(port);
#define OFF(port) output_high(port);
 
typedef enum {UP, DOWN, NOTHING} request;
typedef enum {GO_UP, GO_DOWN, REVERS_UP, REVERS_DOWN, STOP} state;
 
state r103A, r110A, r104A, r104B; // Stavy rolet
int8 tr103A, tr110A, tr104A, tr104B; // Casovace rolet
 
#int_TIMER0
void TIMER0_isr(void)
{
if(tr103A>0) tr103A--;
if(tr110A>0) tr110A--;
if(tr104A>0) tr104A--;
if(tr104B>0) tr104B--;
output_toggle(LED2);
}
 
void up(state *status, int8 *timer) // Zmena stavu rolety smer nahoru
{
switch (*status)
{
case STOP:
case GO_DOWN:
*status=REVERS_UP;
*timer=REVERS;
break;
case REVERS_UP:
case GO_UP:
*status=STOP;
*timer=0;
break;
}
}
 
void down(state *status, int8 *timer) // Zmena stavu rolety smer dolu
{
switch (*status)
{
case STOP:
case GO_UP:
*status=REVERS_DOWN;
*timer=REVERS;
break;
case REVERS_DOWN:
case GO_DOWN:
*status=STOP;
*timer=0;
break;
}
}
 
#define run(x) { \
switch(r##x) \
{ \
case STOP: \
OFF(R##x##U); \
OFF(R##x##D); \
break; \
case GO_UP: \
ON(R##x##U); \
OFF(R##x##D); \
if(tr##x==0) {r##x=STOP;} \
break; \
case GO_DOWN: \
OFF(R##x##U); \
ON(R##x##D); \
if(tr##x==0) {r##x=STOP;} \
break; \
case REVERS_UP: \
OFF(R##x##U); \
OFF(R##x##D); \
if(tr##x==0) {r##x=GO_UP; tr##x=GO;} \
break; \
case REVERS_DOWN: \
OFF(R##x##U); \
OFF(R##x##D); \
if(tr##x==0) {r##x=GO_DOWN; tr##x=GO;} \
break; \
} \
}
 
void main()
{
char c;
100,7 → 183,7
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_ON);
setup_timer_0(RTCC_INTERNAL);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
108,9 → 191,9
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
OFF(S105A);
OFF(R105AU);
OFF(R105AD);
OFF(S105A); // Vsechno zhasni a zastav
OFF(R110AU);
OFF(R110AD);
OFF(S104A);
OFF(R104AU);
OFF(R104AD);
129,8 → 212,18
OFF(S108A);
OFF(S201A);
OFF(S110B);
 
r103A=STOP; // Rolety jsou zastaveny
r110A=STOP;
r104A=STOP;
r104B=STOP;
 
enable_interrupts(INT_TIMER0);
enable_interrupts(GLOBAL);
}
CREN=0; CREN=1; // Reinitialise USART
while(TRUE)
{
if(kbhit())
138,70 → 231,125
c=getc();
if(c=='S')
{
getc();
switch(getc())
if(getc()=='1')
{
case '1':
output_toggle(S101A);
break;
case '2':
output_toggle(S102A);
break;
case '3':
output_toggle(S103A);
break;
case '4':
output_toggle(S104A);
break;
case '5':
c=getc();
if(c=='A') {output_toggle(S105A);}
if(c=='D') {output_toggle(S105D);}
break;
case '6':
output_toggle(S106A);
break;
case '7':
output_toggle(S107A);
break;
case '8':
output_toggle(S108A);
break;
case '9':
output_toggle(S109A);
break;
case 'a':
output_toggle(S110B);
output_toggle(S110C);
break;
switch(getc())
{
case '1':
output_toggle(S101A);
break;
case '2':
output_toggle(S102A);
break;
case '3':
output_toggle(S103A);
break;
case '4':
output_toggle(S104A);
break;
case '5':
c=getc();
if(c=='A') {output_toggle(S105A);}
if(c=='D') {output_toggle(S105D);}
break;
case '6':
output_toggle(S106A);
break;
case '7':
output_toggle(S107A);
break;
case '8':
output_toggle(S108A);
break;
case '9':
output_toggle(S109A);
break;
case 'a':
output_toggle(S110B);
output_toggle(S110C);
break;
}
}
}
if(c=='R')
{
getc();
switch(getc())
if(getc()=='1')
{
case '3':
getc();
c=getc();
if((c=='U')) {};
break;
case '4':
c=getc();
if(c=='A') {};
if(c=='B') {};
break;
case '5':
getc();
getc();
break;
switch(getc())
{
case '3':
getc(); // A
if((getc()=='U')) {up(&r103A,&tr103A);} else {down(&r103A,&tr103A);}
break;
case '4':
c=getc();
if(c=='A') if((getc()=='U')) {up(&r104A,&tr104A);} else {down(&r104A,&tr104A);}
if(c=='B') if((getc()=='U')) {up(&r104B,&tr104B);} else {down(&r104B,&tr104B);}
break;
case 'a':
getc(); // A
if((getc()=='U')) {up(&r110A,&tr110A);} else {down(&r110A,&tr110A);}
break;
}
}
}
output_toggle(LED1);
 
output_toggle(LED1); // Prijmuli jsme cely prikaz
}
else
{
run(103A);
run(104A);
run(104B);
 
switch(r110A)
{
case STOP:
OFF(R110AU);
OFF(R110AD);
break;
case GO_UP:
ON(R110AU);
OFF(R110AD);
if(tr110A==0) {r110A=STOP;}
break;
case GO_DOWN:
OFF(R110AU);
ON(R110AD);
if(tr110A==0) {r110A=STOP;}
break;
case REVERS_UP:
OFF(R110AU);
OFF(R110AD);
if(tr110A==0) {r110A=GO_UP; tr110A=GO_ZALUZIE;}
break;
case REVERS_DOWN:
OFF(R110AU);
OFF(R110AD);
if(tr110A==0) {r110A=GO_DOWN; tr110A=GO_ZALUZIE;}
break;
}
/*
switch(r110A)
{
case GO_UP:
printf("U");
break;
case GO_DOWN:
printf("D");
break;
case REVERS_UP:
printf("R");
break;
case REVERS_DOWN:
printf("E");
break;
case STOP:
printf("S");
break;
}
*/
restart_wdt();
}
}
/Designs/dum/SW/2patra/2np/main.h
2,7 → 2,7
#device adc=8
 
#FUSES WDT //No Watch Dog Timer
#FUSES WDT16 //Watch Dog Timer uses 1:16 Postscale
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORV46 //Brownout reset at 4.6V
/Designs/dum/SW/2patra/2np/main.pjt
49,4 → 49,6
1=main.c
2=main.h
3=..\..\..\..\..\..\..\..\..\Program Files\PICC\Devices\18F8310.h
4=
4=..\1np\ble\main.c
5=..\..\..\..\MRAKOMER4\SW\irmrak4.c
6=