-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
274 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
- Remove excessive and unnecessary comments. | ||
- Add definition for double line spacing. | ||
- Add definition for color formatting. | ||
- Remove unnecessary variable that converted string to double. | ||
- Simplified Celsius conversion. Formatted spacing and alignment of output. | ||
- Add evaluation of temperature data and corresponding text color. | ||
- Add status output. Add message to user. | ||
- Improved formatting of output using 'setw()' and 'right' manipulators from iomanip. | ||
- Add "fixed" precision to output. | ||
- Update README.md | ||
- Update README.md | ||
- Updated change log. | ||
- Update CHANGELOG.md | ||
- Update CHANGELOG.md | ||
- Adding changelog. | ||
- Merge branch 'Darin755/master' Merging and approving proposed change to README.md with edit to FOSS definition. | ||
- Remove "FLOSS". | ||
- Add FOSS and definition. | ||
- Delete README.md.backup | ||
- Update README.md | ||
- Update README.md | ||
- fixed formating | ||
- improved readme | ||
- Add release information. | ||
- Corrected version date. | ||
- Updated project description. Add guide to installation. | ||
- Corrected version date. | ||
- Moved temperature conversion variables to while loop. Remove 'tempFahrenheit = tempCelsius * (9/5) + 32'. Add 'tempFahrenheit = (tempCelsius * 1.8) + 32' | ||
- Created GNU General Public License version 3 (GPLv3). Removed template information. Added program name. Added program description. | ||
- Added comment before thermal.open() function. Compiled and test run. Program compiled but failed to run. | ||
- Added comment before thermal.open() function. Attempted debug and received error: | ||
- Removed unnecessary comments. Cleaned up code spacing. | ||
- Corrected version number in description. | ||
- Determined that separate function was overkill. Merged operation into main(). Removed Thermal() function. Added variables to output system temp data to: * Degrees Celsius * Degrees Fahrenheit * Kelvin Added 'ios::in' to thermal.open() correcting syntax error. | ||
- Added statement to convert string to double. Added statement to divide temperature output and store result in variable to be output to the screen in degrees C. Added iomanip and string libraries. | ||
- Corrected syntax errors. | ||
- Corrected variable syntax error. | ||
- Created function for fetching information from /sys/class/thermal/thermal_zone0/temp. | ||
- Updated application name. | ||
- Added new file tempmonCPU.cpp. | ||
- Delete LICENSE | ||
- Initial commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
TESTFILE=tempmonTEST.cpp | ||
SOURCE=../src/tempmon.cpp | ||
|
||
if [ -f $TESTFILE ]; then | ||
g++ $TESTFILE --verbose -o tempmonTEST | ||
printf "\n\n\xE2\x9C\x94 \e[1;32mExecutable 'tempmonTEST' created . . . \n\n\e[0m" | ||
else | ||
cp $SOURCE $TESTFILE | ||
g++ $TESTFILE --verbose -o tempmonTEST | ||
printf "\n\n\xE2\x9C\x94 \e[1;32mtempmonTEST.cpp created . . . \n\e[0m" | ||
printf "\xE2\x9C\x94 \e[1;32mExecutable 'tempmonTEST' created . . . \n\n\e[0m" | ||
fi |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/*============================================================== | ||
Program: CPU Temperature Monitor | ||
Version: 0.2.1 | ||
Version Date: 09/06/2022 | ||
Author: Kevin Wilkins | ||
Date: 02/05/2022 | ||
Parameters: | ||
This application will read out CPU temperature data from | ||
'/sys/class/thermal/thermal_zone0/temp' file on Linux and will | ||
convert output to human readable format in degrees Celsius, | ||
degrees Fahrenheit, and Kelvin. | ||
==============================================================*/ | ||
|
||
// Preprocessor directives and namespace usage | ||
#include <iostream> | ||
#include <iomanip> | ||
#include <fstream> | ||
#include <string> | ||
|
||
using namespace std; | ||
|
||
// Special definitions | ||
#define DOUBLELINE "\n\n" | ||
#define RESTORE "\033[0m" // Return to default terminal color | ||
#define GREEN "\033[1m\033[32m" // Bold green | ||
#define YELLOW "\033[1m\033[33m" // Bold yellow | ||
#define RED "\033[1m\033[31m" // Bold red | ||
|
||
// Main function | ||
int main() | ||
{ | ||
ifstream thermal; | ||
string sysTemp = ""; | ||
|
||
// Read in /sys/.../temp file | ||
thermal.open("/sys/class/thermal/thermal_zone0/temp", ios::in); | ||
|
||
// Check if file is open and output in human readable format | ||
if (thermal.is_open()) | ||
{ | ||
while (getline (thermal, sysTemp)) | ||
{ | ||
// Convert output | ||
// double tempCelsius = stod(sysTemp) / 1000; | ||
|
||
double tempCelsius = 87; //Test value | ||
|
||
double tempFahrenheit = (tempCelsius * 1.8) + 32; | ||
double tempKelvin = tempCelsius + 273.15; | ||
string colorCode = ""; | ||
string status = ""; | ||
string message = ""; | ||
|
||
// Evaluate Temperature Safety Level | ||
if(tempCelsius < 60) | ||
{ | ||
colorCode = GREEN; | ||
status = "GOOD"; | ||
message = "CPU temperature is very good."; | ||
} | ||
else if(tempCelsius >= 60 && tempCelsius < 75) | ||
{ | ||
colorCode = YELLOW; | ||
status = "CAUTION"; | ||
message = "CPU temperature is somewhat elevated."; | ||
} | ||
else if(tempCelsius >= 75) | ||
{ | ||
colorCode = RED; | ||
status = "WARNING"; | ||
message = "CPU temperature is high and needs attention."; | ||
} | ||
|
||
// Output to terminal as human readable | ||
cout << fixed << setprecision(3); | ||
cout << "System Temperature\n"; | ||
cout << "Status:" << colorCode << status << RESTORE; | ||
cout << DOUBLELINE; | ||
cout << colorCode; | ||
cout << setw(10) << right << tempCelsius << " \u00B0C\n" | ||
<< setw(10) << right << tempFahrenheit << " \u00B0F\n" | ||
<< setw(10) << right << tempKelvin << " K" << DOUBLELINE; | ||
cout << RESTORE; | ||
cout << message << DOUBLELINE; | ||
} | ||
thermal.close(); | ||
} | ||
else | ||
{ | ||
cout << "Failure to open '/sys/class/thermal/thermal_zone0/temp'\n" | ||
<< "Please try again . . ." | ||
<< DOUBLELINE; | ||
} | ||
|
||
// Exit program without errors | ||
return 0; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/*============================================================== | ||
Program: CPU Temperature Monitor | ||
Version: 0.2.1 | ||
Version Date: 09/06/2022 | ||
Author: Kevin Wilkins | ||
Date: 02/05/2022 | ||
Parameters: | ||
This application will read out CPU temperature data from | ||
'/sys/class/thermal/thermal_zone0/temp' file on Linux and will | ||
convert output to human readable format in degrees Celsius, | ||
degrees Fahrenheit, and Kelvin. | ||
==============================================================*/ | ||
|
||
// Preprocessor directives and namespace usage | ||
#include <iostream> | ||
#include <iomanip> | ||
#include <fstream> | ||
#include <string> | ||
|
||
using namespace std; | ||
|
||
// Special definitions | ||
#define DOUBLELINE "\n\n" | ||
#define RESTORE "\033[0m" // Return to default terminal color | ||
#define GREEN "\033[1m\033[32m" // Bold green | ||
#define YELLOW "\033[1m\033[33m" // Bold yellow | ||
#define RED "\033[1m\033[31m" // Bold red | ||
|
||
// Main function | ||
int main() | ||
{ | ||
ifstream thermal; | ||
string sysTemp = ""; | ||
|
||
// Read in /sys/.../temp file | ||
thermal.open("/sys/class/thermal/thermal_zone0/temp", ios::in); | ||
|
||
// Check if file is open and output in human readable format | ||
if (thermal.is_open()) | ||
{ | ||
while (getline (thermal, sysTemp)) | ||
{ | ||
// Convert output | ||
double tempCelsius = stod(sysTemp) / 1000; | ||
double tempFahrenheit = (tempCelsius * 1.8) + 32; | ||
double tempKelvin = tempCelsius + 273.15; | ||
string colorCode = ""; | ||
string status = ""; | ||
string message = ""; | ||
|
||
// Evaluate Temperature Safety Level | ||
if(tempCelsius < 60) | ||
{ | ||
colorCode = GREEN; | ||
status = "GOOD"; | ||
message = "CPU temperature is very good."; | ||
} | ||
else if(tempCelsius >= 60 && tempCelsius < 75) | ||
{ | ||
colorCode = YELLOW; | ||
status = "CAUTION"; | ||
message = "CPU temperature is somewhat elevated."; | ||
} | ||
else if(tempCelsius >= 75) | ||
{ | ||
colorCode = RED; | ||
status = "WARNING"; | ||
message = "CPU temperature is high and needs attention."; | ||
} | ||
|
||
// Output to terminal as human readable | ||
cout << fixed << setprecision(3); | ||
cout << "System Temperature\n"; | ||
cout << "Status:" << colorCode << status << RESTORE; | ||
cout << DOUBLELINE; | ||
cout << colorCode; | ||
cout << setw(10) << right << tempCelsius << " \u00B0C\n" | ||
<< setw(10) << right << tempFahrenheit << " \u00B0F\n" | ||
<< setw(10) << right << tempKelvin << " K" << DOUBLELINE; | ||
cout << RESTORE; | ||
cout << message << DOUBLELINE; | ||
} | ||
thermal.close(); | ||
} | ||
else | ||
{ | ||
cout << "Failure to open '/sys/class/thermal/thermal_zone0/temp'\n" | ||
<< "Please try again . . ." | ||
<< DOUBLELINE; | ||
} | ||
|
||
// Exit program without errors | ||
return 0; | ||
} |
This file was deleted.
Oops, something went wrong.