forked from enlightenment/enlightenment
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. SVN revision: 28133
This commit is contained in:
parent
de7e05e8c5
commit
b438740bc8
|
@ -72,6 +72,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
|
||||||
double p;
|
double p;
|
||||||
Ecore_List *therms;
|
Ecore_List *therms;
|
||||||
char *name;
|
char *name;
|
||||||
|
char path[PATH_MAX];
|
||||||
|
|
||||||
cfdata->units = cfdata->inst->units;
|
cfdata->units = cfdata->inst->units;
|
||||||
if (cfdata->inst->units == CELCIUS)
|
if (cfdata->inst->units == CELCIUS)
|
||||||
|
@ -124,10 +125,29 @@ _fill_data(E_Config_Dialog_Data *cfdata)
|
||||||
case SENSOR_TYPE_LINUX_MACMINI:
|
case SENSOR_TYPE_LINUX_MACMINI:
|
||||||
break;
|
break;
|
||||||
case SENSOR_TYPE_LINUX_I2C:
|
case SENSOR_TYPE_LINUX_I2C:
|
||||||
ecore_list_append(cfdata->sensors, strdup("temp1"));
|
therms = ecore_file_ls("/sys/bus/i2c/devices");
|
||||||
ecore_list_append(cfdata->sensors, strdup("temp2"));
|
if (therms)
|
||||||
ecore_list_append(cfdata->sensors, strdup("temp3"));
|
{
|
||||||
ecore_list_append(cfdata->sensors, strdup("temp4"));
|
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);
|
ecore_list_goto_first(cfdata->sensors);
|
||||||
while ((name = ecore_list_next(cfdata->sensors)))
|
while ((name = ecore_list_next(cfdata->sensors)))
|
||||||
{
|
{
|
||||||
|
|
|
@ -238,8 +238,6 @@ _temperature_sensor_init(Config_Face *inst)
|
||||||
}
|
}
|
||||||
else
|
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");
|
therms = ecore_file_ls("/sys/bus/i2c/devices");
|
||||||
if (therms)
|
if (therms)
|
||||||
{
|
{
|
||||||
|
@ -247,17 +245,17 @@ _temperature_sensor_init(Config_Face *inst)
|
||||||
|
|
||||||
while ((name = ecore_list_next(therms)))
|
while ((name = ecore_list_next(therms)))
|
||||||
{
|
{
|
||||||
char *sensors[] = { "temp1", "temp2", "temp3", "temp4" };
|
|
||||||
int i;
|
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",
|
sprintf(path, "/sys/bus/i2c/devices/%s/temp%d_input", name, i);
|
||||||
name, sensors[i]);
|
|
||||||
if (ecore_file_exists(path))
|
if (ecore_file_exists(path))
|
||||||
{
|
{
|
||||||
|
sprintf(path, "temp%d", i);
|
||||||
inst->sensor_type = SENSOR_TYPE_LINUX_I2C;
|
inst->sensor_type = SENSOR_TYPE_LINUX_I2C;
|
||||||
inst->sensor_name = evas_stringshare_add(sensors[i]);
|
inst->sensor_name = evas_stringshare_add(path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue