From 545d9bf45b3fa34dfee30ee8ec34818b2a8a3886 Mon Sep 17 00:00:00 2001 From: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> Date: Wed, 23 Mar 2022 12:58:54 -0400 Subject: [PATCH] [EFR32] Clean up gn files for QRcode Lib (#16527) * clean up gn files --- examples/light-switch-app/efr32/BUILD.gn | 11 ++++- examples/lighting-app/efr32/BUILD.gn | 12 +++++- examples/lighting-app/efr32/src/AppTask.cpp | 2 + examples/lock-app/efr32/BUILD.gn | 13 ++++-- examples/lock-app/efr32/src/AppTask.cpp | 2 + examples/ota-requestor-app/efr32/BUILD.gn | 11 ++++- .../ota-requestor-app/efr32/src/AppTask.cpp | 2 + examples/platform/efr32/display/lcd.c | 10 +++++ examples/window-app/efr32/BUILD.gn | 16 ++++++-- .../window-app/efr32/src/WindowAppImpl.cpp | 8 +++- third_party/efr32_sdk/efr32_sdk.gni | 40 +++++++++---------- 11 files changed, 92 insertions(+), 35 deletions(-) diff --git a/examples/light-switch-app/efr32/BUILD.gn b/examples/light-switch-app/efr32/BUILD.gn index 412917bba38279..62f164e933a0d3 100644 --- a/examples/light-switch-app/efr32/BUILD.gn +++ b/examples/light-switch-app/efr32/BUILD.gn @@ -66,6 +66,10 @@ declare_args() { if (efr32_board == "BRD4166A" || efr32_board == "BRD4180A") { show_qr_code = false } + +# Enables LCD on supported devices +lcd_on = show_qr_code + if (use_rs911x || use_wf200) { wifi_sdk_dir = "${chip_root}/third_party/efr32_sdk/repo/matter/wifi" if (use_rs911x) { @@ -163,7 +167,6 @@ efr32_executable("light_switch_app") { deps = [ ":sdk", - "${chip_root}/examples/common/QRCode", "${chip_root}/examples/light-switch-app/light-switch-common", "${chip_root}/src/lib", "${chip_root}/src/setup_payload", @@ -218,9 +221,13 @@ efr32_executable("light_switch_app") { include_dirs += wf200_plat_incs } - if (show_qr_code) { + if (lcd_on) { sources += [ "${examples_plat_dir}/display/lcd.c" ] defines += [ "DISPLAY_ENABLED" ] + if (show_qr_code) { + defines += [ "QR_CODE_ENABLED" ] + deps += [ "${chip_root}/examples/common/QRCode" ] + } } if (chip_enable_pw_rpc) { diff --git a/examples/lighting-app/efr32/BUILD.gn b/examples/lighting-app/efr32/BUILD.gn index ab64c2f757c2a4..9543da7df39507 100644 --- a/examples/lighting-app/efr32/BUILD.gn +++ b/examples/lighting-app/efr32/BUILD.gn @@ -66,6 +66,10 @@ declare_args() { if (efr32_board == "BRD4166A" || efr32_board == "BRD4180A") { show_qr_code = false } + +# Enables LCD on supported devices +lcd_on = show_qr_code + if (use_rs911x || use_wf200) { wifi_sdk_dir = "${chip_root}/third_party/efr32_sdk/repo/matter/wifi" if (use_rs911x) { @@ -161,7 +165,6 @@ efr32_executable("lighting_app") { deps = [ ":sdk", - "${chip_root}/examples/common/QRCode", "${chip_root}/examples/lighting-app/lighting-common", "${chip_root}/src/lib", "${chip_root}/src/setup_payload", @@ -216,9 +219,14 @@ efr32_executable("lighting_app") { include_dirs += wf200_plat_incs } - if (show_qr_code) { + if (lcd_on) { sources += [ "${examples_plat_dir}/display/lcd.c" ] defines += [ "DISPLAY_ENABLED" ] + if (show_qr_code) { + defines += [ "QR_CODE_ENABLED" ] + + deps += [ "${chip_root}/examples/common/QRCode" ] + } } if (chip_enable_pw_rpc) { diff --git a/examples/lighting-app/efr32/src/AppTask.cpp b/examples/lighting-app/efr32/src/AppTask.cpp index 1ed50c2a8bb952..21f47ad76072e4 100644 --- a/examples/lighting-app/efr32/src/AppTask.cpp +++ b/examples/lighting-app/efr32/src/AppTask.cpp @@ -21,8 +21,10 @@ #include "AppConfig.h" #include "AppEvent.h" #include "LEDWidget.h" +#ifdef DISPLAY_ENABLED #include "lcd.h" #include "qrcodegen.h" +#endif // DISPLAY_ENABLED #include "sl_simple_led_instances.h" #include #include diff --git a/examples/lock-app/efr32/BUILD.gn b/examples/lock-app/efr32/BUILD.gn index 870737f8047f42..4b28d1732ddcd2 100644 --- a/examples/lock-app/efr32/BUILD.gn +++ b/examples/lock-app/efr32/BUILD.gn @@ -65,6 +65,10 @@ declare_args() { if (efr32_board == "BRD4166A" || efr32_board == "BRD4180A") { show_qr_code = false } + +# Enables LCD on supported devices +lcd_on = show_qr_code + if (use_rs911x || use_wf200) { wifi_sdk_dir = "${chip_root}/third_party/efr32_sdk/repo/matter/wifi" if (use_rs911x) { @@ -160,7 +164,6 @@ efr32_executable("lock_app") { deps = [ ":sdk", - "${chip_root}/examples/common/QRCode", "${chip_root}/examples/lock-app/lock-common", "${chip_root}/src/lib", "${chip_root}/src/setup_payload", @@ -218,10 +221,14 @@ efr32_executable("lock_app") { include_dirs += wf200_plat_incs } - if (show_qr_code) { + if (lcd_on) { sources += [ "${examples_plat_dir}/display/lcd.c" ] - defines += [ "DISPLAY_ENABLED" ] + if (show_qr_code) { + defines += [ "QR_CODE_ENABLED" ] + + deps += [ "${chip_root}/examples/common/QRCode" ] + } } if (chip_enable_pw_rpc) { diff --git a/examples/lock-app/efr32/src/AppTask.cpp b/examples/lock-app/efr32/src/AppTask.cpp index 59a5c7b22c6654..ec4bb10f44a964 100644 --- a/examples/lock-app/efr32/src/AppTask.cpp +++ b/examples/lock-app/efr32/src/AppTask.cpp @@ -21,8 +21,10 @@ #include "AppConfig.h" #include "AppEvent.h" #include "LEDWidget.h" +#ifdef DISPLAY_ENABLED #include "lcd.h" #include "qrcodegen.h" +#endif // DISPLAY_ENABLED #include "sl_simple_led_instances.h" #include #include diff --git a/examples/ota-requestor-app/efr32/BUILD.gn b/examples/ota-requestor-app/efr32/BUILD.gn index 5a860287976351..fe27b4ceaa8e63 100644 --- a/examples/ota-requestor-app/efr32/BUILD.gn +++ b/examples/ota-requestor-app/efr32/BUILD.gn @@ -54,6 +54,9 @@ if (efr32_board == "BRD4166A" || efr32_board == "BRD4180A") { show_qr_code = false } +# Enables LCD on supported devices +lcd_on = show_qr_code + efr32_sdk("sdk") { sources = [ "${efr32_project_dir}/include/CHIPProjectConfig.h", @@ -102,7 +105,6 @@ efr32_executable("ota_requestor_app") { deps = [ ":sdk", - "${chip_root}/examples/common/QRCode", "${chip_root}/examples/ota-requestor-app/ota-requestor-common", "${chip_root}/src/lib", "${chip_root}/src/setup_payload", @@ -123,9 +125,14 @@ efr32_executable("ota_requestor_app") { ] } - if (show_qr_code) { + if (lcd_on) { sources += [ "${examples_plat_dir}/display/lcd.c" ] defines += [ "DISPLAY_ENABLED" ] + if (show_qr_code) { + defines += [ "QR_CODE_ENABLED" ] + + deps += [ "${chip_root}/examples/common/QRCode" ] + } } if (chip_enable_pw_rpc) { diff --git a/examples/ota-requestor-app/efr32/src/AppTask.cpp b/examples/ota-requestor-app/efr32/src/AppTask.cpp index 95d2e9f36ca41c..f2a37c63ccce0d 100644 --- a/examples/ota-requestor-app/efr32/src/AppTask.cpp +++ b/examples/ota-requestor-app/efr32/src/AppTask.cpp @@ -21,8 +21,10 @@ #include "AppConfig.h" #include "AppEvent.h" #include "LEDWidget.h" +#ifdef DISPLAY_ENABLED #include "lcd.h" #include "qrcodegen.h" +#endif // DISPLAY_ENABLED #include "sl_simple_led_instances.h" #include #include diff --git a/examples/platform/efr32/display/lcd.c b/examples/platform/efr32/display/lcd.c index 04cdd6fa6f4e34..a62f89c8ba25ab 100644 --- a/examples/platform/efr32/display/lcd.c +++ b/examples/platform/efr32/display/lcd.c @@ -23,7 +23,11 @@ #include "dmd.h" #include "glib.h" + +#ifdef QR_CODE_ENABLED #include "qrcodegen.h" +#endif // QR_CODE_ENABLED + #include "sl_board_control.h" #define LCD_SIZE 128 @@ -32,10 +36,14 @@ #define QR_CODE_BORDER_SIZE 0 static GLIB_Context_t glibContext; +#ifdef QR_CODE_ENABLED static uint8_t qrCode[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_CODE_VERSION)]; static uint8_t workBuffer[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_CODE_VERSION)]; +#endif // QR_CODE_ENABLED +#ifdef QR_CODE_ENABLED static void LCDFillRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h); +#endif // QR_CODE_ENABLED void initLCD(void) { @@ -92,6 +100,7 @@ int LCD_update(void) return DMD_updateDisplay(); } +#ifdef QR_CODE_ENABLED void LCDWriteQRCode(uint8_t * str) { if (!qrcodegen_encodeText((const char *) str, workBuffer, qrCode, qrcodegen_Ecc_LOW, QR_CODE_VERSION, QR_CODE_VERSION, @@ -134,3 +143,4 @@ void LCDFillRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h) } } } +#endif // QR_CODE_ENABLED diff --git a/examples/window-app/efr32/BUILD.gn b/examples/window-app/efr32/BUILD.gn index 6b1b894c73a0ba..7d6e4961e71a9b 100644 --- a/examples/window-app/efr32/BUILD.gn +++ b/examples/window-app/efr32/BUILD.gn @@ -51,14 +51,19 @@ declare_args() { sl_wfx_config_softap = false sl_wfx_config_scan = true - # Enables LCD Qr Code on supported devices + # Enables Qr Code on supported devices show_qr_code = true } +# Enables LCD on supported devices +lcd_on = true + # BRD4166A --> ThunderBoard Sense 2 (No LCD) if (efr32_board == "BRD4166A" || efr32_board == "BRD4180A") { show_qr_code = false + lcd_on = false } + if (use_rs911x || use_wf200) { wifi_sdk_dir = "${chip_root}/third_party/efr32_sdk/repo/matter/wifi" if (use_rs911x) { @@ -180,7 +185,6 @@ efr32_executable("window_app") { } deps = [ ":sdk", - "${chip_root}/examples/common/QRCode", "${chip_root}/examples/window-app/common:window-common", "${chip_root}/src/lib", "${chip_root}/src/setup_payload", @@ -205,13 +209,17 @@ efr32_executable("window_app") { } } - if (show_qr_code) { + if (lcd_on) { sources += [ "${examples_plat_dir}/display/lcd.c", "src/LcdPainter.cpp", ] - defines += [ "DISPLAY_ENABLED" ] + + if (show_qr_code) { + deps += [ "${chip_root}/examples/common/QRCode" ] + defines += [ "QR_CODE_ENABLED" ] + } } if (enable_heap_monitoring) { diff --git a/examples/window-app/efr32/src/WindowAppImpl.cpp b/examples/window-app/efr32/src/WindowAppImpl.cpp index 3f2e08bf81aedc..0e754efb9cae3f 100644 --- a/examples/window-app/efr32/src/WindowAppImpl.cpp +++ b/examples/window-app/efr32/src/WindowAppImpl.cpp @@ -26,7 +26,9 @@ #include #include #include +#ifdef QR_CODE_ENABLED #include +#endif // QR_CODE_ENABLED #include #include #include @@ -413,7 +415,7 @@ void WindowAppImpl::UpdateLCD() if (mState.isThreadProvisioned) #else if (mState.isWiFiProvisioned) -#endif +#endif // CHIP_ENABLE_OPENTHREAD { Cover & cover = GetCover(); chip::app::DataModel::Nullable lift; @@ -431,6 +433,7 @@ void WindowAppImpl::UpdateLCD() LcdPainter::Paint(type, static_cast(lift.Value()), static_cast(tilt.Value()), mIcon); } } +#ifdef QR_CODE_ENABLED else { if (GetQRCode(mQRCode, chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)) == CHIP_NO_ERROR) @@ -438,7 +441,8 @@ void WindowAppImpl::UpdateLCD() LCDWriteQRCode((uint8_t *) mQRCode.c_str()); } } -#endif +#endif // QR_CODE_ENABLED +#endif // DISPLAY_ENABLED } void WindowAppImpl::OnMainLoop() diff --git a/third_party/efr32_sdk/efr32_sdk.gni b/third_party/efr32_sdk/efr32_sdk.gni index 92bb1d824e7796..5af0f01991c1da 100644 --- a/third_party/efr32_sdk/efr32_sdk.gni +++ b/third_party/efr32_sdk/efr32_sdk.gni @@ -175,7 +175,8 @@ template("efr32_sdk") { # USART include files if ((defined(invoker.chip_enable_pw_rpc) && invoker.chip_enable_pw_rpc) || chip_build_libshell || enable_openthread_cli || - (defined(invoker.show_qr_code) && invoker.show_qr_code)) { + (defined(invoker.show_qr_code) && invoker.show_qr_code) || + (defined(invoker.lcd_on) && invoker.lcd_on)) { defines += [ "CONFIG_ENABLE_UART" ] _include_dirs += [ @@ -505,25 +506,24 @@ template("efr32_sdk") { } } - if (defined(invoker.show_qr_code)) { - if (invoker.show_qr_code) { - sources += [ - "${efr32_sdk_root}/hardware/driver/memlcd/src/sl_memlcd.c", - "${efr32_sdk_root}/hardware/driver/memlcd/src/sl_memlcd_display.c", - "${efr32_sdk_root}/platform/middleware/glib/dmd/display/dmd_memlcd.c", - "${efr32_sdk_root}/platform/middleware/glib/glib/bmp.c", - "${efr32_sdk_root}/platform/middleware/glib/glib/glib.c", - "${efr32_sdk_root}/platform/middleware/glib/glib/glib_bitmap.c", - "${efr32_sdk_root}/platform/middleware/glib/glib/glib_circle.c", - "${efr32_sdk_root}/platform/middleware/glib/glib/glib_font_narrow_6x8.c", - "${efr32_sdk_root}/platform/middleware/glib/glib/glib_font_normal_8x8.c", - "${efr32_sdk_root}/platform/middleware/glib/glib/glib_font_number_16x20.c", - "${efr32_sdk_root}/platform/middleware/glib/glib/glib_line.c", - "${efr32_sdk_root}/platform/middleware/glib/glib/glib_polygon.c", - "${efr32_sdk_root}/platform/middleware/glib/glib/glib_rectangle.c", - "${efr32_sdk_root}/platform/middleware/glib/glib/glib_string.c", - ] - } + if ((defined(invoker.show_qr_code) && invoker.show_qr_code) || + (defined(invoker.lcd_on) && invoker.lcd_on)) { + sources += [ + "${efr32_sdk_root}/hardware/driver/memlcd/src/sl_memlcd.c", + "${efr32_sdk_root}/hardware/driver/memlcd/src/sl_memlcd_display.c", + "${efr32_sdk_root}/platform/middleware/glib/dmd/display/dmd_memlcd.c", + "${efr32_sdk_root}/platform/middleware/glib/glib/bmp.c", + "${efr32_sdk_root}/platform/middleware/glib/glib/glib.c", + "${efr32_sdk_root}/platform/middleware/glib/glib/glib_bitmap.c", + "${efr32_sdk_root}/platform/middleware/glib/glib/glib_circle.c", + "${efr32_sdk_root}/platform/middleware/glib/glib/glib_font_narrow_6x8.c", + "${efr32_sdk_root}/platform/middleware/glib/glib/glib_font_normal_8x8.c", + "${efr32_sdk_root}/platform/middleware/glib/glib/glib_font_number_16x20.c", + "${efr32_sdk_root}/platform/middleware/glib/glib/glib_line.c", + "${efr32_sdk_root}/platform/middleware/glib/glib/glib_polygon.c", + "${efr32_sdk_root}/platform/middleware/glib/glib/glib_rectangle.c", + "${efr32_sdk_root}/platform/middleware/glib/glib/glib_string.c", + ] } if (use_wf200) { sources += [