Advertisement
RuiViana

AcertaHora

Jan 27th, 2017
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.21 KB | None | 0 0
  1. void acertartc()
  2. // COMANDO PARA ACERTAR A DATA E A HORA.
  3. //Ano: two-digit, from 00 to 99
  4. //Mes: two-digit, from 01 to 12
  5. //Dai do mes, from 01 to 31
  6. //Dia da semana, from 1 (domingo) to 7 (sabado)
  7. //Hora: 24-hour format, from 0 to 23
  8. //Minuto: from 0 to 59
  9. //Second: from 0 to 59
  10. {
  11.   wdt_disable(); // DESABILITA A FUNÇÃO WDT NESTA PARTE DO PROGRAMA.
  12.   delay(1000);
  13.   while ( i > 0 && i < 8)
  14.  
  15.   {
  16.  
  17.     lcd.setCursor(0, 0);
  18.     LerTecla();
  19.     if (i == 1) {
  20.       lcd.print(" Entre com Ano  ");
  21.     }
  22.     if (i == 2) {
  23.       lcd.print(" Entre com Mes  ");
  24.     }
  25.     if (i == 3) {
  26.       lcd.print(" Entre com Dia  ");
  27.     }
  28.     if (i == 4) {
  29.       lcd.print(" Entre cm Semana");
  30.     }
  31.     if (i == 5) {
  32.       lcd.print(" Entre com Hora ");
  33.     }
  34.     if (i == 6) {
  35.       lcd.print(" Entre com Minut");
  36.     }
  37.     if (i == 7) {
  38.       lcd.print(" Entre com Segun");
  39.     }
  40.     if (UP) {
  41.       acertahora[i]++;  //alteração custela
  42.       estouro = 0;
  43.       UP = 0;
  44.     }
  45.     if (DOWN && acertahora[i] >= 0) {
  46.       acertahora[i]--;  //alteração custela
  47.       estouro = 0;
  48.       DOWN = 0;
  49.     }
  50.     if (SELECT) {
  51.       i ++; estouro = 0; SELECT = 0;
  52.       delay(200);
  53.     } //alteração custela
  54.  
  55.     if (acertahora[1] < 1 ) {
  56.       acertahora[1] = 13;
  57.     }
  58.     if (acertahora[2] > 12) {
  59.       acertahora[2] = 1;
  60.     }
  61.     if (acertahora[2] == 0) {
  62.       acertahora[2] = 12;
  63.     }
  64.     if (acertahora[3] > 31) {
  65.       acertahora[3] = 1;
  66.     }
  67.     if (acertahora[3] == 0) {
  68.       acertahora[3] = 31;
  69.     }
  70.     // 1 domigo 2 segunda 3 terca 4 quarta 5 quinta 6 sexta 7 sabado
  71.     if (acertahora[4] > 7) {
  72.       acertahora[4] = 1;
  73.     }
  74.     if (acertahora[4] == 0) {
  75.       acertahora[4] = 7;
  76.     }
  77.  
  78.     if (acertahora[5] > 23) {
  79.       acertahora[5] = 0;
  80.     }
  81.     if (acertahora[5] == -1) {
  82.       acertahora[5] = 23;
  83.     }
  84.     if (acertahora[6] > 59) {
  85.       acertahora[6] = 0;
  86.     }
  87.     if (acertahora[6] == -1) {
  88.       acertahora[6] = 59;
  89.     }
  90.     if (acertahora[7] > 59) {
  91.       acertahora[7] = 0;
  92.     }
  93.     if (acertahora[7] == -1) {
  94.       acertahora[7] = 59;
  95.     }
  96.     if (acertahora[i] == 4) MostraDia();              /// <  <   <   modifiquei
  97.    
  98.     lcd.setCursor(9, 1);
  99.     lcd.print(acertahora[i], DEC); lcd.print("  ");
  100.    
  101.    
  102.     if (estouro == 90) {
  103.       i = 0 ;
  104.       estouro = 0;
  105.     }
  106.     lcd.clear();
  107.  
  108.   }
  109.  
  110.   DS1307.setDate(acertahora[1], acertahora[2], acertahora[3], acertahora[4], acertahora[5], acertahora[6], acertahora[7]);
  111.   // AQUI ENVIAMOS OS DADOS DEFINIDOS PARA O REAL TIME CLOK
  112.   lcd.clear();
  113.  
  114. }
  115. Quero incluir essse case para quando eu selecionar o acertahora[4] mostre
  116.   //----------------------------------------------
  117. void MostraDia()                  /// <  <   <   modifiquei
  118. {                                 /// <  <   <   modifiquei
  119.   switch (acertahora[4])
  120.   {
  121.     case 1: lcd.print("Dom");
  122.       break;
  123.     case 2: lcd.print("Seg");
  124.       break;
  125.     case 3: lcd.print("Ter");
  126.       break;
  127.     case 4: lcd.print("Quar");
  128.       break;
  129.     case 5: lcd.print("Qui");
  130.       break;
  131.     case 6: lcd.print("Sex");
  132.       break;
  133.     case 7: lcd.print("Sab");
  134.   }
  135. }                                   /// <  <   <   modifiquei
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement