Skip to content

Commit

Permalink
Merge pull request #41 from martinberlin/39-c3
Browse files Browse the repository at this point in the history
#39 Add C3 as a target
  • Loading branch information
martinberlin authored Jul 5, 2021
2 parents 3bee8a9 + 0058d34 commit 61a9f4c
Show file tree
Hide file tree
Showing 8 changed files with 1,374 additions and 37 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

### Requirements

* esp32 or esp32S2
* esp32 or esp32S2 (C3 also works check notes below)
* Espressif IDF framework 4.3
* An SPI epaper (see wiki for supported models)

ESP32C3 also works as a target. For C3 the compilation of
/component/epd_driver is excluded since this uses ESP32 two cores and won't compile in C3.
Please check also config-examples/C3-riscv-spi where is a PIN configuration that is prove to be working.

Then just select one of the SPI examples, and do a: **idf.py set-target esp32c3**


Cale-idf is the official ESP-IDF firmware of our Web-Service [CALE.es](https://cale.es) and also the repository where the development of CalEPD epaper component takes place. The main class extends Adafruit GFX so this library has full geometric functions and also fonts including German/Spanish/French special characters support.
On latest release, CalEPD has also support for FocalTech I2C touch panel, enabling you to make simple UX interfaces using small epaper displays. This is optional and can be enabled only when the Firmware requires touch.
Please check the [Wiki](https://github.com/martinberlin/cale-idf/wiki) for latest news and to see what displays are supported. The Wiki is the perfect place to make updates that are not branch dependant so our documentation efforts will be focused there.
Expand Down
18 changes: 9 additions & 9 deletions components/CalEPD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ set(srcs
"models/plasticlogic/plasticlogic021.cpp"
"models/plasticlogic/plasticlogic031.cpp"

# Parallel epapers supported by Epdiy driver (Component)
"models/parallel/ED047TC1.cpp"
"models/parallel/ED047TC1touch.cpp"
"models/parallel/ED060SC4.cpp"
# Parallel epapers supported by Epdiy driver (Uncomment epdParallel & REQUIRES "epd_driver")
# Uncomment for parallel epapers:
#"epdParallel.cpp"
#"models/parallel/ED047TC1.cpp"
#"models/parallel/ED047TC1touch.cpp"
#"models/parallel/ED060SC4.cpp"

# Pending for more testing:
"models/gdeh0213b73.cpp"
Expand All @@ -45,16 +47,14 @@ set(srcs
"epd7color.cpp"
"epdspi.cpp"
"epd4spi.cpp"
"epdParallel.cpp"
)

# If the project does not use a touch display component FT6X36-IDF can be removed or #commented
idf_component_register(SRCS ${srcs}
REQUIRES "Adafruit-GFX"
REQUIRES "FT6X36-IDF"
# Only for parallel epapers:
REQUIRES "epd_driver"


# Uncomment for parallel epapers:
#REQUIRES "epd_driver"
INCLUDE_DIRS "include"
)

13 changes: 8 additions & 5 deletions components/CalEPD/epd4spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
#include "soc/rtc_wdt.h"

#ifdef CONFIG_IDF_TARGET_ESP32
#define EPD_HOST HSPI_HOST
#define DMA_CHAN 2

#define EPD_HOST HSPI_HOST
#define DMA_CHAN 2
#elif defined CONFIG_IDF_TARGET_ESP32S2
#define EPD_HOST SPI2_HOST
#define DMA_CHAN EPD_HOST
#define EPD_HOST SPI2_HOST
#define DMA_CHAN EPD_HOST
#elif defined CONFIG_IDF_TARGET_ESP32C3
// chip only support spi dma channel auto-alloc
#define EPD_HOST SPI2_HOST
#define DMA_CHAN SPI_DMA_CH_AUTO
#endif
/** DISPLAYS REF:
__________
Expand Down
30 changes: 16 additions & 14 deletions components/CalEPD/epdspi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
#include "freertos/task.h"
#include "esp_log.h"
#ifdef CONFIG_IDF_TARGET_ESP32
#define EPD_HOST HSPI_HOST
#define DMA_CHAN 2
#define EPD_HOST HSPI_HOST
#define DMA_CHAN 2

#elif defined CONFIG_IDF_TARGET_ESP32S2
#define EPD_HOST SPI2_HOST
#define DMA_CHAN EPD_HOST
#define EPD_HOST SPI2_HOST
#define DMA_CHAN EPD_HOST

#elif defined CONFIG_IDF_TARGET_ESP32C3
// chip only support spi dma channel auto-alloc
#define EPD_HOST SPI2_HOST
#define DMA_CHAN SPI_DMA_CH_AUTO
#endif

void EpdSpi::init(uint8_t frequency=4,bool debug=false){
debug_enabled = debug;
if (debug) {
printf("MOSI: %d CLK: %d\nSPI_CS: %d DC: %d RST: %d BUSY: %d\n\n", CONFIG_EINK_SPI_MOSI, CONFIG_EINK_SPI_CLK,
CONFIG_EINK_SPI_CS,CONFIG_EINK_DC,CONFIG_EINK_RST,CONFIG_EINK_BUSY);
}

//Initialize GPIOs direction & initial states
gpio_set_direction((gpio_num_t)CONFIG_EINK_SPI_CS, GPIO_MODE_OUTPUT);
gpio_set_direction((gpio_num_t)CONFIG_EINK_DC, GPIO_MODE_OUTPUT);
Expand Down Expand Up @@ -67,9 +69,9 @@ void EpdSpi::init(uint8_t frequency=4,bool debug=false){
ESP_ERROR_CHECK(ret);

if (debug_enabled) {
printf("EpdSpi::init() Debug enabled. SPI master at frequency:%d MOSI:%d CLK:%d CS:%d DC:%d RST:%d BUSY:%d\n",
printf("EpdSpi::init() Debug enabled. SPI master at frequency:%d MOSI:%d CLK:%d CS:%d DC:%d RST:%d BUSY:%d DMA_CH: %d\n",
frequency*multiplier*1000, CONFIG_EINK_SPI_MOSI, CONFIG_EINK_SPI_CLK, CONFIG_EINK_SPI_CS,
CONFIG_EINK_DC,CONFIG_EINK_RST,CONFIG_EINK_BUSY);
CONFIG_EINK_DC,CONFIG_EINK_RST,CONFIG_EINK_BUSY, DMA_CHAN);
} else {
printf("EpdSPI started at frequency: %d000\n", frequency*multiplier);
}
Expand All @@ -86,7 +88,7 @@ void EpdSpi::cmd(const uint8_t cmd)
{
if (debug_enabled) {
printf("C %x\n",cmd);
}
}

esp_err_t ret;
spi_transaction_t t;
Expand All @@ -105,9 +107,9 @@ void EpdSpi::cmd(const uint8_t cmd)

void EpdSpi::data(uint8_t data)
{
if (debug_enabled) {
/* if (debug_enabled) {
printf("D %x\n",data);
}
} */
esp_err_t ret;
spi_transaction_t t;
memset(&t, 0, sizeof(t)); //Zero out the transaction
Expand Down Expand Up @@ -138,7 +140,7 @@ void EpdSpi::dataBuffer(uint8_t data)
void EpdSpi::data(const uint8_t *data, int len)
{
if (len==0) return;
if (debug_enabled) {
if (debug_enabled && false) {
printf("D\n");
for (int i = 0; i < len; i++) {
printf("%x ",data[i]);
Expand Down
13 changes: 9 additions & 4 deletions components/CalEPD/models/plasticlogic/epdspi2cs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
#include "esp_log.h"

#ifdef CONFIG_IDF_TARGET_ESP32
#define EPD_HOST HSPI_HOST
#define DMA_CHAN 2
#define EPD_HOST HSPI_HOST
#define DMA_CHAN 2

#elif defined CONFIG_IDF_TARGET_ESP32S2
#define EPD_HOST SPI2_HOST
#define DMA_CHAN EPD_HOST
#define EPD_HOST SPI2_HOST
#define DMA_CHAN EPD_HOST

#elif defined CONFIG_IDF_TARGET_ESP32C3
// chip only support spi dma channel auto-alloc
#define EPD_HOST SPI2_HOST
#define DMA_CHAN SPI_DMA_DISABLED
#endif


Expand Down
4 changes: 4 additions & 0 deletions components/epd_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
idf_build_get_property(target IDF_TARGET)
if(${target} STREQUAL "esp32c3")
return()
endif()

set(app_sources "epd_driver.c"
"render.c"
Expand Down
Loading

0 comments on commit 61a9f4c

Please sign in to comment.