Skip to content

Commit

Permalink
diy: fix support for M5CoreS3
Browse files Browse the repository at this point in the history
  • Loading branch information
greenaddress authored and JamieDriver committed Oct 3, 2024
1 parent 7ec365c commit b721efb
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 361 deletions.
4 changes: 2 additions & 2 deletions configs/sdkconfig_display_m5cores3.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
CONFIG_SPI_MASTER_ISR_IN_IRAM=n
CONFIG_SPI_SLAVE_ISR_IN_IRAM=n
CONFIG_TINYUSB_CDC_ENABLED=y
CONFIG_TINYUSB_INIT_IN_DEFAULT_TASK=y
CONFIG_TINYUSB_TASK_AFFINITY_CPU0=y
CONFIG_TINYUSB_CDC_RX_BUFSIZE=64
CONFIG_TINYUSB_NO_DEFAULT_TASK=y
CONFIG_WIFI_PROV_BLE_SEC_CONN=n
1 change: 1 addition & 0 deletions main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ menu "Blockstream Jade"

config CAMERA_ROTATE_180
bool "Rotate Camera Image by 180 degrees"
default y if BOARD_TYPE_M5_CORES3
default n

config CAMERA_ROTATE_270
Expand Down
7 changes: 7 additions & 0 deletions main/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include "power.h"
#include "sensitive.h"
#include "ui.h"
#if defined(CONFIG_DISPLAY_TOUCHSCREEN)
#include "input.h"
#endif
#include "utils/event.h"
#include "utils/malloc_ext.h"

Expand Down Expand Up @@ -289,6 +292,10 @@ static void jade_camera_init(void)
JADE_LOGE("Failed to set camera hmirror/vflip, returned: %d/%d", hret, vret);
}
}
#if defined(CONFIG_DISPLAY_TOUCHSCREEN)
touchscreen_deinit();
touchscreen_init();
#endif
}
#endif

Expand Down
19 changes: 18 additions & 1 deletion main/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
void input_init(void) {}

#if defined(CONFIG_DISPLAY_TOUCHSCREEN)
static volatile bool shutdown_requested = false;
static volatile bool shutdown_finished = false;

esp_err_t _i2c_init_master(i2c_port_t port_num, int sda_io_num, int scl_io_num, uint32_t clk_speed);
esp_err_t _i2c_deinit(i2c_port_t port_num);

static void touchscreen_task(void* ignored)
{
Expand Down Expand Up @@ -52,7 +56,7 @@ static void touchscreen_task(void* ignored)
// FIXME: don't allow multiple touches within 300 ms?
// FIXME: this doesn't currently work with Display -> Flip Orientation feature
// but it could by changing the touch_y[0] > 200 logic with < 40 and inverting prev with next and viceversa
for (;;) {
while (!shutdown_requested) {
if (esp_lcd_touch_read_data(ret_touch) == ESP_OK) {
bool touchpad_pressed
= esp_lcd_touch_get_coordinates(ret_touch, touch_x, touch_y, touch_strength, &touch_cnt, 1);
Expand All @@ -75,6 +79,9 @@ static void touchscreen_task(void* ignored)
}
vTaskDelay(20 / portTICK_PERIOD_MS);
}
ESP_ERROR_CHECK(_i2c_deinit(CONFIG_DISPLAY_TOUCHSCREEN_I2C));
shutdown_finished = true;
vTaskDelete(NULL);
}

void touchscreen_init(void)
Expand All @@ -84,6 +91,16 @@ void touchscreen_init(void)
JADE_ASSERT_MSG(
retval == pdPASS, "Failed to create touchscreen task, xTaskCreatePinnedToCore() returned %d", retval);
}

void touchscreen_deinit(void)
{
shutdown_requested = true;
while (!shutdown_finished) {
vTaskDelay(100 / portTICK_PERIOD_MS);
}
shutdown_requested = false;
shutdown_finished = false;
}
#endif

#if CONFIG_INPUT_FRONT_SW >= 0
Expand Down
1 change: 1 addition & 0 deletions main/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void button_long(void* arg);

#if defined(CONFIG_DISPLAY_TOUCHSCREEN)
void touchscreen_init(void);
void touchscreen_deinit(void);
#else
void wheel_init(void);
#endif
Expand Down
Loading

0 comments on commit b721efb

Please sign in to comment.