Go Down

Topic: Cant fix this error (Read 93 times) previous topic - next topic

IcyBlade

hey so I'm following a tutorial but I'm constantly getting new errors so far I've been able to fix them but i can't get past this now any help is appreciated.

Code:
Code: [Select]
void DisplayStyle1 () {

  //--------------------------------------- Display Background ----------------------------------------------------

  /* OLED Background */
  display.setTextSize(2); //set background txt font size
  display.setCursor(1, 12);
  display.println("CPU");
  display.setCursor(1, 38);
  display.println("GPU");
  display.setTextSize(1); //set background txt font size
  display.setCursor(1, 56);
  display.println("SYSRAM");


  //display.display();
  //oledDraw = 1;

  /*CPU/GPU/RAM  Clearing Boxes, eg: display.fillRect(<X>, ^Y^, W, H, Color);*/
  display.fillRect(38, 11, 90, 16, BLACK); // fill CPU live stats section only
  display.fillRect(38, 37, 90, 16, BLACK); // fill GPU live stats section only
  display.fillRect(38, 54, 36, 10, BLACK); // fill RAM live stats section only
  /* Position Test*/
  //display.drawRect(38, 11, 90, 16, WHITE); // fill CPU live stats section only
  //display.drawRect(38, 37, 90, 16, WHITE); // fill GPU live stats section only
  //display.drawRect(38, 54, 36, 10, WHITE); // fill RAM live stats section only
  //display.drawRect(68, 54, 58, 10, WHITE); // Flash bottom right corner when updating

  //---------------------------------------CPU & GPU Hardware ID----------------------------------------------------

  /*CPU & GPU Hardware ID*/

  /*CPU Manual Position Test*/
  //display.setTextSize(0);
  //display.setCursor(-35, 1);// Negative spacing so, CPU ID doesn't cause a rollover, on the next line
  //String cpuName = "Intel Core i7-5820K"; // Name spacing test

  display.setTextSize(0); // string font size
  String cpuName = "";
  display.println(cpuName);

  /* GPU Manual Position Test*/
  //display.setTextSize(0);
  //display.setCursor(-42, 28); // Negative spacing so, GPU ID doesn't cause a rollover, on the next line
  //String gpuName = "Nvidia GeForce GTX 1080"; // Name spacing test

  display.setTextSize(0); // string font size
  String gpuName = "";
  display.println(gpuName);

  if (inputString.indexOf("CPU") > -1)
  {
    String cpuName = "";
    display.setTextSize(1);
    display.setCursor(0, 1);
    //display.setCursor(-35, 1);

    int cpuNameStart = inputString.indexOf("CPU:");
    if (inputString.indexOf("Intel", cpuNameStart) > -1) {
      cpuNameStart = cpuNameStart + 10;
    }
    else {
      cpuNameStart = cpuNameStart + 8;
    }
    if (inputString.indexOf("GPU") > -1)
    {
      cpuName = inputString.substring(cpuNameStart, inputString.indexOf("GPU:"));
    }
    else
      cpuName = inputString.substring(cpuNameStart);
    display.println(cpuName);

  }
  if (inputString.indexOf("GPU") > -1)
  {
    display.setTextSize(0);

    display.setCursor(0, 28);
    //display.setCursor(-41, 28); // Negative spacing so, Nvidia doesn't cause a rollover, on the next line
    int gpuNameStart = inputString.indexOf("GPU:");
    if (inputString.indexOf("NVIDIA", gpuNameStart) > -1) {
      gpuNameStart = gpuNameStart + 11;
    }
    else {
      gpuNameStart = gpuNameStart + 8;
    }


    int gpuNameEnd = inputString.indexOf("|", gpuNameStart);
    String gpuName = inputString.substring(gpuNameStart, gpuNameEnd);
    display.println(gpuName);
  }

  //------------------------------------------ CPU Load/Temp -------------------------------------------------

  /*CPU Display String*/
  int cpuStringStart = inputString.indexOf("C");
  int cpuDegree = inputString.indexOf("c");
  int cpuStringLimit = inputString.indexOf("|");
  String cpuString1 = inputString.substring(cpuStringStart + 1, cpuDegree);
  String cpuString2 = inputString.substring(cpuDegree + 1, cpuStringLimit - 1);

  /*CPU TEMPERATURE*/
  display.setTextSize(2);
  display.setCursor(42, 12);
  display.print(cpuString1);
  display.setTextSize(1);
 
  #ifdef noDegree
display.print("C");       // Centigrade Symbol
#else
display.print((char)247); //Degrees Symbol
display.print("C");       // Centigrade Symbol
#endif

  /*CPU LOAD, ALL CORES*/
  display.setTextSize(2);
  display.print(cpuString2);
  display.setTextSize(1);
  display.println("%");    // Small Percent Symbol



  //------------------------------------------ GPU Load/Temp -------------------------------------------------

  /*GPU Display String*/
  int gpuStringStart = inputString.indexOf("G", cpuStringLimit);
  int gpuDegree = inputString.indexOf("c", gpuStringStart);
  int gpuStringLimit = inputString.indexOf("|", gpuStringStart);
  String gpuString1 = inputString.substring(gpuStringStart + 1, gpuDegree);
  String gpuString2 = inputString.substring(gpuDegree + 1, gpuStringLimit - 1);

  /*GPU TEMPERATURE*/
  display.setTextSize(2);
  display.setCursor(42, 38);
  display.print(gpuString1);
  display.setTextSize(1);
 
 #ifdef noDegree
display.print("C");       // Centigrade Symbol
#else
display.print((char)247); //Degrees Symbol
display.print("C");       // Centigrade Symbol
#endif

  /*GPU LOAD*/
  display.setTextSize(2);
  display.print(gpuString2);
  display.setTextSize(1);
  display.println("%");      // Small Percent Symbol


  //----------------------------------------SYSTEM RAM USAGE---------------------------------------------------

  /*SYSTEM RAM String*/
  int ramStringStart = inputString.indexOf("R", gpuStringLimit);
  int ramStringLimit = inputString.indexOf("|", ramStringStart);
  String ramString = inputString.substring(ramStringStart + 1 , ramStringLimit);


  /*RAM USAGE*/
  display.setTextSize(1); //set background txt font size
  display.setCursor(42, 56);
  display.println(ramString);

 
  display.setTextSize(1);
  display.setCursor(115, 1);
  display.println("D1");
  display.display();

  oledDraw = 1;

}




Errors:
Code: [Select]
Arduino: 1.8.5 (Windows 10), Board: "Arduino Nano, ATmega328P (Old Bootloader)"

C:\Users\Alex\AppData\Local\Temp\Temp2_GnatStats Release v1.2.zip\GnatStats Release v1.2\Arduino_GNAT_STATS_OLED_V1.2\DisplayStyle1\DisplayStyle1.ino: In function 'void DisplayStyle1()':

DisplayStyle1:12: error: 'display' was not declared in this scope

   display.setTextSize(2); //set background txt font size

   ^

DisplayStyle1:26: error: 'BLACK' was not declared in this scope

   display.fillRect(38, 11, 90, 16, BLACK); // fill CPU live stats section only

                                    ^

DisplayStyle1:57: error: 'inputString' was not declared in this scope

   if (inputString.indexOf("CPU") > -1)

       ^

DisplayStyle1:80: error: 'inputString' was not declared in this scope

   if (inputString.indexOf("GPU") > -1)

       ^

DisplayStyle1:103: error: 'inputString' was not declared in this scope

   int cpuStringStart = inputString.indexOf("C");

                        ^

DisplayStyle1:178: error: 'oledDraw' was not declared in this scope

   oledDraw = 1;

   ^

exit status 1
'display' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

DKWatson

You have not posted your complete code. What you have posted, and from the error messages, suggest the whatever library exposes the class display is missing.
Live as if you were to die tomorrow. Learn as if you were to live forever. - Mahatma Gandhi

UKHeliBob

Code: [Select]

'display' was not declared in this scope


So where is it declared in your program, if at all ?
It looks like it should be an instance of an object that displays text/graphics.  Which library are you using ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Go Up