More style rework.

This commit is contained in:
imi415 2022-01-03 13:48:09 +08:00
parent 228883c700
commit 66c4b9b064
Signed by: imi415
GPG Key ID: 17F01E106F9F5E0A
12 changed files with 113 additions and 78679 deletions

View File

@ -175,6 +175,7 @@ INCLUDE_DIRS
"lib/htu21d"
"lib/lvgl"
"impl"
"include"
"interface"
"service"
)

View File

@ -0,0 +1,18 @@
#ifndef FONT_HELPER_H
#define FONT_HELPER_H
#define MDI_WIFI_STRENGTH_OFF "\U000F092D"
#define MDI_WIFI_STRENGTH_4 "\U000F0928"
#define MDI_WIFI_STRENGTH_3 "\U000F0925"
#define MDI_WIFI_STRENGTH_2 "\U000F0922"
#define MDI_WIFI_STRENGTH_1 "\U000F091F"
#define MDI_WIFI_STRENGTH_1_ALERT "\U000F0920"
#define MDI_BATTERY "\U000F0079"
#define MDI_BATTERY_10 "\U000F007A"
#define MDI_WEATHER_SUNNY "\U000F0599"
#define MDI_WATER "\U000F058C"
#define MDI_WATER_CHECK "\U000F1504"
#endif

View File

@ -1 +1 @@
0xF007A, 0xF0504, 0xF058C, 0xF0599, 0xF05AD, 0xF092D, 0xF0928
0xF0079, 0xF007A, 0xF0504, 0xF058C, 0xF0599, 0xF05AD, 0xF0928, 0xF092D, 0xF1504

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,7 @@
#include "esp_log.h"
#include "impl_btn.h"
#include "impl_epd.h"
#include "task_config.h"
#define LOG_TAG "IMPL_LVGL"
@ -38,7 +39,7 @@ static uint8_t s_epd_partial_counter = 0;
static uint32_t s_last_key = 0;
static lv_disp_draw_buf_t s_disp_buf;
static lv_color_t *s_disp_store;
static lv_color_t *s_disp_store;
static lv_disp_drv_t s_disp_drv;
static lv_indev_drv_t s_indev_drv;
@ -144,9 +145,9 @@ static void impl_lvgl_button_read(lv_indev_drv_t *drv, lv_indev_data_t *data) {
}
else {
data->key = s_last_key;
data->state = LV_INDEV_STATE_RELEASED;
s_last_key = 0U;
data->key = s_last_key;
data->state = LV_INDEV_STATE_RELEASED;
s_last_key = 0U;
}
}
@ -195,7 +196,7 @@ esp_err_t impl_lvgl_init(void) {
lv_log_register_print_cb(impl_lvgl_log_cb);
s_disp_store = malloc(EPD_DISPLAY_FRAME_SIZE);
if(s_disp_store == NULL) return ESP_FAIL;
if (s_disp_store == NULL) return ESP_FAIL;
lv_disp_draw_buf_init(&s_disp_buf, s_disp_store, NULL, EPD_DISPLAY_PIXEL_COUNT);
lv_disp_drv_init(&s_disp_drv);
@ -217,11 +218,11 @@ esp_err_t impl_lvgl_init(void) {
impl_btn_init();
lv_indev_drv_init(&s_indev_drv);
s_indev_drv.type = LV_INDEV_TYPE_KEYPAD;
s_indev_drv.type = LV_INDEV_TYPE_KEYPAD;
s_indev_drv.read_cb = impl_lvgl_button_read;
lv_indev_t *indev = lv_indev_drv_register(&s_indev_drv);
if(indev == NULL) {
lv_indev_t *indev = lv_indev_drv_register(&s_indev_drv);
if (indev == NULL) {
ESP_LOGE(LOG_TAG, "LVGL indev register failed.");
return ESP_FAIL;
}
@ -241,11 +242,13 @@ esp_err_t impl_lvgl_init(void) {
xSemaphoreGive(s_lv_semphr_handle);
if (xTaskCreate(impl_lvgl_tick_task, "LV_TICK", 4096, NULL, 5, &s_lv_tick_handle) != pdPASS) {
if (xTaskCreate(impl_lvgl_tick_task, "IMPL_LVT", TASK_IMPL_LVT_STACK_SIZE, NULL, TASK_IMPL_LVT_PRIORITY,
&s_lv_tick_handle) != pdPASS) {
ESP_LOGE(LOG_TAG, "LVGL tick task creation failed.");
return ESP_FAIL;
}
if (xTaskCreate(impl_lvgl_timer_task, "LV_TMR", 4096, NULL, 4, &s_lv_task_handle) != pdPASS) {
if (xTaskCreate(impl_lvgl_timer_task, "IMPL_LVE", TASK_IMPL_LVE_STACK_SIZE, NULL, TASK_IMPL_LVE_PRIORITY,
&s_lv_task_handle) != pdPASS) {
ESP_LOGE(LOG_TAG, "LVGL timer handler task creation failed.");
return ESP_FAIL;
}

View File

@ -0,0 +1,19 @@
#ifndef TASK_CONFIG_H
#define TASK_CONFIG_H
#define TASK_IMPL_LVE_STACK_SIZE 4096
#define TASK_IMPL_LVE_PRIORITY 4
#define TASK_IMPL_LVT_STACK_SIZE 4096
#define TASK_IMPL_LVT_PRIORITY 5
#define TASK_SVC_CLK_STACK_SIZE 2048
#define TASK_SVC_CLK_PRIORITY 6
#define TASK_SVC_DHT_STACK_SIZE 2048
#define TASK_SVC_DHT_PRIORITY 6
#define TASK_SVC_WIFI_STACK_SIZE 2048
#define TASK_SVC_WIFI_PRIORITY 6
#endif

View File

@ -13,13 +13,13 @@
typedef struct {
if_standby_component_t component;
char payload[IF_STANDBY_PAYLOAD_LENGTH];
char payload[IF_STANDBY_PAYLOAD_LENGTH];
} if_standby_request_t;
static TaskHandle_t s_if_standby_handle;
static TaskHandle_t s_if_standby_handle;
static QueueHandle_t s_standby_screen_queue;
lv_obj_t *g_standby_screen;
lv_obj_t *g_standby_screen;
void if_standby_event_handler(lv_event_t *ev) {
int button_event = (int)ev->user_data;
@ -159,22 +159,30 @@ void if_standby_task(void *pvParameters) {
xQueueReceive(s_standby_screen_queue, &update_request, portMAX_DELAY);
impl_lvgl_lock();
switch (update_request.component) {
case IF_STANDBY_COMPONENT_TEMP:
lv_label_set_text(temp_label, update_request.payload);
lv_obj_align(temp_label, LV_ALIGN_CENTER, 0, 16);
case IF_STANDBY_COMPONENT_DATE:
lv_label_set_text(date_label, update_request.payload);
lv_obj_set_align(date_label, LV_ALIGN_CENTER);
break;
case IF_STANDBY_COMPONENT_HUMID:
lv_label_set_text(humid_label, update_request.payload);
lv_obj_align(humid_label, LV_ALIGN_CENTER, 0, 16);
break;
case IF_STANDBY_COMPONENT_HUMID_ICON:
lv_label_set_text(humid_icon_label, update_request.payload);
lv_obj_align(humid_icon_label, LV_ALIGN_CENTER, 0, -16);
break;
case IF_STANDBY_COMPONENT_TEMP:
lv_label_set_text(temp_label, update_request.payload);
lv_obj_align(temp_label, LV_ALIGN_CENTER, 0, 16);
break;
case IF_STANDBY_COMPONENT_TEMP_ICON:
lv_label_set_text(temp_icon_label, update_request.payload);
lv_obj_align(temp_icon_label, LV_ALIGN_CENTER, 0, -16);
break;
case IF_STANDBY_COMPONENT_TIME:
lv_label_set_text(time_label, update_request.payload);
lv_obj_set_align(time_label, LV_ALIGN_CENTER);
break;
case IF_STANDBY_COMPONENT_DATE:
lv_label_set_text(date_label, update_request.payload);
lv_obj_set_align(date_label, LV_ALIGN_CENTER);
break;
case IF_STANDBY_COMPONENT_WEEKDAY:
lv_label_set_text(weekday_label, update_request.payload);
lv_obj_set_align(weekday_label, LV_ALIGN_CENTER);
@ -201,16 +209,24 @@ esp_err_t if_standby_init(void) {
return ESP_FAIL;
}
if (xTaskCreate(if_standby_task, "STBY_TASK", 4096, NULL, 6, &s_if_standby_handle) != pdPASS) {
if (xTaskCreate(if_standby_task, "IF_STBY", 4096, NULL, 6, &s_if_standby_handle) != pdPASS) {
return ESP_FAIL;
}
return ESP_OK;
}
/**
* @brief Update component content on standby screen.
*
* @param component if_standby_component_t
* @param fmt printf-style format
* @param ...
* @return esp_err_t
*/
esp_err_t if_standby_component_update(if_standby_component_t component, const char *fmt, ...) {
if_standby_request_t req;
va_list ap;
va_list ap;
req.component = component;
@ -218,9 +234,10 @@ esp_err_t if_standby_component_update(if_standby_component_t component, const ch
vsnprintf(req.payload, IF_STANDBY_PAYLOAD_LENGTH, fmt, ap);
va_end(ap);
if(xQueueSendToBack(s_standby_screen_queue, &req, 0) != pdPASS) {
// Queue update command.
if (xQueueSendToBack(s_standby_screen_queue, &req, 0) != pdPASS) {
return ESP_FAIL;
}
return ESP_OK;
}
}

View File

@ -3,21 +3,22 @@
#include "esp_system.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/task.h"
#include "lvgl.h"
#define IF_STANDBY_PAYLOAD_LENGTH 16
typedef enum {
IF_STANDBY_COMPONENT_WIFI,
IF_STANDBY_COMPONENT_WEEKDAY,
IF_STANDBY_COMPONENT_DATE,
IF_STANDBY_COMPONENT_BAT,
IF_STANDBY_COMPONENT_DATE,
IF_STANDBY_COMPONENT_HUMID,
IF_STANDBY_COMPONENT_HUMID_ICON,
IF_STANDBY_COMPONENT_TIME,
IF_STANDBY_COMPONENT_TEMP,
IF_STANDBY_COMPONENT_HUMID,
IF_STANDBY_COMPONENT_TEMP_ICON,
IF_STANDBY_COMPONENT_WEEKDAY,
IF_STANDBY_COMPONENT_WIFI,
} if_standby_component_t;
extern lv_obj_t *g_standby_screen;
@ -25,4 +26,4 @@ extern lv_obj_t *g_standby_screen;
esp_err_t if_standby_init(void);
esp_err_t if_standby_component_update(if_standby_component_t component, const char *fmt, ...);
#endif
#endif

View File

@ -4,6 +4,7 @@
#include "esp_log.h"
#include "if_standby.h"
#include "task_config.h"
#define LOG_TAG "SERVICE_CLOCK"
@ -48,7 +49,8 @@ void clock_task(void *pvParameters) {
}
esp_err_t service_clock_init(void) {
if (xTaskCreate(clock_task, "CLOCK", 2048, NULL, 6, &s_clock_task_handle) != pdTRUE) {
if (xTaskCreate(clock_task, "SVC_CLK", TASK_SVC_CLK_STACK_SIZE, NULL, TASK_SVC_CLK_PRIORITY,
&s_clock_task_handle) != pdTRUE) {
return ESP_FAIL;
}

View File

@ -3,6 +3,7 @@
#include "esp_log.h"
#include "if_standby.h"
#include "impl_dht.h"
#include "task_config.h"
#define LOG_TAG "SERVICE_DHT"
@ -22,7 +23,7 @@ void dht_task(void *pvParameters) {
htu21d_result_t result;
for (;;) {
while(htu21d_measure(&s_htu, &result) != HTU21D_OK) {
while (htu21d_measure(&s_htu, &result) != HTU21D_OK) {
vTaskDelay(pdMS_TO_TICKS(100));
}
@ -36,7 +37,8 @@ void dht_task(void *pvParameters) {
esp_err_t service_dht_init(void) {
htu21d_init(&s_htu);
if (xTaskCreate(dht_task, "DHT", 2048, NULL, 6, &s_dht_task_handle) != pdTRUE) {
if (xTaskCreate(dht_task, "SVC_DHT", TASK_SVC_DHT_STACK_SIZE, NULL, TASK_SVC_DHT_PRIORITY, &s_dht_task_handle) !=
pdTRUE) {
return ESP_FAIL;
}

View File

@ -10,6 +10,7 @@
#include "if_wifi.h"
#include "nvs_flash.h"
#include "sdkconfig.h"
#include "task_config.h"
#define LOG_TAG "SVC_WIFI"
@ -118,7 +119,8 @@ esp_err_t service_wifi_init(void) {
return ESP_FAIL;
}
if (xTaskCreate(service_wifi_task, "SVC_WIFI", 2048, NULL, 6, &s_service_wifi_task_handle) != pdPASS) {
if (xTaskCreate(service_wifi_task, "SVC_WIFI", TASK_SVC_WIFI_STACK_SIZE, NULL, TASK_SVC_WIFI_PRIORITY,
&s_service_wifi_task_handle) != pdPASS) {
return ESP_FAIL;
}

12
partitions.csv Normal file
View File

@ -0,0 +1,12 @@
# This file format is not compatible with CSV,
# as comments are supported, whitespaces are trimmed.
#
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x4000,
otadata, data, ota, 0xd000, 0x2000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 2M,
ota_0, app, ota_0, 0x210000, 2M,
ota_1, app, ota_1, 0x410000, 2M,
nvs_keys, data, nvs_keys, 0x610000, 0x1000,
spiffs, data, spiffs, 0x620000, 8M,
1 # This file format is not compatible with CSV,
2 # as comments are supported, whitespaces are trimmed.
3 #
4 # Name, Type, SubType, Offset, Size, Flags
5 nvs, data, nvs, 0x9000, 0x4000,
6 otadata, data, ota, 0xd000, 0x2000,
7 phy_init, data, phy, 0xf000, 0x1000,
8 factory, app, factory, 0x10000, 2M,
9 ota_0, app, ota_0, 0x210000, 2M,
10 ota_1, app, ota_1, 0x410000, 2M,
11 nvs_keys, data, nvs_keys, 0x610000, 0x1000,
12 spiffs, data, spiffs, 0x620000, 8M,