@@ -72,10 +72,10 @@ static void draw_dec_number(Canvas* canvas, uint8_t x, uint8_t y, uint8_t num) {
72
72
73
73
static void draw_static_mode (Canvas * canvas , uint8_t mode ) {
74
74
const uint8_t s1 = 13 ;
75
- const uint8_t s2 = 30 ;
76
- const uint8_t s3 = 17 ;
77
- const uint8_t s4 = 20 ;
78
- const uint8_t s = 40 ;
75
+ const uint8_t s2 = 31 ;
76
+ const uint8_t s3 = 19 ;
77
+ const uint8_t s4 = 21 ;
78
+ const uint8_t s = 35 ;
79
79
const uint8_t h = 7 ;
80
80
const uint8_t y = 10 ;
81
81
const uint8_t y1 = 15 ;
@@ -84,25 +84,25 @@ static void draw_static_mode(Canvas* canvas, uint8_t mode) {
84
84
canvas_invert_color (canvas );
85
85
canvas_draw_box (canvas , s , y , s1 , h );
86
86
canvas_invert_color (canvas );
87
- canvas_draw_str (canvas , 43 , y1 , "ip" );
87
+ canvas_draw_str (canvas , 38 , y1 , "ip" );
88
88
}
89
89
if (mode == EthViewDrawStaticModeMask ) {
90
90
canvas_invert_color (canvas );
91
91
canvas_draw_box (canvas , s + s1 , y , s2 , h );
92
92
canvas_invert_color (canvas );
93
- canvas_draw_str (canvas , 57 , y1 , "mask" );
93
+ canvas_draw_str (canvas , 53 , y1 , "mask" );
94
94
}
95
95
if (mode == EthViewDrawStaticModeGateway ) {
96
96
canvas_invert_color (canvas );
97
97
canvas_draw_box (canvas , s + s1 + s2 , y , s3 , h );
98
98
canvas_invert_color (canvas );
99
- canvas_draw_str (canvas , 85 , y1 , "gw" );
99
+ canvas_draw_str (canvas , 82 , y1 , "gw" );
100
100
}
101
101
if (mode == EthViewDrawStaticModeDNS ) {
102
102
canvas_invert_color (canvas );
103
103
canvas_draw_box (canvas , s + s1 + s2 + s3 , y , s4 , h );
104
104
canvas_invert_color (canvas );
105
- canvas_draw_str (canvas , 104 , y1 , "dns" );
105
+ canvas_draw_str (canvas , 102 , y1 , "dns" );
106
106
}
107
107
}
108
108
@@ -154,17 +154,17 @@ void ethernet_view_process_draw(EthViewProcess* process, Canvas* canvas) {
154
154
}
155
155
}
156
156
} else if (process -> type == EthWorkerProcessStatic ) {
157
- canvas_draw_frame (canvas , 36 , 18 , 21 , 13 );
158
- canvas_draw_frame (canvas , 59 , 18 , 21 , 13 );
159
- canvas_draw_frame (canvas , 82 , 18 , 21 , 13 );
160
- canvas_draw_frame (canvas , 105 , 18 , 21 , 13 );
161
- canvas_draw_box (canvas , 36 , 10 , 90 , 7 );
157
+ canvas_draw_frame (canvas , 31 , 18 , 21 , 13 );
158
+ canvas_draw_frame (canvas , 55 , 18 , 21 , 13 );
159
+ canvas_draw_frame (canvas , 79 , 18 , 21 , 13 );
160
+ canvas_draw_frame (canvas , 103 , 18 , 21 , 13 );
161
+ canvas_draw_box (canvas , 29 , 10 , 97 , 7 );
162
162
uint8_t mode = ((EthViewDrawStatic * )process -> draw_struct )-> current_mode ;
163
163
uint8_t current_digit = ((EthViewDrawStatic * )process -> draw_struct )-> current_digit ;
164
164
uint8_t * adress = draw_static_get_current_adress ((EthViewDrawStatic * )process -> draw_struct );
165
165
uint8_t editing = ((EthViewDrawStatic * )process -> draw_struct )-> editing ;
166
166
for (uint8_t i = 0 ; i < 4 ; ++ i ) {
167
- if (i == mode ) {
167
+ if (i == mode && process -> editing ) {
168
168
draw_static_mode (canvas , mode );
169
169
} else {
170
170
canvas_invert_color (canvas );
@@ -173,7 +173,7 @@ void ethernet_view_process_draw(EthViewProcess* process, Canvas* canvas) {
173
173
}
174
174
}
175
175
for (uint8_t i = 0 ; i < 4 ; ++ i ) {
176
- uint8_t x = 38 + i * 23 ;
176
+ uint8_t x = 33 + i * 24 ;
177
177
draw_dec_number (canvas , x , 27 , adress [i ]);
178
178
if (editing && (current_digit / 3 == i )) {
179
179
uint8_t x1 = x + 6 * (current_digit % 3 );
@@ -213,7 +213,11 @@ void ethernet_view_process_keyevent(EthViewProcess* process, InputKey key) {
213
213
uint8_t octet = ((EthViewDrawInit * )process -> draw_struct )-> current_octet ;
214
214
uint8_t * mac = ((EthViewDrawInit * )process -> draw_struct )-> mac ;
215
215
if (key == InputKeyLeft ) {
216
- if (octet > 0 ) octet -= 1 ;
216
+ if (octet > 0 ) {
217
+ octet -= 1 ;
218
+ } else {
219
+ process -> editing = 0 ;
220
+ }
217
221
} else if (key == InputKeyRight ) {
218
222
if (octet < 11 ) octet += 1 ;
219
223
} else if (key == InputKeyUp ) {
@@ -231,7 +235,11 @@ void ethernet_view_process_keyevent(EthViewProcess* process, InputKey key) {
231
235
uint8_t editing = ((EthViewDrawStatic * )process -> draw_struct )-> editing ;
232
236
if (editing ) {
233
237
if (key == InputKeyLeft ) {
234
- if (digit > 0 ) digit -= 1 ;
238
+ if (digit > 0 ) {
239
+ digit -= 1 ;
240
+ } else {
241
+ ((EthViewDrawStatic * )process -> draw_struct )-> editing = 0 ;
242
+ }
235
243
} else if (key == InputKeyRight ) {
236
244
if (digit < 11 ) digit += 1 ;
237
245
} else if (key == InputKeyUp ) {
@@ -240,6 +248,9 @@ void ethernet_view_process_keyevent(EthViewProcess* process, InputKey key) {
240
248
adress_change_dec_digit (adress , digit , -1 );
241
249
} else if (key == InputKeyOk ) {
242
250
((EthViewDrawStatic * )process -> draw_struct )-> editing = 0 ;
251
+ } else if (key == InputKeyBack ) {
252
+ mode = 0 ;
253
+ ((EthViewDrawStatic * )process -> draw_struct )-> editing = 0 ;
243
254
}
244
255
} else {
245
256
if (key == InputKeyLeft ) {
@@ -252,12 +263,18 @@ void ethernet_view_process_keyevent(EthViewProcess* process, InputKey key) {
252
263
if (mode < 3 ) {
253
264
mode += 1 ;
254
265
}
255
- } else if (key == InputKeyUp || key == InputKeyDown ) {
266
+ } else if (key == InputKeyDown || key == InputKeyOk ) {
256
267
((EthViewDrawStatic * )process -> draw_struct )-> editing = 1 ;
268
+ } else if (key == InputKeyBack || key == InputKeyUp ) {
269
+ process -> editing = 0 ;
257
270
}
258
271
}
259
272
((EthViewDrawStatic * )process -> draw_struct )-> current_mode = mode ;
260
273
((EthViewDrawStatic * )process -> draw_struct )-> current_digit = digit ;
274
+ } else {
275
+ if (key == InputKeyBack || key == InputKeyLeft ) {
276
+ process -> editing = 0 ;
277
+ }
261
278
}
262
279
}
263
280
0 commit comments