From a15ac5f039bf28e35ce4fb6d54630955a8e61953 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Sun, 4 Dec 2016 22:46:02 +0900 Subject: [PATCH] temp module - avoid a bit of cpu sendingh edje message if temp same each poll - check if temp actually changed and only send edje message if tempt actually did change. saves some cpu while polling in the bg for these things. @optimize --- src/modules/temperature/e_mod_main.c | 3 +++ src/modules/temperature/e_mod_main.h | 1 + 2 files changed, 4 insertions(+) diff --git a/src/modules/temperature/e_mod_main.c b/src/modules/temperature/e_mod_main.c index f1e242228..861e31332 100644 --- a/src/modules/temperature/e_mod_main.c +++ b/src/modules/temperature/e_mod_main.c @@ -77,6 +77,8 @@ _temperature_apply(Config_Face *inst, int temp) { char buf[64]; + if (inst->temp == temp) return; + inst->temp = temp; if (temp != -999) { if (inst->units == FAHRENHEIT) temp = (temp * 9.0 / 5.0) + 32; @@ -139,6 +141,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) inst->high = 80; inst->sensor_type = SENSOR_TYPE_NONE; inst->sensor_name = NULL; + inst->temp = -900; inst->units = CELSIUS; #ifdef HAVE_EEZE inst->backend = UDEV; diff --git a/src/modules/temperature/e_mod_main.h b/src/modules/temperature/e_mod_main.h index a61c92148..52077405c 100644 --- a/src/modules/temperature/e_mod_main.h +++ b/src/modules/temperature/e_mod_main.h @@ -55,6 +55,7 @@ struct _Config_Face int poll_interval; int low, high; int sensor_type; + int temp; const char *sensor_name; Unit units; /* config state */