Skip to content

Commit 9372de5

Browse files
committed
examples/calculator: Add an LVGL touchscreen calculator.
Add a calculator example that can run as either a built-in application or loadable module. It uses configurable framebuffer and touchscreen paths, reserves the nxstore supervisor bar, and exits cooperatively on SIGTERM. Validate display, touchscreen, and signal-handler setup before entering the LVGL loop. Reset static state on every invocation so built-in relaunches behave like fresh module loads. Assisted-by: OpenAI Codex:gpt-5.6-sol Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
1 parent 79daf2c commit 9372de5

5 files changed

Lines changed: 647 additions & 0 deletions

File tree

examples/calculator/CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# ##############################################################################
2+
# apps/examples/calculator/CMakeLists.txt
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
7+
# license agreements. See the NOTICE file distributed with this work for
8+
# additional information regarding copyright ownership. The ASF licenses this
9+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
10+
# use this file except in compliance with the License. You may obtain a copy of
11+
# the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations under
19+
# the License.
20+
#
21+
# ##############################################################################
22+
23+
if(CONFIG_EXAMPLES_CALCULATOR)
24+
nuttx_add_application(
25+
NAME
26+
calc
27+
PRIORITY
28+
${CONFIG_EXAMPLES_CALCULATOR_PRIORITY}
29+
STACKSIZE
30+
${CONFIG_EXAMPLES_CALCULATOR_STACKSIZE}
31+
MODULE
32+
${CONFIG_EXAMPLES_CALCULATOR}
33+
DEPENDS
34+
lvgl
35+
SRCS
36+
calculator_main.c)
37+
endif()

examples/calculator/Kconfig

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
menuconfig EXAMPLES_CALCULATOR
7+
tristate "Calculator"
8+
default n
9+
depends on GRAPHICS_LVGL && INPUT_TOUCHSCREEN
10+
---help---
11+
Enable the simple LVGL touchscreen calculator example.
12+
13+
if EXAMPLES_CALCULATOR
14+
15+
config EXAMPLES_CALCULATOR_PRIORITY
16+
int "calculator task priority"
17+
default 100
18+
19+
config EXAMPLES_CALCULATOR_STACKSIZE
20+
int "calculator stack size"
21+
default 16384
22+
23+
config EXAMPLES_CALCULATOR_INPUT_DEVPATH
24+
string "Touchscreen device path"
25+
default "/dev/input0"
26+
---help---
27+
The path to the touchscreen device. Default: "/dev/input0"
28+
29+
config EXAMPLES_CALCULATOR_FBDEVPATH
30+
string "Framebuffer device path"
31+
default "/dev/fb0"
32+
---help---
33+
The path to the framebuffer device. Default: "/dev/fb0"
34+
35+
endif # EXAMPLES_CALCULATOR

examples/calculator/Make.defs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
############################################################################
2+
# apps/examples/calculator/Make.defs
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
ifneq ($(CONFIG_EXAMPLES_CALCULATOR),)
24+
CONFIGURED_APPS += $(APPDIR)/examples/calculator
25+
endif

examples/calculator/Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
############################################################################
2+
# apps/examples/calculator/Makefile
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
include $(APPDIR)/Make.defs
24+
25+
PROGNAME = calc
26+
PRIORITY = $(CONFIG_EXAMPLES_CALCULATOR_PRIORITY)
27+
STACKSIZE = $(CONFIG_EXAMPLES_CALCULATOR_STACKSIZE)
28+
MODULE = $(CONFIG_EXAMPLES_CALCULATOR)
29+
30+
MAINSRC = calculator_main.c
31+
32+
include $(APPDIR)/Application.mk

0 commit comments

Comments
 (0)