Enlightenment CVS committal

Author  : onefang
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/modules/temperature


Modified Files:
        e_mod_config.c e_mod_main.c e_mod_main.h 


Log Message:
No more limits to the number of I2C temperatures allowed.

===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/temperature/e_mod_config.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -3 -r1.29 -r1.30
--- e_mod_config.c      27 Jan 2007 06:21:07 -0000      1.29
+++ e_mod_config.c      28 Jan 2007 16:08:12 -0000      1.30
@@ -125,28 +125,27 @@
       case SENSOR_TYPE_LINUX_MACMINI:
         break;
       case SENSOR_TYPE_LINUX_I2C:
-        therms = ecore_file_ls("/sys/bus/i2c/devices");
+        therms = temperature_get_i2c_files();
         if (therms)
-           {
-              char *therm_name;
+          {
+              char *name;
 
-              while ((therm_name = ecore_list_next(therms)))
-                {
-                   int i;
+             while ((name = ecore_list_next(therms)))
+               {
+                  if (ecore_file_exists(name))
+                    {
+                       int len;
 
-                    /* If there are ever more than 9 temperatures, then just 
increase this number. */
-                   for (i = 0; i < 9; i++)
-                     {
-                        sprintf(path, "/sys/bus/i2c/devices/%s/temp%d_input", 
therm_name, i);
-                        if (ecore_file_exists(path))
-                          {
-                             sprintf(path, "temp%d", i);
-                             ecore_list_append(cfdata->sensors, strdup(path));
-                          }
-                     }
-                }
-              ecore_list_destroy(therms);
-           }
+                       sprintf(path, "%s", ecore_file_get_file(name));
+                       len = strlen(path);
+                       if (len > 6)
+                          path[len - 6] = '\0';
+                       ecore_list_append(cfdata->sensors, strdup(path));
+                       /* TODO: Track down the user friendly names and display 
them instead. */
+                    }
+               }
+             ecore_list_destroy(therms);
+          }
 
         ecore_list_goto_first(cfdata->sensors);
         while ((name = ecore_list_next(cfdata->sensors)))
===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/temperature/e_mod_main.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -3 -r1.79 -r1.80
--- e_mod_main.c        27 Jan 2007 06:21:07 -0000      1.79
+++ e_mod_main.c        28 Jan 2007 16:08:12 -0000      1.80
@@ -238,28 +238,25 @@
               }
             else
               {
-                 therms = ecore_file_ls("/sys/bus/i2c/devices");
+                  therms = temperature_get_i2c_files();
                  if (therms)
                    {
                       char *name;
 
-                      while ((name = ecore_list_next(therms)))
-                        {
-                           int i;
-
-                            /* If there are ever more than 9 temperatures, 
then just increase this number. */
-                           for (i = 0; i < 9; i++)
-                             {
-                                sprintf(path, 
"/sys/bus/i2c/devices/%s/temp%d_input", name, i);
-                                if (ecore_file_exists(path))
+                      if ((name = ecore_list_next(therms)))
+                        {
+                                if (ecore_file_exists(name))
                                   {
-                                     sprintf(path, "temp%d", i);
+                                     int len;
+
+                                     sprintf(path, "%s", 
ecore_file_get_file(name));
+                                     len = strlen(path);
+                                     if (len > 6)
+                                        path[len - 6] = '\0';
                                      inst->sensor_type = SENSOR_TYPE_LINUX_I2C;
+                                     inst->sensor_path = 
evas_stringshare_add(name);
                                      inst->sensor_name = 
evas_stringshare_add(path);
-                                     break;
                                   }
-                             }
-                           if (inst->sensor_type) break;
                         }
                       ecore_list_destroy(therms);
                    }
@@ -304,6 +301,7 @@
                        if (ecore_file_exists(path))
                          {
                             inst->sensor_path = evas_stringshare_add(path);
+                            /* We really only care about the first one for the 
default. */
                             break;
                          }
                     }
@@ -525,6 +523,58 @@
    if (inst->temperature_check_timer) 
ecore_timer_del(inst->temperature_check_timer);
    inst->temperature_check_timer = 
      ecore_timer_add(inst->poll_time, _temperature_cb_check, inst);
+}
+
+Ecore_List *
+temperature_get_i2c_files()
+{
+   Ecore_List *result;
+   Ecore_List *therms;
+   char        path[PATH_MAX];
+
+   result = ecore_list_new();
+   if (result)
+     {
+        ecore_list_set_free_cb(result, free);
+
+        /* Look through all the i2c devices. */
+        therms = ecore_file_ls("/sys/bus/i2c/devices");
+        if (therms)
+          {
+             char *name;
+
+            while ((name = ecore_list_next(therms)))
+              {
+                  Ecore_List *files;
+
+                  /* Search each device for temp*_input, these should be i2c 
temperature devices. */
+                 sprintf(path, "/sys/bus/i2c/devices/%s", name);
+                 files = ecore_file_ls(path);
+                 if (files)
+                   {
+                       char *file;
+
+                      while ((file = ecore_list_next(files)))
+                        {
+                           if ((strncmp("temp", file, 4) == 0) && 
(strcmp("_input", &file[strlen(file) - 6]) == 0))
+                             {
+                                char *f;
+
+                                sprintf(path, "/sys/bus/i2c/devices/%s/%s", 
name, file);
+                                f = strdup(path);
+                                if (f)
+                                   ecore_list_append(result, f);
+                             }
+                        }
+                      ecore_list_destroy(files);
+                   }
+              }
+            ecore_list_destroy(therms);
+          }
+        ecore_list_goto_first(result);
+     }
+
+   return result;
 }
 
 /***************************************************************************/
===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/temperature/e_mod_main.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -3 -r1.26 -r1.27
--- e_mod_main.h        17 Dec 2006 22:01:45 -0000      1.26
+++ e_mod_main.h        28 Jan 2007 16:08:12 -0000      1.27
@@ -64,6 +64,7 @@
 
 void config_temperature_module(Config_Face *inst);
 void temperature_face_update_config(Config_Face *inst);
+Ecore_List *temperature_get_i2c_files(void);
 
 
 #endif



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to