2021-10-03 10:36:05 +00:00
|
|
|
/**
|
|
|
|
* @file input_i.h
|
|
|
|
* Input: internal API
|
|
|
|
*/
|
|
|
|
|
2021-02-10 08:56:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "input.h"
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <furi.h>
|
2021-03-04 12:30:20 +00:00
|
|
|
#include <cli/cli.h>
|
2022-01-05 16:10:18 +00:00
|
|
|
#include <furi_hal_gpio.h>
|
2021-02-10 08:56:05 +00:00
|
|
|
|
|
|
|
#define INPUT_DEBOUNCE_TICKS_HALF (INPUT_DEBOUNCE_TICKS / 2)
|
2021-06-02 12:51:05 +00:00
|
|
|
#define INPUT_PRESS_TICKS 150
|
|
|
|
#define INPUT_LONG_PRESS_COUNTS 2
|
2021-02-10 08:56:05 +00:00
|
|
|
#define INPUT_THREAD_FLAG_ISR 0x00000001
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Input pin state */
|
2021-02-10 08:56:05 +00:00
|
|
|
typedef struct {
|
|
|
|
const InputPin* pin;
|
|
|
|
// State
|
|
|
|
volatile bool state;
|
|
|
|
volatile uint8_t debounce;
|
2022-07-20 10:56:33 +00:00
|
|
|
FuriTimer* press_timer;
|
2021-04-18 19:32:57 +00:00
|
|
|
volatile uint8_t press_counter;
|
2021-09-01 21:05:00 +00:00
|
|
|
volatile uint32_t counter;
|
2021-02-10 08:56:05 +00:00
|
|
|
} InputPinState;
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Input state */
|
2021-02-10 08:56:05 +00:00
|
|
|
typedef struct {
|
2022-06-20 14:54:48 +00:00
|
|
|
FuriThreadId thread_id;
|
2021-11-01 20:35:54 +00:00
|
|
|
FuriPubSub* event_pubsub;
|
2021-02-10 08:56:05 +00:00
|
|
|
InputPinState* pin_states;
|
2021-03-04 12:30:20 +00:00
|
|
|
Cli* cli;
|
2021-09-01 21:05:00 +00:00
|
|
|
volatile uint32_t counter;
|
2021-02-10 08:56:05 +00:00
|
|
|
} Input;
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Input press timer callback */
|
2021-02-10 08:56:05 +00:00
|
|
|
void input_press_timer_callback(void* arg);
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Input interrupt handler */
|
2021-04-29 08:51:48 +00:00
|
|
|
void input_isr(void* _ctx);
|
2022-02-16 11:15:40 +00:00
|
|
|
|
|
|
|
/** Input CLI command handler */
|
2022-10-05 15:15:23 +00:00
|
|
|
void input_cli(Cli* cli, FuriString* args, void* context);
|