Skip to content

Commit

Permalink
show smiley
Browse files Browse the repository at this point in the history
  • Loading branch information
devbis committed Oct 9, 2023
1 parent e92009f commit 7213afb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/app_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
19 changes: 19 additions & 0 deletions src/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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();
}

Expand Down
7 changes: 7 additions & 0 deletions src/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
*/
Expand Down

0 comments on commit 7213afb

Please sign in to comment.