@@ -23,18 +23,52 @@ EthViewProcess* ethernet_view_process_malloc(EthWorkerProcess type) {
23
23
24
24
if (type == EthWorkerProcessInit ) {
25
25
evp -> y += 22 ;
26
- evp -> draw_struct = malloc (sizeof (EthViewDrawInit ));
27
- memset (evp -> draw_struct , 0 , sizeof (EthViewDrawInit ));
26
+ EthViewDrawInit * init = malloc (sizeof (EthViewDrawInit ));
27
+ memset (init , 0 , sizeof (EthViewDrawInit ));
28
+ init -> mac [0 ] = 0x10 ;
29
+ init -> mac [1 ] = 0x08 ;
30
+ init -> mac [2 ] = 0xDC ;
31
+ init -> mac [3 ] = 0x47 ;
32
+ init -> mac [4 ] = 0x47 ;
33
+ init -> mac [5 ] = 0x54 ;
34
+ evp -> draw_struct = init ;
28
35
} else if (type == EthWorkerProcessStatic ) {
29
36
evp -> y += 22 ;
30
- evp -> draw_struct = malloc (sizeof (EthViewDrawStatic ));
31
- memset (evp -> draw_struct , 0 , sizeof (EthViewDrawStatic ));
37
+ EthViewDrawStatic * stat = malloc (sizeof (EthViewDrawStatic ));
38
+ memset (stat , 0 , sizeof (EthViewDrawStatic ));
39
+ stat -> ip [0 ] = 192 ;
40
+ stat -> ip [1 ] = 168 ;
41
+ stat -> ip [2 ] = 0 ;
42
+ stat -> ip [3 ] = 101 ;
43
+ stat -> mask [0 ] = 255 ;
44
+ stat -> mask [1 ] = 255 ;
45
+ stat -> mask [2 ] = 255 ;
46
+ stat -> mask [3 ] = 0 ;
47
+ stat -> gateway [0 ] = 192 ;
48
+ stat -> gateway [1 ] = 168 ;
49
+ stat -> gateway [2 ] = 0 ;
50
+ stat -> gateway [3 ] = 1 ;
51
+ stat -> dns [0 ] = 192 ;
52
+ stat -> dns [1 ] = 168 ;
53
+ stat -> dns [2 ] = 0 ;
54
+ stat -> dns [3 ] = 1 ;
55
+ evp -> draw_struct = stat ;
56
+ } else if (type == EthWorkerProcessPing ) {
57
+ evp -> y += 11 ;
58
+ EthViewDrawPing * ping = malloc (sizeof (EthViewDrawPing ));
59
+ memset (ping , 0 , sizeof (EthViewDrawPing ));
60
+ ping -> ip [0 ] = 8 ;
61
+ ping -> ip [1 ] = 8 ;
62
+ ping -> ip [2 ] = 8 ;
63
+ ping -> ip [3 ] = 8 ;
64
+ evp -> draw_struct = ping ;
32
65
}
33
66
return evp ;
34
67
}
35
68
36
69
void ethernet_view_process_free (EthViewProcess * evp ) {
37
- if (evp -> type == EthWorkerProcessInit || evp -> type == EthWorkerProcessStatic ) {
70
+ if (evp -> type == EthWorkerProcessInit || evp -> type == EthWorkerProcessStatic ||
71
+ evp -> type == EthWorkerProcessPing ) {
38
72
free (evp -> draw_struct );
39
73
}
40
74
free (evp );
@@ -181,6 +215,22 @@ void ethernet_view_process_draw(EthViewProcess* process, Canvas* canvas) {
181
215
canvas_draw_line (canvas , x1 , 29 , x1 + 4 , 29 );
182
216
}
183
217
}
218
+ } else if (process -> type == EthWorkerProcessPing ) {
219
+ canvas_draw_frame (canvas , 31 , 8 , 21 , 13 );
220
+ canvas_draw_frame (canvas , 55 , 8 , 21 , 13 );
221
+ canvas_draw_frame (canvas , 79 , 8 , 21 , 13 );
222
+ canvas_draw_frame (canvas , 103 , 8 , 21 , 13 );
223
+ uint8_t current_digit = ((EthViewDrawPing * )process -> draw_struct )-> current_digit ;
224
+ uint8_t * adress = ((EthViewDrawPing * )process -> draw_struct )-> ip ;
225
+ for (uint8_t i = 0 ; i < 4 ; ++ i ) {
226
+ uint8_t x = 33 + i * 24 ;
227
+ draw_dec_number (canvas , x , 17 , adress [i ]);
228
+ if (process -> editing && (current_digit / 3 == i )) {
229
+ uint8_t x1 = x + 6 * (current_digit % 3 );
230
+ canvas_draw_line (canvas , x1 , 18 , x1 + 4 , 18 );
231
+ canvas_draw_line (canvas , x1 , 19 , x1 + 4 , 19 );
232
+ }
233
+ }
184
234
}
185
235
}
186
236
@@ -246,10 +296,7 @@ void ethernet_view_process_keyevent(EthViewProcess* process, InputKey key) {
246
296
adress_change_dec_digit (adress , digit , 1 );
247
297
} else if (key == InputKeyDown ) {
248
298
adress_change_dec_digit (adress , digit , -1 );
249
- } else if (key == InputKeyOk ) {
250
- ((EthViewDrawStatic * )process -> draw_struct )-> editing = 0 ;
251
- } else if (key == InputKeyBack ) {
252
- mode = 0 ;
299
+ } else if (key == InputKeyOk || key == InputKeyBack ) {
253
300
((EthViewDrawStatic * )process -> draw_struct )-> editing = 0 ;
254
301
}
255
302
} else {
@@ -266,11 +313,31 @@ void ethernet_view_process_keyevent(EthViewProcess* process, InputKey key) {
266
313
} else if (key == InputKeyDown || key == InputKeyOk ) {
267
314
((EthViewDrawStatic * )process -> draw_struct )-> editing = 1 ;
268
315
} else if (key == InputKeyBack || key == InputKeyUp ) {
316
+ mode = 0 ;
269
317
process -> editing = 0 ;
270
318
}
271
319
}
272
320
((EthViewDrawStatic * )process -> draw_struct )-> current_mode = mode ;
273
321
((EthViewDrawStatic * )process -> draw_struct )-> current_digit = digit ;
322
+ } else if (process -> type == EthWorkerProcessPing ) {
323
+ uint8_t digit = ((EthViewDrawPing * )process -> draw_struct )-> current_digit ;
324
+ uint8_t * adress = ((EthViewDrawPing * )process -> draw_struct )-> ip ;
325
+ if (key == InputKeyLeft ) {
326
+ if (digit > 0 ) {
327
+ digit -= 1 ;
328
+ } else {
329
+ process -> editing = 0 ;
330
+ }
331
+ } else if (key == InputKeyRight ) {
332
+ if (digit < 11 ) digit += 1 ;
333
+ } else if (key == InputKeyUp ) {
334
+ adress_change_dec_digit (adress , digit , 1 );
335
+ } else if (key == InputKeyDown ) {
336
+ adress_change_dec_digit (adress , digit , -1 );
337
+ } else if (key == InputKeyOk || key == InputKeyBack ) {
338
+ process -> editing = 0 ;
339
+ }
340
+ ((EthViewDrawPing * )process -> draw_struct )-> current_digit = digit ;
274
341
} else {
275
342
if (key == InputKeyBack || key == InputKeyLeft ) {
276
343
process -> editing = 0 ;
0 commit comments