forked from enlightenment/enlightenment
I'm really bad at this whole subversion thing...
SVN revision: 49070
This commit is contained in:
parent
e41b1d92f1
commit
19e7a56f65
|
@ -1,14 +1,77 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
|
||||
|
||||
int
|
||||
_temperature_cb_exe_data(void *data, int type, void *event)
|
||||
{
|
||||
return 1;
|
||||
{
|
||||
Ecore_Exe_Event_Data *ev;
|
||||
Config_Face *inst;
|
||||
int temp;
|
||||
|
||||
ev = event;
|
||||
inst = data;
|
||||
if (ev->exe != inst->tempget_exe) return 1;
|
||||
temp = -999;
|
||||
if ((ev->lines) && (ev->lines[0].line))
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; ev->lines[i].line; i++)
|
||||
{
|
||||
if (!strcmp(ev->lines[i].line, "ERROR"))
|
||||
temp = -999;
|
||||
else
|
||||
temp = atoi(ev->lines[i].line);
|
||||
}
|
||||
}
|
||||
if (temp != -999)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
if (inst->units == FAHRENHEIT)
|
||||
temp = (temp * 9.0 / 5.0) + 32;
|
||||
|
||||
if (!inst->have_temp)
|
||||
{
|
||||
/* enable therm object */
|
||||
edje_object_signal_emit(inst->o_temp, "e,state,known", "");
|
||||
inst->have_temp = 1;
|
||||
}
|
||||
|
||||
if (inst->units == FAHRENHEIT)
|
||||
snprintf(buf, sizeof(buf), "%i°F", temp);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%i°C", temp);
|
||||
|
||||
_temperature_face_level_set(inst,
|
||||
(double)(temp - inst->low) /
|
||||
(double)(inst->high - inst->low));
|
||||
edje_object_part_text_set(inst->o_temp, "e.text.reading", buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inst->have_temp)
|
||||
{
|
||||
/* disable therm object */
|
||||
edje_object_signal_emit(inst->o_temp, "e,state,unknown", "");
|
||||
edje_object_part_text_set(inst->o_temp, "e.text.reading", "N/A");
|
||||
_temperature_face_level_set(inst, 0.5);
|
||||
inst->have_temp = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_temperature_cb_exe_del(void *data, int type, void *event)
|
||||
{
|
||||
return 1;
|
||||
Ecore_Exe_Event_Del *ev;
|
||||
Config_Face *inst;
|
||||
|
||||
ev = event;
|
||||
inst = data;
|
||||
if (ev->exe != inst->tempget_exe) return 1;
|
||||
inst->tempget_exe = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
|
||||
int
|
||||
temperature_udev_update_poll(void *data)
|
||||
{
|
||||
temperature_udev_update(data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
temperature_udev_update(void *data)
|
||||
{
|
||||
Config_Face *inst;
|
||||
Eina_List *l, *l2;
|
||||
double temp;
|
||||
char *syspath;
|
||||
const char *test;
|
||||
char buf[256];
|
||||
|
||||
inst = data;
|
||||
temp = -999;
|
||||
|
||||
if (!inst->tempdevs)
|
||||
{
|
||||
inst->tempdevs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR, NULL);
|
||||
EINA_LIST_FOREACH_SAFE(inst->tempdevs, l, l2, syspath)
|
||||
{
|
||||
if ((eeze_udev_syspath_get_sysattr(syspath, "fan1_input")) ||
|
||||
(eeze_udev_syspath_get_sysattr(syspath, "pwm1_stop_time")))
|
||||
{
|
||||
eina_stringshare_del(syspath);
|
||||
inst->tempdevs = eina_list_remove_list(inst->tempdevs, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (eina_list_count(inst->tempdevs))
|
||||
{
|
||||
temp = 0;
|
||||
EINA_LIST_FOREACH(inst->tempdevs, l, syspath)
|
||||
{
|
||||
if ((test = eeze_udev_syspath_get_sysattr(syspath, "temp1_input")))
|
||||
temp += (strtod(test, NULL) / 1000); /* udev reports temp in (celcius * 1000) for some reason */
|
||||
}
|
||||
temp /= (double)eina_list_count(inst->tempdevs);
|
||||
}
|
||||
if (temp != -999)
|
||||
{
|
||||
if (inst->units == FAHRENHEIT)
|
||||
temp = (temp * 9.0 / 5.0) + 32;
|
||||
|
||||
if (!inst->have_temp)
|
||||
{
|
||||
/* enable therm object */
|
||||
edje_object_signal_emit(inst->o_temp, "e,state,known", "");
|
||||
inst->have_temp = 1;
|
||||
}
|
||||
|
||||
if (inst->units == FAHRENHEIT)
|
||||
snprintf(buf, sizeof(buf), "%2.2f°F", temp);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%2.2f°C", temp);
|
||||
|
||||
_temperature_face_level_set(inst,
|
||||
(double)(temp - inst->low) /
|
||||
(double)(inst->high - inst->low));
|
||||
edje_object_part_text_set(inst->o_temp, "e.text.reading", buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inst->have_temp)
|
||||
{
|
||||
/* disable therm object */
|
||||
edje_object_signal_emit(inst->o_temp, "e,state,unknown", "");
|
||||
edje_object_part_text_set(inst->o_temp, "e.text.reading", "N/A");
|
||||
_temperature_face_level_set(inst, 0.5);
|
||||
inst->have_temp = 0;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue