56 lines
2.1 KiB
C
56 lines
2.1 KiB
C
/*
|
|
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include "domain.h"
|
|
#include "esp_err.h"
|
|
|
|
/*
|
|
* domain 私有协作接口:目录、角度数学、校准存储和 platform 适配器只供本组件实现
|
|
* 使用。上层不得包含此文件;所有跨层契约必须经 domain.h 暴露。
|
|
*/
|
|
typedef struct {
|
|
const char *name_cn;
|
|
const char *name_en;
|
|
float angle;
|
|
} domain_direction_entry_t;
|
|
|
|
size_t domain_direction_catalog_count(void);
|
|
const domain_direction_entry_t *domain_direction_catalog_get(size_t index);
|
|
bool domain_direction_catalog_find_by_name(const char *input, size_t *out_index);
|
|
bool domain_direction_catalog_find_by_angle(float angle, size_t *out_index);
|
|
|
|
float domain_angle_normalize(float angle);
|
|
float domain_angle_shortest_rotation(float current, float target);
|
|
|
|
void domain_calibration_store_set(const domain_direction_calibration_t *config);
|
|
bool domain_calibration_store_get(domain_direction_calibration_t *out_config);
|
|
|
|
bool domain_direction_lock_state(int timeout_ms);
|
|
/* 状态锁保护角度/初始化快照,物理运动由 direction service 的另一互斥锁串行化。 */
|
|
void domain_direction_unlock_state(void);
|
|
|
|
typedef struct {
|
|
int gpio_num;
|
|
int active_level;
|
|
bool pullup_enabled;
|
|
bool pulldown_enabled;
|
|
} domain_digital_input_config_t;
|
|
|
|
esp_err_t domain_runtime_platform_init(void);
|
|
esp_err_t domain_runtime_stepper_rotate_angle_with_accel_timeout(float angle,
|
|
int target_delay_us,
|
|
int timeout_ms);
|
|
esp_err_t domain_runtime_stepper_release_hold(int timeout_ms);
|
|
void domain_runtime_stepper_power_off(void);
|
|
esp_err_t domain_runtime_digital_input_configure(const domain_digital_input_config_t *config);
|
|
bool domain_runtime_digital_input_is_active(const domain_digital_input_config_t *config);
|
|
esp_err_t domain_runtime_calibration_switch_init(void);
|
|
bool domain_runtime_calibration_switch_is_active(void);
|