整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
38
util/Temperature.cpp
Normal file
38
util/Temperature.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* INCLUDE
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "Temperature.h"
|
||||
#include "Device.h"
|
||||
#include "Application.h"
|
||||
|
||||
namespace Util
|
||||
{
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DEFINE
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
float Temperature::read()
|
||||
{
|
||||
Device device("/sys/devices/virtual/mstar/msys/TEMP_R");
|
||||
|
||||
try
|
||||
{
|
||||
device.open();
|
||||
char str[64];
|
||||
device.read((uint8_t*)str, sizeof(str));
|
||||
int temp;
|
||||
sscanf(str, "Temperature %d", &temp);
|
||||
device.close();
|
||||
return temp;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
}
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue