Skip to content

Commit

Permalink
esp8266/modesp: Add freemem() and meminfo() functions.
Browse files Browse the repository at this point in the history
They call into vendor SDK functions system_get_free_heap_size() and
system_print_meminfo() respectively.
  • Loading branch information
Paul Sokolovsky committed Apr 10, 2016
1 parent c734de4 commit 1cc81ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions esp8266/modesp.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,17 @@ STATIC mp_obj_t esp_neopixel_write_(mp_obj_t pin, mp_obj_t buf, mp_obj_t is800k)
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(esp_neopixel_write_obj, esp_neopixel_write_);

STATIC mp_obj_t esp_freemem() {
return MP_OBJ_NEW_SMALL_INT(system_get_free_heap_size());
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_freemem_obj, esp_freemem);

STATIC mp_obj_t esp_meminfo() {
system_print_meminfo();
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_meminfo_obj, esp_meminfo);

STATIC const mp_map_elem_t esp_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_esp) },

Expand All @@ -632,6 +643,8 @@ STATIC const mp_map_elem_t esp_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_getaddrinfo), (mp_obj_t)&esp_getaddrinfo_obj },
#endif
{ MP_OBJ_NEW_QSTR(MP_QSTR_neopixel_write), (mp_obj_t)&esp_neopixel_write_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_freemem), (mp_obj_t)&esp_freemem_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_meminfo), (mp_obj_t)&esp_meminfo_obj },

#if MODESP_INCLUDE_CONSTANTS
{ MP_OBJ_NEW_QSTR(MP_QSTR_SLEEP_NONE),
Expand Down
2 changes: 2 additions & 0 deletions esp8266/qstrdefsport.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ Q(flash_read)
Q(flash_write)
Q(flash_erase)
Q(sdk_version)
Q(freemem)
Q(meminfo)
Q(getaddrinfo)
Q(send)
Q(sendto)
Expand Down

0 comments on commit 1cc81ed

Please sign in to comment.