Skip to content

Commit d13d29e

Browse files
committed
Clean up
1 parent fe2a588 commit d13d29e

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

examples/lvglterm/lvglterm.c

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
/* How often to poll for output from NSH Shell (milliseconds) */
6565

66-
#define TIMER_PERIOD 100
66+
#define TIMER_PERIOD_MS 100
6767

6868
/* Read and Write Pipes for NSH stdin, stdout and stderr */
6969

@@ -101,20 +101,20 @@ static int g_nsh_stderr[2];
101101

102102
/* LVGL Column Container for NSH Widgets */
103103

104-
static lv_obj_t *col;
104+
static lv_obj_t *g_col;
105105

106106
/* LVGL Text Area Widgets for NSH Input and Output */
107107

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;
110110

111111
/* LVGL Keyboard Widget for NSH Terminal */
112112

113-
static lv_obj_t *kb;
113+
static lv_obj_t *g_kb;
114114

115115
/* LVGL Font Style for NSH Input and Output */
116116

117-
static lv_style_t terminal_style;
117+
static lv_style_t g_terminal_style;
118118

119119
/* LVGL Timer for polling NSH Output */
120120

@@ -181,7 +181,7 @@ static int create_terminal(void)
181181
/* Create an LVGL Timer to poll for output from NSH Shell */
182182

183183
g_timer = lv_timer_create(timer_callback, /* Callback Function */
184-
TIMER_PERIOD, /* Timer Period (millisec) */
184+
TIMER_PERIOD_MS, /* Timer Period (millisec) */
185185
NULL); /* Callback Argument */
186186
DEBUGASSERT(g_timer != NULL);
187187

@@ -220,8 +220,8 @@ static void timer_callback(lv_timer_t *timer)
220220
buf[ret] = 0;
221221
remove_escape_codes(buf, ret);
222222

223-
DEBUGASSERT(output != NULL);
224-
lv_textarea_add_text(output, buf);
223+
DEBUGASSERT(g_output != NULL);
224+
lv_textarea_add_text(g_output, buf);
225225
}
226226
}
227227

@@ -240,8 +240,8 @@ static void timer_callback(lv_timer_t *timer)
240240
buf[ret] = 0;
241241
remove_escape_codes(buf, ret);
242242

243-
DEBUGASSERT(output != NULL);
244-
lv_textarea_add_text(output, buf);
243+
DEBUGASSERT(g_output != NULL);
244+
lv_textarea_add_text(g_output, buf);
245245
}
246246
}
247247
}
@@ -251,45 +251,45 @@ static int create_widgets(void)
251251
{
252252
/* Set the Font Style for NSH Input and Output to a Monospaced Font */
253253

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);
256256

257257
/* Create an LVGL Container with Column Flex Direction */
258258

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 */
264264

265265
/* Create an LVGL Text Area Widget for NSH Output */
266266

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 */
272272

273273
/* Create an LVGL Text Area Widget for NSH Input */
274274

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);
279279

280280
/* Create an LVGL Keyboard Widget */
281281

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 */
285285

286286
/* Register the Callback Function for NSH Input */
287287

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);
289289

290290
/* Set the Keyboard to populate the NSH Input Text Area */
291291

292-
lv_keyboard_set_textarea(kb, input);
292+
lv_keyboard_set_textarea(g_kb, g_input);
293293

294294
return OK;
295295
}
@@ -309,11 +309,11 @@ static void input_callback(lv_event_t *e)
309309
{
310310
/* Get the Button Index of the Keyboard Button Pressed */
311311

312-
const uint16_t id = lv_keyboard_get_selected_btn(kb);
312+
const uint16_t id = lv_keyboard_get_selected_btn(g_kb);
313313

314314
/* Get the Text of the Keyboard Button */
315315

316-
const char *key = lv_keyboard_get_btn_text(kb, id);
316+
const char *key = lv_keyboard_get_btn_text(g_kb, id);
317317
if (key == NULL)
318318
{
319319
return;
@@ -326,8 +326,8 @@ static void input_callback(lv_event_t *e)
326326
/* Read the NSH Input */
327327

328328
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);
331331
if (cmd == NULL || cmd[0] == 0)
332332
{
333333
return;
@@ -341,7 +341,7 @@ static void input_callback(lv_event_t *e)
341341

342342
/* Erase the NSH Input */
343343

344-
lv_textarea_set_text(input, "");
344+
lv_textarea_set_text(g_input, "");
345345
}
346346
}
347347
}

0 commit comments

Comments
 (0)