Verified Commit 175bb234 authored by Vinod Mishra's avatar Vinod Mishra
Browse files

Add a 4th display file based on HWInfo Stats. Remove a lot of global variables to save memory

parent 2a86b226
......@@ -26,28 +26,26 @@ void DisplayStyle1() {
display.println("");
display.setTextSize(1);
display.setCursor(0, 1);
display.println(data.CpuName);
display.println(getCpuName());
display.setTextSize(0);
display.setCursor(0, 28);
display.println(data.GpuName);
display.println(getGpuName());
//------------------------------------------ CPU Load/Temp -------------------------------------------------
/*CPU TEMPERATURE*/
display.setTextSize(2);
display.setCursor(42, 12);
display.print(data.CpuTemperature);
display.print(getValue("CT"));
display.setTextSize(1);
#ifdef noDegree
display.print("C"); // Centigrade Symbol
#else
#ifndef noDegree
display.print((char)247); //Degrees Symbol
display.print("C"); // Centigrade Symbol
#endif
display.print("C "); // Centigrade Symbol
/*CPU LOAD, ALL CORES*/
display.setTextSize(2);
display.print(" " + data.CpuLoad);
display.print(" " + getValue("CL"));
display.setTextSize(1);
display.println("%"); // Small Percent Symbol
......@@ -56,19 +54,17 @@ void DisplayStyle1() {
/*GPU TEMPERATURE*/
display.setTextSize(2);
display.setCursor(42, 38);
display.print(data.GpuTemperature);
display.print(getValue("GT"));
display.setTextSize(1);
#ifdef noDegree
display.print("C"); // Centigrade Symbol
#else
#ifndef noDegree
display.print((char)247); //Degrees Symbol
display.print("C"); // Centigrade Symbol
#endif
display.print("C "); // Centigrade Symbol
/*GPU LOAD*/
display.setTextSize(2);
display.print(" " + data.GpuLoad);
display.print(" " + getValue("GL"));
display.setTextSize(1);
display.println("%"); // Small Percent Symbol
......@@ -77,7 +73,7 @@ void DisplayStyle1() {
/*RAM USAGE*/
display.setTextSize(1); //set background txt font size
display.setCursor(42, 56);
display.print(data.RamUsed + "GB");
display.print(getValue("RU") + "GB");
display.fillRect(118, 0, 10, 10, BLACK);
......
......@@ -24,17 +24,17 @@ void DisplayStyle2() {
display.println("");
display.setTextSize(1);
display.setCursor(0, 1);
display.println(data.CpuName);
display.println(getCpuName());
display.setTextSize(0);
display.setCursor(0, 28);
display.println(data.GpuName);
display.println(getGpuName());
//------------------------------------------ CPU Freq -------------------------------------------------
/*CPU Core Freq*/
display.setTextSize(2);
display.setCursor(42, 12);
display.print(data.CpuClock);
display.print(getValue("CC"));
display.setTextSize(1);
display.print("MHz");
......@@ -42,14 +42,12 @@ void DisplayStyle2() {
/*CPU TEMPERATURE*/
display.setTextSize(1);
display.setCursor(105, 22);
display.print(data.CpuTemperature);
display.print(getValue("CT"));
display.setTextSize(1);
#ifdef noDegree
display.print("C"); // Centigrade Symbol
#else
#ifndef noDegree
display.print((char)247); //Degrees Symbol
display.print("C"); // Centigrade Symbol
#endif
display.print("C "); // Centigrade Symbol
//------------------------------------------ GPU Freq/Temp -------------------------------------------------
......@@ -58,30 +56,28 @@ void DisplayStyle2() {
display.setTextSize(1);
display.setCursor(42, 38);
display.print("Core :");
display.print(data.GpuCoreClock);
display.print(getValue("GCC"));
display.setTextSize(1);
display.print("MHz"); // Centigrade Symbol
display.setCursor(42, 46);
display.print("VRAM :");
display.print(data.GpuMemoryClock);
display.print(getValue("GMC"));
display.print("MHz");
display.setCursor(42, 54);
display.print("Shader:");
display.print(data.GpuShaderClock);
display.print(getValue("GSC"));
display.print("MHz");
/*GPU TEMPERATURE*/
display.setTextSize(1);
display.setCursor(1, 56);
display.print(data.GpuTemperature);
display.print(getValue("GT"));
display.setTextSize(1);
#ifdef noDegree
display.print("C"); // Centigrade Symbol
#else
#ifndef noDegree
display.print((char)247); //Degrees Symbol
display.print("C"); // Centigrade Symbol
#endif
display.print("C "); // Centigrade Symbol
display.fillRect(118, 0, 10, 10, BLACK);
......
......@@ -24,17 +24,17 @@ void DisplayStyle3() {
display.println("");
display.setTextSize(1);
display.setCursor(0, 1);
display.println(data.CpuName);
display.println(getCpuName());
display.setTextSize(0);
display.setCursor(0, 28);
display.println(data.GpuName);
display.println(getGpuName());
//------------------------------------------ CPU Freq -------------------------------------------------
/*CPU Freq Display*/
display.setTextSize(2);
display.setCursor(42, 12);
display.print(data.CpuClock);
display.print(getValue("CC"));
display.setTextSize(1);
display.print("MHz");
......@@ -43,14 +43,12 @@ void DisplayStyle3() {
/*CPU Temp Display*/
display.setTextSize(1);
display.setCursor(105, 22);
display.print(data.CpuTemperature);
display.print(getValue("CT"));
display.setTextSize(1);
#ifdef noDegree
display.print("C"); // Centigrade Symbol
#else
#ifndef noDegree
display.print((char)247); //Degrees Symbol
display.print("C"); // Centigrade Symbol
#endif
display.print("C "); // Centigrade Symbol
//------------------------------------------ GPU Freq/Temp -------------------------------------------------
......@@ -59,28 +57,26 @@ void DisplayStyle3() {
/*GPU Core Freq Display*/
display.setTextSize(2);
display.setCursor(42, 38);
display.print(data.GpuCoreClock);
display.print(getValue("GCC"));
display.setTextSize(1);
display.print("MHz");
/*GPU VRAM Freq Display*/
display.setCursor(1, 56);
display.print("VRAM: ");
display.print(data.GpuMemoryClock);
display.print(getValue("GMC"));
display.print("MHz");
/*GPU Core Temp Display*/
display.setTextSize(1);
display.setCursor(105, 48);
display.print(data.GpuTemperature);
display.print(getValue("GT"));
display.setTextSize(1);
#ifdef noDegree
display.print("C"); // Centigrade Symbol
#else
#ifndef noDegree
display.print((char)247); //Degrees Symbol
display.print("C"); // Centigrade Symbol
#endif
display.print("C "); // Centigrade Symbol
display.fillRect(118, 0, 10, 10, BLACK);
......
/*----------------------------------------------------------------------------------
DISPLAY STYLE 4
----------------------------------------------------------------------------------*/
void DisplayStyle4() {
//-------------------------------------------Clearing Box ----------------------------------------------------
//Clearing Boxes, eg: display.fillRect(<X>, ^Y^, W, H, Color);*/
display.fillRect(0, 0, 128, 64, BLACK); // Clear entire screen
//--------------------------------------- Display Background ----------------------------------------------------
/* OLED Background */
display.setTextSize(1);
display.setCursor(0, 1);
display.println("WATER");
display.setCursor(45, 1);
display.println("VRM");
display.setCursor(87, 1);
display.println("MB");
display.setCursor(0, 30);
display.println("OS DRIVE: ");
display.setCursor(55, 30);
display.print(getValue("OSDT"));
#ifndef noDegree
display.print((char)247); //Degrees Symbol
#endif
display.print("C "); // Centigrade Symbol
display.setCursor(0, 38);
display.println("INTAKE: ");
display.setCursor(0, 46);
display.println("EXHAUST: ");
display.setCursor(1, 54);
display.println("WATER PUMP: ");
display.setTextSize(2); //set background txt font size
display.setCursor(1, 12);
display.print(getValue("WOT"));
display.setTextSize(1);
#ifndef noDegree
display.print((char)247); //Degrees Symbol
#endif
display.print("C "); // Centigrade Symbol
display.setTextSize(2); //set background txt font size
display.print(getValue("VRMT"));
display.setTextSize(1);
#ifndef noDegree
display.print((char)247); //Degrees Symbol
#endif
display.print("C "); // Centigrade Symbol
display.setTextSize(2); //set background txt font size
display.print(getValue("MBT"));
display.setTextSize(1);
#ifndef noDegree
display.print((char)247); //Degrees Symbol
#endif
display.print("C "); // Centigrade Symbol
display.setCursor(45, 38);
display.print(getValue("FI") + " RPM");
display.setCursor(50, 46);
display.print(getValue("FO") + " RPM");
display.setCursor(67, 54);
display.print(getValue("WP") + " RPM");
display.fillRect(118, 0, 10, 10, BLACK);
display.display();
oledDraw = 1;
}
......@@ -143,20 +143,6 @@ boolean bootMode = true;
/*vars for serial input*/
String inputString = "";
boolean stringComplete = false;
struct HardwareInfo {
String CpuName;
String CpuTemperature;
String CpuLoad;
String CpuClock;
String GpuName;
String GpuTemperature;
String GpuLoad;
String GpuCoreClock;
String GpuMemoryClock;
String GpuShaderClock;
String RamUsed;
};
HardwareInfo data = HardwareInfo();
//----------------------
/* Start DisplayStyle */
int displayChangeMode = 1;
......@@ -216,6 +202,9 @@ void loop() {
displayChangeMode = 3;
display.fillRect(0, 0, 128, 64, BLACK);
} else if (displayChangeMode == 3) {
displayChangeMode = 4;
display.fillRect(0, 0, 128, 64, BLACK);
} else if (displayChangeMode == 4) {
displayChangeMode = 1;
display.fillRect(0, 0, 128, 64, BLACK);
}
......@@ -239,6 +228,8 @@ void loop() {
DisplayStyle2();
} else if (displayChangeMode == 3) {
DisplayStyle3();
} else if (displayChangeMode == 4) {
DisplayStyle4();
}
inputString = "";
......@@ -270,7 +261,6 @@ void serialEvent() {
inputString += inChar;
if (inChar == '|') {
stringComplete = true;
populateData();
delay(Serial_eventDelay); //delay screen event to stop screen data corruption
display.drawBitmap(118, 0, DownloadBMP, 10, 10, WHITE);// Update symbol in top right corner when updating
display.display();
......@@ -278,20 +268,6 @@ void serialEvent() {
}
}
void populateData() {
setCpuName();
data.CpuTemperature = getValue("CT");
data.CpuLoad = getValue("CL");
data.CpuClock = getValue("CC");
setGpuName();
data.GpuTemperature = getValue("GT");
data.GpuLoad = getValue("GL");
data.GpuCoreClock = getValue("GCC");
data.GpuMemoryClock = getValue("GMC");
data.GpuShaderClock = getValue("GSC");
data.RamUsed = getValue("RU");
}
void activityChecker() {
if (millis() - lastActiveConn > lastActiveDelay)
activeConn = false;
......@@ -321,30 +297,34 @@ String getValue(String key) {
}
}
void setCpuName() {
data.CpuName = getValue("CN");
String getCpuName() {
String cpuName = getValue("CN");
int cpuNameStart;
if (data.CpuName.indexOf("Intel") > -1) {
if (cpuName.indexOf("Intel") > -1) {
cpuNameStart = 6;
} else {
cpuNameStart = 4;
}
data.CpuName = data.CpuName.substring(cpuNameStart);
cpuName = cpuName.substring(cpuNameStart);
if (data.CpuName.length() > 20) {
data.CpuName = data.CpuName.substring(0, data.CpuName.lastIndexOf(" "));
if (cpuName.length() > 20) {
return cpuName.substring(0, cpuName.lastIndexOf(" "));
}
else {
return cpuName;
}
}
void setGpuName() {
data.GpuName = getValue("GN");
String getGpuName() {
String gpuName = getValue("GN");
int gpuNameStart;
if (data.GpuName.indexOf("NVIDIA") > -1) {
if (gpuName.indexOf("NVIDIA") > -1) {
gpuNameStart = 7;
} else {
gpuNameStart = 4;
}
data.GpuName = data.GpuName.substring(gpuNameStart);
return gpuName.substring(gpuNameStart);
}
//-------------------------------------------- Anti Screen Burn inverter ------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment