-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadData.cpp
39 lines (35 loc) · 858 Bytes
/
readData.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "readData.h"
int ReadData::readFreq()
{
QFile file("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq");
if(!file.open(QIODevice::ReadOnly)){
qDebug()<<"Failed to open";
return 0;
}
QString freqs;
QTextStream in(&file);
freqs = in.readLine();
if(file.isOpen())
file.close();
int freq = freqs.toInt();
return freq;
}
double ReadData::readTemp()
{
QFile file("/sys/class/thermal/thermal_zone1/temp");
if(!file.open(QIODevice::ReadOnly)){
qDebug()<<"Failed to open";
return 0;
}
QString temps;
QTextStream in(&file);
temps = in.readLine();
if(file.isOpen())
file.close();
double temp = temps.toDouble()/1000;
return temp;
}
int ReadData::getReadFreq()
{return readFreq();}
double ReadData::getReadTemp()
{return readTemp();}