Line -... |
Line 1... |
- |
|
1 |
/* |
- |
|
2 |
Ovladani domu rozvadec 1. n.p. pod schodama |
- |
|
3 |
|
- |
|
4 |
Syntaxe prikazu: |
- |
|
5 |
|
- |
|
6 |
<Roleta/Svetlo><#patro><#mistnost><Nord/Jih/Vychod/Zapad/A/B><Up/Down> |
- |
|
7 |
R2aNU - roleta, 2. n.p., mistnost 10, sever, nahoru |
- |
|
8 |
S12A - svetlo, 1. n.p., mistnost 2, prostredni |
- |
|
9 |
|
- |
|
10 |
Rozmisteni desek: |
- |
|
11 |
|
- |
|
12 |
[IN B] [IN D] |
- |
|
13 |
[CPU] |
- |
|
14 |
[IN A] [CAN] [IN E] [IN F] |
- |
|
15 |
|
- |
|
16 |
*/ |
- |
|
17 |
|
1 |
#include "main.h" |
18 |
#include "main.h" |
2 |
|
19 |
|
3 |
#case |
20 |
#case |
4 |
|
21 |
|
5 |
#define S105AN input(PIN_A0) // Kuchyne hlavni svetlo severni vypinac |
22 |
#define S105AN input(PIN_A0) // Kuchyne hlavni svetlo severni vypinac |
Line 9... |
Line 26... |
9 |
#define R104VZU input(PIN_A4) // Roleta laborator vychod |
26 |
#define R104VZU input(PIN_A4) // Roleta laborator vychod |
10 |
#define R104VZD input(PIN_A5) |
27 |
#define R104VZD input(PIN_A5) |
11 |
#define R104JZU input(PIN_A6) // Roleta laborator jih |
28 |
#define R104JZU input(PIN_A6) // Roleta laborator jih |
12 |
#define R104JZD input(PIN_A7) |
29 |
#define R104JZD input(PIN_A7) |
13 |
|
30 |
|
14 |
#define S103JZ input(PIN_B0) // Svetlo loznice jih vypinac u dveri |
31 |
#define S103JZ input(PIN_B0) // A Svetlo loznice jih vypinac u dveri |
15 |
#define S103JN input(PIN_B1) // -"- vypinac KAKL |
32 |
#define S103JN input(PIN_B1) // B -"- vypinac KAKL |
16 |
#define S103JV input(PIN_B2) // -"- vypinac mama |
33 |
#define S103JV input(PIN_B2) // C -"- vypinac mama |
17 |
#define R103VZU input(PIN_B3) // Roleta loznice vypinac u dveri |
34 |
#define R103VZU input(PIN_B3) // D Roleta loznice vypinac u dveri |
18 |
#define R103VZD input(PIN_B4) |
35 |
#define R103VZD input(PIN_B4) // E |
19 |
#define S106AV input(PIN_B5) // Hlavni svetlo trucovna vypinac u dveri do kuchyne |
36 |
//#define S input(PIN_B5) // F |
20 |
#define S107AN input(PIN_B6) // Svetlo satna vypinac do chodby |
37 |
#define S107AN input(PIN_B6) // G Svetlo satna vypinac do chodby |
21 |
#define S109AJ input(PIN_B7) // Svetlo tech. mistnost vypinac do chodby |
38 |
#define S109AJ input(PIN_B7) // H Svetlo tech. mistnost vypinac do chodby |
22 |
|
39 |
|
23 |
#define OS101A PIN_C0 // Spinac svetla v bunecce prizemi |
40 |
#define OS101A PIN_C0 // Spinac svetla v bunecce prizemi |
24 |
#define OS105V PIN_C1 // Svetlo nad chlebarnou |
41 |
#define OS105V PIN_C1 // Svetlo nad chlebarnou |
25 |
#define OS105N PIN_C2 // Severni svetlo kuchyne |
42 |
#define OS105N PIN_C2 // Severni svetlo kuchyne |
26 |
|
43 |
|
Line 38... |
Line 55... |
38 |
#define S105ZZ input(PIN_D4) // Svetlo kuchyne zapad vypinac zapadni |
55 |
#define S105ZZ input(PIN_D4) // Svetlo kuchyne zapad vypinac zapadni |
39 |
#define S102AN input(PIN_D5) // Vypinac chodba dole u schodu |
56 |
#define S102AN input(PIN_D5) // Vypinac chodba dole u schodu |
40 |
#define S110AN input(PIN_D6) // Vypinac koupelna sever |
57 |
#define S110AN input(PIN_D6) // Vypinac koupelna sever |
41 |
#define S108AV input(PIN_D7) // Dvere do spajzu |
58 |
#define S108AV input(PIN_D7) // Dvere do spajzu |
42 |
|
59 |
|
43 |
/* |
- |
|
44 |
#define PIN_E0 31776 |
60 |
//#define S input(PIN_E0) // A |
45 |
#define PIN_E1 31777 |
61 |
//#define S input(PIN_E1) // B |
46 |
#define PIN_E2 31778 |
62 |
//#define S input(PIN_E2) // C |
47 |
#define PIN_E3 31779 |
63 |
//#define S input(PIN_E3) // D |
48 |
#define PIN_E4 31780 |
64 |
//#define S input(PIN_E4) // E |
49 |
#define PIN_E5 31781 |
65 |
//#define S input(PIN_E5) // F |
50 |
#define PIN_E6 31782 |
66 |
//#define S input(PIN_E6) // G |
51 |
#define PIN_E7 31783 |
67 |
//#define S input(PIN_E7) // H |
52 |
|
68 |
|
53 |
#define PIN_F0 31784 |
69 |
#define S106AV input(PIN_F0) // A Hlavni svetlo trucovna vypinac u dveri do kuchyne |
54 |
#define PIN_F1 31785 |
70 |
#define R106JVD input(PIN_F1) // B Roleta trucovna jih vypinac u dveri do kuchyne |
55 |
#define PIN_F2 31786 |
71 |
#define R106JVU input(PIN_F2) // C |
56 |
#define PIN_F3 31787 |
72 |
#define R106ZVD input(PIN_F3) // D Roleta trucovna zapad vypinac u dveri do kuchyne |
57 |
#define PIN_F4 31788 |
73 |
#define R106ZVU input(PIN_F4) // E |
58 |
#define PIN_F5 31789 |
74 |
#define S107AJ input(PIN_F5) // F Svetlo satna vypinac u trucovny |
59 |
#define PIN_F6 31790 |
75 |
#define S109AN input(PIN_F6) // G Svetlo technologicka mistnost vypinac do prujezdu |
60 |
#define PIN_F7 31791 |
76 |
#define S106AN input(PIN_F7) // H Hlavni svetlo trucovna vypinac u dveri do satny |
- |
|
77 |
|
61 |
|
78 |
|
- |
|
79 |
/* |
62 |
#define PIN_G0 31792 |
80 |
#define PIN_G0 31792 |
63 |
#define PIN_G1 31793 |
81 |
#define PIN_G1 31793 |
64 |
#define PIN_G2 31794 |
82 |
#define PIN_G2 31794 |
65 |
#define PIN_G3 31795 |
83 |
#define PIN_G3 31795 |
66 |
#define PIN_G4 31796 |
84 |
#define PIN_G4 31796 |
Line 102... |
Line 120... |
102 |
int1 s103JZ; |
120 |
int1 s103JZ; |
103 |
int1 s103JN; |
121 |
int1 s103JN; |
104 |
int1 s103JV; |
122 |
int1 s103JV; |
105 |
int1 r103VZU; |
123 |
int1 r103VZU; |
106 |
int1 r103VZD; |
124 |
int1 r103VZD; |
107 |
int1 s106AV; |
- |
|
108 |
int1 s107AN; |
125 |
int1 s107AN; |
109 |
int1 s109AJ; |
126 |
int1 s109AJ; |
110 |
int1 s101AN; |
127 |
int1 s101AN; |
111 |
int1 s101AJ; |
128 |
int1 s101AJ; |
112 |
int1 s105VV; |
129 |
int1 s105VV; |
113 |
int1 s105NZ; |
130 |
int1 s105NZ; |
114 |
int1 s105ZZ; |
131 |
int1 s105ZZ; |
115 |
int1 s102AN; |
132 |
int1 s102AN; |
116 |
int1 s110AN; |
133 |
int1 s110AN; |
117 |
int1 s108AV; |
134 |
int1 s108AV; |
- |
|
135 |
int1 r106JVU; |
- |
|
136 |
int1 r106JVD; |
- |
|
137 |
int1 r106ZVU; |
- |
|
138 |
int1 r106ZVD; |
- |
|
139 |
int1 s106AV; |
- |
|
140 |
int1 s106AN; |
- |
|
141 |
int1 s107AJ; |
- |
|
142 |
int1 s109AN; |
118 |
|
143 |
|
119 |
#define send(s) \ |
144 |
#define send(s) \ |
120 |
{\ |
145 |
{\ |
121 |
printf("%s\r\n",#s);\ |
146 |
printf("%s\r\n",#s);\ |
122 |
output_toggle(LED1);\ |
147 |
output_toggle(LED1);\ |
123 |
delay_ms(100);\ |
148 |
delay_ms(100);\ |
124 |
} |
149 |
} |
125 |
|
150 |
|
126 |
void main() |
151 |
void main() |
127 |
{ |
152 |
{ |
128 |
|
- |
|
129 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
153 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
130 |
setup_adc(ADC_CLOCK_DIV_2); |
154 |
setup_adc(ADC_CLOCK_DIV_2); |
131 |
setup_psp(PSP_DISABLED); |
155 |
setup_psp(PSP_DISABLED); |
132 |
setup_spi(SPI_SS_DISABLED); |
156 |
setup_spi(SPI_SS_DISABLED); |
133 |
setup_wdt(WDT_OFF); |
157 |
setup_wdt(WDT_OFF); |
Line 139... |
Line 163... |
139 |
setup_comparator(NC_NC_NC_NC); |
163 |
setup_comparator(NC_NC_NC_NC); |
140 |
setup_vref(FALSE); |
164 |
setup_vref(FALSE); |
141 |
|
165 |
|
142 |
OFF(OS101A); |
166 |
OFF(OS101A); |
143 |
|
167 |
|
- |
|
168 |
{ |
- |
|
169 |
int n; |
- |
|
170 |
|
- |
|
171 |
for(n=0;n<10;n++) |
- |
|
172 |
{ |
- |
|
173 |
output_low(LED1); // Indikace restartu (pockame na nabiti kondenzatoru ve vstupnich obvodech) |
- |
|
174 |
delay_ms(100); |
- |
|
175 |
output_high(LED1); |
- |
|
176 |
delay_ms(100); |
- |
|
177 |
restart_wdt(); |
- |
|
178 |
} |
- |
|
179 |
} |
- |
|
180 |
|
- |
|
181 |
|
144 |
s105AN=S105AN; // Poznamenej vychozi stav vypinacu |
182 |
s105AN=S105AN; // Poznamenej vychozi stav vypinacu |
145 |
r110NJU=R110NJU; |
183 |
r110NJU=R110NJU; |
146 |
r110NJD=R110NJD; |
184 |
r110NJD=R110NJD; |
147 |
s104AZ=S104AZ; |
185 |
s104AZ=S104AZ; |
148 |
r104VZU=R104VZU; |
186 |
r104VZU=R104VZU; |
Line 152... |
Line 190... |
152 |
s103JZ=S103JZ; |
190 |
s103JZ=S103JZ; |
153 |
s103JN=S103JN; |
191 |
s103JN=S103JN; |
154 |
s103JV=S103JV; |
192 |
s103JV=S103JV; |
155 |
r103VZU=R103VZU; |
193 |
r103VZU=R103VZU; |
156 |
r103VZD=R103VZD; |
194 |
r103VZD=R103VZD; |
157 |
s106AV=S106AV; |
- |
|
158 |
s107AN=S107AN; |
195 |
s107AN=S107AN; |
159 |
s109AJ=S109AJ; |
196 |
s109AJ=S109AJ; |
160 |
s101AN=S101AN; |
197 |
s101AN=S101AN; |
161 |
s101AJ=S101AJ; |
198 |
s101AJ=S101AJ; |
162 |
s105VV=S105VV; |
199 |
s105VV=S105VV; |
163 |
s105NZ=S105NZ; |
200 |
s105NZ=S105NZ; |
164 |
s105ZZ=S105ZZ; |
201 |
s105ZZ=S105ZZ; |
165 |
s102AN=S102AN; |
202 |
s102AN=S102AN; |
166 |
s110AN=S110AN; |
203 |
s110AN=S110AN; |
167 |
s108AV=S108AV; |
204 |
s108AV=S108AV; |
- |
|
205 |
r106JVU=R106JVU; |
- |
|
206 |
r106JVD=R106JVD; |
- |
|
207 |
r106ZVU=R106ZVU; |
- |
|
208 |
r106ZVD=R106ZVD; |
- |
|
209 |
s106AV=S106AV; |
- |
|
210 |
s106AN=S106AN; |
- |
|
211 |
s107AJ=S107AJ; |
- |
|
212 |
s109AN=S109AN; |
168 |
|
213 |
|
169 |
while(TRUE) |
214 |
while(TRUE) |
170 |
{ |
215 |
{ |
171 |
if(s105AN!=S105AN) {s105AN=S105AN; send(S15A);} |
216 |
if(s105AN!=S105AN) {s105AN=S105AN; send(S15A);} |
172 |
if(r110NJU!=R110NJU) {r110NJU=R110NJU; send(R1aNU);} |
217 |
if(r110NJU!=R110NJU) {r110NJU=R110NJU; send(R1aNU);} |
Line 186... |
Line 231... |
186 |
if(s103JN!=S103JN) {s103JN=S103JN; send(S13A);} |
231 |
if(s103JN!=S103JN) {s103JN=S103JN; send(S13A);} |
187 |
if(s103JV!=S103JV) {s103JV=S103JV; send(S13A);} |
232 |
if(s103JV!=S103JV) {s103JV=S103JV; send(S13A);} |
188 |
if(r103VZU!=R103VZU) {r103VZU=R103VZU; send(R13VU);} |
233 |
if(r103VZU!=R103VZU) {r103VZU=R103VZU; send(R13VU);} |
189 |
if(r103VZD!=R103VZD) {r103VZD=R103VZD; send(R13VD);} |
234 |
if(r103VZD!=R103VZD) {r103VZD=R103VZD; send(R13VD);} |
190 |
|
235 |
|
191 |
if(s106AV!=S106AV) {s106AV=S106AV; send(S16A);} |
- |
|
192 |
if(s107AN!=S107AN) {s107AN=S107AN; send(S17A);} |
236 |
if(s107AN!=S107AN) {s107AN=S107AN; send(S17A);} |
193 |
if(s109AJ!=S109AJ) {s109AJ=S109AJ; send(S19A);} |
237 |
if(s109AJ!=S109AJ) {s109AJ=S109AJ; send(S19A);} |
194 |
|
238 |
|
195 |
if(s101AN!=S101AN) {s101AN=S101AN; output_toggle(OS101A); delay_ms(100);} |
239 |
if(s101AN!=S101AN) {s101AN=S101AN; output_toggle(OS101A); delay_ms(100);} |
196 |
if(s101AJ!=S101AJ) {s101AJ=S101AJ; output_toggle(OS101A); delay_ms(100);} |
240 |
if(s101AJ!=S101AJ) {s101AJ=S101AJ; output_toggle(OS101A); delay_ms(100);} |
197 |
|
241 |
|
198 |
if(s102AN!=S102AN) {s102AN=S102AN; send(S12A);} |
242 |
if(s102AN!=S102AN) {s102AN=S102AN; send(S12A);} |
199 |
if(s110AN!=S110AN) {s110AN=S110AN; send(S1aA);} |
243 |
if(s110AN!=S110AN) {s110AN=S110AN; send(S1aA);} |
200 |
if(s108AV!=S108AV) {s108AV=S108AV; send(S18A);} |
244 |
if(s108AV!=S108AV) {s108AV=S108AV; send(S18A);} |
201 |
|
245 |
|
- |
|
246 |
if(r106JVU!=R106JVU) {r106JVU=R106JVU; send(R16JU);} |
- |
|
247 |
if(r106JVD!=R106JVD) {r106JVD=R106JVD; send(R16JD);} |
- |
|
248 |
if(r106ZVU!=R106ZVU) {r106ZVU=R106ZVU; send(R16ZU);} |
- |
|
249 |
if(r106ZVD!=R106ZVD) {r106ZVD=R106ZVD; send(R16ZD);} |
- |
|
250 |
if(s106AV!=S106AV) {s106AV=S106AV; send(S16A);} |
- |
|
251 |
if(s106AN!=S106AN) {s106AN=S106AN; send(S16A);} |
- |
|
252 |
if(s107AJ!=S107AJ) {s107AJ=S107AJ; send(S17A);} |
- |
|
253 |
if(s109AN!=S109AN) {s109AN=S109AN; send(S19A);} |
- |
|
254 |
|
202 |
if(get_timer0()>65000) {output_toggle(LED2); set_timer0(0);} |
255 |
if(get_timer0()>65000) {output_toggle(LED2); set_timer0(0);} |
203 |
} |
256 |
} |
204 |
} |
257 |
} |