mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-26 23:05:05 +03:00
Merge branch 'flipperdevices:dev' into dev
This commit is contained in:
commit
dae2cc6b38
3
Brewfile
3
Brewfile
@ -1,7 +1,8 @@
|
||||
cask "gcc-arm-embedded"
|
||||
brew "protobuf"
|
||||
brew "gdb"
|
||||
brew "heatshrink"
|
||||
brew "open-ocd"
|
||||
brew "clang-format"
|
||||
brew "dfu-util"
|
||||
brew "imagemagick"
|
||||
brew "imagemagick"
|
||||
|
240
applications/gui/modules/text_input.c
Executable file → Normal file
240
applications/gui/modules/text_input.c
Executable file → Normal file
@ -259,173 +259,159 @@ static void text_input_view_draw_callback(Canvas* canvas, void* _model) {
|
||||
}
|
||||
}
|
||||
|
||||
static void text_input_handle_up(TextInput* text_input) {
|
||||
with_view_model(
|
||||
text_input->view, (TextInputModel * model) {
|
||||
if(model->selected_row > 0) {
|
||||
model->selected_row--;
|
||||
if(model->selected_column > get_row_size(model->selected_row) - 6) {
|
||||
model->selected_column = model->selected_column + 1;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
static void text_input_handle_up(TextInput* text_input, TextInputModel* model) {
|
||||
if(model->selected_row > 0) {
|
||||
model->selected_row--;
|
||||
if(model->selected_column > get_row_size(model->selected_row) - 6) {
|
||||
model->selected_column = model->selected_column + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void text_input_handle_down(TextInput* text_input) {
|
||||
with_view_model(
|
||||
text_input->view, (TextInputModel * model) {
|
||||
if(model->selected_row < keyboard_row_count - 1) {
|
||||
model->selected_row++;
|
||||
if(model->selected_column > get_row_size(model->selected_row) - 4) {
|
||||
model->selected_column = model->selected_column - 1;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
static void text_input_handle_down(TextInput* text_input, TextInputModel* model) {
|
||||
if(model->selected_row < keyboard_row_count - 1) {
|
||||
model->selected_row++;
|
||||
if(model->selected_column > get_row_size(model->selected_row) - 4) {
|
||||
model->selected_column = model->selected_column - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void text_input_handle_left(TextInput* text_input) {
|
||||
with_view_model(
|
||||
text_input->view, (TextInputModel * model) {
|
||||
if(model->selected_column > 0) {
|
||||
model->selected_column--;
|
||||
} else {
|
||||
model->selected_column = get_row_size(model->selected_row) - 1;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
static void text_input_handle_left(TextInput* text_input, TextInputModel* model) {
|
||||
if(model->selected_column > 0) {
|
||||
model->selected_column--;
|
||||
} else {
|
||||
model->selected_column = get_row_size(model->selected_row) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void text_input_handle_right(TextInput* text_input) {
|
||||
with_view_model(
|
||||
text_input->view, (TextInputModel * model) {
|
||||
if(model->selected_column < get_row_size(model->selected_row) - 1) {
|
||||
model->selected_column++;
|
||||
} else {
|
||||
model->selected_column = 0;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
static void text_input_handle_right(TextInput* text_input, TextInputModel* model) {
|
||||
if(model->selected_column < get_row_size(model->selected_row) - 1) {
|
||||
model->selected_column++;
|
||||
} else {
|
||||
model->selected_column = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void text_input_handle_ok(TextInput* text_input, bool shift) {
|
||||
with_view_model(
|
||||
text_input->view, (TextInputModel * model) {
|
||||
char selected = get_selected_char(model);
|
||||
uint8_t text_length = strlen(model->text_buffer);
|
||||
static void text_input_handle_ok(TextInput* text_input, TextInputModel* model, bool shift) {
|
||||
char selected = get_selected_char(model);
|
||||
uint8_t text_length = strlen(model->text_buffer);
|
||||
|
||||
if(shift) {
|
||||
selected = char_to_uppercase(selected);
|
||||
}
|
||||
if(shift) {
|
||||
selected = char_to_uppercase(selected);
|
||||
}
|
||||
|
||||
if(selected == ENTER_KEY) {
|
||||
if(model->validator_callback && (!model->validator_callback(
|
||||
model->text_buffer,
|
||||
model->validator_text,
|
||||
model->validator_callback_context))) {
|
||||
model->valadator_message_visible = true;
|
||||
osTimerStart(text_input->timer, osKernelGetTickFreq() * 4);
|
||||
} else if(model->callback != 0 && text_length > 0) {
|
||||
model->callback(model->callback_context);
|
||||
}
|
||||
} else if(selected == BACKSPACE_KEY) {
|
||||
text_input_backspace_cb(model);
|
||||
} else if(text_length < (model->text_buffer_size - 1)) {
|
||||
if(model->clear_default_text) {
|
||||
text_length = 0;
|
||||
}
|
||||
if(text_length == 0 && char_is_lowercase(selected)) {
|
||||
selected = char_to_uppercase(selected);
|
||||
}
|
||||
model->text_buffer[text_length] = selected;
|
||||
model->text_buffer[text_length + 1] = 0;
|
||||
}
|
||||
model->clear_default_text = false;
|
||||
return true;
|
||||
});
|
||||
if(selected == ENTER_KEY) {
|
||||
if(model->validator_callback &&
|
||||
(!model->validator_callback(
|
||||
model->text_buffer, model->validator_text, model->validator_callback_context))) {
|
||||
model->valadator_message_visible = true;
|
||||
osTimerStart(text_input->timer, osKernelGetTickFreq() * 4);
|
||||
} else if(model->callback != 0 && text_length > 0) {
|
||||
model->callback(model->callback_context);
|
||||
}
|
||||
} else if(selected == BACKSPACE_KEY) {
|
||||
text_input_backspace_cb(model);
|
||||
} else if(text_length < (model->text_buffer_size - 1)) {
|
||||
if(model->clear_default_text) {
|
||||
text_length = 0;
|
||||
}
|
||||
if(text_length == 0 && char_is_lowercase(selected)) {
|
||||
selected = char_to_uppercase(selected);
|
||||
}
|
||||
model->text_buffer[text_length] = selected;
|
||||
model->text_buffer[text_length + 1] = 0;
|
||||
}
|
||||
model->clear_default_text = false;
|
||||
}
|
||||
|
||||
static bool text_input_view_input_callback(InputEvent* event, void* context) {
|
||||
TextInput* text_input = context;
|
||||
furi_assert(text_input);
|
||||
|
||||
bool consumed = false;
|
||||
|
||||
if(event->type == InputTypeShort) {
|
||||
with_view_model(
|
||||
text_input->view, (TextInputModel * model) {
|
||||
if(model->valadator_message_visible) {
|
||||
if(event->key == InputKeyBack) {
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
model->valadator_message_visible = false;
|
||||
return false;
|
||||
});
|
||||
// Acquire model
|
||||
TextInputModel* model = view_get_model(text_input->view);
|
||||
|
||||
if((!(event->type == InputTypePress) && !(event->type == InputTypeRelease)) &&
|
||||
model->valadator_message_visible) {
|
||||
model->valadator_message_visible = false;
|
||||
consumed = true;
|
||||
} else if(event->type == InputTypeShort) {
|
||||
consumed = true;
|
||||
switch(event->key) {
|
||||
case InputKeyUp:
|
||||
text_input_handle_up(text_input);
|
||||
consumed = true;
|
||||
text_input_handle_up(text_input, model);
|
||||
break;
|
||||
case InputKeyDown:
|
||||
text_input_handle_down(text_input);
|
||||
consumed = true;
|
||||
text_input_handle_down(text_input, model);
|
||||
break;
|
||||
case InputKeyLeft:
|
||||
text_input_handle_left(text_input);
|
||||
consumed = true;
|
||||
text_input_handle_left(text_input, model);
|
||||
break;
|
||||
case InputKeyRight:
|
||||
text_input_handle_right(text_input);
|
||||
consumed = true;
|
||||
text_input_handle_right(text_input, model);
|
||||
break;
|
||||
case InputKeyOk:
|
||||
text_input_handle_ok(text_input, false);
|
||||
consumed = true;
|
||||
text_input_handle_ok(text_input, model, false);
|
||||
break;
|
||||
default:
|
||||
consumed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if((event->type == InputTypeLong || event->type == InputTypeRepeat) &&
|
||||
event->key == InputKeyBack) {
|
||||
with_view_model(
|
||||
text_input->view, (TextInputModel * model) {
|
||||
if(model->valadator_message_visible) {
|
||||
model->valadator_message_visible = false;
|
||||
} else {
|
||||
text_input_backspace_cb(model);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
} else if(event->type == InputTypeLong) {
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
// Allow shift key on long press
|
||||
if(event->type == InputTypeLong && event->key == InputKeyOk) {
|
||||
with_view_model(
|
||||
text_input->view, (TextInputModel * model) {
|
||||
if(model->valadator_message_visible) {
|
||||
if(event->key == InputKeyBack) {
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
model->valadator_message_visible = false;
|
||||
return false;
|
||||
});
|
||||
|
||||
switch(event->key) {
|
||||
case InputKeyUp:
|
||||
text_input_handle_up(text_input, model);
|
||||
break;
|
||||
case InputKeyDown:
|
||||
text_input_handle_down(text_input, model);
|
||||
break;
|
||||
case InputKeyLeft:
|
||||
text_input_handle_left(text_input, model);
|
||||
break;
|
||||
case InputKeyRight:
|
||||
text_input_handle_right(text_input, model);
|
||||
break;
|
||||
case InputKeyOk:
|
||||
text_input_handle_ok(text_input, true);
|
||||
consumed = true;
|
||||
text_input_handle_ok(text_input, model, true);
|
||||
break;
|
||||
case InputKeyBack:
|
||||
text_input_backspace_cb(model);
|
||||
break;
|
||||
default:
|
||||
consumed = false;
|
||||
break;
|
||||
}
|
||||
} else if(event->type == InputTypeRepeat) {
|
||||
consumed = true;
|
||||
switch(event->key) {
|
||||
case InputKeyUp:
|
||||
text_input_handle_up(text_input, model);
|
||||
break;
|
||||
case InputKeyDown:
|
||||
text_input_handle_down(text_input, model);
|
||||
break;
|
||||
case InputKeyLeft:
|
||||
text_input_handle_left(text_input, model);
|
||||
break;
|
||||
case InputKeyRight:
|
||||
text_input_handle_right(text_input, model);
|
||||
break;
|
||||
case InputKeyBack:
|
||||
text_input_backspace_cb(model);
|
||||
break;
|
||||
default:
|
||||
consumed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Commit model
|
||||
view_commit_model(text_input->view, consumed);
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ upload: $(OBJ_DIR)/upload
|
||||
|
||||
.PHONY: debug
|
||||
debug: flash
|
||||
arm-none-eabi-gdb-py \
|
||||
$(GDB) \
|
||||
-ex 'target extended-remote | openocd -c "gdb_port pipe" $(OPENOCD_OPTS)' \
|
||||
-ex "set confirm off" \
|
||||
-ex "source ../debug/FreeRTOS/FreeRTOS.py" \
|
||||
@ -105,7 +105,7 @@ debug: flash
|
||||
|
||||
.PHONY: debug_other
|
||||
debug_other:
|
||||
arm-none-eabi-gdb-py \
|
||||
$(GDB) \
|
||||
-ex 'target extended-remote | openocd -c "gdb_port pipe" $(OPENOCD_OPTS)' \
|
||||
-ex "set confirm off" \
|
||||
-ex "source ../debug/PyCortexMDebug/PyCortexMDebug.py" \
|
||||
@ -113,7 +113,7 @@ debug_other:
|
||||
|
||||
.PHONY: blackmagic
|
||||
blackmagic:
|
||||
arm-none-eabi-gdb-py \
|
||||
$(GDB) \
|
||||
-ex 'target extended-remote $(BLACKMAGIC)' \
|
||||
-ex 'monitor swdp_scan' \
|
||||
-ex 'monitor debug_bmp enable' \
|
||||
|
@ -1,3 +1,5 @@
|
||||
OS := $(shell uname -s)
|
||||
|
||||
# Compiller
|
||||
ifeq ($(TOOLCHAIN), arm)
|
||||
PREFIX = arm-none-eabi-
|
||||
@ -15,6 +17,12 @@ SZ = $(PREFIX)size
|
||||
HEX = $(CP) -O ihex
|
||||
BIN = $(CP) -O binary -S
|
||||
|
||||
ifeq ($(OS), Darwin)
|
||||
GDB = gdb
|
||||
else
|
||||
GDB = $(PREFIX)gdb-py
|
||||
endif
|
||||
|
||||
DEBUG ?= 1
|
||||
COMPACT ?= 0
|
||||
ifeq ($(DEBUG), 1)
|
||||
@ -27,4 +35,4 @@ endif
|
||||
|
||||
CFLAGS += -fdata-sections -ffunction-sections -fno-math-errno -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)"
|
||||
CPPFLAGS += -fno-threadsafe-statics -fno-use-cxa-atexit -fno-exceptions -fno-rtti
|
||||
LDFLAGS += -Wl,-Map=$(OBJ_DIR)/$(PROJECT).map,--cref -Wl,--gc-sections -Wl,--undefined=uxTopUsedPriority -n
|
||||
LDFLAGS += -Wl,-Map=$(OBJ_DIR)/$(PROJECT).map,--cref -Wl,--gc-sections -Wl,--undefined=uxTopUsedPriority -n
|
||||
|
Loading…
Reference in New Issue
Block a user