[FL-2975] Bug fixes and improvements: Furi, Input, Cli (#2004)
* Furi: configurable heap allocation tracking * Furi: relax restriction in thread heap setter asserts, apply heap tracking setting on app start instead of thread allocation * Furi: hide dangerous heap tracking levels in release build * Input: fix non-working debounce
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "input_i.h"
|
||||
|
||||
// #define INPUT_DEBUG
|
||||
|
||||
#define GPIO_Read(input_pin) (furi_hal_gpio_read(input_pin.pin->gpio) ^ (input_pin.pin->inverted))
|
||||
|
||||
static Input* input = NULL;
|
||||
@@ -72,6 +74,10 @@ int32_t input_srv(void* p) {
|
||||
input->event_pubsub = furi_pubsub_alloc();
|
||||
furi_record_create(RECORD_INPUT_EVENTS, input->event_pubsub);
|
||||
|
||||
#if INPUT_DEBUG
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pa4, GpioModeOutputPushPull);
|
||||
#endif
|
||||
|
||||
#ifdef SRV_CLI
|
||||
input->cli = furi_record_open(RECORD_CLI);
|
||||
if(input->cli) {
|
||||
@@ -95,10 +101,16 @@ int32_t input_srv(void* p) {
|
||||
bool is_changing = false;
|
||||
for(size_t i = 0; i < input_pins_count; i++) {
|
||||
bool state = GPIO_Read(input->pin_states[i]);
|
||||
if(state) {
|
||||
if(input->pin_states[i].debounce < INPUT_DEBOUNCE_TICKS)
|
||||
input->pin_states[i].debounce += 1;
|
||||
} else {
|
||||
if(input->pin_states[i].debounce > 0) input->pin_states[i].debounce -= 1;
|
||||
}
|
||||
|
||||
if(input->pin_states[i].debounce > 0 &&
|
||||
input->pin_states[i].debounce < INPUT_DEBOUNCE_TICKS) {
|
||||
is_changing = true;
|
||||
input->pin_states[i].debounce += (state ? 1 : -1);
|
||||
} else if(input->pin_states[i].state != state) {
|
||||
input->pin_states[i].state = state;
|
||||
|
||||
@@ -129,8 +141,14 @@ int32_t input_srv(void* p) {
|
||||
}
|
||||
|
||||
if(is_changing) {
|
||||
#if INPUT_DEBUG
|
||||
furi_hal_gpio_write(&gpio_ext_pa4, 1);
|
||||
#endif
|
||||
furi_delay_tick(1);
|
||||
} else {
|
||||
#if INPUT_DEBUG
|
||||
furi_hal_gpio_write(&gpio_ext_pa4, 0);
|
||||
#endif
|
||||
furi_thread_flags_wait(INPUT_THREAD_FLAG_ISR, FuriFlagWaitAny, FuriWaitForever);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user