Skip to content

Commit 131d87c

Browse files
committed
Clean up the code to remove warnings.
1 parent 8ee9f2f commit 131d87c

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

Nextion.cpp

+17-16
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ m_berCount1(0U),
6161
m_berCount2(0U),
6262
m_txFrequency(txFrequency),
6363
m_rxFrequency(rxFrequency),
64+
m_fl_txFrequency(0.0F),
65+
m_fl_rxFrequency(0.0F),
6466
m_displayTempInF(displayTempInF),
6567
m_location(location)
6668
{
@@ -84,19 +86,16 @@ bool CNextion::open()
8486
return false;
8587
}
8688

87-
info[0]=0;
89+
info[0] = 0;
8890
m_network = new CNetworkInfo;
8991
m_network->getNetworkInterface(info);
9092
m_ipaddress = (char*)info;
9193

9294
sendCommand("bkcmd=0");
9395
sendCommandAction(0U);
9496

95-
m_fl_txFrequency = m_txFrequency;
96-
m_fl_txFrequency/=1000000U;
97-
98-
m_fl_rxFrequency = m_rxFrequency;
99-
m_fl_rxFrequency/=1000000U;
97+
m_fl_txFrequency = float(m_txFrequency) / 1000000.0F;
98+
m_fl_rxFrequency = float(m_rxFrequency) / 1000000.0F;
10099

101100
setIdle();
102101

@@ -133,22 +132,24 @@ void CNextion::setIdleInt()
133132
sendCommand(command);
134133
sendCommandAction(21U);
135134

136-
FILE *deviceInfoFile;
137-
double val;
138-
//CPU temperature
139-
deviceInfoFile = fopen ("/sys/class/thermal/thermal_zone0/temp", "r");
140-
if (deviceInfoFile != NULL) {
141-
fscanf (deviceInfoFile, "%lf", &val);
142-
fclose(deviceInfoFile);
143-
val /= 1000;
144-
if( m_displayTempInF){
145-
val = (1.8 * val) + 32;
135+
// CPU temperature
136+
FILE* fp = ::fopen("/sys/class/thermal/thermal_zone0/temp", "rt");
137+
if (fp != NULL) {
138+
double val = 0.0;
139+
int n = ::fscanf(fp, "%lf", &val);
140+
::fclose(fp);
141+
142+
if (n == 1) {
143+
val /= 1000.0;
144+
if (m_displayTempInF) {
145+
val = (1.8 * val) + 32.0;
146146
::sprintf(command, "t20.txt=\"%2.1f %cF\"", val, 176);
147147
} else {
148148
::sprintf(command, "t20.txt=\"%2.1f %cC\"", val, 176);
149149
}
150150
sendCommand(command);
151151
sendCommandAction(22U);
152+
}
152153
}
153154

154155
::sprintf(command, "t31.txt=\"%s\"", m_location.c_str()); // location

Nextion.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ class CNextion : public CDisplay
9999
unsigned int m_berCount2;
100100
unsigned int m_txFrequency;
101101
unsigned int m_rxFrequency;
102-
float m_fl_txFrequency=0;
103-
float m_fl_rxFrequency=0;
102+
float m_fl_txFrequency;
103+
float m_fl_rxFrequency;
104104
bool m_displayTempInF;
105105
std::string m_location;
106106

0 commit comments

Comments
 (0)