Skip to content

Commit

Permalink
Add a sample UI for linux apps - lighting app (#24979)
Browse files Browse the repository at this point in the history
* Initial version of a imgui UI in light app for linux.

Also fixed linux app shutdown to handle signals
by loop terminating instead of app killing.

* remove some fixme comments

* Fix unit tests ... with-ui variant was added

* Restyle

* Update text and remove some commented out code

* Restyle

---------

Co-authored-by: Andrei Litvin <andreilitvin@google.com>
  • Loading branch information
2 people authored and pull[bot] committed Jul 7, 2023
1 parent 7b714ff commit 1760562
Show file tree
Hide file tree
Showing 13 changed files with 532 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,7 @@
path = third_party/libwebsockets/repo
url = https://github.com/warmcat/libwebsockets
platforms = linux,darwin,tizen
[submodule "third_party/imgui/repo"]
path = third_party/imgui/repo
url = https://github.com/ocornut/imgui
platforms = linux
5 changes: 4 additions & 1 deletion examples/common/QRCode/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ config("qrcode-common_config") {
static_library("QRCode") {
output_name = "libqrcode-common"

sources = [ "repo/c/qrcodegen.c" ]
sources = [
"repo/c/qrcodegen.c",
"repo/c/qrcodegen.h",
]

public_configs = [ ":qrcode-common_config" ]

Expand Down
13 changes: 13 additions & 0 deletions examples/lighting-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import("//build_overrides/chip.gni")

import("${chip_root}/build/chip/tools.gni")
import("${chip_root}/src/app/common_flags.gni")
import("${chip_root}/third_party/imgui/imgui.gni")

assert(chip_build_tools)

Expand Down Expand Up @@ -46,6 +47,18 @@ executable("chip-lighting-app") {
"${chip_root}/src/lib",
]

if (chip_examples_enable_imgui_ui) {
deps += [
"${chip_root}/examples/common/QRCode",
"${chip_root}/third_party/imgui",
]

sources += [
"ui.cpp",
"ui.h",
]
}

include_dirs = [ "include" ]

if (chip_enable_pw_rpc) {
Expand Down
13 changes: 13 additions & 0 deletions examples/lighting-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#include <lib/support/logging/CHIPLogging.h>
#include <platform/Linux/NetworkCommissioningDriver.h>

#if defined(CHIP_IMGUI_ENABLED) && CHIP_IMGUI_ENABLED
#include "ui.h"
#endif

using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
Expand Down Expand Up @@ -81,7 +85,16 @@ int main(int argc, char * argv[])
}

LightingMgr().Init();

#if defined(CHIP_IMGUI_ENABLED) && CHIP_IMGUI_ENABLED
example::Ui::Start();
#endif

ChipLinuxAppMainLoop();

#if defined(CHIP_IMGUI_ENABLED) && CHIP_IMGUI_ENABLED
example::Ui::Stop();
#endif

return 0;
}
Loading

0 comments on commit 1760562

Please sign in to comment.