Skip to content

Commit

Permalink
Increase the awtk memory to support demo_ui_app
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-mao committed Nov 12, 2019
1 parent 4a87244 commit f812fed
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion components/awtk
29 changes: 25 additions & 4 deletions components/esp32-port/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <time.h>
#include <sys/time.h>


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;
}

0 comments on commit f812fed

Please sign in to comment.