netstar pushed a commit to branch master.

http://git.enlightenment.org/apps/evisum.git/commit/?id=af63cd9ce6759f408cde7b32725967269f99af22

commit af63cd9ce6759f408cde7b32725967269f99af22
Author: Alastair Poole <nets...@gmail.com>
Date:   Mon Sep 7 12:50:32 2020 +0100

    cpu...leeenooks
---
 src/bin/system/machine.h         |  6 ++++
 src/bin/system/machine/cpu.bogox | 69 ++++++++++++++++++++++++++++++++++++++++
 src/bin/ui/ui_cpu.c              |  9 ++++++
 src/bin/ui/ui_util.c             |  4 +--
 4 files changed, 86 insertions(+), 2 deletions(-)

diff --git a/src/bin/system/machine.h b/src/bin/system/machine.h
index 8d95ea4..9e010f1 100644
--- a/src/bin/system/machine.h
+++ b/src/bin/system/machine.h
@@ -100,6 +100,12 @@ system_cpu_usage_delayed_get(int *ncpu, int usecs);
 int
 system_cpu_frequency_get(void);
 
+int
+system_cpu_n_frequency_get(int n);
+
+int
+system_cpu_frequency_min_max_get(int *min, int *max);
+
 void
 system_memory_usage_get(meminfo_t *memory);
 
diff --git a/src/bin/system/machine/cpu.bogox b/src/bin/system/machine/cpu.bogox
index 6451f66..e4d0754 100644
--- a/src/bin/system/machine/cpu.bogox
+++ b/src/bin/system/machine/cpu.bogox
@@ -279,6 +279,75 @@ system_cpu_usage_get(int *ncpu)
    return system_cpu_usage_delayed_get(ncpu, 1000000);
 }
 
+int
+system_cpu_n_frequency_get(int n)
+{
+   int freq = -1;
+   FILE *f;
+   char buf[4096];
+   int tmp;
+
+   snprintf(buf, sizeof(buf), 
"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq", n);
+   f = fopen(buf, "r");
+   if (f)
+     {
+        if (fgets(buf, sizeof(buf), f))
+          {
+             tmp = strtol(buf, NULL, 10);
+             if (!((tmp == LONG_MIN || tmp == LONG_MAX) && errno == ERANGE))
+               freq = tmp;
+          }
+        fclose(f);
+        if (freq != -1) return freq;
+     }
+
+   return freq;
+}
+
+int
+system_cpu_frequency_min_max_get(int *min, int *max)
+{
+   char *s;
+   int freq_min = 0x7fffffff, freq_max = 0;
+
+   s = file_contents("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq");
+   if (s)
+     {
+        freq_min = atoi(s);
+        free(s);
+        s = 
file_contents("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq");
+        if (s)
+          {
+             freq_max = atoi(s);
+             free(s);
+             *min = freq_min;
+             *max = freq_max;
+             return 0;
+          }
+     }
+
+   s = 
file_contents("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies");
+   if (!s) return -1;
+
+   char *t = strtok(s, " ");
+   while (t)
+     {
+        int freq = atoi(t);
+        if (freq > freq_max) freq_max = freq;
+        if (freq < freq_min) freq_min = freq;
+        t = strtok(NULL, " ");
+     }
+
+   free(s);
+
+   if (freq_min == 0x7fffffff || freq_max == 0) return -1;
+
+   *min = freq_min;
+   *max = freq_max;
+
+   return 0;
+}
+
 int
 system_cpu_frequency_get(void)
 {
diff --git a/src/bin/ui/ui_cpu.c b/src/bin/ui/ui_cpu.c
index f3ec071..d9a45c9 100644
--- a/src/bin/ui/ui_cpu.c
+++ b/src/bin/ui/ui_cpu.c
@@ -25,6 +25,8 @@ typedef struct {
    Animate_Data   *anim_data;
    double         *value;
    Evas_Object    *pb;
+
+   int             freq;
 } Progress;
 
 static void
@@ -161,12 +163,19 @@ _core_times_cb(void *data, Ecore_Thread *thread)
 
    ui = data;
 
+   int min, max;
+
+   if (!system_cpu_frequency_min_max_get(&min, &max))
+     {
+        printf("min %d and max %d\n", min, max);
+     }
    for (int i = 0; !ecore_thread_check(thread); i = 0)
      {
         cores = system_cpu_usage_get(&ncpu);
         EINA_LIST_FOREACH(ui->cpu_list, l, progress)
           {
              *progress->value = cores[i]->percent;
+             progress->freq = 
system_cpu_n_frequency_get(progress->anim_data->cpu_id);
              ecore_thread_main_loop_begin();
              elm_progressbar_value_set(progress->pb, cores[i]->percent / 100);
              ecore_thread_main_loop_end();
diff --git a/src/bin/ui/ui_util.c b/src/bin/ui/ui_util.c
index 5aa8410..755f21b 100644
--- a/src/bin/ui/ui_util.c
+++ b/src/bin/ui/ui_util.c
@@ -585,7 +585,7 @@ evisum_ui_animate(void *data)
    evas_object_image_fill_set(bg, ww / 3, 0, iw, wh);
    evas_object_resize(bg, iw, wh);
    evas_object_move(bg, 0, 0);
-   evas_object_color_set(bg, 255, 255, 255, 128);
+   evas_object_color_set(bg, 64, 64, 64, 64);
    evas_object_pass_events_set(bg, 1);
    evas_object_show(bg);
 
@@ -602,7 +602,7 @@ evisum_ui_animate(void *data)
    evas_object_image_fill_set(im, ww / 2, 0, iw, wh);
    evas_object_resize(im, iw, wh);
    evas_object_move(im, 0, 0);
-   evas_object_color_set(im, 255, 255, 255, 128);
+   evas_object_color_set(im, 192, 192, 192, 192);
    evas_object_pass_events_set(im, 1);
    evas_object_show(im);
 

-- 


Reply via email to