Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bitclock-fw/main/libs/aqi_alert.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ aqi_alert_reason_t aqi_alerts_check(aqi_data_t *aqi_data) {
if (aqi_data->voc_index >= 250) {
return AQI_ALERT_VOC_HIGH;
}
if (aqi_data->co2_ppm >= 700) {
if (aqi_data->co2_ppm >= 800) {
return AQI_ALERT_CO2_HIGH;
}

Expand Down
15 changes: 15 additions & 0 deletions bitclock-fw/main/lvgl/views/aqi_alert.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ LV_IMAGE_DECLARE(material_mode_fan);

lv_obj_t *fan_img;
lv_obj_t *alert_label;
lv_obj_t *co2_label;

lv_helper_aqi_alert_data_t lv_helper_aqi_alert_data = {0};

Expand All @@ -29,6 +30,13 @@ void lv_helper_aqi_alert_create(bool align_right) {
lv_obj_align(alert_label,
align_right ? LV_ALIGN_TOP_RIGHT : LV_ALIGN_TOP_LEFT,
36 * (align_right ? -1 : 1), 17);

co2_label = lv_label_create(screen);
bool align_co2_right = !align_right;
lv_obj_add_style(co2_label, &sublabel_style, LV_PART_MAIN);
lv_obj_align(co2_label,
LV_ALIGN_TOP_MID,
0, 17);
}

void lv_helper_aqi_alert_update(lv_helper_aqi_alert_data_t *data) {
Expand Down Expand Up @@ -60,8 +68,15 @@ void lv_helper_aqi_alert_update(lv_helper_aqi_alert_data_t *data) {
label_str = "";
break;
}

set_text_if_changed(alert_label, label_str);

// Round to down to nearest 50 ppm
uint16_t rounded_co2 = data->co2_ppm / 50 * 50;
static char co2_str[12];
snprintf(co2_str, sizeof(co2_str), "%" PRIu16 " PPM", rounded_co2);
set_text_if_changed(co2_label, co2_str);

void *image_src = NULL;
if (data->alert_reason != AQI_ALERT_NONE) {
image_src = &material_mode_fan;
Expand Down
1 change: 1 addition & 0 deletions bitclock-fw/main/lvgl/views/aqi_alert.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

typedef struct {
aqi_alert_reason_t alert_reason;
uint16_t co2_ppm;
} lv_helper_aqi_alert_data_t;
extern lv_helper_aqi_alert_data_t lv_helper_aqi_alert_data;

Expand Down
1 change: 1 addition & 0 deletions bitclock-fw/main/tasks/eink_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ void eink_task_run(void *pvParameters) {
static bool demo_mode = false;
if (!demo_mode) {
lv_helper_aqi_alert_data.alert_reason = aqi_alerts_check(&aqi_data);
lv_helper_aqi_alert_data.co2_ppm = aqi_data.co2_ppm;
} else {
// Conference display mode
// If it is 0-5 seconds within the minute, or 30-35 seconds within the
Expand Down