View difference between Paste ID: MMBTp49Y and mZGS1Svz
SHOW: | | - or go back to the newest paste.
1
/*************************************************************************/
2
/*  Program testowy dla obiektu X oprogamowania SPSym                    */
3
/*************************************************************************/
4
#include "spsym.h"         	// Pomocnicze funkcje i deklaracje
5
#include <stdio.h>         	// Stadnardowe I/O
6
#include <conio.h>
7
8
// --- Makrodefinicje dla obiektu X ---
9
#define T  X8
10
#define Z1 Y1
11
#define Z2 Y2
12
#define Z3 Y3
13
#define Z4 Y4
14
#define Z5 Y5
15
#define M  Y6
16
#define G1 Y7
17
18
// --- Zmienne użytkownika ---
19
int timsec = 0;
20
int licz=0;                	// Licznik przerwań
21
22
//TIMERY
23
char counterBeeps, counterTimer = 0;
24
int timTime = 3000;
25
26
//ZMIENNE ODPOWIEDZIALNE ZA OTWARCIE/ZAMKNIECIE DRZWICZEK
27
char door = 0, workMode = 1, pause = 0;
28
char work = 0;
29
30
//ZMIENNE ODPOWIEDZIALNE ZA CZAS I TRYBY
31
char helpmodevar = 1;
32
char chosenMode = 1;
33
char viewingChosenMode = 1;
34
char counterViewingChosenMode;
35
char timeMode = 1;
36
char timeViewMode = 1;
37
char viewingTime = 1;
38
char timeShowingMode = 1;
39
char counterTimerBeeps;
40
41
//ZMIENNE ODP ZA WYSWIETLANIE NAPISOW
42
const char *text0 = "DOOR";
43
const char *text1 = "FROZEN";
44
const char *text2 = "WARMING";
45
const char *text3 = "GRILL";
46
const char *text4 = "BOILING";
47
const char *text5 = "SERVICE";
48
const char *text;
49
const char *p = "NO";
50
51
52
//ZMIENNE ODPOWIEDZIALNE ZA STEROWANIE MOCA
53
int powerMode = 1;
54
char timPower, power1, power0;
55
int power = 0;
56
char powerAdjusting = 1;
57
58
char timeshowing2 = 1;
59
60
void prolog(void)			
61
{
62
    L1=L2=L3=L4=L5=0;         	
63
}
64
65
void oblicz(void)			
66
{ 
67
   
68
pK1=aK1; pK2=aK2; pK3=aK3; pK4=aK4;
69
pK5=aK5; pK6=aK6; pK7=aK7; pK8=aK8;
70
71
power1 = (int)(power*25)/1000;
72
power0 = 5 - power1/1000;
73
74
75
//OTWARCIE/ZAMKNIECIE DRZWICZEK
76
if(!work && !door && pK1) {door = 1; L1=1;
77
viewingChosenMode=0; timeMode=0; workMode = 0;}
78
else if(!work && door && pK1 && L1 == 1) {door = 0; L1=0;
79
viewingChosenMode=1; timeMode=1; powerMode=1; workMode = helpmodevar; }
80
81
82
//TRYB PRACY MIKROFALOWKI
83
//ODMRAZANIE
84
//GRZANIE
85
//GRILLOWANIE
86
//GOTOWANIE
87
//CZYSZCZENIE SPRZĘTU
88
if(!work)
89
{
90
	switch(chosenMode)
91
	{
92
		case 1:
93
		{
94
			if(pK2 && door == 0 && workMode >=1 && workMode <=5) chosenMode = 2;
95
		}
96
		break;
97
		case 2:
98
		{
99
			if(!pK2 && door == 0 && workMode <=5)
100
			{
101
				chosenMode = 1;
102
				workMode++;
103
				helpmodevar = workMode;
104
				if(workMode > 5) {workMode = 1; helpmodevar = 1;}
105
			}
106
			
107
		}
108
		break;
109
	}
110
}
111
112
//NAPISY
113
if(workMode == 0)text = text0;
114
else if(workMode == 1)text = text1;
115
else if (workMode == 2)text = text2;
116
else if (workMode == 3)text = text3;
117
else if (workMode == 4)text = text4;
118
else if (workMode == 5)text = text5;
119
120
//WYSWIETLANIE WYBRANEGO TRYBU PRACY MIKROFALOWKI
121
switch(viewingChosenMode)
122
    {
123
    case 0: L2=0;
124
    break;
125
    case 1:
126
    {
127
        L2 = 0;
128
        counterViewingChosenMode = workMode;
129
        if(counterViewingChosenMode)
130
        {
131
            counterBeeps = 2;
132
            viewingChosenMode = 2;
133
        }
134
        else L2 = 1;
135
    }
136
        break;
137
    case 2:
138
    {
139
        L2 = 1;
140
        if(!counterBeeps && counterViewingChosenMode > 1)
141
        {viewingChosenMode = 3; counterBeeps = 2;
142
        counterViewingChosenMode--;}
143
        else if(!counterBeeps && counterViewingChosenMode == 1)
144
        {viewingChosenMode = 3; counterBeeps = 15;
145
        counterViewingChosenMode--;}
146
    }
147
        break;
148
    case 3:
149
    {
150
        L2 = 0;
151
        if(!counterBeeps && counterViewingChosenMode)
152
        {viewingChosenMode = 2; counterBeeps = 2;}
153
        else if(!counterBeeps && !counterViewingChosenMode)
154
        viewingChosenMode = 1;
155
    }
156
        break;
157
 }
158
    
159
//USTAWIENIA CZASU
160
switch(timeMode)
161
{
162
	case 1:
163
		if(aK6 && timTime>0) {timTime=timTime-10;}
164
		else if(aK6 && timTime==0);
165
		else if(aK7 && timTime<3000) {timTime=timTime+10;}
166
		else if(aK7 && timTime==3000);
167
		break;
168
}
169
170
//USTAWIENIE SYGNALIZACJI DIOD DLA CZASU
171
switch(timeViewMode)
172
{
173
case 1:
174
		{
175
			if(pK6 && door == 0) {timeViewMode = 2; L6=1;}
176
			else if(pK7 && door == 0) {timeViewMode = 3; L7=1;}
177
		}
178
		break;
179
case 2:
180
		{	
181
			if(!pK6 && work == 0)
182
			{
183
				timeViewMode = 1;
184
				L6=0;
185
			}
186
			else if(work == 1) L6=1;
187
		}
188
		break;
189
case 3:
190
		{
191
			if(!pK7 && work == 0)
192
			{
193
				timeViewMode = 1;
194
				L7=0;
195
			}
196
			else if(work == 1) L7=1;
197
		}
198
		break;
199
}
200
201
 
202
 //ZMIANA MOCY MIKROFALOWKI
203
 
204
 switch(powerAdjusting)
205
	{
206
		case 1:
207
		{
208
			if(pK4) powerAdjusting = 2;
209
			else if(pK3) powerAdjusting = 3;
210
		}
211
		break;
212
		case 2:
213
		{
214
			if(!pK4 && L5 == 0)
215
			{
216
				powerAdjusting = 1;
217
				power+=100.00;
218
 				if(power>1000) power = 0;
219
			}		
220
		}
221
		break;
222
		case 3:
223
		{
224
			if(!pK3 && L5 == 0)
225
			{
226
				powerAdjusting = 1;
227
				power-=100.00;
228
				if(power<0) power = 0;
229
			}
230
		}
231
		break;
232
	}
233
 
234
// USTAWIENIE MOCY
235
// WSPOLCZYNNIK WYPELNIENIA
236
switch(powerMode)
237
    {
238
    case 1:
239
    {
240
        L4 = 0; L3=0;
241
        timPower = power1;
242
        if(power) powerMode = 2;
243
        else powerMode = 4;
244
    }
245
        break;
246
    case 2:
247
    {
248
        L4 = 1; L3 = 1;
249
        if(!timPower && power < 1000.00)
250
        {powerMode = 3; timPower = power0;}
251
        else if(!power) powerMode = 4;
252
    }
253
        break;
254
    case 3:
255
    {
256
        L4 = 0; L3 = 0;
257
        if(!timPower && power > 0)
258
        {powerMode = 2; timPower = power1;}
259
        else if(!power) powerMode = 5;
260
    }
261
        break;
262
    case 4:
263
    {
264
    	L4 = 0; L3 = 0;
265
    	if(power) {powerMode = 3; timPower = power0;}
266
    	else powerMode = 5;
267
    }
268
    break;
269
    case 5:
270
    {
271
    	L4 = 1; L3 = 1;
272
    	if(power) {powerMode = 3; timPower = power0;}
273
    	else powerMode = 4;
274
    }
275
    break;
276
    }
277
    
278
//PRACA MIKROFALOWKI
279
if(door == 0 && pK5 && work==0 && timTime > 0 && power != 0)
280
{work=1; door = 0;
281
timeMode=0; p="ON"; L5=1; L6=1; L7=1;}
282
else if( pK5 && work==1)
283
{L5 = 0; work=0; viewingChosenMode=1; timeMode=1;
284
powerMode=1; p="P"; L6=0; L7=0;}
285
else if( timTime == 0 && work==1)
286
{L5 = 0; work=0; viewingChosenMode=1; timeMode=1;
287
powerMode=1; power=0; workMode=1; p="NO"; L6=0; L7=0;}
288
289
    
290
if(counterBeeps) --counterBeeps;
291
if(timTime && work) --timTime;
292
if(timPower) --timPower;
293
    
294
sprintf(buf,"Time:%d   Power:%d               ",
295
(int)timTime/10, (int)power);
296
LCD_xy(1,1); LCD_puts(buf);
297
sprintf(buf,"Mode:0%d   %s %s  ", 
298
(int)workMode, text, p);
299
LCD_xy(1,2); LCD_puts(buf);
300
    
301
}
302
303
304
void przerwanie(void)      	
305
{
306
}
307
308
void komunikacja(void)		
309
{}
310
311
#ifdef Symulator_PC
312
void wykres(void)			
313
{
314
    aTab[0] = (int)(AI[0]/10.0);
315
    aTab[1] = (int)(AI[1]/5.0);
316
    aTab[2] = AI[7];
317
    aTab[3] = (int)(licz/100.0);
318
    aTab[4] = AO[0];
319
    aTab[5] = AO[7];
320
    aTab[6] = -120;
321
    aTab[7] =  120;
322
    bTab[0] = (int)aK1;
323
    bTab[1] = (int)aK2;
324
    bTab[2] = (int)aK3;
325
    bTab[3] = (int)aK4;
326
    bTab[4] = (int)L1;
327
    bTab[5] = (int)L2;
328
    bTab[6] = (int)L3;
329
    bTab[7] = (int)L4;
330
    bTab[8] = (int)L5;
331
    bTab[9] = (int)L6;
332
    bTab[10] = (int)L7;
333
    //bTab[11] = 11;
334
    bTab[12] = 12;
335
    bTab[13] = 13;
336
    bTab[14] = 14;
337
    bTab[15] = 15;
338
}
339
#endif