Skip to content

Commit

Permalink
consistency: update libraries
Browse files Browse the repository at this point in the history
Includes fix to isr gpio service handling between wheel and camera
  • Loading branch information
greenaddress authored and JamieDriver committed May 13, 2024
1 parent 4fb8176 commit 5ae5db4
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 75 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
idf_build_set_property(DEPENDENCIES_LOCK dependencies.lock.${IDF_TARGET})
project(jade)
12 changes: 9 additions & 3 deletions ci_flash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ REDIS_PORT="$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); prin
# Pinserver tests use a short session lifetime (for session-timeout tests)
PINSVR_SESSION_TIMEOUT=3

python ${IDF_PATH}/components/esptool_py/esptool/esptool.py --chip esp32 --port ${JADESERIALPORT} --baud 2000000 --before default_reset erase_flash

python ${IDF_PATH}/components/esptool_py/esptool/esptool.py --chip esp32 --port ${JADESERIALPORT} --baud 2000000 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0xE000 build/ota_data_initial.bin 0x1000 build/bootloader/bootloader.bin 0x10000 build/jade.bin 0x9000 build/partition_table/partition-table.bin
TARGET_CHIP=${1:-esp32}

if [ "$TARGET_CHIP" = "esp32" ]; then
python ${IDF_PATH}/components/esptool_py/esptool/esptool.py --chip ${TARGET_CHIP} --port ${JADESERIALPORT} --baud 2000000 --before default_reset erase_flash
python ${IDF_PATH}/components/esptool_py/esptool/esptool.py --chip ${TARGET_CHIP} --port ${JADESERIALPORT} --baud 2000000 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0xE000 build/ota_data_initial.bin 0x1000 build/bootloader/bootloader.bin 0x10000 build/jade.bin 0x9000 build/partition_table/partition-table.bin
else
python ${IDF_PATH}/components/esptool_py/esptool/esptool.py --chip ${TARGET_CHIP} --port ${JADESERIALPORT} --baud 460800 --before default_reset erase_flash
python ${IDF_PATH}/components/esptool_py/esptool/esptool.py --chip ${TARGET_CHIP} --port ${JADESERIALPORT} --baud 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 8MB 0x0 build/bootloader/bootloader.bin 0x20000 build/jade.bin 0x8000 build/partition_table/partition-table.bin 0x1a000 build/ota_data_initial.bin
fi

sleep 1

Expand Down
45 changes: 0 additions & 45 deletions dependencies.lock

This file was deleted.

57 changes: 57 additions & 0 deletions dependencies.lock.esp32
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
dependencies:
espressif/button:
component_hash: 1f5297fe16f0ee988dbb14b6f4c91782fe2baf85025bb15cc1e0093edd3fb2ee
source:
service_url: https://api.components.espressif.com/
type: service
version: 3.2.0
espressif/cbor:
component_hash: 440f4ee4504841cc9b4f3a8ef755776a612ac9dace355514c68b999868f990ff
source:
service_url: https://api.components.espressif.com/
type: service
version: 0.6.0~1
espressif/cmake_utilities:
component_hash: 351350613ceafba240b761b4ea991e0f231ac7a9f59a9ee901f751bddc0bb18f
source:
service_url: https://api.components.espressif.com/
type: service
version: 0.5.3
espressif/esp32-camera:
component_hash: e00e75c24164b5d097bf98f325938558697916a0cb6b68872b9927587b46882a
source:
service_url: https://api.components.espressif.com/
type: service
version: 2.0.8
espressif/esp_lcd_touch:
component_hash: d4d8f2dc33205797169a97a02e0d89a8982f59fe0509129b54422052b8522f59
source:
service_url: https://api.components.espressif.com/
type: service
version: 1.1.1
espressif/esp_lcd_touch_ft5x06:
component_hash: 97759953d9436a365e9427078c5b04ecce4e6a50f50cf62c68cd6bfa229b812c
source:
service_url: https://api.components.espressif.com/
type: service
version: 1.0.6
espressif/libsodium:
component_hash: f6e982479a2389cb6868e8fb761cf23aba6c355a8090b3e906299807775f58a3
source:
service_url: https://api.components.espressif.com/
type: service
version: 1.0.20~1
espressif/nghttp:
component_hash: 5e55c2fc982f7ddd257818be86f50d60705f3fd3a39d709c399434e81d458e1e
source:
service_url: https://api.components.espressif.com/
type: service
version: 1.58.0
idf:
component_hash: null
source:
type: idf
version: 5.1.3
manifest_hash: 86a960cf40f1aaed226ad32e8af9725f0288f1f6a7f38e3d89bfda8196794ba0
target: esp32
version: 1.0.0
4 changes: 3 additions & 1 deletion jadepy/jade_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#
class JadeSerialImpl:
# Used when searching for devices that might be a Jade/compatible hw
JADE_DEVICE_IDS = [(0x10c4, 0xea60), (0x1a86, 0x55d4), (0x0403, 0x6001), (0x1a86, 0x7523)]
JADE_DEVICE_IDS = [
(0x10c4, 0xea60), (0x1a86, 0x55d4), (0x0403, 0x6001),
(0x1a86, 0x7523), (0x303a, 0x4001), (0x303a, 0x1001)]

@classmethod
def _get_first_compatible_device(cls):
Expand Down
19 changes: 19 additions & 0 deletions main/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include "button_events.h"
#include "camera.h"
#include "idletimer.h"
#ifdef CONFIG_BOARD_TYPE_JADE
#include "input.h"
#endif
#include "jade_assert.h"
#include "jade_tasks.h"
#include "power.h"
Expand Down Expand Up @@ -116,6 +119,10 @@ static void jade_camera_init(void)
.grab_mode = CAMERA_GRAB_LATEST,

.jpeg_quality = 0 };
#ifdef CONFIG_BOARD_TYPE_JADE
/* uninit wheel in order to fully cleanup in anticipation of camera calling gpio_install_isr_service itself */
wheel_uninit(/* uninstall gpio isr service */ true);
#endif
const esp_err_t err = esp_camera_init(&camera_config);
JADE_LOGI("Camera init done");
if (err != ESP_OK) {
Expand All @@ -142,14 +149,26 @@ static void jade_camera_init(void)
JADE_LOGE("Failed to set camera hmirror/vflip, returned: %d/%d", hret, vret);
}
}
#ifdef CONFIG_BOARD_TYPE_JADE
/* make wheel work with interrupt service from camera */
wheel_reinit(/* install_gpio_isr_service */ false);
#endif
}
#endif

// Stop the camera
static void jade_camera_stop(void)
{
#ifdef CONFIG_BOARD_TYPE_JADE
/* wheel is currently using the camera gpio_install_isr_service , clean up only part of it */
wheel_uninit(/* uninstall_gpio_isr_service */ false);
#endif
esp_camera_deinit();
power_camera_off();
#ifdef CONFIG_BOARD_TYPE_JADE
/* create a new gpio_install_isr_service for the wheel before restarting it */
wheel_reinit(/* install_gpio_isr_service */ true);
#endif
}

static inline bool invoke_user_cb_fn(const camera_task_config_t* camera_config, const camera_fb_t* fb)
Expand Down
27 changes: 22 additions & 5 deletions main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
dependencies:
espressif/button: "==3.0.1"
espressif/nghttp: "==1.52.0"
espressif/button: "==3.2.0"
espressif/nghttp: "==1.58.0"
espressif/cbor: "==0.6.0~1"
espressif/libsodium: "==1.0.20"
espressif/esp32-camera: "==2.0.3"
espressif/cmake_utilities: "==0.5.2"
espressif/libsodium: "==1.0.20~1"
espressif/cmake_utilities: "==0.5.3"
espressif/esp32-camera:
version: "==2.0.8"
espressif/esp_lcd_touch_ft5x06:
version: "==1.0.6"
espressif/esp_lcd_touch:
version: "==1.1.1"
espressif/esp_tinyusb:
version: "==1.4.4"
rules:
- if: "target in [esp32s3]"
espressif/tinyusb:
version: "==0.15.0~9"
rules:
- if: "target in [esp32s3]"
espressif/usb_host_msc:
version: "==1.1.2"
rules:
- if: "target in [esp32s3]"
idf:
version: "==5.1.3"
54 changes: 33 additions & 21 deletions main/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@

static bool invert_wheel = false;

void input_init(void)
{
const esp_err_t rc = gpio_install_isr_service(0);
JADE_ASSERT(rc == ESP_OK);
invert_wheel = false;
}
void input_init(void) { invert_wheel = false; }

void set_invert_wheel(bool inverted) { invert_wheel = inverted; }

Expand Down Expand Up @@ -134,10 +129,10 @@ static void wheel_common(button_handle_t* btn_handle_prev, button_handle_t* btn_

// Jade proper wheel init
static QueueHandle_t event_queue;
static rotary_encoder_info_t info = {};

void wheel_watch_task(void* info_void)
void wheel_watch_task(void* unused)
{
rotary_encoder_info_t* info = (rotary_encoder_info_t*)info_void;
int32_t last_position = 0;

for (;;) {
Expand All @@ -154,37 +149,54 @@ void wheel_watch_task(void* info_void)
}

JADE_LOGE("queue receive failed");
const esp_err_t rc = rotary_encoder_uninit(info);
JADE_ASSERT(rc == ESP_OK);
free(info);

vTaskDelete(NULL);
}

void wheel_init(void)
void wheel_uninit(bool uninstall_gpio_isr_service)
{
const esp_err_t rc = rotary_encoder_uninit(&info);
JADE_ASSERT(rc == ESP_OK);
if (uninstall_gpio_isr_service) {
gpio_uninstall_isr_service();
}
}

/* reinit reuses same queue and Task */
void wheel_reinit(bool install_gpio_isr_service)
{
if (install_gpio_isr_service) {
const esp_err_t rc = gpio_install_isr_service(0);
JADE_ASSERT(rc == ESP_OK);
}
// Initialise the rotary encoder device with the GPIOs for A and B signals
rotary_encoder_info_t* info = (rotary_encoder_info_t*)JADE_MALLOC(sizeof(rotary_encoder_info_t));
esp_err_t rc = rotary_encoder_init(info, CONFIG_INPUT_WHEEL_A, CONFIG_INPUT_WHEEL_B);
esp_err_t rc = rotary_encoder_init(&info, CONFIG_INPUT_WHEEL_A, CONFIG_INPUT_WHEEL_B);
JADE_ASSERT(rc == ESP_OK);
rc = rotary_encoder_enable_half_steps(info, ENABLE_HALF_STEPS);
rc = rotary_encoder_enable_half_steps(&info, ENABLE_HALF_STEPS);
JADE_ASSERT(rc == ESP_OK);
#ifdef FLIP_DIRECTION
rc = rotary_encoder_flip_direction(info);
rc = rotary_encoder_flip_direction(&info);
JADE_ASSERT(rc == ESP_OK);
#endif
JADE_ASSERT(event_queue);

// Create a queue for events from the rotary encoder driver.
event_queue = rotary_encoder_create_queue();
// Tasks can read from this queue to receive up to date position information.
rc = rotary_encoder_set_queue(info, event_queue);
rc = rotary_encoder_set_queue(&info, event_queue);
JADE_ASSERT(rc == ESP_OK);
}

void wheel_init(void)
{
// Create a queue for events from the rotary encoder driver.
event_queue = rotary_encoder_create_queue();

wheel_reinit(/* install_gpio_isr_service */ true);

const BaseType_t retval = xTaskCreatePinnedToCore(
&wheel_watch_task, "wheel_watcher", 2 * 1024, info, JADE_TASK_PRIO_WHEEL, NULL, JADE_CORE_SECONDARY);
&wheel_watch_task, "wheel_watcher", 2 * 1024, NULL, JADE_TASK_PRIO_WHEEL, NULL, JADE_CORE_SECONDARY);
JADE_ASSERT_MSG(
retval == pdPASS, "Failed to create wheel_watcher task, xTaskCreatePinnedToCore() returned %d", retval);
}

#elif defined(CONFIG_BOARD_TYPE_TTGO_TDISPLAY)
// wheel_init() to mock wheel with buttons

Expand Down
4 changes: 4 additions & 0 deletions main/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ void button_tap(void* arg);
void button_long(void* arg);

void wheel_init(void);
#ifdef CONFIG_BOARD_TYPE_JADE
void wheel_uninit(bool uninstall_gpio_isr_service);
void wheel_reinit(bool install_gpio_isr_service);
#endif

#endif /* BUTTONS_H_ */

0 comments on commit 5ae5db4

Please sign in to comment.