Skip to content

Commit

Permalink
Refactored 'machine.Pin' module
Browse files Browse the repository at this point in the history
  better interrupt handling, debouncing added

Refactored 'machine.ADC' module
  new functions added
  background data collecting and timed read to array or file

Refactored 'machine.DAC' module
  new functions added
  timed write from array or file
  waveform generator
  playing wav files

Updated 'machine' module
  fixed reading internal temperature sensor
  added reading internal Vdd (experimental)

Updated 'display' module
  added 'readScreen()' function

Updated 'neopixel' module
  fixed issue when neopixel is configured on multiple pins

Refactored 'utimeq' module
  new sort method for time item, ascending and descending sort available
  new functions added:
    len() returns tuple of current queue length and allocated length
    dump([True]) is provided which prints the detailed que information.
    peek(idx, res) is provided, which peeks the queue item form the index idx
    peektime([idx]) accepts optional argument to peek the time value from queue at index idx.
    time values in a range of int64_t are accepted and properly sorted. Floats can be accepted as time value and are rounded to int64_t
    overflow on time value never occurs as the time range is more then 290000 years with micro seconds value.

Menuconfig:
  added option to enable/disable automatic garbage collection on boot
  added option to set automatic garbage collection threshold

'esp-idf' updated
     date: 2018-05-19
  version: v3.1-dev-1101-g1f7b41e2
     hash: 1f7b41e206646417adc572da928175d33c986bd3

Other minor updates, improvements and bug fixes
  • Loading branch information
loboris committed Jun 4, 2018
1 parent f724c16 commit a122bff
Show file tree
Hide file tree
Showing 74 changed files with 3,092 additions and 1,063 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Expand Up @@ -7,7 +7,7 @@ All the source code in this repository is released under MIT or Apache v2.0 lice

All the sources related to **MicroPython** are under **MIT** license.

**esp-idf** on which this port is based, is released under **Apache v2.0** license.
**esp-idf** on which this port is based, is released under **Apache v2.0** license ([details](http://esp-idf.readthedocs.io/en/latest/COPYRIGHT.html)).

> All the sources created/modified by the repository owner are released under **MIT** license and contains the following copyright notice:<br>
> *Copyright (c) 2018 LoBo (https://github.com/loboris)*
Expand Down
3 changes: 2 additions & 1 deletion MicroPython_BUILD/.cproject
Expand Up @@ -44,7 +44,6 @@
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/wear_levelling/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/soc/esp32/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/heap/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/mbedtls/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/mbedtls/port/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/app_update/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/mdns/include&quot;"/>
Expand All @@ -59,13 +58,15 @@
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/bt/bluedroid/api/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${PWD}/../Tools/xtensa-esp32-elf/bin&quot;"/>
<listOptionValue builtIn="false" value="&quot;${PWD}/../Tools/xtensa-esp32-elf/xtensa-esp32-elf/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${IDF_PATH}/components/mbedtls/mbedtls/include&quot;"/>
</option>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.507238637" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="BUILD_TIME=100000"/>
<listOptionValue builtIn="false" value="LED_ACT=5"/>
<listOptionValue builtIn="false" value="LWIP_DNS=1"/>
<listOptionValue builtIn="false" value="LWIP_SOCKET=1"/>
<listOptionValue builtIn="false" value="IDF_USEHEAP=1"/>
<listOptionValue builtIn="false" value="HAVE_CONFIG_H"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.827066523" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
Expand Down
3 changes: 1 addition & 2 deletions MicroPython_BUILD/.gitignore
Expand Up @@ -23,7 +23,7 @@ build/
patches/

qstrdefs.generated.h
partitions_mpy.csv
/partitions_mpy.csv
/sdkconfig
sdkconfig.old
_sdkconfig.saved
Expand All @@ -36,4 +36,3 @@ sdkconfig.fw_psram_all

make_firmwares.sh
mncfg_exit.txt
updates.txt
4 changes: 2 additions & 2 deletions MicroPython_BUILD/BUILD.sh
Expand Up @@ -50,8 +50,8 @@


#=======================
TOOLS_VER=ver20180515.id
BUILD_VER=ver20180516.id
TOOLS_VER=ver20180604.id
BUILD_VER=ver20180604.id
#=======================

# -----------------------------
Expand Down
4 changes: 2 additions & 2 deletions MicroPython_BUILD/components/curl/lib/ssh.c
Expand Up @@ -395,7 +395,7 @@ static void state(struct connectdata *conn, sshstate nowstate)
sshc->state = nowstate;
}


/*
// ==== LoBo ===============================================
int access (const char *file, int type)
Expand Down Expand Up @@ -446,7 +446,7 @@ return 0;
}
// ==== LoBo ===============================================

*/

#ifdef HAVE_LIBSSH2_KNOWNHOST_API
static int sshkeycallback(struct Curl_easy *easy,
Expand Down
20 changes: 17 additions & 3 deletions MicroPython_BUILD/components/micropython/Kconfig.projbuild
Expand Up @@ -122,6 +122,20 @@ menu "MicroPython"
Whether to return number of collected objects from gc.collect()
If enabled, gc.collect will return the tuple of marked (used) and collected heap blocks

config MICROPY_GC_SET_THRESHOLD
bool "Set GC threshold on boot"
default y
help
Set the automatic garbage collector threshold on boot

config MICROPY_GC_THRESHOLD_VALUE
int "GC threshold percentage"
range 50 95
default 90
help
Default automatic garbage collector threshold value as percentage of the available heap
Threshold value can be changed at runtime using gc.threshold() function

config MICROPY_SCHEDULER_DEPTH
int "Scheduler depth"
range 6 32
Expand Down Expand Up @@ -167,7 +181,7 @@ menu "MicroPython"
help
Run MicroPython tasks on both cores, if not selected MicroPython tasks are created pinned to one core
WARNING: When enabled, it may introduce some issues with uasyncio and threads
not recommended for now!
There is no benefits from using it at the moment, so it is not recommended for now!

config MICROPY_TASK_PRIORITY
int "Main task priority"
Expand All @@ -182,7 +196,7 @@ menu "MicroPython"
range 6 64 if SPIRAM_SUPPORT
default 16
help
Set the size of the MicroPython stack in Kbytes.
Set the default size of the MicroPython stack in Kbytes.

config MICROPY_HEAP_SIZE
int "MicroPython heap size (KB)"
Expand All @@ -193,7 +207,7 @@ menu "MicroPython"
default 72 if !SPIRAM_SUPPORT && MICROPY_USE_CURL && MICROPY_USE_CURL_TLS
default 3072 if SPIRAM_SUPPORT
help
Set the size of the MicroPython heap in Kbytes
Set the default size of the MicroPython heap in Kbytes
If SPIRAM is not used, heap is allocated from DRAM and setting the heap size too large
may result in insuficient heap for C services like mqtt, gsm, curl...

Expand Down
4 changes: 2 additions & 2 deletions MicroPython_BUILD/components/micropython/component.mk
Expand Up @@ -83,7 +83,7 @@ MP_EXTRA_INC += -I$(ESPCOMP)/tcpip_adapter/include
MP_EXTRA_INC += -I$(ESPCOMP)/lwip/include/lwip
MP_EXTRA_INC += -I$(ESPCOMP)/lwip/include/lwip/port
MP_EXTRA_INC += -I$(ESPCOMP)/lwip/include/lwip/posix
MP_EXTRA_INC += -I$(ESPCOMP)/mbedtls/include
MP_EXTRA_INC += -I$(ESPCOMP)/mbedtls/mbedtls/include
MP_EXTRA_INC += -I$(ESPCOMP)/mbedtls/port/include
MP_EXTRA_INC += -I$(ESPCOMP)/spi_flash/include
MP_EXTRA_INC += -I$(ESPCOMP)/wear_levelling/include
Expand Down Expand Up @@ -137,7 +137,7 @@ MP_CLEAN_EXTRA += $(COMPONENT_PATH)/genhdr/qstrdefs.generated.h
# --------------------------------
include $(COMPONENT_PATH)/py/py.mk

#CFLAGS += -std=gnu99
#CFLAGS += -DESP_PLATFORM
CFLAGS += $(CFLAGS_MOD)


Expand Down
29 changes: 18 additions & 11 deletions MicroPython_BUILD/components/micropython/esp32/libs/neopixel.c
Expand Up @@ -237,10 +237,13 @@ int neopixel_init(int gpioNum, rmt_channel_t channel)
if (neopixel_sem == NULL) {
neopixel_sem = xSemaphoreCreateBinary();
if (neopixel_sem == NULL) return ESP_FAIL;
// Note: binary semaphores created using xSemaphoreCreateBinary() are created in a state
// such that the semaphore must first be 'given' before it can be 'taken' !
xSemaphoreGive(neopixel_sem);

DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_RMT_CLK_EN);
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_RMT_RST);
}
// Note: binary semaphores created using xSemaphoreCreateBinary() are created in a state
// such that the semaphore must first be 'given' before it can be 'taken' !
xSemaphoreGive(neopixel_sem);

// Allocate RMT interrupt if needed
if (rmt_intr_handle == NULL) {
Expand All @@ -253,9 +256,6 @@ int neopixel_init(int gpioNum, rmt_channel_t channel)
uint32_t tx_thr_event_mask = 0x01000000 << channel;
uint32_t tx_end_event_mask = 1 << (channel*3);

DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_RMT_CLK_EN);
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_RMT_RST);

res = rmt_set_pin(channel, RMT_MODE_TX, (gpio_num_t)gpioNum);
if (res != ESP_OK) {
xSemaphoreGive(neopixel_sem);
Expand Down Expand Up @@ -321,20 +321,27 @@ void neopixel_deinit(rmt_channel_t channel)
}

// Start the transfer of Neopixel color bytes from buffer
//=====================================================================
void np_show(pixel_settings_t *px, rmt_channel_t channel, uint8_t wait)
//=======================================================
void np_show(pixel_settings_t *px, rmt_channel_t channel)
{
// Wait for previous operation to finish
xSemaphoreTake(neopixel_sem, portMAX_DELAY);

RMTchannel = channel;
// Enable interrupt for neopixel RMT channel
uint32_t tx_thr_event_mask = 0x01000000 << channel;
uint32_t tx_end_event_mask = 1 << (channel*3);
RMT.int_ena.val = tx_thr_event_mask | tx_end_event_mask;

uint16_t blen = px->pixel_count * (px->nbits / 8);

// Allocate neopixel buffer if needed
if (neopixel_buffer == NULL) {
neopixel_buffer = (uint8_t *)malloc(blen);
if (neopixel_buffer == NULL) return;
neopixel_buf_len = blen;
}
// Resize neopixel buffer if needed
if (neopixel_buf_len < blen) {
// larger buffer needed
free(neopixel_buffer);
Expand Down Expand Up @@ -362,11 +369,11 @@ void np_show(pixel_settings_t *px, rmt_channel_t channel, uint8_t wait)
RMT.conf_ch[RMTchannel].conf1.mem_rd_rst = 1;
RMT.conf_ch[RMTchannel].conf1.tx_start = 1;

if (wait) {
// Wait for operation to finish
// Wait for operation to finish
if (xSemaphoreTake(neopixel_sem, 0) == pdTRUE) {
xSemaphoreTake(neopixel_sem, portMAX_DELAY);
xSemaphoreGive(neopixel_sem);
}
xSemaphoreGive(neopixel_sem);
}

// Clear the Neopixel color buffer
Expand Down
Expand Up @@ -60,7 +60,7 @@ typedef struct pixel_settings {
void np_set_pixel_color(pixel_settings_t *px, uint16_t idx, uint32_t color);
void np_set_pixel_color_hsb(pixel_settings_t *px, uint16_t idx, float hue, float saturation, float brightness);
uint32_t np_get_pixel_color(pixel_settings_t *px, uint16_t idx, uint8_t *white);
void np_show(pixel_settings_t *px, rmt_channel_t channel, uint8_t wait);
void np_show(pixel_settings_t *px, rmt_channel_t channel);
void np_clear(pixel_settings_t *px);

int neopixel_init(int gpioNum, rmt_channel_t channel);
Expand Down
2 changes: 2 additions & 0 deletions MicroPython_BUILD/components/micropython/esp32/libs/tft/tft.h
Expand Up @@ -205,6 +205,7 @@ void TFT_drawPixel(int16_t x, int16_t y, color_t color, uint8_t sel);
//------------------------------------------
color_t TFT_readPixel(int16_t x, int16_t y);


/*
* Draw vertical line at given x,y coordinates
*
Expand Down Expand Up @@ -628,6 +629,7 @@ int TFT_getStringWidth(char* str);
/*
* Fills the rectangle occupied by string with current background color
*/
//------------------------------------------------
void TFT_clearStringRect(int x, int y, char *str);

/*
Expand Down

0 comments on commit a122bff

Please sign in to comment.