input_i.h 877 B

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