SHARE
TWEET

kskks

pabloducato Apr 17th, 2019 110 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  11. #define Z1 Y1
  12. #define Z2 Y2
  13. #define Z3 Y3
  14. #define Z4 Y4
  15. #define Z5 Y5
  16. #define M  Y6
  17. #define G1 Y7
  18.  
  19. // --- Zmienne użytkownika ---
  20. int licz=0;                 // Licznik przerwań
  21.  
  22. //TIMERY
  23. char counterBeeps, counterTimer = 0, TSP;
  24. int timTime = 0;
  25.  
  26. //ZMIENNE ODPOWIEDZIALNE ZA OTWARCIE/ZAMKNIECIE DRZWICZEK
  27.  
  28. char door = 0, workMode = 1, pause = 0;
  29. char work = 0;
  30.  
  31.  
  32. char chosenMode = 1;
  33. char viewingChosenMode = 1;
  34. char counterViewingChosenMode;
  35. char timeMode = 1;
  36. char viewingTime = 1;
  37. char timeShowingMode = 1;
  38. char counterTimerBeeps;
  39. unsigned char tmpMiuntes;
  40. unsigned char tmpSecondsD;
  41. unsigned char tmpSecondsJ;
  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=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*20);
  72. power0 = 20 - power1;
  73.  
  74.  
  75. //OTWARCIE/ZAMKNIECIE DRZWICZEK
  76. if(!work && !door && pK1) {door = 1; L1=1;
  77. viewingChosenMode=0; timeMode=0; powerMode=0; workMode = 0; }
  78. else if(!work && door && pK1) {door = 0; L1=0;
  79. viewingChosenMode=1; timeMode=1; powerMode=1; workMode = 1;}
  80.  
  81.  
  82. //TRYB PRACY MIKROFALOWKI
  83. //ODMRAZANIE
  84. //GRZANIE
  85. //GRILLOWANIE
  86. //GOTOWANIE
  87. //CZYSZCZENIE SPRZĘTU
  88.  
  89. if(!work)
  90. {
  91.     switch(chosenMode)
  92.     {
  93.         case 1:
  94.         {
  95.             if(pK2) chosenMode = 2;
  96.         }
  97.         break;
  98.         case 2:
  99.         {
  100.             if(!pK2)
  101.             {
  102.                 chosenMode = 1;
  103.                 workMode++;
  104.                 if(workMode > 5) workMode = 1;
  105.             }
  106.            
  107.         }
  108.         break;
  109.     }
  110. }
  111.  
  112. if(workMode == 0)
  113. text = text0;
  114. else if(workMode == 1)
  115. text = text1;
  116. else if (workMode == 2)
  117. text = text2;
  118. else if (workMode == 3)
  119. text = text3;
  120. else if (workMode == 4)
  121. text = text4;
  122. else if (workMode == 5)
  123. text = text5;
  124.  
  125.  
  126. //WYSWIETLANIE WYBRANEGO TRYBU PRACY MIKROFALOWKI
  127.  
  128. switch(viewingChosenMode)
  129.     {
  130.     case 0: L2=0;
  131.     break;
  132.     case 1:
  133.     {
  134.         L2 = 0;
  135.         counterViewingChosenMode = workMode;
  136.         if(counterViewingChosenMode)
  137.         {
  138.             counterBeeps = 2;
  139.             viewingChosenMode = 2;
  140.         }
  141.         else L2 = 1;
  142.     }
  143.         break;
  144.     case 2:
  145.     {
  146.         L2 = 1;
  147.         if(!counterBeeps && counterViewingChosenMode > 1)
  148.         {viewingChosenMode = 3; counterBeeps = 2;
  149.         counterViewingChosenMode--;}
  150.         else if(!counterBeeps && counterViewingChosenMode == 1)
  151.         {viewingChosenMode = 3; counterBeeps = 15;
  152.         counterViewingChosenMode--;}
  153.     }
  154.         break;
  155.     case 3:
  156.     {
  157.         L2 = 0;
  158.         if(!counterBeeps && counterViewingChosenMode)
  159.         {viewingChosenMode = 2; counterBeeps = 2;}
  160.         else if(!counterBeeps && !counterViewingChosenMode)
  161.         viewingChosenMode = 1;
  162.     }
  163.         break;
  164.  }
  165.    
  166. //USTAWIENIA CZASU
  167.  
  168. switch(timeMode)
  169. {
  170.         case 1:
  171.             if(aK6 && timTime>0) {timTime=timTime-10;}
  172.             else if(aK6 && timTime==0);
  173.             else if(aK7 && timTime<3000) {timTime=timTime+10;}
  174.             else if(aK7 && timTime==3000);
  175.             break;
  176. }
  177.  
  178.  //ZMIANA MOCY MIKROFALOWKI
  179.  
  180.  switch(powerAdjusting)
  181.     {
  182.         case 1:
  183.         {
  184.             if(pK4) powerAdjusting = 2;
  185.             else if(pK3) powerAdjusting = 3;
  186.         }
  187.         break;
  188.         case 2:
  189.         {
  190.             if(!pK4 && L5 == 0)
  191.             {
  192.                 powerAdjusting = 1;
  193.                 power+=100.00;
  194.                 if(power>1000) power = 0;
  195.             }      
  196.         }
  197.         break;
  198.         case 3:
  199.         {
  200.             if(!pK3 && L5 == 0)
  201.             {
  202.                 powerAdjusting = 1;
  203.                 power-=100.00;
  204.                 if(power<0) power = 0;
  205.             }
  206.         }
  207.         break;
  208.     }
  209.  
  210.  // USTAWIENIE MOCY
  211.  // WSPOLCZYNNIK WYPELNIENIA
  212.  
  213.  switch(powerMode)
  214.     {
  215.     case 0: L4=0; L3=0;
  216.     break;
  217.     case 1:
  218.     {
  219.         L4 = 0; L3=0;
  220.         timPower = power1;
  221.         if(power) powerMode = 2;
  222.         else powerMode = 4;
  223.     }
  224.         break;
  225.     case 2:
  226.     {
  227.         L4 = 1; L3 = 1;
  228.         if(!timPower && power < 1)
  229.         {powerMode = 3; timPower = power0;}
  230.         else if(!power) powerMode = 4;
  231.     }
  232.         break;
  233.     case 3:
  234.     {
  235.         L4 = 0; L3 = 0;
  236.         if(!timPower && power > 0)
  237.         {powerMode = 2; timPower = power1;}
  238.         else if(!power) powerMode = 5;
  239.     }
  240.         break;
  241.     case 4:
  242.     {
  243.         L4 = 0; L3 = 0;
  244.         if(power) {powerMode = 3; timPower = power0;}
  245.         else powerMode = 5;
  246.     }
  247.     break;
  248.     case 5:
  249.     {
  250.         L4 = 1; L3 = 1;
  251.         if(power) {powerMode = 3; timPower = power0;}
  252.         else powerMode = 4;
  253.     }
  254.     break;
  255.     }
  256.  
  257. if(door == 0 && pK5 && work==0 && timTime > 0 && power != 0)
  258. {L5 = 1; work=1; door = 0; viewingChosenMode=0;
  259. timeMode=0; powerMode=0; p="ON";}
  260. else if(L5 == 1 && timTime%206)
  261. {L5 = 0;}
  262. else if( pK5 && work==1)
  263. {L5 = 0; work=0; viewingChosenMode=1; timeMode=1;
  264. powerMode=1; p="P";}
  265. else if( timTime == 0 && work==1)
  266. {L5 = 0; work=0; viewingChosenMode=1; timeMode=1;
  267. powerMode=1; power=0; p="NO";}
  268.  
  269.    
  270.     if(counterBeeps) --counterBeeps;
  271.     if(timTime && work) --timTime;
  272.     if(timPower) --timPower; //USTAWIENIE MOCY - WSPOLCZYNNIK WYPELNIENIA
  273.    
  274.     sprintf(buf,"Time:%d   Power:%d               ",
  275.     (int)timTime/9, (int)power);
  276.     LCD_xy(1,1); LCD_puts(buf);
  277.     sprintf(buf,"Mode:0%d   %s %s  ",
  278.     (int)workMode, text, p);
  279.     LCD_xy(1,2); LCD_puts(buf);
  280.    
  281. }
  282.  
  283.  
  284. void przerwanie(void)      
  285. {
  286. }
  287.  
  288. void komunikacja(void)     
  289. {}
  290.  
  291. #ifdef Symulator_PC
  292. void wykres(void)          
  293. {
  294.     aTab[0] = (int)(AI[0]/10.0);
  295.     aTab[1] = (int)(AI[1]/5.0);
  296.     aTab[2] = AI[7];
  297.     aTab[3] = (int)(licz/100.0);
  298.     aTab[4] = AO[0];
  299.     aTab[5] = AO[7];
  300.     aTab[6] = -120;
  301.     aTab[7] =  120;
  302.  
  303.     bTab[0] = (int)aK1;
  304.     bTab[1] = (int)aK2;
  305.     bTab[2] = (int)aK3;
  306.     bTab[3] = (int)aK4;
  307.     bTab[4] = (int)L1;
  308.     bTab[5] = (int)L2;
  309.     bTab[6] = (int)L3;
  310.     bTab[7] = (int)L4;
  311.     bTab[8] = (int)L5;
  312.     bTab[9] = G1;
  313.     bTab[10] = M;
  314.     bTab[11] = 11;
  315.     bTab[12] = 12;
  316.     bTab[13] = 13;
  317.     bTab[14] = 14;
  318.     bTab[15] = 15;
  319. }
  320. #endif
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top