I have trouble changing the chart sequence number, please help, how to calculate this math, I tried it was not good.
this is the code that I use
Code: Select all
void LedgrphScreen()//------------------------------------------------------------ tela =61
{
  int x, y, z, grafico;
  int16_t n;
  char buf[8];
  float temperatura;
  int j = 0;
  int i = 0;
  int k = 0;
  float soma = 0.0f; // Soma dos valores de todos os elementos
  float media = 0.0f; // Média dos valores
  float linhaR;
  int f = 30;
  strcpy_P(buffer, (char*)pgm_read_word_near(&(tabela_textos[51])));
  printHeader("TEMP.LED GRAPHIC"); // "TEMP.WATER GRAPHIC"; // tabela_textos[51]
  setFont(SMALL, 255, 255, 255, 0, 0, 0);
  myGLCD.print("TEMP. LED NOW :", 5, 220);
  for (float i = 47; i > 25.0; i -= 2)
  {
    myGLCD.printNumF(i, 1, 5, 3 + f);
    f += 15;
  }
  f = 255;
  for (int i = 22; i > 0; i -= 2)
  {
    myGLCD.printNumI(i, f, 193);
    f -= 20;
  }
  myGLCD.print("0", 275, 193);
  myGLCD.drawCircle(15, 21, 2);
  myGLCD.print("C", 20, 18);
  myGLCD.print("H", 290, 193);
  myGLCD.drawLine(40, 30, 40, 190); // Eixo y
  myGLCD.drawLine(40, 190, 290, 190);  // Eixo x
  myGLCD.setColor(64, 64, 64);  // Malha
  //EIXO X
  for (int k = 30; k < 190; k += 7)
  {
    myGLCD.drawLine(40, k, 290, k);
  }
  //EIXO Y
  for (int l = 60; l < 300; l += 20)
  {
    myGLCD.drawLine(l, 30, l, 190);
  }
  linhaR = tempH;  //  Linhas de comparação
  if ((linhaR >= 27) && (linhaR <= 47))
  {
    x = (190 - ((linhaR - 27) * 10));
  }
  else if (linhaR > 47)
  {
    x = 30;
  }
  else if (linhaR < 27)
  {
    x = 190;
  }
  myGLCD.setColor(255, 0, 0);
  myGLCD.drawLine(40, x, 290, x);// Temperatura desejada
  strcpy_P(buffer, (char*)pgm_read_word_near(&(tabela_textos[11])));
  printButton(buffer, iniC[0], iniC[1], iniC[2], iniC[3], false, 4);
  strcpy_P(buffer, (char*)pgm_read_word_near(&(tabela_textos[1])));
  printButton(buffer, menU[0], menU[1], menU[2], menU[3]);
  strcpy_P(buffer, (char*)pgm_read_word_near(&(tabela_textos[66])));
  printButton(buffer, prOK[0], prOK[1], prOK[2], prOK[3]);
  setFont(SMALL, 255, 255, 0, 0, 0, 0);
  myGLCD.printNumF(tempH, 2, 135, 220);  // LED
  int d = 41 + (NumMins(t.hour, t.min) / 6);
  myGLCD.drawLine(d, 30, d, 190); // Linha de marcação do horário.
  myGLCD.print(rtc.getTimeStr(FORMAT_SHORT), d + 2, 75, 270);
  selecionar_SPI(SD_CARD);
  if (file.open("LOGTLED.TXT", O_READ))
  {
    while ((n = file.read(buf, sizeof(buf))) > 0)
    {
      temperatura = atof(buf);
      soma += temperatura;
      if (strlen(buf) == 5)
      {
        i++;
        k++;
      }
      if (temperatura <= 2 )
      {
        k -= 1;
      }
      if (i == 6)
      {
        media = soma / k;
        i = 0;
        j++;
        soma = 0;
        k = 0;
        if ((media) > 47)
        {
          grafico = 30;
        }
        else if ((media >= 27) && (media <= 47))
        {
          grafico = (190 - ((media - 27) * 10));
        }
        else
        {
          grafico = 190;
        }
        setFont(SMALL, 204, 32, 255, 0, 0, 0);
        if (j < 250)
        {
          myGLCD.drawPixel((40 + j), grafico);
          myGLCD.drawPixel((40 + j), (1 + grafico));
          myGLCD.drawPixel((41 + j), grafico);
          myGLCD.drawPixel((41 + j), (1 + grafico));
        }
      }
    }
    file.close();
  }
}result images this code

thanks

                            
                        
                            
                        