Fixes for text box and uart echo

thanks Willy-JL !
This commit is contained in:
MX
2024-03-22 22:47:24 +03:00
parent 09c46a3381
commit 6d73b266d5
2 changed files with 9 additions and 6 deletions

View File

@@ -283,13 +283,14 @@ static UartEchoApp* uart_echo_app_alloc(uint32_t baudrate) {
static void uart_echo_app_free(UartEchoApp* app) {
furi_assert(app);
furi_hal_serial_async_rx_stop(app->serial_handle);
furi_hal_serial_deinit(app->serial_handle);
furi_hal_serial_control_release(app->serial_handle);
furi_thread_flags_set(furi_thread_get_id(app->worker_thread), WorkerEventStop);
furi_thread_join(app->worker_thread);
furi_thread_free(app->worker_thread);
furi_hal_serial_deinit(app->serial_handle);
furi_hal_serial_control_release(app->serial_handle);
// Free views
view_dispatcher_remove_view(app->view_dispatcher, 0);

View File

@@ -102,9 +102,11 @@ static void text_box_insert_endline(Canvas* canvas, TextBoxModel* model) {
model->text_pos = (char*)model->text;
if(model->focus == TextBoxFocusEnd && line_num > 5) {
// Set text position to 5th line from the end
for(uint8_t i = 0; i < line_num - 5; i++) {
while(*model->text_pos++ != '\n') {
};
const char* end = model->text + furi_string_size(model->text_formatted);
for(size_t i = 0; i < line_num - 5; i++) {
while(model->text_pos < end) {
if(*model->text_pos++ == '\n') break;
}
}
model->scroll_num = line_num - 4;
model->scroll_pos = line_num - 5;