1 |
#include "main.h" |
1 |
#include "main.h" |
2 |
|
2 |
|
3 |
#case |
3 |
#case |
4 |
|
4 |
|
5 |
#define S105AN input(PIN_A0) // Kuchyne hlavni svetlo severni vypinac |
5 |
#define S105AN input(PIN_A0) // Kuchyne hlavni svetlo severni vypinac |
6 |
#define R110NJU input(PIN_A1) // Roleta koupelna |
6 |
#define R110NJU input(PIN_A1) // Roleta koupelna |
7 |
#define R110NJD input(PIN_A2) |
7 |
#define R110NJD input(PIN_A2) |
8 |
#define S104AZ input(PIN_A3) // Svetlo laborator vypinac u dveri |
8 |
#define S104AZ input(PIN_A3) // Svetlo laborator vypinac u dveri |
9 |
#define R104VZU input(PIN_A4) // Roleta laborator vychod |
9 |
#define R104VZU input(PIN_A4) // Roleta laborator vychod |
10 |
#define R104VZD input(PIN_A5) |
10 |
#define R104VZD input(PIN_A5) |
11 |
#define R104JZU input(PIN_A6) // Roleta laborator jih |
11 |
#define R104JZU input(PIN_A6) // Roleta laborator jih |
12 |
#define R104JZD input(PIN_A7) |
12 |
#define R104JZD input(PIN_A7) |
13 |
|
13 |
|
14 |
#define S103JZ input(PIN_B0) // Svetlo loznice jih vypinac u dveri |
14 |
#define S103JZ input(PIN_B0) // Svetlo loznice jih vypinac u dveri |
15 |
#define S103JN input(PIN_B1) // -"- vypinac KAKL |
15 |
#define S103JN input(PIN_B1) // -"- vypinac KAKL |
16 |
#define S103JV input(PIN_B2) // -"- vypinac mama |
16 |
#define S103JV input(PIN_B2) // -"- vypinac mama |
17 |
#define R103VZU input(PIN_B3) // Roleta loznice vypinac u dveri |
17 |
#define R103VZU input(PIN_B3) // Roleta loznice vypinac u dveri |
18 |
#define R103VZD input(PIN_B4) |
18 |
#define R103VZD input(PIN_B4) |
19 |
#define S106AV input(PIN_B5) // Hlavni svetlo trucovna vypinac u dveri do kuchyne |
19 |
#define S106AV input(PIN_B5) // Hlavni svetlo trucovna vypinac u dveri do kuchyne |
20 |
#define S107AN input(PIN_B6) // Svetlo satna vypinac do chodby |
20 |
#define S107AN input(PIN_B6) // Svetlo satna vypinac do chodby |
21 |
#define S109AJ input(PIN_B7) // Svetlo tech. mistnost vypinac do chodby |
21 |
#define S109AJ input(PIN_B7) // Svetlo tech. mistnost vypinac do chodby |
22 |
|
22 |
|
23 |
#define OS101A PIN_C0 // Spinac svetla v bunecce prizemi |
23 |
#define OS101A PIN_C0 // Spinac svetla v bunecce prizemi |
24 |
#define OS105V PIN_C1 // Svetlo nad chlebarnou |
24 |
#define OS105V PIN_C1 // Svetlo nad chlebarnou |
25 |
#define OS105N PIN_C2 // Severni svetlo kuchyne |
25 |
#define OS105N PIN_C2 // Severni svetlo kuchyne |
26 |
|
26 |
|
27 |
//#define PIN_C3 31763 |
27 |
//#define PIN_C3 31763 |
28 |
//#define PIN_C4 31764 |
28 |
//#define PIN_C4 31764 |
29 |
//#define PIN_C5 31765 |
29 |
//#define PIN_C5 31765 |
30 |
|
30 |
|
31 |
//#define PIN_C6 31766 //TX |
31 |
//#define PIN_C6 31766 //TX |
32 |
//#define PIN_C7 31767 //RX |
32 |
//#define PIN_C7 31767 //RX |
33 |
|
33 |
|
34 |
#define S101AN input(PIN_D0) // Hlavni svetlo bunecka severni vypinac bliz u dveri |
34 |
#define S101AN input(PIN_D0) // Hlavni svetlo bunecka severni vypinac bliz u dveri |
35 |
#define S101AJ input(PIN_D1) // Hlavni svetlo bunecka jizni vypinac |
35 |
#define S101AJ input(PIN_D1) // Hlavni svetlo bunecka jizni vypinac |
36 |
#define S105VV input(PIN_D2) // Vypinac nad chlebarnou |
36 |
#define S105VV input(PIN_D2) // Vypinac nad chlebarnou |
37 |
#define S105NZ input(PIN_D3) // Svetlo kuchyne sever vypinac zapadni |
37 |
#define S105NZ input(PIN_D3) // Svetlo kuchyne sever vypinac zapadni |
38 |
#define S105ZZ input(PIN_D4) // Svetlo kuchyne zapad vypinac zapadni |
38 |
#define S105ZZ input(PIN_D4) // Svetlo kuchyne zapad vypinac zapadni |
39 |
#define S102AN input(PIN_D5) // Vypinac chodba dole u schodu |
39 |
#define S102AN input(PIN_D5) // Vypinac chodba dole u schodu |
40 |
#define S110AN input(PIN_D6) // Vypinac koupelna sever |
40 |
#define S110AN input(PIN_D6) // Vypinac koupelna sever |
41 |
#define S108AV input(PIN_D7) // Dvere do spajzu |
41 |
#define S108AV input(PIN_D7) // Dvere do spajzu |
42 |
|
42 |
|
43 |
/* |
43 |
/* |
44 |
#define PIN_E0 31776 |
44 |
#define PIN_E0 31776 |
45 |
#define PIN_E1 31777 |
45 |
#define PIN_E1 31777 |
46 |
#define PIN_E2 31778 |
46 |
#define PIN_E2 31778 |
47 |
#define PIN_E3 31779 |
47 |
#define PIN_E3 31779 |
48 |
#define PIN_E4 31780 |
48 |
#define PIN_E4 31780 |
49 |
#define PIN_E5 31781 |
49 |
#define PIN_E5 31781 |
50 |
#define PIN_E6 31782 |
50 |
#define PIN_E6 31782 |
51 |
#define PIN_E7 31783 |
51 |
#define PIN_E7 31783 |
52 |
|
52 |
|
53 |
#define PIN_F0 31784 |
53 |
#define PIN_F0 31784 |
54 |
#define PIN_F1 31785 |
54 |
#define PIN_F1 31785 |
55 |
#define PIN_F2 31786 |
55 |
#define PIN_F2 31786 |
56 |
#define PIN_F3 31787 |
56 |
#define PIN_F3 31787 |
57 |
#define PIN_F4 31788 |
57 |
#define PIN_F4 31788 |
58 |
#define PIN_F5 31789 |
58 |
#define PIN_F5 31789 |
59 |
#define PIN_F6 31790 |
59 |
#define PIN_F6 31790 |
60 |
#define PIN_F7 31791 |
60 |
#define PIN_F7 31791 |
61 |
|
61 |
|
62 |
#define PIN_G0 31792 |
62 |
#define PIN_G0 31792 |
63 |
#define PIN_G1 31793 |
63 |
#define PIN_G1 31793 |
64 |
#define PIN_G2 31794 |
64 |
#define PIN_G2 31794 |
65 |
#define PIN_G3 31795 |
65 |
#define PIN_G3 31795 |
66 |
#define PIN_G4 31796 |
66 |
#define PIN_G4 31796 |
67 |
#define PIN_G5 31797 |
67 |
#define PIN_G5 31797 |
68 |
|
68 |
|
69 |
#define PIN_H0 31800 |
69 |
#define PIN_H0 31800 |
70 |
#define PIN_H1 31801 |
70 |
#define PIN_H1 31801 |
71 |
#define PIN_H2 31802 |
71 |
#define PIN_H2 31802 |
72 |
#define PIN_H3 31803 |
72 |
#define PIN_H3 31803 |
73 |
#define PIN_H4 31804 |
73 |
#define PIN_H4 31804 |
74 |
#define PIN_H5 31805 |
74 |
#define PIN_H5 31805 |
75 |
#define PIN_H6 31806 |
75 |
#define PIN_H6 31806 |
76 |
#define PIN_H7 31807 |
76 |
#define PIN_H7 31807 |
77 |
|
77 |
|
78 |
#define PIN_J0 31808 |
78 |
#define PIN_J0 31808 |
79 |
#define PIN_J1 31809 |
79 |
#define PIN_J1 31809 |
80 |
#define PIN_J2 31810 |
80 |
#define PIN_J2 31810 |
81 |
#define PIN_J3 31811 |
81 |
#define PIN_J3 31811 |
82 |
#define PIN_J4 31812 |
82 |
#define PIN_J4 31812 |
83 |
#define PIN_J5 31813 |
83 |
#define PIN_J5 31813 |
84 |
#define PIN_J6 31814 |
84 |
#define PIN_J6 31814 |
85 |
#define PIN_J7 31815 |
85 |
#define PIN_J7 31815 |
86 |
*/ |
86 |
*/ |
87 |
|
87 |
|
88 |
#define LED1 PIN_J7 |
88 |
#define LED1 PIN_J7 |
89 |
#define LED2 PIN_J6 |
89 |
#define LED2 PIN_J6 |
90 |
|
90 |
|
- |
|
91 |
#define ON(port) output_low(port); |
- |
|
92 |
#define OFF(port) output_high(port); |
- |
|
93 |
|
91 |
int1 s105AN; // Predchozi stav vypinacu |
94 |
int1 s105AN; // Predchozi stav vypinacu |
92 |
int1 r110NJU; |
95 |
int1 r110NJU; |
93 |
int1 r110NJD; |
96 |
int1 r110NJD; |
94 |
int1 s104AZ; |
97 |
int1 s104AZ; |
95 |
int1 r104VZU; |
98 |
int1 r104VZU; |
96 |
int1 r104VZD; |
99 |
int1 r104VZD; |
97 |
int1 r104JZU; |
100 |
int1 r104JZU; |
98 |
int1 r104JZD; |
101 |
int1 r104JZD; |
99 |
int1 s103JZ; |
102 |
int1 s103JZ; |
100 |
int1 s103JN; |
103 |
int1 s103JN; |
101 |
int1 s103JV; |
104 |
int1 s103JV; |
102 |
int1 r103VZU; |
105 |
int1 r103VZU; |
103 |
int1 r103VZD; |
106 |
int1 r103VZD; |
104 |
int1 s106AV; |
107 |
int1 s106AV; |
105 |
int1 s107AN; |
108 |
int1 s107AN; |
106 |
int1 s109AJ; |
109 |
int1 s109AJ; |
107 |
int1 s101AN; |
110 |
int1 s101AN; |
108 |
int1 s101AJ; |
111 |
int1 s101AJ; |
109 |
int1 s105VV; |
112 |
int1 s105VV; |
110 |
int1 s105NZ; |
113 |
int1 s105NZ; |
111 |
int1 s105ZZ; |
114 |
int1 s105ZZ; |
112 |
int1 s102AN; |
115 |
int1 s102AN; |
113 |
int1 s110AN; |
116 |
int1 s110AN; |
114 |
int1 s108AV; |
117 |
int1 s108AV; |
115 |
|
118 |
|
116 |
#define send(s) \ |
119 |
#define send(s) \ |
117 |
{\ |
120 |
{\ |
118 |
printf("%s\r\n",#s);\ |
121 |
printf("%s\r\n",#s);\ |
119 |
output_toggle(LED1);\ |
122 |
output_toggle(LED1);\ |
120 |
delay_ms(100);\ |
123 |
delay_ms(100);\ |
121 |
} |
124 |
} |
122 |
|
125 |
|
123 |
void main() |
126 |
void main() |
124 |
{ |
127 |
{ |
125 |
|
128 |
|
126 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
129 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
127 |
setup_adc(ADC_CLOCK_DIV_2); |
130 |
setup_adc(ADC_CLOCK_DIV_2); |
128 |
setup_psp(PSP_DISABLED); |
131 |
setup_psp(PSP_DISABLED); |
129 |
setup_spi(SPI_SS_DISABLED); |
132 |
setup_spi(SPI_SS_DISABLED); |
130 |
setup_wdt(WDT_OFF); |
133 |
setup_wdt(WDT_OFF); |
131 |
setup_timer_0(RTCC_INTERNAL); |
134 |
setup_timer_0(RTCC_INTERNAL); |
132 |
setup_timer_1(T1_DISABLED); |
135 |
setup_timer_1(T1_DISABLED); |
133 |
setup_timer_2(T2_DISABLED,0,1); |
136 |
setup_timer_2(T2_DISABLED,0,1); |
134 |
setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
137 |
setup_timer_3(T3_DISABLED|T3_DIV_BY_1); |
135 |
setup_ccp1(CCP_OFF); |
138 |
setup_ccp1(CCP_OFF); |
136 |
setup_comparator(NC_NC_NC_NC); |
139 |
setup_comparator(NC_NC_NC_NC); |
137 |
setup_vref(FALSE); |
140 |
setup_vref(FALSE); |
138 |
|
141 |
|
- |
|
142 |
OFF(OS101A); |
- |
|
143 |
|
139 |
s105AN=S105AN; // Poznamenej vychozi stav vypinacu |
144 |
s105AN=S105AN; // Poznamenej vychozi stav vypinacu |
140 |
r110NJU=R110NJU; |
145 |
r110NJU=R110NJU; |
141 |
r110NJD=R110NJD; |
146 |
r110NJD=R110NJD; |
142 |
s104AZ=S104AZ; |
147 |
s104AZ=S104AZ; |
143 |
r104VZU=R104VZU; |
148 |
r104VZU=R104VZU; |
144 |
r104VZD=R104VZD; |
149 |
r104VZD=R104VZD; |
145 |
r104JZU=R104JZU; |
150 |
r104JZU=R104JZU; |
146 |
r104JZD=R104JZD; |
151 |
r104JZD=R104JZD; |
147 |
s103JZ=S103JZ; |
152 |
s103JZ=S103JZ; |
148 |
s103JN=S103JN; |
153 |
s103JN=S103JN; |
149 |
s103JV=S103JV; |
154 |
s103JV=S103JV; |
150 |
r103VZU=R103VZU; |
155 |
r103VZU=R103VZU; |
151 |
r103VZD=R103VZD; |
156 |
r103VZD=R103VZD; |
152 |
s106AV=S106AV; |
157 |
s106AV=S106AV; |
153 |
s107AN=S107AN; |
158 |
s107AN=S107AN; |
154 |
s109AJ=S109AJ; |
159 |
s109AJ=S109AJ; |
155 |
s101AN=S101AN; |
160 |
s101AN=S101AN; |
156 |
s101AJ=S101AJ; |
161 |
s101AJ=S101AJ; |
157 |
s105VV=S105VV; |
162 |
s105VV=S105VV; |
158 |
s105NZ=S105NZ; |
163 |
s105NZ=S105NZ; |
159 |
s105ZZ=S105ZZ; |
164 |
s105ZZ=S105ZZ; |
160 |
s102AN=S102AN; |
165 |
s102AN=S102AN; |
161 |
s110AN=S110AN; |
166 |
s110AN=S110AN; |
162 |
s108AV=S108AV; |
167 |
s108AV=S108AV; |
163 |
|
168 |
|
164 |
while(TRUE) |
169 |
while(TRUE) |
165 |
{ |
170 |
{ |
166 |
if(s105AN!=S105AN) {s105AN=S105AN; send(S15A);} |
171 |
if(s105AN!=S105AN) {s105AN=S105AN; send(S15A);} |
167 |
if(r110NJU!=R110NJU) {r110NJU=R110NJU; send(R1aNU);} |
172 |
if(r110NJU!=R110NJU) {r110NJU=R110NJU; send(R1aNU);} |
168 |
if(r110NJD!=R110NJD) {r110NJD=R110NJD; send(R1aND);} |
173 |
if(r110NJD!=R110NJD) {r110NJD=R110NJD; send(R1aND);} |
169 |
|
174 |
|
170 |
if(!S105VV) {output_low(OS105V);} else {output_high(OS105V);} |
175 |
if(!S105VV) {output_low(OS105V);} else {output_high(OS105V);} |
171 |
if(!S105NZ) {output_low(OS105N);} else {output_high(OS105N);} |
176 |
if(!S105NZ) {output_low(OS105N);} else {output_high(OS105N);} |
172 |
if(s105ZZ!=S105ZZ) {s105ZZ=S105ZZ; send(S15Z);} |
177 |
if(s105ZZ!=S105ZZ) {s105ZZ=S105ZZ; send(S15Z);} |
173 |
|
178 |
|
174 |
if(s104AZ!=S104AZ) {s104AZ=S104AZ; send(S14A);} |
179 |
if(s104AZ!=S104AZ) {s104AZ=S104AZ; send(S14A);} |
175 |
if(r104VZU!=R104VZU) {r104VZU=R104VZU; send(R14VU);} |
180 |
if(r104VZU!=R104VZU) {r104VZU=R104VZU; send(R14VU);} |
176 |
if(r104VZD!=R104VZD) {r104VZD=R104VZD; send(R14VD);} |
181 |
if(r104VZD!=R104VZD) {r104VZD=R104VZD; send(R14VD);} |
177 |
if(r104JZU!=R104JZU) {r104JZU=R104JZU; send(R14JU);} |
182 |
if(r104JZU!=R104JZU) {r104JZU=R104JZU; send(R14JU);} |
178 |
if(r104JZD!=R104JZD) {r104JZD=R104JZD; send(R14JD);} |
183 |
if(r104JZD!=R104JZD) {r104JZD=R104JZD; send(R14JD);} |
179 |
|
184 |
|
180 |
if(s103JZ!=S103JZ) {s103JZ=S103JZ; send(S13A);} |
185 |
if(s103JZ!=S103JZ) {s103JZ=S103JZ; send(S13A);} |
181 |
if(s103JN!=S103JN) {s103JN=S103JN; send(S13A);} |
186 |
if(s103JN!=S103JN) {s103JN=S103JN; send(S13A);} |
182 |
if(s103JV!=S103JV) {s103JV=S103JV; send(S13A);} |
187 |
if(s103JV!=S103JV) {s103JV=S103JV; send(S13A);} |
183 |
if(r103VZU!=R103VZU) {r103VZU=R103VZU; send(R13VU);} |
188 |
if(r103VZU!=R103VZU) {r103VZU=R103VZU; send(R13VU);} |
184 |
if(r103VZD!=R103VZD) {r103VZD=R103VZD; send(R13VD);} |
189 |
if(r103VZD!=R103VZD) {r103VZD=R103VZD; send(R13VD);} |
185 |
|
190 |
|
186 |
if(s106AV!=S106AV) {s106AV=S106AV; send(S16A);} |
191 |
if(s106AV!=S106AV) {s106AV=S106AV; send(S16A);} |
187 |
if(s107AN!=S107AN) {s107AN=S107AN; send(S17A);} |
192 |
if(s107AN!=S107AN) {s107AN=S107AN; send(S17A);} |
188 |
if(s109AJ!=S109AJ) {s109AJ=S109AJ; send(S19A);} |
193 |
if(s109AJ!=S109AJ) {s109AJ=S109AJ; send(S19A);} |
189 |
|
194 |
|
190 |
if(s101AN!=S101AN) {s101AN=S101AN; send(S11A);} |
195 |
if(s101AN!=S101AN) {s101AN=S101AN; output_toggle(OS101A); delay_ms(100);} |
191 |
if(s101AJ!=S101AJ) {s101AJ=S101AJ; send(S11A);} |
196 |
if(s101AJ!=S101AJ) {s101AJ=S101AJ; output_toggle(OS101A); delay_ms(100);} |
192 |
|
197 |
|
193 |
if(s102AN!=S102AN) {s102AN=S102AN; send(S12A);} |
198 |
if(s102AN!=S102AN) {s102AN=S102AN; send(S12A);} |
194 |
if(s110AN!=S110AN) {s110AN=S110AN; send(S1aA);} |
199 |
if(s110AN!=S110AN) {s110AN=S110AN; send(S1aA);} |
195 |
if(s108AV!=S108AV) {s108AV=S108AV; send(S18A);} |
200 |
if(s108AV!=S108AV) {s108AV=S108AV; send(S18A);} |
- |
|
201 |
|
- |
|
202 |
if(get_timer0()>65000) {output_toggle(LED2); set_timer0(0);} |
196 |
} |
203 |
} |
197 |
} |
204 |
} |