Skip to content

Commit

Permalink
Merge branch '0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
kwilkins committed Sep 21, 2022
2 parents 3dfbd4f + 7a78c2b commit 444ed5e
Show file tree
Hide file tree
Showing 10 changed files with 274 additions and 70 deletions.
42 changes: 42 additions & 0 deletions CHANGELOG.md
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
38 changes: 27 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
<center>

# TemperatureMonitor
## Release v0.1.2-stable
First release on 07/23/2022.

</center>

# Releases

## `v0.1.2-stable`

* First release on 07/23/2022.

<hr>

## What does it do?
Reads system temperature from `/sys/class/thermal/thermal_zone0/temp` and outputs to human readable format. This is a terminal based application is intended for Linux machines and will not work on Windows or Mac.
# Program Description
Reads system temperature from `/sys/class/thermal/thermal_zone0/temp` and outputs to human readable format in Celsius (&deg;C), Fahrenheit (&deg;F), and Kelvin (K). This is a terminal based application is intended for exclusive use on Linux machines and will not work on Windows or Mac.

Please report issues.

This software is FOSS (Free and Open Source Software). Therefore there is NO COST to download and use this software. If you would like to support my work you can [Buy Me a Coffee](https://www.buymeacoffee.com/kwilkins)
This software is FOSS (Free and Open Source Software). Therefore there is NO COST to download and use this software. If you would like to support my work you can [Buy Me a Coffee](https://www.buymeacoffee.com/kwilkins).

<hr>

## Quick setup
# Screenshots

![Preview](https://raw.githubusercontent.com/kawilkins/TemperatureMonitor/0.2.1/screenshots/tempmon-preview01.png)

![Preview](https://raw.githubusercontent.com/kawilkins/TemperatureMonitor/0.2.1/screenshots/tempmon-preview02.png)

![Preview](https://raw.githubusercontent.com/kawilkins/TemperatureMonitor/0.2.1/screenshots/tempmon-preview03.png)

# Quick setup

**Download binary from github**
```
Expand All @@ -30,20 +46,20 @@ sudo mv tempmon /usr/bin
```
**Test it out**
```
watch tempmon
tempmon
```
<hr>

## Compiling
# Compiling
It is easy to Compile but you need to have g++

**clone the repo with git**
**Clone the repo with git**
```
git clone https://github.com/kawilkins/TemperatureMonitor.git
```
**change directory and then compile it**
**Change directory and then compile it**
```
cd TemperatureMonitor/src
g++ -o tempmon tempmonCPU.cpp
```
Additionally you may want to move the complied binary to ```/usr/bin```
Additionally you may want to move the complied binary to ```/usr/bin```.
14 changes: 14 additions & 0 deletions Test/TestCompileRun.sh
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 added Test/tempmonTEST
Binary file not shown.
97 changes: 97 additions & 0 deletions Test/tempmonTEST.cpp
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;
}
Binary file added screenshots/tempmon-preview01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/tempmon-preview02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/tempmon-preview03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 94 additions & 0 deletions src/tempmon.cpp
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;
}
59 changes: 0 additions & 59 deletions src/tempmonCPU.cpp

This file was deleted.

0 comments on commit 444ed5e

Please sign in to comment.