Updated dependencies.

This commit is contained in:
Joe Kearney 2026-02-07 16:06:20 -06:00
parent d86c494d45
commit 58748fcef1
101 changed files with 5845 additions and 2391 deletions

View file

@ -23,6 +23,7 @@
#include <SystemK.h>
#include <driver/gpio.h>
#include <iot_button.h>
#include <button_gpio.h>
#include <freertos/FreeRTOS.h>
#include <freertos/portmacro.h>
@ -32,28 +33,24 @@ static const char *TAG = "Switches";
#define TRIGGER_GPIO GPIO_NUM_1
#define ACCESSORY_GPIO GPIO_NUM_4
static button_handle_t Trigger_Button;
static button_config_t Trigger_Button_Config = {
.type = BUTTON_TYPE_GPIO,
static const button_config_t Button_Config = {
.long_press_time = CONFIG_BUTTON_LONG_PRESS_TIME_MS,
.short_press_time = CONFIG_BUTTON_SHORT_PRESS_TIME_MS,
.gpio_button_config = {
.gpio_num = TRIGGER_GPIO,
.active_level = 0,
},
};
static button_handle_t Accessory_Button;
static button_config_t Accessory_Button_Config = {
.type = BUTTON_TYPE_GPIO,
.long_press_time = CONFIG_BUTTON_LONG_PRESS_TIME_MS,
.short_press_time = CONFIG_BUTTON_SHORT_PRESS_TIME_MS,
.gpio_button_config = {
.gpio_num = ACCESSORY_GPIO,
.active_level = 0,
},
static const button_gpio_config_t Trigger_GPIO_Config = {
.gpio_num = TRIGGER_GPIO,
.active_level = 0,
};
static const button_gpio_config_t Accessory_GPIO_Config = {
.gpio_num = ACCESSORY_GPIO,
.active_level = 0,
};
static button_handle_t Trigger_Button;
static button_handle_t Accessory_Button;
static TickType_t TicksAtTriggerPress = 0;
static TickType_t TicksAtAccessoryPress = 0;
static TickType_t TicksAtAccessoryRelease = 0;
@ -70,7 +67,7 @@ static void trigger_release_cb(void *arg, void *usr_data)
{
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
uint32_t triggerPressDurationInms = pdTICKS_TO_MS(xTaskGetTickCountFromISR() - TicksAtTriggerPress);
KEvent_T switch_event = {.ID = KEVENT_TRIGGER_SWITCH_RELEASED, .Data = (void *) triggerPressDurationInms};
KEvent_T switch_event = {.ID = KEVENT_TRIGGER_SWITCH_RELEASED, .Data = (void *)triggerPressDurationInms};
Post_KEvent_From_ISR(&switch_event, &xHigherPriorityTaskWoken);
}
@ -79,7 +76,7 @@ static void accessory_press_cb(void *arg, void *usr_data)
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
TicksAtAccessoryPress = xTaskGetTickCountFromISR();
uint32_t accessoryTimeReleasedInms = pdTICKS_TO_MS(xTaskGetTickCountFromISR() - TicksAtAccessoryRelease);
KEvent_T switch_event = {.ID = KEVENT_ACCESSORY_SWITCH_PRESSED, .Data = (void *) accessoryTimeReleasedInms};
KEvent_T switch_event = {.ID = KEVENT_ACCESSORY_SWITCH_PRESSED, .Data = (void *)accessoryTimeReleasedInms};
Post_KEvent_From_ISR(&switch_event, &xHigherPriorityTaskWoken);
}
@ -88,23 +85,90 @@ static void accessory_release_cb(void *arg, void *usr_data)
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
TicksAtAccessoryRelease = xTaskGetTickCountFromISR();
uint32_t accessoryPressDurationInms = pdTICKS_TO_MS(xTaskGetTickCountFromISR() - TicksAtAccessoryPress);
KEvent_T switch_event = {.ID = KEVENT_ACCESSORY_SWITCH_RELEASED, .Data = (void *) accessoryPressDurationInms};
KEvent_T switch_event = {.ID = KEVENT_ACCESSORY_SWITCH_RELEASED, .Data = (void *)accessoryPressDurationInms};
Post_KEvent_From_ISR(&switch_event, &xHigherPriorityTaskWoken);
}
void Initialize_Switches(void)
esp_err_t Initialize_Switches(void)
{
KLOG_INFO(TAG, "Initializing Switches...");
Trigger_Button = iot_button_create(&Trigger_Button_Config);
assert(Trigger_Button);
esp_err_t err;
Accessory_Button = iot_button_create(&Accessory_Button_Config);
assert(Accessory_Button);
err = iot_button_new_gpio_device(
&Button_Config,
&Trigger_GPIO_Config,
&Trigger_Button);
iot_button_register_cb(Trigger_Button, BUTTON_PRESS_DOWN, trigger_press_cb, NULL);
iot_button_register_cb(Trigger_Button, BUTTON_PRESS_UP, trigger_release_cb, NULL);
if (err != ESP_OK) {
KLOG_ERROR(TAG, "Failed to create Trigger button (%s)",
esp_err_to_name(err));
return err;
}
iot_button_register_cb(Accessory_Button, BUTTON_PRESS_DOWN, accessory_press_cb, NULL);
iot_button_register_cb(Accessory_Button, BUTTON_PRESS_UP, accessory_release_cb, NULL);
err = iot_button_new_gpio_device(
&Button_Config,
&Accessory_GPIO_Config,
&Accessory_Button);
if (err != ESP_OK) {
KLOG_ERROR(TAG, "Failed to create Accessory button (%s)",
esp_err_to_name(err));
return err;
}
err = iot_button_register_cb(
Trigger_Button,
BUTTON_PRESS_DOWN,
NULL,
trigger_press_cb,
NULL);
if (err != ESP_OK) {
KLOG_ERROR(TAG, "Trigger PRESS_DOWN cb failed (%s)",
esp_err_to_name(err));
return err;
}
err = iot_button_register_cb(
Trigger_Button,
BUTTON_PRESS_UP,
NULL,
trigger_release_cb,
NULL);
if (err != ESP_OK) {
KLOG_ERROR(TAG, "Trigger PRESS_UP cb failed (%s)",
esp_err_to_name(err));
return err;
}
err = iot_button_register_cb(
Accessory_Button,
BUTTON_PRESS_DOWN,
NULL,
accessory_press_cb,
NULL);
if (err != ESP_OK) {
KLOG_ERROR(TAG, "Accessory PRESS_DOWN cb failed (%s)",
esp_err_to_name(err));
return err;
}
err = iot_button_register_cb(
Accessory_Button,
BUTTON_PRESS_UP,
NULL,
accessory_release_cb,
NULL);
if (err != ESP_OK) {
KLOG_ERROR(TAG, "Accessory PRESS_UP cb failed (%s)",
esp_err_to_name(err));
return err;
}
KLOG_INFO(TAG, "Switch initialization complete");
return ESP_OK;
}