From 4e522dc30ba604651cce9e5c1b58c08db81ef0e7 Mon Sep 17 00:00:00 2001 From: celso Date: Sat, 19 Nov 2022 12:50:19 -0300 Subject: [PATCH] added other half of main loop and cleared up cpufreq file mistake --- src/homemade_speedstep.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/homemade_speedstep.c b/src/homemade_speedstep.c index 26c4179..8dbc3f5 100644 --- a/src/homemade_speedstep.c +++ b/src/homemade_speedstep.c @@ -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; }