input_i.h 820 B

1234567891011121314151617181920212223242526272829303132333435363738
  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_REPEATE_PRESS_TICKS 256
  11. #define INPUT_THREAD_FLAG_ISR 0x00000001
  12. /* Input pin state */
  13. typedef struct {
  14. const InputPin* pin;
  15. // State
  16. volatile bool state;
  17. volatile bool repeat_event;
  18. volatile uint8_t debounce;
  19. volatile osTimerId_t press_timer;
  20. } InputPinState;
  21. /* Input state */
  22. typedef struct {
  23. osThreadId_t thread;
  24. PubSub event_pubsub;
  25. InputPinState* pin_states;
  26. Cli* cli;
  27. } Input;
  28. /* Input press timer callback */
  29. void input_press_timer_callback(void* arg);
  30. /* Input interrupt handler */
  31. void input_isr(void* _pin, void* _ctx);