ls.
#ifndef MYO_LIBMYO_H
#define MYO_LIBMYO_H
#include <stdint.h>
#include "libmyo/detail/visibility.h"
#ifdef __cplusplus
extern "C" {
#endif
/// @file libmyo.h
/// libmyo C API declarations.
typedef void* libmyo_hub_t;
/// \defgroup errors Error Handling
/// @{
/// Function result codes.
/// All libmyo functions that can fail return a value of this type.
typedef enum {
libmyo_success,
libmyo_error,
libmyo_error_invalid_argument,
libmyo_error_runtime
} libmyo_result_t;
/// Opaque handle to detailed error information.
typedef void* libmyo_error_details_t;
/// Return a null-terminated string with a detailed error message.
LIBMYO_EXPORT
const char* libmyo_error_cstring(libmyo_error_details_t);
/// Returns the kind of error that occurred.
LIBMYO_EXPORT
libmyo_result_t libmyo_error_kind(libmyo_error_details_t);
/// Free the resources allocated by an error object.
LIBMYO_EXPORT
void libmyo_free_error_details(libmyo_error_details_t);
/// @}
/// \defgroup libmyo_string Strings
/// @{
// Opaque string.
typedef void* libmyo_string_t;
// Return a null-terminated string from the opaque string.
LIBMYO_EXPORT
const char* libmyo_string_c_str(libmyo_string_t);
// Free the resources allocated by the string object.
LIBMYO_EXPORT
void libmyo_string_free(libmyo_string_t);
/// @}
/// \defgroup libmyo_direct_mac_addresses MAC address utilities
/// @{
/// Retrieve the string representation of a MAC address in hex.
/// Returns a string in the format of 00-00-00-00-00-00.
LIBMYO_EXPORT
libmyo_string_t libmyo_mac_address_to_string(uint64_t);
/// Retrieve the MAC address from a null-terminated string in the format of 00-00-00-00-00-00.
/// Returns 0 if the string does not match the format.
LIBMYO_EXPORT
uint64_t libmyo_string_to_mac_address(const char*);
/// @}
/// @defgroup libmyo_hub Hub instance
/// @{
/// Initialize a connection to the hub.
/// \a application_identifier must follow a reverse domain name format (ex. com.domainname.appname). Application
/// identifiers can be formed from the set of alphanumeric ASCII characters (a-z, A-Z, 0-9). The hyphen (-) and
/// underscore (_) characters are permitted if they are not adjacent to a period (.) character (i.e. not at the start or
/// end of each segment), but are not permitted in the top-level domain. Application identifiers must have three or more
/// segments. For example, if a company's domain is example.com and the application is named hello-world, one could use
/// "com.example.hello-world" as a valid application identifier. \a application_identifier can be NULL or empty.
/// @returns libmyo_success if the connection is successfully established, otherwise:
/// - libmyo_error_runtime if a connection could not be established
/// - libmyo_error_invalid_argument if \a out_hub is NULL
/// - libmyo_error_invalid_argument if \a application_identifier is longer than 255 characters
/// - libmyo_error_invalid_argument if \a application_identifier is not in the proper reverse domain name format
LIBMYO_EXPORT
libmyo_result_t libmyo_init_hub(libmyo_hub_t* out_hub, const char* application_identifier,
libmyo_error_details_t* out_error);
/// Free the resources allocated to a hub.
/// @returns libmyo_success if shutdown is successful, otherwise:
/// - libmyo_error_invalid_argument if \a hub is NULL
/// - libmyo_error if \a hub is not a valid hub
LIBMYO_EXPORT
libmyo_result_t libmyo_shutdown_hub(libmyo_hub_t hub, libmyo_error_details_t* out_error);
// Locking policies.
typedef enum {
libmyo_locking_policy_none, ///< Pose events are always sent.
libmyo_locking_policy_standard ///< Pose events are not sent while a Myo is locked.
} libmyo_locking_policy_t;
/// Set the locking policy for Myos connected to the hub.
/// @returns libmyo_success if the locking policy is successfully set, otherwise
/// - libmyo_error_invalid_argument if \a hub is NULL
/// - libmyo_error if \a hub is not a valid hub
LIBMYO_EXPORT
libmyo_result_t libmyo_set_locking_policy(libmyo_hub_t hub, libmyo_locking_policy_t locking_policy,
libmyo_error_details_t* out_error);
/// @}
/// @defgroup libmyo_myo Myo instances
/// @{
/// Opaque type corresponding to a known Myo device.
typedef void* libmyo_myo_t;
/// Types of vibration
typedef enum {
libmyo_vibration_short,
libmyo_vibration_medium,
libmyo_vibration_long
} libmyo_vibration_type_t;
/// Retrieve the MAC address of a Myo.
/// The MAC address is unique to the physical Myo, and is a 48-bit number.
LIBMYO_EXPORT
uint64_t libmyo_get_mac_address(libmyo_myo_t myo);
/// Vibrate the given myo.
/// Can be called when a Myo is paired.
/// @returns libmyo_success if the Myo successfully vibrated, otherwise
/// - libmyo_error_invalid_argument if \a myo is NULL
LIBMYO_EXPORT
libmyo_result_t libmyo_vibrate(libmyo_myo_t myo, libmyo_vibration_type_t type, libmyo_error_details_t* out_error);
/// Request the RSSI for a given myo.
/// Can be called when a Myo is paired. A libmyo_event_rssi event will likely be generated with the value of the RSSI.
/// @returns libmyo_success if the Myo successfully got the RSSI, otherwise
/// - libmyo_error_invalid_argument if \a myo is NULL
LIBMYO_EXPORT
libmyo_result_t libmyo_request_rssi(libmyo_myo_t myo, libmyo_error_details_t* out_error);
/// Request the battery level for a given Myo.
/// A libmyo_event_battery_level event will be generated with the value of the battery level.
/// @returns libmyo_success if the Myo successfully requested the battery level, otherwise
/// - libmyo_error_invalid_argument if \a myo is NULL
LIBMYO_EXPORT
libmyo_result_t libmyo_request_battery_level(libmyo_myo_t myo_opq, libmyo_error_details_t* out_error);
/// EMG streaming modes.
typedef enum {
libmyo_stream_emg_disabled, ///< Do not send EMG data.
libmyo_stream_emg_enabled ///< Send EMG data.
} libmyo_stream_emg_t;
/// Set whether or not to stream EMG data for a given myo.
/// Can be called when a Myo is paired.
/// @returns libmyo_success if the EMG mode was set successfully, otherwise
/// - libmyo_error_invalid_argument if \a myo is NULL
LIBMYO_EXPORT
libmyo_result_t libmyo_set_stream_emg(libmyo_myo_t myo, libmyo_stream_emg_t emg, libmyo_error_details_t* out_error);
/// @}
/// @defgroup libmyo_poses Pose recognition.
/// @{
/// Supported poses.
typedef enum {
libmyo_pose_rest = 0, ///< Rest pose.
libmyo_pose_fist = 1, ///< User is making a fist.
libmyo_pose_wave_in = 2, ///< User has an open palm rotated towards the posterior of their wrist.
libmyo_pose_wave_out = 3, ///< User has an open palm rotated towards the anterior of their wrist.
libmyo_pose_fingers_spread = 4, ///< User has an open palm with their fingers spread away from each other.
libmyo_pose_double_tap = 5, ///< User tapped their thumb and middle finger together twice in succession.
libmyo_num_poses, ///< Number of poses supported; not a valid pose.
libmyo_pose_unknown = 0xffff ///< Unknown pose.
} libmyo_pose_t;
/// @}
/// @defgroup libmyo_locking Myo locking mechanism
/// Valid unlock types.
typedef enum {
libmyo_unlock_timed = 0, ///< Unlock for a fixed period of time.
libmyo_unlock_hold = 1, ///< Unlock until explicitly told to re-lock.
} libmyo_unlock_type_t;
/// Unlock the given Myo.
/// Can be called when a Myo is paired. A libmyo_event_unlocked event will be generated if the Myo was locked.
/// @returns libmyo_success if the Myo was successfully unlocked, otherwise
/// - libmyo_error_invalid_argument if \a myo is NULL
LIBMYO_EXPORT
libmyo_result_t libmyo_myo_unlock(libmyo_myo_t myo, libmyo_unlock_type_t type, libmyo_error_details_t* out_error);
/// Lock the given Myo
zt.zip_判断
版权申诉
152 浏览量
2022-09-20
10:27:47
上传
评论
收藏 4KB ZIP 举报
钱亚锋
- 粉丝: 90
- 资源: 1万+