63
63
64
64
/* How often to poll for output from NSH Shell (milliseconds) */
65
65
66
- #define TIMER_PERIOD 100
66
+ #define TIMER_PERIOD_MS 100
67
67
68
68
/* Read and Write Pipes for NSH stdin, stdout and stderr */
69
69
@@ -101,20 +101,20 @@ static int g_nsh_stderr[2];
101
101
102
102
/* LVGL Column Container for NSH Widgets */
103
103
104
- static lv_obj_t * col ;
104
+ static lv_obj_t * g_col ;
105
105
106
106
/* LVGL Text Area Widgets for NSH Input and Output */
107
107
108
- static lv_obj_t * input ;
109
- static lv_obj_t * output ;
108
+ static lv_obj_t * g_input ;
109
+ static lv_obj_t * g_output ;
110
110
111
111
/* LVGL Keyboard Widget for NSH Terminal */
112
112
113
- static lv_obj_t * kb ;
113
+ static lv_obj_t * g_kb ;
114
114
115
115
/* LVGL Font Style for NSH Input and Output */
116
116
117
- static lv_style_t terminal_style ;
117
+ static lv_style_t g_terminal_style ;
118
118
119
119
/* LVGL Timer for polling NSH Output */
120
120
@@ -181,7 +181,7 @@ static int create_terminal(void)
181
181
/* Create an LVGL Timer to poll for output from NSH Shell */
182
182
183
183
g_timer = lv_timer_create (timer_callback , /* Callback Function */
184
- TIMER_PERIOD , /* Timer Period (millisec) */
184
+ TIMER_PERIOD_MS , /* Timer Period (millisec) */
185
185
NULL ); /* Callback Argument */
186
186
DEBUGASSERT (g_timer != NULL );
187
187
@@ -220,8 +220,8 @@ static void timer_callback(lv_timer_t *timer)
220
220
buf [ret ] = 0 ;
221
221
remove_escape_codes (buf , ret );
222
222
223
- DEBUGASSERT (output != NULL );
224
- lv_textarea_add_text (output , buf );
223
+ DEBUGASSERT (g_output != NULL );
224
+ lv_textarea_add_text (g_output , buf );
225
225
}
226
226
}
227
227
@@ -240,8 +240,8 @@ static void timer_callback(lv_timer_t *timer)
240
240
buf [ret ] = 0 ;
241
241
remove_escape_codes (buf , ret );
242
242
243
- DEBUGASSERT (output != NULL );
244
- lv_textarea_add_text (output , buf );
243
+ DEBUGASSERT (g_output != NULL );
244
+ lv_textarea_add_text (g_output , buf );
245
245
}
246
246
}
247
247
}
@@ -251,45 +251,45 @@ static int create_widgets(void)
251
251
{
252
252
/* Set the Font Style for NSH Input and Output to a Monospaced Font */
253
253
254
- lv_style_init (& terminal_style );
255
- lv_style_set_text_font (& terminal_style , & lv_font_unscii_16 );
254
+ lv_style_init (& g_terminal_style );
255
+ lv_style_set_text_font (& g_terminal_style , & lv_font_unscii_16 );
256
256
257
257
/* Create an LVGL Container with Column Flex Direction */
258
258
259
- col = lv_obj_create (lv_scr_act ());
260
- DEBUGASSERT (col != NULL );
261
- lv_obj_set_size (col , LV_PCT (100 ), LV_PCT (100 ));
262
- lv_obj_set_flex_flow (col , LV_FLEX_FLOW_COLUMN );
263
- lv_obj_set_style_pad_all (col , 0 , 0 ); /* No padding */
259
+ g_col = lv_obj_create (lv_scr_act ());
260
+ DEBUGASSERT (g_col != NULL );
261
+ lv_obj_set_size (g_col , LV_PCT (100 ), LV_PCT (100 ));
262
+ lv_obj_set_flex_flow (g_col , LV_FLEX_FLOW_COLUMN );
263
+ lv_obj_set_style_pad_all (g_col , 0 , 0 ); /* No padding */
264
264
265
265
/* Create an LVGL Text Area Widget for NSH Output */
266
266
267
- output = lv_textarea_create (col );
268
- DEBUGASSERT (output != NULL );
269
- lv_obj_add_style (output , & terminal_style , 0 );
270
- lv_obj_set_width (output , LV_PCT (100 ));
271
- lv_obj_set_flex_grow (output , 1 ); /* Fill the column */
267
+ g_output = lv_textarea_create (g_col );
268
+ DEBUGASSERT (g_output != NULL );
269
+ lv_obj_add_style (g_output , & g_terminal_style , 0 );
270
+ lv_obj_set_width (g_output , LV_PCT (100 ));
271
+ lv_obj_set_flex_grow (g_output , 1 ); /* Fill the column */
272
272
273
273
/* Create an LVGL Text Area Widget for NSH Input */
274
274
275
- input = lv_textarea_create (col );
276
- DEBUGASSERT (input != NULL );
277
- lv_obj_add_style (input , & terminal_style , 0 );
278
- lv_obj_set_size (input , LV_PCT (100 ), LV_SIZE_CONTENT );
275
+ g_input = lv_textarea_create (g_col );
276
+ DEBUGASSERT (g_input != NULL );
277
+ lv_obj_add_style (g_input , & g_terminal_style , 0 );
278
+ lv_obj_set_size (g_input , LV_PCT (100 ), LV_SIZE_CONTENT );
279
279
280
280
/* Create an LVGL Keyboard Widget */
281
281
282
- kb = lv_keyboard_create (col );
283
- DEBUGASSERT (kb != NULL );
284
- lv_obj_set_style_pad_all (kb , 0 , 0 ); /* No padding */
282
+ g_kb = lv_keyboard_create (g_col );
283
+ DEBUGASSERT (g_kb != NULL );
284
+ lv_obj_set_style_pad_all (g_kb , 0 , 0 ); /* No padding */
285
285
286
286
/* Register the Callback Function for NSH Input */
287
287
288
- lv_obj_add_event_cb (input , input_callback , LV_EVENT_ALL , NULL );
288
+ lv_obj_add_event_cb (g_input , input_callback , LV_EVENT_ALL , NULL );
289
289
290
290
/* Set the Keyboard to populate the NSH Input Text Area */
291
291
292
- lv_keyboard_set_textarea (kb , input );
292
+ lv_keyboard_set_textarea (g_kb , g_input );
293
293
294
294
return OK ;
295
295
}
@@ -309,11 +309,11 @@ static void input_callback(lv_event_t *e)
309
309
{
310
310
/* Get the Button Index of the Keyboard Button Pressed */
311
311
312
- const uint16_t id = lv_keyboard_get_selected_btn (kb );
312
+ const uint16_t id = lv_keyboard_get_selected_btn (g_kb );
313
313
314
314
/* Get the Text of the Keyboard Button */
315
315
316
- const char * key = lv_keyboard_get_btn_text (kb , id );
316
+ const char * key = lv_keyboard_get_btn_text (g_kb , id );
317
317
if (key == NULL )
318
318
{
319
319
return ;
@@ -326,8 +326,8 @@ static void input_callback(lv_event_t *e)
326
326
/* Read the NSH Input */
327
327
328
328
const char * cmd ;
329
- DEBUGASSERT (input != NULL );
330
- cmd = lv_textarea_get_text (input );
329
+ DEBUGASSERT (g_input != NULL );
330
+ cmd = lv_textarea_get_text (g_input );
331
331
if (cmd == NULL || cmd [0 ] == 0 )
332
332
{
333
333
return ;
@@ -341,7 +341,7 @@ static void input_callback(lv_event_t *e)
341
341
342
342
/* Erase the NSH Input */
343
343
344
- lv_textarea_set_text (input , "" );
344
+ lv_textarea_set_text (g_input , "" );
345
345
}
346
346
}
347
347
}
0 commit comments