input_i.h 750 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include "input.h"
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include <stdio.h>
  6. #include <furi.h>
  7. #include <cli/cli.h>
  8. #define INPUT_DEBOUNCE_TICKS_HALF (INPUT_DEBOUNCE_TICKS / 2)
  9. #define INPUT_LONG_PRESS_TICKS 2048
  10. #define INPUT_THREAD_FLAG_ISR 0x00000001
  11. /* Input pin state */
  12. typedef struct {
  13. const InputPin* pin;
  14. // State
  15. volatile bool state;
  16. volatile uint8_t debounce;
  17. volatile osTimerId_t press_timer;
  18. } InputPinState;
  19. /* Input state */
  20. typedef struct {
  21. osThreadId_t thread;
  22. PubSub event_pubsub;
  23. InputPinState* pin_states;
  24. Cli* cli;
  25. } Input;
  26. /* Input press timer callback */
  27. void input_press_timer_callback(void* arg);
  28. /* Input interrupt handler */
  29. void input_isr(void* _pin, void* _ctx);