added other half of main loop and cleared up cpufreq file mistake
This commit is contained in:
parent
58c0d9f503
commit
4e522dc30b
|
@ -4,7 +4,6 @@
|
|||
#define CURGOV "/sys/devices/system/cpu/cpufreq/policy0/scaling_governor"
|
||||
#define FREQS "/sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies"
|
||||
#define MAXSPDPATH "/sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq"
|
||||
#define SETSPDPATH "/sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed"
|
||||
#define CURTEMPPATH "/sys/devices/virtual/thermal/thermal_zone0/temp"
|
||||
|
||||
int comparestrings(char *a, char *b){
|
||||
|
@ -203,15 +202,24 @@ int main(int argc, char** argv){
|
|||
getfilec(curtempfile, temperature);
|
||||
newlinetonullbyte(temperature);
|
||||
if (stringtoint(temperature, stringlength(temperature)) >= maxtemp
|
||||
&& curstep <= stepc){
|
||||
&& curstep < stepc - 1){
|
||||
curstep++;
|
||||
curmaxfile = fopen(MAXSPDPATH, "w");
|
||||
fprintf(curmaxfile, "%s\n", steps[curstep]);
|
||||
fclose(curmaxfile);
|
||||
}
|
||||
if (stringtoint(temperature, stringlength(temperature)) <= mintemp
|
||||
&& curstep > 0){
|
||||
curstep--;
|
||||
curmaxfile = fopen(MAXSPDPATH, "w");
|
||||
fprintf(curmaxfile, "%s\n", steps[curstep]);
|
||||
fclose(curmaxfile);
|
||||
}
|
||||
free(temperature);
|
||||
fclose(curtempfile);
|
||||
}
|
||||
/* cleanup for graceful exit */
|
||||
free(steps);
|
||||
FILE* setspeedfile = fopen(SETSPDPATH, "w");
|
||||
fclose(setspeedfile);
|
||||
fclose(curtempfile);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue