@@ -20,6 +20,7 @@ EthViewProcess* ethernet_view_process_malloc(EthWorkerProcess type) {
2020 evp -> position = 0 ;
2121 evp -> x = 27 ;
2222 evp -> y = 6 ;
23+ evp -> strings_cnt = 10 ;
2324
2425 if (type == EthWorkerProcessInit ) {
2526 evp -> y += 22 ;
@@ -53,6 +54,9 @@ EthViewProcess* ethernet_view_process_malloc(EthWorkerProcess type) {
5354 stat -> dns [2 ] = 0 ;
5455 stat -> dns [3 ] = 1 ;
5556 evp -> draw_struct = stat ;
57+ evp -> strings_cnt = 20 ;
58+ } else if (type == EthWorkerProcessDHCP ) {
59+ evp -> strings_cnt = 20 ;
5660 } else if (type == EthWorkerProcessPing ) {
5761 evp -> y += 11 ;
5862 EthViewDrawPing * ping = malloc (sizeof (EthViewDrawPing ));
@@ -62,11 +66,15 @@ EthViewProcess* ethernet_view_process_malloc(EthWorkerProcess type) {
6266 ping -> ip [2 ] = 8 ;
6367 ping -> ip [3 ] = 8 ;
6468 evp -> draw_struct = ping ;
69+ evp -> strings_cnt = 20 ;
6570 }
71+
72+ evp -> fifo = malloc (sizeof (EthViewProcessLine ) * evp -> strings_cnt );
6673 return evp ;
6774}
6875
6976void ethernet_view_process_free (EthViewProcess * evp ) {
77+ free (evp -> fifo );
7078 if (evp -> type == EthWorkerProcessInit || evp -> type == EthWorkerProcessStatic ||
7179 evp -> type == EthWorkerProcessPing ) {
7280 free (evp -> draw_struct );
@@ -162,13 +170,13 @@ void ethernet_view_process_draw(EthViewProcess* process, Canvas* canvas) {
162170 uint8_t position = process -> position ;
163171
164172 if (process -> autofill ) {
165- position = (carriage + SCREEN_STRINGS_COUNT - str_count ) % SCREEN_STRINGS_COUNT ;
173+ position = (carriage + process -> strings_cnt - str_count ) % process -> strings_cnt ;
166174 process -> position = position ;
167175 }
168176
169177 for (uint8_t i = 0 ; i < str_count ; ++ i ) {
170178 uint8_t y1 = y + (i + 1 ) * str_height ;
171- canvas_draw_str (canvas , x , y1 , process -> fifo [(position + i ) % SCREEN_STRINGS_COUNT ] );
179+ canvas_draw_str (canvas , x , y1 , process -> fifo [(position + i ) % process -> strings_cnt ]. data );
172180 }
173181
174182 if (process -> type == EthWorkerProcessInit ) {
@@ -360,12 +368,12 @@ void ethernet_view_process_keyevent(EthViewProcess* process, InputKey key) {
360368void ethernet_view_process_move (EthViewProcess * process , int8_t shift ) {
361369 furi_assert (process );
362370 uint8_t position = process -> position ;
363- if (shift <= - SCREEN_STRINGS_COUNT ) {
371+ if (shift <= - process -> strings_cnt ) {
364372 position = 0 ;
365- } else if (shift >= SCREEN_STRINGS_COUNT ) {
373+ } else if (shift >= process -> strings_cnt ) {
366374 position = process -> carriage - 1 ;
367375 } else {
368- position = (position + (SCREEN_STRINGS_COUNT + shift )) % SCREEN_STRINGS_COUNT ;
376+ position = (position + (process -> strings_cnt + shift )) % process -> strings_cnt ;
369377 }
370378 process -> position = position ;
371379 process -> autofill = !shift ;
@@ -402,6 +410,15 @@ static uint16_t get_string_with_width(const char* str, uint16_t width) {
402410 return end ;
403411}
404412
413+ void evp_printf (EthViewProcess * process , const char * format , ...) {
414+ va_list args ;
415+ va_start (args , format );
416+ FuriString * fstring = furi_string_alloc_vprintf (format , args );
417+ va_end (args );
418+ ethernet_view_process_print (process , furi_string_get_cstr (fstring ));
419+ furi_string_free (fstring );
420+ }
421+
405422void ethernet_view_process_print (EthViewProcess * process , const char * str ) {
406423 furi_assert (process );
407424
@@ -413,13 +430,13 @@ void ethernet_view_process_print(EthViewProcess* process, const char* str) {
413430 uint16_t start = ptr ;
414431 ptr += get_string_with_width (str + ptr , max_width );
415432 uint8_t carriage = process -> carriage ;
416- uint8_t carriage1 = (carriage + 1 ) % SCREEN_STRINGS_COUNT ;
417- uint8_t carriage2 = (carriage + 2 ) % SCREEN_STRINGS_COUNT ;
433+ uint8_t carriage1 = (carriage + 1 ) % process -> strings_cnt ;
434+ uint8_t carriage2 = (carriage + 2 ) % process -> strings_cnt ;
418435 FURI_LOG_I (TAG , "print %d %d %d %d %d" , max_width , len , start , carriage , carriage1 );
419- memset (process -> fifo [carriage ], 0 , SCREEN_SYMBOLS_WIDTH );
420- memset (process -> fifo [carriage1 ], 0 , SCREEN_SYMBOLS_WIDTH );
421- memset (process -> fifo [carriage2 ], 0 , SCREEN_SYMBOLS_WIDTH );
422- memcpy (process -> fifo [carriage ], str + start , ptr - start );
436+ memset (process -> fifo [carriage ]. data , 0 , SCREEN_SYMBOLS_WIDTH );
437+ memset (process -> fifo [carriage1 ]. data , 0 , SCREEN_SYMBOLS_WIDTH );
438+ memset (process -> fifo [carriage2 ]. data , 0 , SCREEN_SYMBOLS_WIDTH );
439+ memcpy (process -> fifo [carriage ]. data , str + start , ptr - start );
423440 process -> carriage = carriage1 ;
424441 }
425442}
0 commit comments