Skip to content

Commit

Permalink
Merge branch 'vector-extension-experimentation' into s3_color_impleme…
Browse files Browse the repository at this point in the history
…ntation
  • Loading branch information
martinberlin committed Apr 22, 2024
2 parents d43f590 + 097b36a commit 46e55ba
Show file tree
Hide file tree
Showing 38 changed files with 1,907 additions and 661 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ set(app_sources "src/epdiy.c"
"src/output_i2s/rmt_pulse.c"
"src/output_i2s/i2s_data_bus.c"
"src/output_common/lut.c"
"src/output_common/lut.S"
"src/output_common/line_queue.c"
"src/output_common/render_context.c"
"src/font.c"
"src/displays.c"
"src/diff.S"
"src/board_specific.c"
"src/builtin_waveforms.c"
"src/highlevel.c"
Expand Down
1 change: 1 addition & 0 deletions examples/demo/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
set(app_sources "main.c")

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
idf_component_register(SRCS ${app_sources} REQUIRES epdiy)
5 changes: 5 additions & 0 deletions examples/demo/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ void idf_setup() {
epd_rotated_display_height()
);

// The display bus settings for V7 may be conservative, you can manually
// override the bus speed to tune for speed, i.e., if you set the PSRAM speed
// to 120MHz.
// epd_set_lcd_pixel_clock_MHz(17);

heap_caps_print_heap_info(MALLOC_CAP_INTERNAL);
heap_caps_print_heap_info(MALLOC_CAP_SPIRAM);
}
Expand Down
11 changes: 11 additions & 0 deletions examples/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is the project CMakeLists.txt file for the test subproject
cmake_minimum_required(VERSION 3.16)

# Add newly added components to one of these lines:
# 1. Add here if the component is compatible with IDF >= v4.3
set(EXTRA_COMPONENT_DIRS "../../")

set(TEST_COMPONENTS "epdiy")

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(epdiy_testrunner)
3 changes: 3 additions & 0 deletions examples/test/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

idf_component_register(SRCS "main.c" INCLUDE_DIRS ".")
19 changes: 19 additions & 0 deletions examples/test/main/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>
#include <unity.h>
#include "unity_test_runner.h"

static void print_banner(const char* text)
{
printf("\n#### %s #####\n\n", text);
}


void app_main(void)
{
print_banner("Running all the registered tests");
UNITY_BEGIN();
//unity_run_tests_by_tag("unit", false);
unity_run_all_tests();
UNITY_END();
}

17 changes: 17 additions & 0 deletions examples/www-image/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## IDF Component Manager Manifest File
dependencies:
espressif/esp-dsp: "^1.4.12"
## Required IDF version
idf:
version: ">=4.1.0"
# # Put list of dependencies here
# # For components maintained by Espressif:
# component: "~1.0.0"
# # For 3rd party components:
# username/component: ">=1.0.0,<2.0.0"
# username2/component2:
# version: "~1.0.0"
# # For transient dependencies `public` flag can be set.
# # `public` flag doesn't have an effect dependencies of the `main` component.
# # All dependencies of `main` are public by default.
# public: true
2 changes: 1 addition & 1 deletion examples/www-image/main/jpgdec-render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ void wifi_init_sta(void) {
void app_main() {
enum EpdInitOptions init_options = EPD_LUT_64K;

epd_init(&epd_board_v7, &ED133UT2, init_options);
epd_init(&epd_board_v7, &EC060KH5, init_options);
color_filter_type = epd_get_display()->display_color_filter;
// Set VCOM for boards that allow to set this in software (in mV).
// This will print an error if unsupported. In this case,
Expand Down
10 changes: 5 additions & 5 deletions examples/www-image/main/settings.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// WiFi configuration:
#define ESP_WIFI_SSID "sagemcom6AE0"
#define ESP_WIFI_PASSWORD ""
#define ESP_WIFI_SSID "SercommB918"
#define ESP_WIFI_PASSWORD "MEFWMYSWDGCM5P"

// Affects the gamma to calculate gray (lower is darker/higher contrast)
// Nice test values: 0.9 1.2 1.4 higher and is too bright
double gamma_value = 0.7;
double gamma_value = 0.9;

// - - - - Display configuration - - - - - - - - -
// EPD Waveform should match your EPD for good grayscales
Expand All @@ -19,7 +19,7 @@ double gamma_value = 0.7;
// Image URL and jpg settings. Make sure to update WIDTH/HEIGHT if using loremflickr
// Note: Only HTTP protocol supported (Check README to use SSL secure URLs) loremflickr
//#define IMG_URL ("https://loremflickr.com/2232/1680")
#define IMG_URL ("http://img.cale.es/jpg/fasani/5ef2ee980a4ec")
#define IMG_URL ("http://img.cale.es/jpg/fasani/5e5ff140694ee")
// idf >= 4.3 needs VALIDATE_SSL_CERTIFICATE set to true for https URLs
// Please check the README to understand how to use an SSL Certificate
// Note: This makes a sntp time sync query for cert validation (It's slower)
Expand All @@ -38,7 +38,7 @@ double gamma_value = 0.7;
#define JPG_DITHERING true

// NONE - DES_COLOR (Fabricated by wf-tech.com) applicable to jpgdec-render.cpp
#define DISPLAY_COLOR_TYPE "DES_COLOR"
#define DISPLAY_COLOR_TYPE "DISPLAY_CFA_KALEIDO"
// As default is 512 without setting buffer_size property in esp_http_client_config_t
#define HTTP_RECEIVE_BUFFER_SIZE 1986

Expand Down
2 changes: 1 addition & 1 deletion src/board/epd_board.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void epd_set_board(const EpdBoardDefinition *board_definition) {
if (epd_board == NULL) {
epd_board = board_definition;
} else {
ESP_LOGE("epdiy", "EPD board can only be set once!");
ESP_LOGW("epdiy", "EPD board can only be set once!");
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/board/epd_board_v6.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "driver/gpio.h"
#include "epd_board.h"

#include <esp_log.h>
Expand Down Expand Up @@ -144,8 +145,11 @@ static void epd_board_deinit() {
vTaskDelay(500);
pca9555_read_input(config_reg.port, 0);
pca9555_read_input(config_reg.port, 1);
ESP_LOGI("epdiy", "going to sleep.");
i2c_driver_delete(EPDIY_I2C_PORT);
gpio_isr_handler_remove(CFG_INTR);
gpio_uninstall_isr_service();
gpio_reset_pin(CFG_INTR);
gpio_reset_pin(V4_LATCH_ENABLE);
}

static void epd_board_set_ctrl(epd_ctrl_state_t *state, const epd_ctrl_state_t * const mask) {
Expand Down
45 changes: 23 additions & 22 deletions src/board/epd_board_v7.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,22 @@ static lcd_bus_config_t lcd_config = {
.leh = LEH,
.start_pulse = STH,
.stv = STV,
.data_0 = D0,
.data_1 = D1,
.data_2 = D2,
.data_3 = D3,
.data_4 = D4,
.data_5 = D5,
.data_6 = D6,
.data_7 = D7,
.data_8 = D8,
.data_9 = D9,
.data_10 = D10,
.data_11 = D11,
.data_12 = D12,
.data_13 = D13,
.data_14 = D14,
.data_15 = D15,
.data[0] = D0,
.data[1] = D1,
.data[2] = D2,
.data[3] = D3,
.data[4] = D4,
.data[5] = D5,
.data[6] = D6,
.data[7] = D7,
.data[8] = D8,
.data[9] = D9,
.data[10] = D10,
.data[11] = D11,
.data[12] = D12,
.data[13] = D13,
.data[14] = D14,
.data[15] = D15,
};

static void epd_board_init(uint32_t epd_row_width) {
Expand Down Expand Up @@ -158,24 +158,27 @@ static void epd_board_init(uint32_t epd_row_width) {

static void epd_board_deinit() {

epd_lcd_deinit();

ESP_ERROR_CHECK(pca9555_set_config(config_reg.port, CFG_PIN_PWRGOOD | CFG_PIN_INT | CFG_PIN_VCOM_CTRL | CFG_PIN_PWRUP, 1));

int tries = 0;
while (!((pca9555_read_input(config_reg.port, 1) & 0xC0) == 0x80)) {
if (tries >= 500) {
if (tries >= 50) {
ESP_LOGE("epdiy", "failed to shut down TPS65185!");
break;
}
tries++;
vTaskDelay(1);
printf("%X\n", pca9555_read_input(config_reg.port, 1));
}

// Not sure why we need this delay, but the TPS65185 seems to generate an interrupt after some time that needs to be cleared.
vTaskDelay(500);
vTaskDelay(50);
pca9555_read_input(config_reg.port, 0);
pca9555_read_input(config_reg.port, 1);
ESP_LOGI("epdiy", "going to sleep.");
i2c_driver_delete(EPDIY_I2C_PORT);

gpio_uninstall_isr_service();
}

static void epd_board_set_ctrl(epd_ctrl_state_t *state, const epd_ctrl_state_t * const mask) {
Expand Down Expand Up @@ -214,8 +217,6 @@ static void epd_board_poweron(epd_ctrl_state_t *state) {
while (!(pca9555_read_input(config_reg.port, 1) & CFG_PIN_PWRGOOD)) {
}

printf("PG is up\n");

ESP_ERROR_CHECK(tps_write_register(config_reg.port, TPS_REG_ENABLE, 0x3F));

tps_set_vcom(config_reg.port, vcom);
Expand Down
9 changes: 9 additions & 0 deletions src/board/pca9555.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ static esp_err_t i2c_master_read_slave(i2c_port_t i2c_num, uint8_t* data_rd, siz
return ESP_OK;
}
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
if (cmd == NULL) {
ESP_LOGE("epdiy", "insufficient memory for I2C transaction");
}
i2c_master_start(cmd);
i2c_master_write_byte(cmd, ( EPDIY_PCA9555_ADDR << 1 ) | I2C_MASTER_WRITE, true);
i2c_master_write_byte(cmd, reg, true);
Expand All @@ -37,6 +40,9 @@ static esp_err_t i2c_master_read_slave(i2c_port_t i2c_num, uint8_t* data_rd, siz
i2c_cmd_link_delete(cmd);

cmd = i2c_cmd_link_create();
if (cmd == NULL) {
ESP_LOGE("epdiy", "insufficient memory for I2C transaction");
}
i2c_master_start(cmd);
i2c_master_write_byte(cmd, ( EPDIY_PCA9555_ADDR << 1 ) | I2C_MASTER_READ, true);
if (size > 1) {
Expand All @@ -57,6 +63,9 @@ static esp_err_t i2c_master_read_slave(i2c_port_t i2c_num, uint8_t* data_rd, siz
static esp_err_t i2c_master_write_slave(i2c_port_t i2c_num, uint8_t ctrl, uint8_t* data_wr, size_t size)
{
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
if (cmd == NULL) {
ESP_LOGE("epdiy", "insufficient memory for I2C transaction");
}
i2c_master_start(cmd);
i2c_master_write_byte(cmd, ( EPDIY_PCA9555_ADDR << 1 ) | I2C_MASTER_WRITE, true);
i2c_master_write_byte(cmd, ctrl, true);
Expand Down
Loading

0 comments on commit 46e55ba

Please sign in to comment.