Advertisement
Guest User

Class Alarm

a guest
Jul 13th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.08 KB | None | 0 0
  1. class Alarm
  2. {
  3.     public:
  4.         void TestRelay();
  5.         void ShowDateMenu();
  6.         void ShowTimeMenu();
  7.         void MoveDTCursor(int move);
  8.         void BlinkTargetCursor();
  9.         void HideDTMenu();
  10. };
  11. void Alarm::TestRelay()
  12. {
  13.     Serial.println("RelayTest_Start");
  14.    
  15.     digitalWrite(RELAI1, LOW);
  16.     delay(1000);
  17.     digitalWrite(RELAI1, HIGH);
  18.    
  19.     digitalWrite(RELAI2, LOW);
  20.     delay(1000);
  21.     digitalWrite(RELAI2, HIGH);
  22.    
  23.     menuStatus = NONE;
  24.     Serial.println("RelayTest_Stop");
  25. }
  26.  
  27. void Alarm::ShowDateMenu()
  28. {
  29.     DTCursorEnabled = true;
  30.     DTMode = 1;
  31.     DTCursorPos = 1;
  32.     ResetScreen();
  33.     BlinkTargetCursor();
  34. }
  35. void Alarm::ShowTimeMenu()
  36. {
  37.     DTCursorEnabled = true;
  38.     DTMode = 2;
  39.     DTCursorPos = 1;
  40.     DTBlinkStatus = false;
  41.     ResetScreen();
  42.     BlinkTargetCursor();
  43. }
  44.  
  45. void Alarm::MoveDTCursor(int move)
  46. {
  47.     DTCursorPos += move;
  48.     if(DTCursorPos == 1 && move < 0)
  49.         DTCursorPos = 3;
  50.     else if(DTCursorPos == 3 && move > 0)
  51.         DTCursorPos = 0;
  52. }
  53.  
  54. void Alarm::BlinkTargetCursor()
  55. {
  56.     if(!DTCursorEnabled) return;
  57.    
  58.     switch(DTCursorPos)
  59.     {
  60.         case 1: // Heure ou jour
  61.         {
  62.             if(!DTBlinkStatus)
  63.             {
  64.                 screen.ClearCharacter(3, 0);
  65.                 screen.ClearCharacter(3, 1*8);
  66.                 DTBlinkStatus = false;
  67.             }
  68.             else
  69.             {
  70.                 if(DTMode == 1)
  71.                 {
  72.                     if(DTValues.year < 10)
  73.                     {
  74.                         screen.SendString("0", 3);
  75.                         screen.SendInt(DTValues.year, 3, 1*8);
  76.                     }
  77.                     else
  78.                         screen.SendInt(DTValues.year, 3);
  79.                 }
  80.                 else
  81.                 {
  82.                     if(DTValues.hour < 10)
  83.                     {
  84.                         screen.SendString("0", 3);
  85.                         screen.SendInt(DTValues.hour, 3, 1*8);
  86.                     }
  87.                     else
  88.                         screen.SendInt(DTValues.hour, 3);
  89.                 }
  90.                 DTBlinkStatus = true;
  91.             }
  92.             break;
  93.         }
  94.         case 2: // Minute ou mois
  95.         {
  96.             if(!DTBlinkStatus)
  97.             {
  98.                 screen.ClearCharacter(3, 3*8);
  99.                 screen.ClearCharacter(3, 4*8);
  100.                 DTBlinkStatus = false;
  101.             }
  102.             else
  103.             {
  104.                 if(DTMode == 1)
  105.                 {
  106.                     if(DTValues.month < 10)
  107.                     {
  108.                         screen.SendString("0", 3, 3*8);
  109.                         screen.SendInt(DTValues.month, 3, 4*8);
  110.                     }
  111.                     else
  112.                         screen.SendInt(DTValues.month, 3, 3*8);
  113.                 }
  114.                 else
  115.                 {
  116.                     if(DTValues.minute < 10)
  117.                     {
  118.                         screen.SendString("0", 3);
  119.                         screen.SendInt(DTValues.minute, 3, 1*8);
  120.                     }
  121.                     else
  122.                         screen.SendInt(DTValues.minute, 3);
  123.                 }
  124.                 DTBlinkStatus = true;
  125.             }
  126.             break;
  127.         }
  128.         case 3: // Seconde ou annĂ©e
  129.         {
  130.             if(!DTBlinkStatus)
  131.             {
  132.                 screen.ClearCharacter(3, 6*8);
  133.                 screen.ClearCharacter(3, 7*8);
  134.                 DTBlinkStatus = false;
  135.             }
  136.             else
  137.             {
  138.                 if(DTMode == 1)
  139.                 {
  140.                     if(DTValues.day < 10)
  141.                     {
  142.                         screen.SendString("0", 3, 6*8);
  143.                         screen.SendInt(DTValues.day, 3, 7*8);
  144.                     }
  145.                     else
  146.                         screen.SendInt(DTValues.day, 3, 6*8);
  147.                 }
  148.                 else
  149.                 {
  150.                     if(DTValues.day < 10)
  151.                     {
  152.                         screen.SendString("0", 3);
  153.                         screen.SendInt(DTValues.day, 3, 1*8);
  154.                     }
  155.                     else
  156.                         screen.SendInt(DTValues.day, 3);
  157.                 }
  158.                 DTBlinkStatus = true;
  159.             }
  160.             break;
  161.         }
  162.         default:
  163.         {
  164.             screen.SendString("Erreur", 3);
  165.             break;
  166.         }
  167.     }
  168. }
  169.  
  170. void Alarm::HideDTMenu()
  171. {
  172.     DTCursorEnabled = false;
  173.     ResetScreen();
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement