Skip to content

verdancy-org/BitsButtonXR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BitsButtonXR

License Language Framework GitHub stars GitHub forks GitHub issues

English | 中文

BitsButtonXR is a high-performance button detection module designed specifically for embedded systems.

Module Introduction

It inherits the classic binary sequence state machine technology from BitsButton framework and has been adapted according to the design concept of XRobot. Through integration with LibXR middleware, BitsButtonXR achieves automated runtime management and standardized event distribution, eliminating the need for manual polling sequence maintenance and greatly simplifying system integration logic.

For detailed usage tutorials and API documentation, please refer to the Project Wiki.

Features

  • Based on LibXR::GPIO and LibXR::Timer interfaces for hardware abstraction, decoupling underlying platform differences and unifying timing scheduling.

  • Follows Application framework specifications, supporting dependency injection and automated lifecycle management through MANIFEST.

  • Uses LibXR::Event signals and LibXR::LockFreeQueue data separation architecture to build a thread-safe single-producer multi-consumer model.

  • Applies a hybrid scheduling mechanism combining interrupt wake-up and timer polling to achieve low-power response and physical isolation from mechanical bounce.

Hardware Requirements

  • GPIO device nodes matching the key_alias in the single_buttons configuration must be provided.

Constructor Parameters

  • single_buttons

    • Single button configuration list (SingleButtonConfig). Contains GPIO alias, active level (high/low), and timing constraint parameters (short press/long press thresholds, etc.).
  • combined_buttons

    • Combined button configuration list (CombinedButtonConfig). Contains combination alias, whether to suppress single button events, and array of button indices that form the combination.

API Reference

/** Timing parameter constraints */
struct ButtonConstraints {
    uint16_t short_press_time_ms;         ///< Time threshold for short press
    uint16_t long_press_start_time_ms;    ///< Time when long press starts
    uint16_t long_press_period_triger_ms; ///< Period for long press hold events
    uint16_t time_window_time_ms;         ///< Window for double click detection
};

/** Combined button configuration */
struct CombinedButtonConfig {
    const char *combined_alias; ///< Name identifier for the combination
    bool suppress_single_keys; ///< Whether to suppress individual button events
    std::initializer_list<const char *> constituent_aliases; ///< List of button aliases in combination
    ButtonConstraints constraints; ///< Timing constraints for this combination
};

/** Single button configuration */
struct SingleButtonConfig {
    const char *key_alias;         ///< GPIO name identifier for the button
    bool active_level;             ///< GPIO level that indicates button press
    ButtonConstraints constraints; ///< Timing constraints for this button
};

Dependencies

  • No dependencies (except for the LibXR basic framework).

About

A high-performance button detection module designed specifically for embedded systems, based on XRobot.

Resources

License

Stars

Watchers

Forks

Packages

No packages published