Input: refactoring, platform agnostic key configuration.
Update input usage across project. Minor queue usage fixes and tick timings. (#330)
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
#include "main.h"
|
||||
#include <furi.h>
|
||||
|
||||
const bool input_invert[GPIO_INPUT_PINS_COUNT] = {
|
||||
true, // {BUTTON_UP_GPIO_Port, BUTTON_UP_Pin},
|
||||
true, // {BUTTON_DOWN_GPIO_Port, BUTTON_DOWN_Pin},
|
||||
true, // {BUTTON_RIGHT_GPIO_Port, BUTTON_RIGHT_Pin},
|
||||
true, // {BUTTON_LEFT_GPIO_Port, BUTTON_LEFT_Pin},
|
||||
false, // {BUTTON_OK_GPIO_Port, BUTTON_OK_Pin},
|
||||
true, // {BUTTON_BACK_GPIO_Port, BUTTON_BACK_Pin},
|
||||
};
|
@@ -1,15 +1,30 @@
|
||||
#include <api-hal-resources.h>
|
||||
#include "main.h"
|
||||
#include <furi.h>
|
||||
|
||||
const GpioPin input_gpio[GPIO_INPUT_PINS_COUNT] = {
|
||||
{BUTTON_UP_GPIO_Port, BUTTON_UP_Pin},
|
||||
{BUTTON_DOWN_GPIO_Port, BUTTON_DOWN_Pin},
|
||||
{BUTTON_RIGHT_GPIO_Port, BUTTON_RIGHT_Pin},
|
||||
{BUTTON_LEFT_GPIO_Port, BUTTON_LEFT_Pin},
|
||||
{BUTTON_OK_GPIO_Port, BUTTON_OK_Pin},
|
||||
{BUTTON_BACK_GPIO_Port, BUTTON_BACK_Pin},
|
||||
const InputPin input_pins[] = {
|
||||
{.port = BUTTON_UP_GPIO_Port, .pin = BUTTON_UP_Pin, .key = InputKeyUp, .inverted = true},
|
||||
{.port = BUTTON_DOWN_GPIO_Port,
|
||||
.pin = BUTTON_DOWN_Pin,
|
||||
.key = InputKeyDown,
|
||||
.inverted = true},
|
||||
{.port = BUTTON_RIGHT_GPIO_Port,
|
||||
.pin = BUTTON_RIGHT_Pin,
|
||||
.key = InputKeyRight,
|
||||
.inverted = true},
|
||||
{.port = BUTTON_LEFT_GPIO_Port,
|
||||
.pin = BUTTON_LEFT_Pin,
|
||||
.key = InputKeyLeft,
|
||||
.inverted = true},
|
||||
{.port = BUTTON_OK_GPIO_Port, .pin = BUTTON_OK_Pin, .key = InputKeyOk, .inverted = false},
|
||||
{.port = BUTTON_BACK_GPIO_Port,
|
||||
.pin = BUTTON_BACK_Pin,
|
||||
.key = InputKeyBack,
|
||||
.inverted = true},
|
||||
};
|
||||
|
||||
const size_t input_pins_count = sizeof(input_pins) / sizeof(InputPin);
|
||||
|
||||
const GpioPin led_gpio[3] = {
|
||||
{LED_RED_GPIO_Port, LED_RED_Pin},
|
||||
{LED_GREEN_GPIO_Port, LED_GREEN_Pin},
|
||||
|
@@ -2,11 +2,28 @@
|
||||
#include "main.h"
|
||||
#include <furi.h>
|
||||
|
||||
#define DEBOUNCE_TICKS 10
|
||||
#define GPIO_INPUT_PINS_COUNT 6
|
||||
/* Input Related Constants */
|
||||
#define INPUT_DEBOUNCE_TICKS 20
|
||||
|
||||
extern const GpioPin input_gpio[GPIO_INPUT_PINS_COUNT];
|
||||
extern const bool input_invert[GPIO_INPUT_PINS_COUNT];
|
||||
/* Input Keys */
|
||||
typedef enum {
|
||||
InputKeyUp,
|
||||
InputKeyDown,
|
||||
InputKeyRight,
|
||||
InputKeyLeft,
|
||||
InputKeyOk,
|
||||
InputKeyBack,
|
||||
} InputKey;
|
||||
|
||||
typedef struct {
|
||||
const GPIO_TypeDef* port;
|
||||
const uint16_t pin;
|
||||
const InputKey key;
|
||||
const bool inverted;
|
||||
} InputPin;
|
||||
|
||||
extern const InputPin input_pins[];
|
||||
extern const size_t input_pins_count;
|
||||
|
||||
extern const GpioPin led_gpio[3];
|
||||
extern const GpioPin backlight_gpio;
|
||||
|
Reference in New Issue
Block a user