diff --git a/src/app_cfg.h b/src/app_cfg.h index c751e52..0f8ecdc 100644 --- a/src/app_cfg.h +++ b/src/app_cfg.h @@ -168,6 +168,12 @@ typedef enum{ EV_POLL_MAX, }ev_poll_e; +/********************************************************************** + * Sensor configuration + */ + +#define SHOW_SMILEY + /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) } diff --git a/src/device.c b/src/device.c index 7cde1f3..7afa863 100644 --- a/src/device.c +++ b/src/device.c @@ -104,6 +104,12 @@ drv_pm_pinCfg_t g_sensorPmCfg[] = { * LOCAL VARIABLES */ +//const scomfort_t def_cmf = { +_attribute_data_retention_ scomfort_t cmf = { + .t = {2100,2600}, // x0.01 C + .h = {3000,6000} // x0.01 % +}; + /********************************************************************** * FUNCTIONS @@ -165,6 +171,14 @@ void user_app_init(void) read_sensor_start(10000); } +_attribute_ram_code_ +u8 is_comfort(s16 t, u16 h) { + u8 ret = 0; + if (t >= cmf.t[0] && t <= cmf.t[1] && h >= cmf.h[0] && h <= cmf.h[1]) + ret = 1; + return ret; +} + void read_sensor_and_save() { s16 temp = 0; u16 humi = 0; @@ -183,6 +197,11 @@ void read_sensor_and_save() { show_temp_symbol(1); show_big_number(g_zcl_temperatureAttrs.measuredValue / 10, 1); show_small_number(g_zcl_relHumidityAttrs.measuredValue / 100, 1); +#if defined(SHOW_SMILEY) + show_smiley( + is_comfort(g_zcl_temperatureAttrs.measuredValue, g_zcl_relHumidityAttrs.measuredValue) ? 1 : 2 + ); +#endif update_lcd(); } diff --git a/src/device.h b/src/device.h index 159fc7c..09229fd 100644 --- a/src/device.h +++ b/src/device.h @@ -103,6 +103,11 @@ typedef struct{ u16 fastPollTimeoutMax; }zcl_pollCtrlAttr_t; +typedef struct _comfort_t { + s16 t[2]; + u16 h[2]; +} scomfort_t; + /********************************************************************** * GLOBAL VARIABLES */ @@ -128,6 +133,8 @@ extern zcl_pollCtrlAttr_t g_zcl_pollCtrlAttrs; #define zcl_iasZoneAttrGet() &g_zcl_iasZoneAttrs #define zcl_pollCtrlAttrGet() &g_zcl_pollCtrlAttrs +extern scomfort_t cmf; + /********************************************************************** * FUNCTIONS */