From 0e4cae521288208e637d609fc00503fc828217b6 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 1 Aug 2016 00:03:55 +0300 Subject: [PATCH] esp8266: Make APA102 driver inclusion configurable. --- esp8266/espapa102.c | 5 +++++ esp8266/modesp.c | 4 ++++ esp8266/mpconfigport.h | 1 + 3 files changed, 10 insertions(+) diff --git a/esp8266/espapa102.c b/esp8266/espapa102.c index e5f3024b10..4295fe42d8 100644 --- a/esp8266/espapa102.c +++ b/esp8266/espapa102.c @@ -24,6 +24,9 @@ * THE SOFTWARE. */ +#include "py/mpconfig.h" +#if MICROPY_ESP8266_APA102 + #include #include "c_types.h" #include "eagle_soc.h" @@ -108,3 +111,5 @@ void esp_apa102_write(uint8_t clockPin, uint8_t dataPin, uint8_t *pixels, uint32 _esp_apa102_append_additionial_cycles(clockPinMask, dataPinMask, numBytes); _esp_apa102_end_frame(clockPinMask, dataPinMask); } + +#endif diff --git a/esp8266/modesp.c b/esp8266/modesp.c index 99f063a756..1b787011c4 100644 --- a/esp8266/modesp.c +++ b/esp8266/modesp.c @@ -642,6 +642,7 @@ 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_); +#if MICROPY_ESP8266_APA102 STATIC mp_obj_t esp_apa102_write_(mp_obj_t clockPin, mp_obj_t dataPin, mp_obj_t buf) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ); @@ -651,6 +652,7 @@ STATIC mp_obj_t esp_apa102_write_(mp_obj_t clockPin, mp_obj_t dataPin, mp_obj_t return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(esp_apa102_write_obj, esp_apa102_write_); +#endif STATIC mp_obj_t esp_freemem() { return MP_OBJ_NEW_SMALL_INT(system_get_free_heap_size()); @@ -695,7 +697,9 @@ 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 }, + #if MICROPY_ESP8266_APA102 { MP_OBJ_NEW_QSTR(MP_QSTR_apa102_write), (mp_obj_t)&esp_apa102_write_obj }, + #endif { MP_OBJ_NEW_QSTR(MP_QSTR_dht_readinto), (mp_obj_t)&dht_readinto_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 }, diff --git a/esp8266/mpconfigport.h b/esp8266/mpconfigport.h index 0cd7e8c313..7b3558ffc2 100644 --- a/esp8266/mpconfigport.h +++ b/esp8266/mpconfigport.h @@ -88,6 +88,7 @@ #define MICROPY_FATFS_LFN_CODE_PAGE (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */ #define MICROPY_FSUSERMOUNT (1) #define MICROPY_VFS_FAT (1) +#define MICROPY_ESP8266_APA102 (1) #define MICROPY_EVENT_POLL_HOOK {ets_event_poll();} #define MICROPY_VM_HOOK_COUNT (10)