Skip to content

Commit

Permalink
Merge pull request #156 from jakkra/jakkra_sensor_summary_co2
Browse files Browse the repository at this point in the history
sensor summary app: Add CO2 levels.
  • Loading branch information
Kampi authored Nov 26, 2023
2 parents ced8bfe + e3f13c1 commit 8b2d33b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/src/applications/sensors_summary/sensors_summary_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,19 @@ static void timer_callback(lv_timer_t *timer)
float humidity = 0.0;
float light = -1.0;
float iaq = -1.0;
float co2 = -1.0;

zsw_environment_sensor_get(&temperature, &humidity, &pressure);
zsw_environment_sensor_get_iaq(&iaq);
zsw_environment_sensor_get_co2(&co2);
zsw_pressure_sensor_get_pressure(&pressure);
zsw_light_sensor_get_light(&light);

sensors_summary_ui_set_pressure(pressure);
sensors_summary_ui_set_temp(temperature);
sensors_summary_ui_set_humidity(humidity);
sensors_summary_ui_set_iaq(iaq);
sensors_summary_ui_set_co2(co2);
sensors_summary_ui_set_light(light);
sensors_summary_ui_set_rel_height(get_relative_height_m(relative_pressure, pressure, temperature));
}
Expand Down
14 changes: 14 additions & 0 deletions app/src/applications/sensors_summary/sensors_summary_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ static lv_obj_t *temp_label;
static lv_obj_t *rel_height_label;
static lv_obj_t *iaq_label;
static lv_obj_t *light_label;
static lv_obj_t *co2_label;

static void event_set_reference_button(lv_event_t *e)
{
Expand Down Expand Up @@ -88,6 +89,14 @@ static void create_ui(lv_obj_t *parent)
lv_obj_set_align(light_label, LV_ALIGN_LEFT_MID);
lv_label_set_text(light_label, "Light:");

co2_label = lv_label_create(parent);
lv_obj_set_width(co2_label, LV_SIZE_CONTENT);
lv_obj_set_height(co2_label, LV_SIZE_CONTENT);
lv_obj_set_x(co2_label, 15);
lv_obj_set_y(co2_label, 35);
lv_obj_set_align(co2_label, LV_ALIGN_LEFT_MID);
lv_label_set_text(co2_label, "CO2:");

lv_obj_add_event_cb(set_ref_btn, event_set_reference_button, LV_EVENT_CLICKED, NULL);
}

Expand Down Expand Up @@ -141,4 +150,9 @@ void sensors_summary_ui_set_light(float light)
void sensors_summary_ui_set_iaq(float iaq)
{
lv_label_set_text_fmt(iaq_label, "IAQ:\t%.2f", iaq);
}

void sensors_summary_ui_set_co2(float co2)
{
lv_label_set_text_fmt(co2_label, "CO2:\t%.2f ppm", co2);
}
4 changes: 3 additions & 1 deletion app/src/applications/sensors_summary/sensors_summary_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ void sensors_summary_ui_set_rel_height(float rel_height);

void sensors_summary_ui_set_light(float light);

void sensors_summary_ui_set_iaq(float iaq);
void sensors_summary_ui_set_iaq(float iaq);

void sensors_summary_ui_set_co2(float co2);

0 comments on commit 8b2d33b

Please sign in to comment.