11#include "../wendigo_app_i.h"
22
3- void wendigo_console_output_handle_rx_data_cb (uint8_t * buf , size_t len , void * context ) {
3+ void wendigo_console_output_handle_rx_data_cb (uint8_t * buf , size_t len , void * context ) {
44 furi_assert (context );
5- WendigoApp * app = context ;
6- FuriString * new_str = furi_string_alloc ();
5+ WendigoApp * app = context ;
6+ FuriString * new_str = furi_string_alloc ();
77
8- if (app -> hex_mode ) {
9- while (len -- ) {
8+ if (app -> hex_mode ) {
9+ while (len -- ) {
1010 uint8_t byte = * (buf ++ );
11- if (byte == '\0' ) break ;
11+ if (byte == '\0' ) break ;
1212 furi_string_cat_printf (new_str , "%02X " , byte );
1313 }
1414 } else {
@@ -19,7 +19,7 @@ void wendigo_console_output_handle_rx_data_cb(uint8_t* buf, size_t len, void* co
1919 // If text box store gets too big, then truncate it
2020 app -> text_box_store_strlen += furi_string_size (new_str );
2121 ;
22- while (app -> text_box_store_strlen >= WENDIGO_TEXT_BOX_STORE_SIZE - 1 ) {
22+ while (app -> text_box_store_strlen >= WENDIGO_TEXT_BOX_STORE_SIZE - 1 ) {
2323 furi_string_right (app -> text_box_store , app -> text_box_store_strlen / 2 );
2424 app -> text_box_store_strlen = furi_string_size (app -> text_box_store ) + len ;
2525 }
@@ -31,48 +31,48 @@ void wendigo_console_output_handle_rx_data_cb(uint8_t* buf, size_t len, void* co
3131}
3232
3333static uint8_t hex_char_to_byte (const char c ) {
34- if (c >= '0' && c <= '9' ) {
34+ if (c >= '0' && c <= '9' ) {
3535 return c - '0' ;
3636 }
37- if (c >= 'A' && c <= 'F' ) {
37+ if (c >= 'A' && c <= 'F' ) {
3838 return c - 'A' + 10 ;
3939 }
40- if (c >= 'a' && c <= 'f' ) {
40+ if (c >= 'a' && c <= 'f' ) {
4141 return c - 'a' + 10 ;
4242 }
4343 return 0 ;
4444}
4545
46- void wendigo_scene_console_output_on_enter (void * context ) {
47- FURI_LOG_T (WENDIGO_TAG , "Start wendigo_scene_console_output_on_enter()\n---------- " );
48- WendigoApp * app = context ;
46+ void wendigo_scene_console_output_on_enter (void * context ) {
47+ FURI_LOG_T (WENDIGO_TAG , "Start wendigo_scene_console_output_on_enter()" );
48+ WendigoApp * app = context ;
4949 app -> current_view = WendigoAppViewConsoleOutput ;
5050
51- TextBox * text_box = app -> text_box ;
51+ TextBox * text_box = app -> text_box ;
5252 text_box_reset (app -> text_box );
5353 text_box_set_font (text_box , TextBoxFontText );
5454 text_box_set_focus (text_box , TextBoxFocusEnd );
5555
5656 bool need_reinit = false;
5757
5858 //Change baudrate
59- if (app -> BAUDRATE != app -> NEW_BAUDRATE && app -> NEW_BAUDRATE ) {
59+ if (app -> BAUDRATE != app -> NEW_BAUDRATE && app -> NEW_BAUDRATE ) {
6060 need_reinit = true;
6161 }
6262
6363 //Change UART port
64- if (app -> uart_ch != app -> new_uart_ch ) {
64+ if (app -> uart_ch != app -> new_uart_ch ) {
6565 need_reinit = true;
6666 }
6767
68- if (need_reinit ) {
68+ if (need_reinit ) {
6969 wendigo_uart_free (app -> uart );
7070 app -> BAUDRATE = app -> NEW_BAUDRATE ;
7171 app -> uart_ch = app -> new_uart_ch ;
7272 app -> uart = wendigo_uart_init (app );
7373 }
7474
75- if (app -> is_command ) {
75+ if (app -> is_command ) {
7676 furi_string_reset (app -> text_box_store );
7777 app -> text_box_store_strlen = 0 ;
7878 }
@@ -87,31 +87,31 @@ void wendigo_scene_console_output_on_enter(void* context) {
8787 wendigo_uart_set_handle_rx_data_cb (
8888 app -> uart , wendigo_console_output_handle_rx_data_cb ); // setup callback for rx thread
8989
90- if (app -> hex_mode ) {
90+ if (app -> hex_mode ) {
9191 // Send binary packet
92- if (app -> selected_tx_string ) {
93- const char * str = app -> selected_tx_string ;
92+ if (app -> selected_tx_string ) {
93+ const char * str = app -> selected_tx_string ;
9494 uint8_t digit_num = 0 ;
9595 uint8_t byte = 0 ;
96- while (* str ) {
96+ while (* str ) {
9797 byte |= (hex_char_to_byte (* str ) << ((1 - digit_num ) * 4 ));
9898
99- if (++ digit_num == 2 ) {
99+ if (++ digit_num == 2 ) {
100100 wendigo_uart_tx (app -> uart , & byte , 1 );
101101 digit_num = 0 ;
102102 byte = 0 ;
103103 }
104104 str ++ ;
105105 }
106106
107- if (digit_num ) {
107+ if (digit_num ) {
108108 wendigo_uart_tx (app -> uart , & byte , 1 );
109109 }
110110 }
111111 } else {
112112 // Send command with CR+LF or newline '\n'
113- if (app -> is_command && app -> selected_tx_string ) {
114- if (app -> TERMINAL_MODE == 1 ) {
113+ if (app -> is_command && app -> selected_tx_string ) {
114+ if (app -> TERMINAL_MODE == 1 ) {
115115 wendigo_uart_tx (
116116 app -> uart ,
117117 (uint8_t * )(app -> selected_tx_string ),
@@ -126,30 +126,30 @@ void wendigo_scene_console_output_on_enter(void* context) {
126126 }
127127 }
128128 }
129- FURI_LOG_T (WENDIGO_TAG , "----------\nEnd wendigo_scene_console_output_on_enter()" );
129+ FURI_LOG_T (WENDIGO_TAG , "End wendigo_scene_console_output_on_enter()" );
130130}
131131
132- bool wendigo_scene_console_output_on_event (void * context , SceneManagerEvent event ) {
133- FURI_LOG_T (WENDIGO_TAG , "Start wendigo_scene_console_output_on_event()\n---------- " );
134- WendigoApp * app = context ;
132+ bool wendigo_scene_console_output_on_event (void * context , SceneManagerEvent event ) {
133+ FURI_LOG_T (WENDIGO_TAG , "Start wendigo_scene_console_output_on_event()" );
134+ WendigoApp * app = context ;
135135
136136 bool consumed = false;
137137
138- if (event .type == SceneManagerEventTypeCustom ) {
138+ if (event .type == SceneManagerEventTypeCustom ) {
139139 text_box_set_text (app -> text_box , furi_string_get_cstr (app -> text_box_store ));
140140 consumed = true;
141- } else if (event .type == SceneManagerEventTypeTick ) {
141+ } else if (event .type == SceneManagerEventTypeTick ) {
142142 consumed = true;
143143 }
144- FURI_LOG_T (WENDIGO_TAG , "----------\nEnd wendigo_scene_console_output_on_event()" );
144+ FURI_LOG_T (WENDIGO_TAG , "End wendigo_scene_console_output_on_event()" );
145145 return consumed ;
146146}
147147
148- void wendigo_scene_console_output_on_exit (void * context ) {
149- FURI_LOG_T (WENDIGO_TAG , "Start wendigo_scene_console_output_on_exit()\n---------- " );
150- WendigoApp * app = context ;
148+ void wendigo_scene_console_output_on_exit (void * context ) {
149+ FURI_LOG_T (WENDIGO_TAG , "Start wendigo_scene_console_output_on_exit()" );
150+ WendigoApp * app = context ;
151151
152152 // Unregister rx callback
153153 wendigo_uart_set_handle_rx_data_cb (app -> uart , NULL );
154- FURI_LOG_T (WENDIGO_TAG , "----------\nEnd wendigo_scene_console_output_on_exit()" );
154+ FURI_LOG_T (WENDIGO_TAG , "End wendigo_scene_console_output_on_exit()" );
155155}
0 commit comments