From f812fed58eb945754ba746067ba2800e0ab7beff Mon Sep 17 00:00:00 2001 From: maojianxin Date: Fri, 1 Nov 2019 19:28:22 +0800 Subject: [PATCH] Increase the awtk memory to support demo_ui_app --- components/awtk | 2 +- components/esp32-port/platform.c | 29 +++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/components/awtk b/components/awtk index cd002a0..036dd4d 160000 --- a/components/awtk +++ b/components/awtk @@ -1 +1 @@ -Subproject commit cd002a018ceab415be8b6e6652178507c1d0dba7 +Subproject commit 036dd4d223186533084868c20eb1068d4da47f1e diff --git a/components/esp32-port/platform.c b/components/esp32-port/platform.c index 24bde36..793c4fd 100644 --- a/components/esp32-port/platform.c +++ b/components/esp32-port/platform.c @@ -22,20 +22,41 @@ #include "tkc/mem.h" #include "base/timer.h" #include "tkc/types_def.h" +#include "tkc/date_time.h" #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" #include "freertos/task.h" +#include #include - static bool_t s_inited = FALSE; -static uint32_t s_heam_mem[4096]; +#define AWTK_MEM_SIZE 1 * 1024 * 1024 + +static ret_t date_time_get_now_impl(date_time_t* dt) { + time_t now = time(0); + struct tm timeinfo; + localtime_r(&now, &timeinfo); + dt->second = timeinfo.tm_sec; + dt->minute = timeinfo.tm_min; + dt->hour = timeinfo.tm_hour; + dt->day = timeinfo.tm_mday; + dt->month = timeinfo.tm_mon + 1; + dt->year = timeinfo.tm_year + 1900; + dt->wday = timeinfo.tm_wday; + + return RET_OK; +} ret_t platform_prepare(void) { if(!s_inited) { s_inited = TRUE; - tk_mem_init(s_heam_mem, sizeof(s_heam_mem)); - } + uint32_t* s_heam_mem = heap_caps_malloc(AWTK_MEM_SIZE, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); + if (s_heam_mem == NULL) { + log_error("s_heam_mem allocate %d bytes memory fail", AWTK_MEM_SIZE); + } + tk_mem_init(s_heam_mem, AWTK_MEM_SIZE); + } + date_time_set_impl(date_time_get_now_impl); return RET_OK; }