1
0
mirror of https://github.com/gryf/wmtemp.git synced 2025-12-18 03:50:27 +01:00

re-added repaint of the fields, added sane limits for the i7 cpu

This commit is contained in:
2014-01-19 19:19:45 +01:00
parent 4e87d06d7e
commit 53b145f044

View File

@@ -26,12 +26,13 @@
#include <NVCtrl/NVCtrlLib.h> #include <NVCtrl/NVCtrlLib.h>
#define MAXSTRLEN 8 #define MAXSTRLEN 8
#define WARN_TEMP 40 #define WARN_TEMP 65
#define CRIT_TEMP 47 #define CRIT_TEMP 80
#define WARN_TEMP_GPU 70 #define WARN_TEMP_GPU 70
#define CRIT_TEMP_GPU 85 #define CRIT_TEMP_GPU 85
#define MAXFNAME 50 #define MAXFNAME 50
void display_values(int, int, int); void display_values(int, int, int);
int get_temp(int core_number, Display*); int get_temp(int core_number, Display*);
int get_offset(int temp, short cpu); int get_offset(int temp, short cpu);
@@ -41,9 +42,10 @@ void read_file_into(char *filepath, int *output);
Display *display; Display *display;
int main(int argc, char **argv){ int main(int argc, char **argv){
int temp1=0, temp2=0, temp3=0, temp4=0, temp5=0; int core1_temp=0, core2_temp=0, core3_temp=0, core4_temp=0, gpu_temp=0;
/* offset is one of 0 (normal), 7 (alert), 14 (warning) */ /* offset is one of 0 (normal), 7 (alert), 14 (warning) */
int offset1=0, offset2=0, offset3=0, offset4=0, offset5=0; int core1_offset=0, core2_offset=0, core3_offset=0, core4_offset=0,
gpu_offset=0;
int counter = 0; int counter = 0;
char* path = ""; char* path = "";
display = XOpenDisplay(NULL); display = XOpenDisplay(NULL);
@@ -71,42 +73,49 @@ int main(int argc, char **argv){
if (counter < 1){ if (counter < 1){
counter = 5; counter = 5;
temp1 = get_temp(0, display); // cpu
offset1 = get_offset(temp1, 1); core1_temp = get_temp(0, display);
temp2 = get_temp(1, display); core1_offset = get_offset(core1_temp, 1);
offset2 = get_offset(temp2, 1); core2_temp = get_temp(1, display);
temp3 = get_temp(2, display); core2_offset = get_offset(core2_temp, 1);
offset3 = get_offset(temp1, 1); core3_temp = get_temp(2, display);
temp4 = get_temp(3, display); core3_offset = get_offset(core3_temp, 1);
offset4 = get_offset(temp2, 1); core4_temp = get_temp(3, display);
temp2 = get_temp(1, display); core4_offset = get_offset(core4_temp, 1);
offset2 = get_offset(temp2, 1);
temp5 = get_gpu_temp(path, display); // gpu
offset5 = get_offset(temp3, 0); gpu_temp = get_gpu_temp(path, display);
gpu_offset = get_offset(gpu_temp, 0);
} }
// core 1 // core 1
//copyXPMArea(0, 87 + offset1, 23, 7, 4, 7); // LCD: "CPU" copyXPMArea(0, 87 + core1_offset, 23, 7, 4, 7); // LCD: "CPU"
//copyXPMArea(69, 87 + offset1, 5, 7, 22, 7); // LCD: number of cpu copyXPMArea(5, 65 + core1_offset, 5, 7, 22, 7); // LCD: number of cpu
//copyXPMArea(66, 65 + offset1, 9, 7, 51, 7); // LCD: "°C" copyXPMArea(66, 65 + core1_offset, 9, 7, 51, 7); // LCD: "°C"
display_values(temp1, 0, offset1); display_values(core1_temp, 0, core1_offset);
// core 2 // core 2
//copyXPMArea(0, 87 + offset2, 23, 7, 4, 21); copyXPMArea(0, 87 + core2_offset, 23, 7, 4, 16);
//copyXPMArea(75, 87 + offset2, 5, 7, 22, 21); copyXPMArea(10, 65 + core2_offset, 5, 7, 22, 16);
//copyXPMArea(66, 65 + offset2, 9, 7, 51, 21); copyXPMArea(66, 65 + core2_offset, 9, 7, 51, 16);
display_values(temp2, 9, offset2); display_values(core2_temp, 9, core2_offset);
// core 3 // core 3
display_values(temp3, 18, offset3); copyXPMArea(0, 87 + core3_offset, 23, 7, 4, 25);
copyXPMArea(15, 65 + core3_offset, 5, 7, 22, 25);
copyXPMArea(66, 65 + core3_offset, 9, 7, 51, 25);
display_values(core3_temp, 18, core3_offset);
// core 4 // core 4
display_values(temp4, 27, offset4); copyXPMArea(0, 87 + core4_offset, 23, 7, 4, 34);
copyXPMArea(20, 65 + core4_offset, 5, 7, 22, 34);
copyXPMArea(66, 65 + core4_offset, 9, 7, 51, 34);
display_values(core4_temp, 27, core4_offset);
// gpu // gpu
//copyXPMArea(23, 87 + offset3, 23, 7, 4, 35); copyXPMArea(23, 87 + gpu_offset, 23, 7, 4, 49);
//copyXPMArea(66, 65 + offset3, 9, 7, 51, 35); copyXPMArea(66, 65 + gpu_offset , 9, 7, 51, 49);
display_values(temp5, 42, offset5); display_values(gpu_temp, 42, gpu_offset);
RedrawWindow(); RedrawWindow();
counter--; counter--;
usleep(100000); usleep(100000);
@@ -131,7 +140,7 @@ int get_offset(int temp, short cpu){
} }
} }
void display_values(int temp, int offset, int offset2){ void display_values(int temp, int offset, int core2_offset){
char text[5], num1, num2, num3, num4; char text[5], num1, num2, num3, num4;
sprintf(text, "%03d", temp); sprintf(text, "%03d", temp);
@@ -140,12 +149,12 @@ void display_values(int temp, int offset, int offset2){
num3 = (text[2] - '0'); num3 = (text[2] - '0');
num4 = (text[3] - '0'); num4 = (text[3] - '0');
if(num1) if(num1)
copyXPMArea(5 * num1, 65 + offset2, 5, 7, 31, 7 + offset); copyXPMArea(5 * num1, 65 + core2_offset, 5, 7, 31, 7 + offset);
else else
copyXPMArea(60, 65 + offset2, 5, 7, 31, 7 + offset); copyXPMArea(60, 65 + core2_offset, 5, 7, 31, 7 + offset);
copyXPMArea(5 * num2, 65 + offset2, 5, 7, 38, 7 + offset); copyXPMArea(5 * num2, 65 + core2_offset, 5, 7, 38, 7 + offset);
copyXPMArea(5 * num3, 65 + offset2, 5, 7, 45, 7 + offset); copyXPMArea(5 * num3, 65 + core2_offset, 5, 7, 45, 7 + offset);
copyXPMArea(5 * num4, 65 + offset2, 5, 7, 51, 7 + offset); copyXPMArea(5 * num4, 65 + core2_offset, 5, 7, 51, 7 + offset);
} }
int get_temp(int core_number, Display *disp){ int get_temp(int core_number, Display *disp){