-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCpuVcoreMeter.c
84 lines (76 loc) · 1.88 KB
/
CpuVcoreMeter.c
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
htop - CpuVcoreMeter.c
(C) 2020 Alexander Finger
*/
#include "CpuVcoreMeter.h"
#include "Platform.h"
#include "CRT.h"
/*{
#include "Meter.h"
}*/
int CpuVcoreMeter_attributes[] = {
CPU_VCORE
};
static void CpuVcoreMeter_setValues(Meter* this, char* buffer, int len) {
int v1,v2;
int Vcore, Vcore_l, Vcore_b;
char buf1[80], buf2[80];
int h;
if (Platform_getCpuBigLITTLE()) {
h = len / 2;
if (h > 79)
h = 79;
Vcore_b = Platform_getCpuVcore_b(this);
if (Vcore_b > 1000) {
Vcore_b /= 1000;
}
if (Vcore_b >= 1000) {
Vcore_b /= 10;
v1 = Vcore_b / 100;
v2 = Vcore_b % 100;
xSnprintf(buf1, h, "%d.%02d V ", v1, v2);
} else {
xSnprintf(buf1, h, "%4d mV", Vcore_b);
}
Vcore_l = Platform_getCpuVcore_l(this);
if (Vcore_l > 1000) {
Vcore_l /= 1000;
}
if (Vcore_l >= 1000) {
Vcore_l /= 10;
v1 = Vcore_l / 100;
v2 = Vcore_l % 100;
xSnprintf(buf2, h, "%d.%02d V ", v1, v2);
} else {
xSnprintf(buf2, h, "%4d mV", Vcore_l);
}
xSnprintf(buffer, len, "%s %s (big.LITTLE)", buf1, buf2);
return;
}
Vcore = Platform_getCpuVcore(this);
if (Vcore > 1000) {
Vcore /= 1000;
}
if (Vcore >= 1000) {
Vcore /= 10;
v1 = Vcore / 100;
v2 = Vcore % 100;
xSnprintf(buffer, len, "%d.%02d V", v1, v2);
} else {
xSnprintf(buffer, len, "%4d mV", Vcore);
}
}
MeterClass CpuVcoreMeter_class = {
.super = {
.extends = Class(Meter),
.delete = Meter_delete
},
.updateValues = CpuVcoreMeter_setValues,
.defaultMode = TEXT_METERMODE,
.maxItems = 1,
.total = 100.0,
.attributes = CpuVcoreMeter_attributes,
.name = "CpuVcore",
.uiName = "CpuVcore",
.caption = "CPU Vcor: "
};