Skip to content

Commit

Permalink
[EFR32] Clean up gn files for QRcode Lib (#16527)
Browse files Browse the repository at this point in the history
* clean up gn files
  • Loading branch information
mkardous-silabs authored Mar 23, 2022
1 parent a8dcee4 commit 545d9bf
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 35 deletions.
11 changes: 9 additions & 2 deletions examples/light-switch-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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) {
Expand Down
12 changes: 10 additions & 2 deletions examples/lighting-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions examples/lighting-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
Expand Down
13 changes: 10 additions & 3 deletions examples/lock-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions examples/lock-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
Expand Down
11 changes: 9 additions & 2 deletions examples/ota-requestor-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions examples/ota-requestor-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
Expand Down
10 changes: 10 additions & 0 deletions examples/platform/efr32/display/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -134,3 +143,4 @@ void LCDFillRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h)
}
}
}
#endif // QR_CODE_ENABLED
16 changes: 12 additions & 4 deletions examples/window-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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",
Expand All @@ -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) {
Expand Down
8 changes: 6 additions & 2 deletions examples/window-app/efr32/src/WindowAppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
#include <lib/dnssd/Advertiser.h>
#include <lib/support/CodeUtils.h>
#include <platform/CHIPDeviceLayer.h>
#ifdef QR_CODE_ENABLED
#include <qrcodegen.h>
#endif // QR_CODE_ENABLED
#include <sl_simple_button_instances.h>
#include <sl_simple_led_instances.h>
#include <sl_system_kernel.h>
Expand Down Expand Up @@ -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<uint16_t> lift;
Expand All @@ -431,14 +433,16 @@ void WindowAppImpl::UpdateLCD()
LcdPainter::Paint(type, static_cast<uint8_t>(lift.Value()), static_cast<uint8_t>(tilt.Value()), mIcon);
}
}
#ifdef QR_CODE_ENABLED
else
{
if (GetQRCode(mQRCode, chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)) == CHIP_NO_ERROR)
{
LCDWriteQRCode((uint8_t *) mQRCode.c_str());
}
}
#endif
#endif // QR_CODE_ENABLED
#endif // DISPLAY_ENABLED
}

void WindowAppImpl::OnMainLoop()
Expand Down
40 changes: 20 additions & 20 deletions third_party/efr32_sdk/efr32_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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 += [
Expand Down Expand Up @@ -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 += [
Expand Down

0 comments on commit 545d9bf

Please sign in to comment.