132 lines
4.5 KiB
C
132 lines
4.5 KiB
C
#include "if_standby.h"
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include "esp_log.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "impl_lvgl.h"
|
|
|
|
#define LOG_TAG "IF_STANDBY"
|
|
|
|
static TaskHandle_t s_if_standby_handle;
|
|
|
|
lv_obj_t *g_standby_screen;
|
|
|
|
void if_standby_task(void *pvParameters) {
|
|
impl_lvgl_lock();
|
|
|
|
// 1st line
|
|
lv_obj_t *top_container = lv_obj_create(g_standby_screen);
|
|
|
|
lv_obj_set_size(top_container, 400, 60);
|
|
lv_obj_align(top_container, LV_ALIGN_TOP_MID, 0, 0);
|
|
lv_obj_set_flex_flow(top_container, LV_FLEX_FLOW_ROW);
|
|
|
|
lv_obj_t *network_status_obj = lv_obj_create(top_container);
|
|
lv_obj_t *weekday_obj = lv_obj_create(top_container);
|
|
lv_obj_t *date_obj = lv_obj_create(top_container);
|
|
lv_obj_t *battery_obj = lv_obj_create(top_container);
|
|
|
|
lv_obj_set_size(network_status_obj, 50, 50);
|
|
lv_obj_set_size(battery_obj, 50, 50);
|
|
|
|
lv_obj_set_height(weekday_obj, 50);
|
|
lv_obj_set_height(date_obj, 50);
|
|
|
|
lv_obj_set_flex_grow(weekday_obj, 1);
|
|
lv_obj_set_flex_grow(date_obj, 3);
|
|
|
|
// 2nd line
|
|
lv_obj_t *main_container = lv_obj_create(g_standby_screen);
|
|
|
|
lv_obj_set_size(main_container, 400, 235);
|
|
lv_obj_align_to(main_container, top_container, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
|
|
lv_obj_set_flex_flow(main_container, LV_FLEX_FLOW_ROW);
|
|
|
|
lv_obj_t *time_obj = lv_obj_create(main_container);
|
|
|
|
lv_obj_set_height(time_obj, 225);
|
|
lv_obj_set_flex_grow(time_obj, 1);
|
|
|
|
// 2nd line, DHT column
|
|
lv_obj_t *dht_container = lv_obj_create(main_container);
|
|
|
|
lv_obj_set_size(dht_container, 110, 225);
|
|
lv_obj_set_flex_flow(dht_container, LV_FLEX_FLOW_COLUMN);
|
|
|
|
lv_obj_t *temp_obj = lv_obj_create(dht_container);
|
|
lv_obj_t *humid_obj = lv_obj_create(dht_container);
|
|
|
|
lv_obj_set_width(temp_obj, 100);
|
|
lv_obj_set_width(humid_obj, 100);
|
|
|
|
lv_obj_set_flex_grow(temp_obj, 1);
|
|
lv_obj_set_flex_grow(humid_obj, 1);
|
|
|
|
// Create labels
|
|
lv_obj_t *network_status_label = lv_label_create(network_status_obj);
|
|
lv_obj_t *weekday_label = lv_label_create(weekday_obj);
|
|
lv_obj_t *date_label = lv_label_create(date_obj);
|
|
lv_obj_t *battery_label = lv_label_create(battery_obj);
|
|
lv_obj_t *time_label = lv_label_create(time_obj);
|
|
lv_obj_t *temp_icon_label = lv_label_create(temp_obj);
|
|
lv_obj_t *temp_label = lv_label_create(temp_obj);
|
|
lv_obj_t *humid_icon_label = lv_label_create(humid_obj);
|
|
lv_obj_t *humid_label = lv_label_create(humid_obj);
|
|
|
|
lv_obj_set_style_text_font(network_status_label, &material_webfont_32, 0);
|
|
lv_obj_set_style_text_font(weekday_label, &bebas_neue_32, 0);
|
|
lv_obj_set_style_text_font(date_label, &bebas_neue_32, 0);
|
|
lv_obj_set_style_text_font(battery_label, &material_webfont_32, 0);
|
|
lv_obj_set_style_text_font(time_label, &bebas_neue_120, 0);
|
|
lv_obj_set_style_text_font(temp_icon_label, &material_webfont_32, 0);
|
|
lv_obj_set_style_text_font(temp_label, &bebas_neue_32, 0);
|
|
lv_obj_set_style_text_font(humid_icon_label, &material_webfont_32, 0);
|
|
lv_obj_set_style_text_font(humid_label, &bebas_neue_32, 0);
|
|
|
|
|
|
lv_label_set_text(network_status_label, "\U000F092D");
|
|
lv_label_set_text(battery_label, "\U000F007A");
|
|
lv_label_set_text(weekday_label, "SUN");
|
|
lv_label_set_text(date_label, "1970/01/01");
|
|
lv_label_set_text(time_label, "23:59");
|
|
lv_label_set_text(temp_icon_label, "\U000F0599");
|
|
lv_label_set_text(temp_label, "30.00C");
|
|
lv_label_set_text(humid_icon_label, "\U000F058C");
|
|
lv_label_set_text(humid_label, "100.00%");
|
|
|
|
lv_obj_set_align(network_status_label, LV_ALIGN_CENTER);
|
|
lv_obj_set_align(battery_label, LV_ALIGN_CENTER);
|
|
lv_obj_set_align(weekday_label, LV_ALIGN_CENTER);
|
|
lv_obj_set_align(date_label, LV_ALIGN_CENTER);
|
|
lv_obj_set_align(time_label, LV_ALIGN_CENTER);
|
|
lv_obj_align(temp_icon_label, LV_ALIGN_CENTER, 0, -16);
|
|
lv_obj_align(temp_label, LV_ALIGN_CENTER, 0, 16);
|
|
lv_obj_align(humid_icon_label, LV_ALIGN_CENTER, 0, -16);
|
|
lv_obj_align(humid_label, LV_ALIGN_CENTER, 0, 16);
|
|
|
|
impl_lvgl_unlock();
|
|
|
|
struct timeval tv;
|
|
struct timezone tz;
|
|
|
|
for (;;) {
|
|
gettimeofday(&tv, &tz);
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
}
|
|
}
|
|
|
|
esp_err_t if_standby_init(void) {
|
|
impl_lvgl_lock();
|
|
g_standby_screen = lv_obj_create(NULL);
|
|
lv_disp_load_scr(g_standby_screen);
|
|
impl_lvgl_unlock();
|
|
|
|
if (xTaskCreate(if_standby_task, "STBY_TASK", 1024, NULL, 6, &s_if_standby_handle) != pdPASS) {
|
|
return ESP_FAIL;
|
|
}
|
|
|
|
return ESP_OK;
|
|
} |