Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*************************************************************************/
- /* Program testowy dla obiektu X oprogamowania SPSym */
- /*************************************************************************/
- #include "spsym.h" // Pomocnicze funkcje i deklaracje
- #include <stdio.h> // Stadnardowe I/O
- #include <conio.h>
- // --- Makrodefinicje dla obiektu X ---
- #define T X8
- #define Z1 Y1
- #define Z2 Y2
- #define Z3 Y3
- #define Z4 Y4
- #define Z5 Y5
- #define M Y6
- #define G1 Y7
- // --- Zmienne użytkownika ---
- int timsec = 0;
- int licz=0; // Licznik przerwań
- //TIMERY
- char counterBeeps, counterTimer = 0;
- int timTime = 3000;
- //ZMIENNE ODPOWIEDZIALNE ZA OTWARCIE/ZAMKNIECIE DRZWICZEK
- char door = 0, workMode = 1, pause = 0;
- char work = 0;
- //ZMIENNE ODPOWIEDZIALNE ZA CZAS I TRYBY
- char helpmodevar = 1;
- char chosenMode = 1;
- char viewingChosenMode = 1;
- char counterViewingChosenMode;
- char timeMode = 1;
- char timeViewMode = 1;
- char viewingTime = 1;
- char timeShowingMode = 1;
- char counterTimerBeeps;
- //ZMIENNE ODP ZA WYSWIETLANIE NAPISOW
- const char *text0 = "DOOR";
- const char *text1 = "FROZEN";
- const char *text2 = "WARMING";
- const char *text3 = "GRILL";
- const char *text4 = "BOILING";
- const char *text5 = "SERVICE";
- const char *text;
- const char *p = "NO";
- //ZMIENNE ODPOWIEDZIALNE ZA STEROWANIE MOCA
- int powerMode = 1;
- char timPower, power1, power0;
- int power = 0;
- char powerAdjusting = 1;
- char timeshowing2 = 1;
- void prolog(void)
- {
- L1=L2=L3=L4=L5=0;
- }
- void oblicz(void)
- {
- pK1=aK1; pK2=aK2; pK3=aK3; pK4=aK4;
- pK5=aK5; pK6=aK6; pK7=aK7; pK8=aK8;
- power1 = (int)(power*25)/1000;
- power0 = 5 - power1/1000;
- //OTWARCIE/ZAMKNIECIE DRZWICZEK
- if(!work && !door && pK1) {door = 1; L1=1;
- viewingChosenMode=0; timeMode=0; workMode = 0;}
- else if(!work && door && pK1 && L1 == 1) {door = 0; L1=0;
- viewingChosenMode=1; timeMode=1; powerMode=1; workMode = helpmodevar; }
- //TRYB PRACY MIKROFALOWKI
- //ODMRAZANIE
- //GRZANIE
- //GRILLOWANIE
- //GOTOWANIE
- //CZYSZCZENIE SPRZĘTU
- if(!work)
- {
- switch(chosenMode)
- {
- case 1:
- {
- if(pK2 && door == 0 && workMode >=1 && workMode <=5) chosenMode = 2;
- }
- break;
- case 2:
- {
- if(!pK2 && door == 0 && workMode <=5)
- {
- chosenMode = 1;
- workMode++;
- helpmodevar = workMode;
- if(workMode > 5) {workMode = 1; helpmodevar = 1;}
- }
- }
- break;
- }
- }
- //NAPISY
- if(workMode == 0)text = text0;
- else if(workMode == 1)text = text1;
- else if (workMode == 2)text = text2;
- else if (workMode == 3)text = text3;
- else if (workMode == 4)text = text4;
- else if (workMode == 5)text = text5;
- //WYSWIETLANIE WYBRANEGO TRYBU PRACY MIKROFALOWKI
- switch(viewingChosenMode)
- {
- case 0: L2=0;
- break;
- case 1:
- {
- L2 = 0;
- counterViewingChosenMode = workMode;
- if(counterViewingChosenMode)
- {
- counterBeeps = 2;
- viewingChosenMode = 2;
- }
- else L2 = 1;
- }
- break;
- case 2:
- {
- L2 = 1;
- if(!counterBeeps && counterViewingChosenMode > 1)
- {viewingChosenMode = 3; counterBeeps = 2;
- counterViewingChosenMode--;}
- else if(!counterBeeps && counterViewingChosenMode == 1)
- {viewingChosenMode = 3; counterBeeps = 15;
- counterViewingChosenMode--;}
- }
- break;
- case 3:
- {
- L2 = 0;
- if(!counterBeeps && counterViewingChosenMode)
- {viewingChosenMode = 2; counterBeeps = 2;}
- else if(!counterBeeps && !counterViewingChosenMode)
- viewingChosenMode = 1;
- }
- break;
- }
- //USTAWIENIA CZASU
- switch(timeMode)
- {
- case 1:
- if(aK6 && timTime>0) {timTime=timTime-10;}
- else if(aK6 && timTime==0);
- else if(aK7 && timTime<3000) {timTime=timTime+10;}
- else if(aK7 && timTime==3000);
- break;
- }
- //USTAWIENIE SYGNALIZACJI DIOD DLA CZASU
- switch(timeViewMode)
- {
- case 1:
- {
- if(pK6 && door == 0) {timeViewMode = 2; L6=1;}
- else if(pK7 && door == 0) {timeViewMode = 3; L7=1;}
- }
- break;
- case 2:
- {
- if(!pK6 && work == 0)
- {
- timeViewMode = 1;
- L6=0;
- }
- else if(work == 1) L6=1;
- }
- break;
- case 3:
- {
- if(!pK7 && work == 0)
- {
- timeViewMode = 1;
- L7=0;
- }
- else if(work == 1) L7=1;
- }
- break;
- }
- //ZMIANA MOCY MIKROFALOWKI
- switch(powerAdjusting)
- {
- case 1:
- {
- if(pK4) powerAdjusting = 2;
- else if(pK3) powerAdjusting = 3;
- }
- break;
- case 2:
- {
- if(!pK4 && L5 == 0)
- {
- powerAdjusting = 1;
- power+=100.00;
- if(power>1000) power = 0;
- }
- }
- break;
- case 3:
- {
- if(!pK3 && L5 == 0)
- {
- powerAdjusting = 1;
- power-=100.00;
- if(power<0) power = 0;
- }
- }
- break;
- }
- // USTAWIENIE MOCY
- // WSPOLCZYNNIK WYPELNIENIA
- switch(powerMode)
- {
- case 1:
- {
- L4 = 0; L3=0;
- timPower = power1;
- if(power) powerMode = 2;
- else powerMode = 4;
- }
- break;
- case 2:
- {
- L4 = 1; L3 = 1;
- if(!timPower && power < 1000.00)
- {powerMode = 3; timPower = power0;}
- else if(!power) powerMode = 4;
- }
- break;
- case 3:
- {
- L4 = 0; L3 = 0;
- if(!timPower && power > 0)
- {powerMode = 2; timPower = power1;}
- else if(!power) powerMode = 5;
- }
- break;
- case 4:
- {
- L4 = 0; L3 = 0;
- if(power) {powerMode = 3; timPower = power0;}
- else powerMode = 5;
- }
- break;
- case 5:
- {
- L4 = 1; L3 = 1;
- if(power) {powerMode = 3; timPower = power0;}
- else powerMode = 4;
- }
- break;
- }
- //PRACA MIKROFALOWKI
- if(door == 0 && pK5 && work==0 && timTime > 0 && power != 0)
- {work=1; door = 0;
- timeMode=0; p="ON"; L5=1; L6=1; L7=1;}
- else if( pK5 && work==1)
- {L5 = 0; work=0; viewingChosenMode=1; timeMode=1;
- powerMode=1; p="P"; L6=0; L7=0;}
- else if( timTime == 0 && work==1)
- {L5 = 0; work=0; viewingChosenMode=1; timeMode=1;
- powerMode=1; power=0; workMode=1; p="NO"; L6=0; L7=0;}
- if(counterBeeps) --counterBeeps;
- if(timTime && work) --timTime;
- if(timPower) --timPower;
- sprintf(buf,"Time:%d Power:%d ",
- (int)timTime/10, (int)power);
- LCD_xy(1,1); LCD_puts(buf);
- sprintf(buf,"Mode:0%d %s %s ",
- (int)workMode, text, p);
- LCD_xy(1,2); LCD_puts(buf);
- }
- void przerwanie(void)
- {
- }
- void komunikacja(void)
- {}
- #ifdef Symulator_PC
- void wykres(void)
- {
- aTab[0] = (int)(AI[0]/10.0);
- aTab[1] = (int)(AI[1]/5.0);
- aTab[2] = AI[7];
- aTab[3] = (int)(licz/100.0);
- aTab[4] = AO[0];
- aTab[5] = AO[7];
- aTab[6] = -120;
- aTab[7] = 120;
- bTab[0] = (int)aK1;
- bTab[1] = (int)aK2;
- bTab[2] = (int)aK3;
- bTab[3] = (int)aK4;
- bTab[4] = (int)L1;
- bTab[5] = (int)L2;
- bTab[6] = (int)L3;
- bTab[7] = (int)L4;
- bTab[8] = (int)L5;
- bTab[9] = (int)L6;
- bTab[10] = (int)L7;
- //bTab[11] = 11;
- bTab[12] = 12;
- bTab[13] = 13;
- bTab[14] = 14;
- bTab[15] = 15;
- }
- #endif
Add Comment
Please, Sign In to add comment