-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.cpp
More file actions
57 lines (45 loc) · 1.26 KB
/
Copy pathutils.cpp
File metadata and controls
57 lines (45 loc) · 1.26 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "utils.h"
#include <stdio.h>
#include <limits.h>
//*****************************************************************************
unsigned int TimeDiff(const unsigned int nNow, const unsigned int nPrev)
{
unsigned nDiff;
if(nNow >= nPrev)
nDiff = nNow - nPrev;
else
nDiff = (UINT_MAX - nPrev) + nNow;
return nDiff;
}
//*****************************************************************************
float GetPiCpuTemperature(void)
{
float fTemp = -459.666;
FILE *pFile = fopen("/sys/class/thermal/thermal_zone0/temp", "r");
if(pFile)
{
unsigned long nTempC;
fscanf(pFile, "%li", &nTempC);
fTemp = C2F((float)nTempC / 1000.0);
fclose(pFile);
}
return fTemp;
}
//*****************************************************************************
const char *GetRowColor(const unsigned int nRow)
{
return ((nRow % 2) == 0) ? "#404060" : "#406040";
}
//*****************************************************************************
int Get12Hour(const int n24Hour)
{
int n12Hour = n24Hour % 12;
if(n12Hour == 0)
n12Hour = 12;
return n12Hour;
}
//*****************************************************************************
const char *AmPm(const int nHour)
{
return (nHour < 12) ? "AM" : "PM";
}