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 Log Message: More I2C work. Made the temperature sensor scanning more generic, but only increased the limit to nine. A better way would be to do an ls and check for all temp*_input. Next time I will do it this way. I still haven't tracked down the sensor name information. It's out there somewhere, I'll have to look at the source code for lm_sensors to see how they do it. =================================================================== RCS file: /cvs/e/e17/apps/e/src/modules/temperature/e_mod_config.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -3 -r1.28 -r1.29 --- e_mod_config.c 26 Jan 2007 10:00:03 -0000 1.28 +++ e_mod_config.c 27 Jan 2007 06:21:07 -0000 1.29 @@ -72,6 +72,7 @@ double p; Ecore_List *therms; char *name; + char path[PATH_MAX]; cfdata->units = cfdata->inst->units; if (cfdata->inst->units == CELCIUS) @@ -124,10 +125,29 @@ case SENSOR_TYPE_LINUX_MACMINI: break; case SENSOR_TYPE_LINUX_I2C: - ecore_list_append(cfdata->sensors, strdup("temp1")); - ecore_list_append(cfdata->sensors, strdup("temp2")); - ecore_list_append(cfdata->sensors, strdup("temp3")); - ecore_list_append(cfdata->sensors, strdup("temp4")); + therms = ecore_file_ls("/sys/bus/i2c/devices"); + if (therms) + { + char *therm_name; + + while ((therm_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", therm_name, i); + if (ecore_file_exists(path)) + { + sprintf(path, "temp%d", i); + ecore_list_append(cfdata->sensors, strdup(path)); + } + } + } + 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.78 retrieving revision 1.79 diff -u -3 -r1.78 -r1.79 --- e_mod_main.c 26 Jan 2007 10:00:03 -0000 1.78 +++ e_mod_main.c 27 Jan 2007 06:21:07 -0000 1.79 @@ -238,8 +238,6 @@ } else { - /* TODO: Is there I2C devices with more than 3 temperature sensors? Yes, mine has 4. */ - /* TODO: What to do when there is more than one tempX? */ therms = ecore_file_ls("/sys/bus/i2c/devices"); if (therms) { @@ -247,17 +245,17 @@ while ((name = ecore_list_next(therms))) { - char *sensors[] = { "temp1", "temp2", "temp3", "temp4" }; int i; - for (i = 0; i < 4; 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/%s_input", - name, sensors[i]); + sprintf(path, "/sys/bus/i2c/devices/%s/temp%d_input", name, i); if (ecore_file_exists(path)) { + sprintf(path, "temp%d", i); inst->sensor_type = SENSOR_TYPE_LINUX_I2C; - inst->sensor_name = evas_stringshare_add(sensors[i]); + inst->sensor_name = evas_stringshare_add(path); break; } } ------------------------------------------------------------------------- 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