Skip to content

Commit 158724f

Browse files
committed
examples/calculator: use final board setup
Initialize the board through the current final-setup interface. Assisted-by: OpenAI Codex:gpt-5.6-sol Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
1 parent 30c0eb7 commit 158724f

1 file changed

Lines changed: 6 additions & 35 deletions

File tree

examples/calculator/calculator_main.c

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,13 @@
3636

3737
#include <system/nxstore_chrome.h>
3838

39-
/****************************************************************************
40-
* Pre-processor Definitions
41-
****************************************************************************/
42-
43-
#undef NEED_BOARDINIT
44-
45-
#if defined(CONFIG_BOARDCTL) && !defined(CONFIG_NSH_ARCHINIT)
46-
# define NEED_BOARDINIT 1
47-
#endif
48-
4939
#define CALC_DISPLAY_MAX 16
5040

5141
/****************************************************************************
5242
* Private Data
5343
****************************************************************************/
5444

55-
/* Set only by quit_signal_handler(), an async-signal-safe flag - the
56-
* actual shutdown happens from the main loop, a known-safe point,
57-
* rather than from the handler itself. See games/NXDoom's
58-
* i_install_quit_signal()/i_poll_quit_signal() for the same pattern:
59-
* an external supervisor (nxstore) has no in-app quit path to drive,
60-
* so it can only ask this process to exit from the outside via
61-
* SIGTERM.
62-
*/
45+
/* Polled by the main loop for cooperative shutdown. */
6346

6447
static volatile sig_atomic_t g_quit_requested;
6548

@@ -79,15 +62,7 @@ static void quit_signal_handler(int signo)
7962
g_quit_requested = 1;
8063
}
8164

82-
/* nxstore's own "Close" bar is confined to the top 36px of the display
83-
* so it can coexist with full-screen children like this one - a
84-
* convention that only works if the child app leaves that strip alone.
85-
* This app's display/keypad fill the entire canvas, so nxstore's bar
86-
* gets overdrawn as soon as this screen loads. Give the calculator its
87-
* own close affordance instead: tapping it just sets the same quit flag
88-
* SIGTERM does, so nxstore's nxstore_poll_running_app() sees the process
89-
* exit on its own and returns to the app list automatically.
90-
*/
65+
/* Let standalone launches exit without an external SIGTERM. */
9166

9267
static void close_event_cb(lv_event_t *e)
9368
{
@@ -162,9 +137,7 @@ static void calc_handle_digit(char digit)
162137
len = strlen(g_display_buf);
163138
if (len + 1 >= sizeof(g_display_buf))
164139
{
165-
/* Display is already at capacity - drop the keypress rather than
166-
* overflow g_display_buf or silently truncate mid-number.
167-
*/
140+
/* Ignore digits that do not fit. */
168141

169142
return;
170143
}
@@ -370,8 +343,8 @@ int main(int argc, FAR char *argv[])
370343
return -1;
371344
}
372345

373-
#ifdef NEED_BOARDINIT
374-
boardctl(BOARDIOC_INIT, 0);
346+
#ifdef CONFIG_BOARDCTL_FINALINIT
347+
boardctl(BOARDIOC_FINALINIT, 0);
375348
#endif
376349

377350
lv_init();
@@ -464,9 +437,7 @@ int main(int argc, FAR char *argv[])
464437

465438
if (row == 4)
466439
{
467-
/* Single wide "=" button spans the whole row - only
468-
* instantiate it once, on the first column.
469-
*/
440+
/* Create the full-width button once. */
470441

471442
if (col > 0)
472443
{

0 commit comments

Comments
 (0)