Skip to content

Commit

Permalink
[EFR32] Upgrade LCD (project-chip#22016)
Browse files Browse the repository at this point in the history
* Upgrade LCD EFR32

* fix CI
  • Loading branch information
jepenven-silabs authored and isiu-apple committed Sep 16, 2022
1 parent 4ccb40f commit 74a17d5
Show file tree
Hide file tree
Showing 21 changed files with 877 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples-efr32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
- name: Build example EFR32 Lighting App for BRD4161A with RPCs
timeout-minutes: 15
run: |
scripts/examples/gn_efr32_example.sh examples/lighting-app/efr32/ out/lighting_app_debug_rpc BRD4161A \
scripts/examples/gn_efr32_example.sh examples/lighting-app/efr32/ out/lighting_app_debug_rpc BRD4161A "is_debug=false" \
'import("//with_pw_rpc.gni")'
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py efr32 BRD4161A+rpc lighting-app \
out/lighting_app_debug_rpc/BRD4161A/chip-efr32-lighting-example.out /tmp/bloat_reports/
Expand Down
6 changes: 5 additions & 1 deletion examples/chef/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,11 @@ efr32_executable("chef_app") {
}

if (!disable_lcd) {
sources += [ "${examples_plat_dir}/display/lcd.c" ]
sources += [
"${examples_plat_dir}/display/demo-ui.c",
"${examples_plat_dir}/display/lcd.cpp",
]
include_dirs += [ "${examples_plat_dir}/display" ]
defines += [ "DISPLAY_ENABLED" ]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]
Expand Down
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 @@ -253,8 +253,15 @@ efr32_executable("light_switch_app") {
}

if (!disable_lcd) {
sources += [ "${examples_plat_dir}/display/lcd.c" ]
defines += [ "DISPLAY_ENABLED" ]
sources += [
"${examples_plat_dir}/display/demo-ui.c",
"${examples_plat_dir}/display/lcd.cpp",
]
include_dirs += [ "${examples_plat_dir}/display" ]
defines += [
"DISPLAY_ENABLED",
"IS_DEMO_SWITCH=1",
]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]
deps += [ "${chip_root}/examples/common/QRCode" ]
Expand Down
21 changes: 20 additions & 1 deletion examples/light-switch-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ namespace {

EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT;

bool mCurrentButtonState = false;

/**********************************************************
* Identify Callbacks
*********************************************************/
Expand Down Expand Up @@ -146,6 +148,9 @@ AppTask AppTask::sAppTask;
CHIP_ERROR AppTask::Init()
{
CHIP_ERROR err = CHIP_NO_ERROR;
#ifdef DISPLAY_ENABLED
GetLCD().Init((uint8_t *) "Light Switch");
#endif

err = BaseApplication::Init(&gIdentify);
if (err != CHIP_NO_ERROR)
Expand Down Expand Up @@ -221,9 +226,23 @@ void AppTask::SwitchActionEventHandler(AppEvent * aEvent)
if (aEvent->Type == AppEvent::kEventType_Button)
{
BindingCommandData * data = Platform::New<BindingCommandData>();
data->commandId = chip::app::Clusters::OnOff::Commands::Toggle::Id;
data->clusterId = chip::app::Clusters::OnOff::Id;

if (mCurrentButtonState)
{
mCurrentButtonState = false;
data->commandId = chip::app::Clusters::OnOff::Commands::Off::Id;
}
else
{
data->commandId = chip::app::Clusters::OnOff::Commands::On::Id;
mCurrentButtonState = true;
}

#ifdef DISPLAY_ENABLED
sAppTask.GetLCD().WriteDemoUI(mCurrentButtonState);
#endif

DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast<intptr_t>(data));
}
}
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 @@ -253,8 +253,16 @@ efr32_executable("lighting_app") {
}

if (!disable_lcd) {
sources += [ "${examples_plat_dir}/display/lcd.c" ]
defines += [ "DISPLAY_ENABLED" ]
sources += [
"${examples_plat_dir}/display/demo-ui.c",
"${examples_plat_dir}/display/lcd.cpp",
]

include_dirs += [ "${examples_plat_dir}/display" ]
defines += [
"DISPLAY_ENABLED",
"IS_DEMO_LIGHT=1",
]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]

Expand Down
27 changes: 11 additions & 16 deletions examples/lighting-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@
#include "AppConfig.h"
#include "AppEvent.h"
#include "LEDWidget.h"
#ifdef DISPLAY_ENABLED
#include "lcd.h"
#ifdef QR_CODE_ENABLED
#include "qrcodegen.h"
#endif // QR_CODE_ENABLED
#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 Expand Up @@ -132,6 +127,9 @@ AppTask AppTask::sAppTask;
CHIP_ERROR AppTask::Init()
{
CHIP_ERROR err = CHIP_NO_ERROR;
#ifdef DISPLAY_ENABLED
GetLCD().Init((uint8_t *) "Lighting-App");
#endif

err = BaseApplication::Init(&gIdentify);
if (err != CHIP_NO_ERROR)
Expand Down Expand Up @@ -266,16 +264,13 @@ void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAc
void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor)
{
// Action initiated, update the light led
if (aAction == LightingManager::ON_ACTION)
{
EFR32_LOG("Turning light ON")
sLightLED.Set(true);
}
else if (aAction == LightingManager::OFF_ACTION)
{
EFR32_LOG("Turning light OFF")
sLightLED.Set(false);
}
bool lightOn = aAction == LightingManager::ON_ACTION;
EFR32_LOG("Turning light %s", (lightOn) ? "On" : "Off")
sLightLED.Set(lightOn);

#ifdef DISPLAY_ENABLED
sAppTask.GetLCD().WriteDemoUI(lightOn);
#endif

if (aActor == AppEvent::kEventType_Button)
{
Expand Down
11 changes: 9 additions & 2 deletions examples/lock-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,15 @@ efr32_executable("lock_app") {
}

if (!disable_lcd) {
sources += [ "${examples_plat_dir}/display/lcd.c" ]
defines += [ "DISPLAY_ENABLED" ]
sources += [
"${examples_plat_dir}/display/demo-ui.c",
"${examples_plat_dir}/display/lcd.cpp",
]
include_dirs += [ "${examples_plat_dir}/display" ]
defines += [
"DISPLAY_ENABLED",
"IS_DEMO_LOCK=1",
]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]
deps += [ "${chip_root}/examples/common/QRCode" ]
Expand Down
20 changes: 11 additions & 9 deletions examples/lock-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ CHIP_ERROR AppTask::Init()
{
CHIP_ERROR err = CHIP_NO_ERROR;

#ifdef DISPLAY_ENABLED
GetLCD().Init((uint8_t *) "Lock-App", true);
#endif

err = BaseApplication::Init(&gIdentify);
if (err != CHIP_NO_ERROR)
{
Expand Down Expand Up @@ -354,16 +358,14 @@ void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAc

void AppTask::ActionInitiated(LockManager::Action_t aAction, int32_t aActor)
{
// Action initiated, update the light led
if (aAction == LockManager::LOCK_ACTION)
if (aAction == LockManager::UNLOCK_ACTION || aAction == LockManager::LOCK_ACTION)
{
EFR32_LOG("Lock Action has been initiated")
sLockLED.Set(false);
}
else if (aAction == LockManager::UNLOCK_ACTION)
{
EFR32_LOG("Unlock Action has been initiated")
sLockLED.Set(true);
bool locked = (aAction == LockManager::LOCK_ACTION);
EFR32_LOG("%s Action has been initiated", (locked) ? "Lock" : "Unlock");
sLockLED.Set(!locked);
#ifdef DISPLAY_ENABLED
sAppTask.GetLCD().WriteDemoUI(locked);
#endif
}

if (aActor == AppEvent::kEventType_Button)
Expand Down
17 changes: 16 additions & 1 deletion examples/platform/efr32/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ bool mFunctionTimerActive;

Identify * gIdentifyptr = nullptr;

#ifdef DISPLAY_ENABLED
SilabsLCD slLCD;
#endif

} // namespace

/**********************************************************
Expand Down Expand Up @@ -214,7 +218,8 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj)

if (GetQRCode(QRCode, chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)) == CHIP_NO_ERROR)
{
LCDWriteQRCode((uint8_t *) QRCode.data());
slLCD.SetQRCode((uint8_t *) QRCode.data(), QRCode.size());
slLCD.ShowQRCode(true, true);
}
else
{
Expand Down Expand Up @@ -386,6 +391,9 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
CancelFunctionTimer();
mFunction = kFunction_NoneSelected;

// TOGGLE QRCode/LCD demo UI
slLCD.ToggleQRCode();

#ifdef SL_WIFI
if (!ConnectivityMgr().IsWiFiStationProvisioned())
#else
Expand Down Expand Up @@ -469,6 +477,13 @@ void BaseApplication::LightTimerEventHandler(TimerHandle_t xTimer)
LightEventHandler();
}

#ifdef DISPLAY_ENABLED
SilabsLCD & BaseApplication::GetLCD(void)
{
return slLCD;
}
#endif

void BaseApplication::PostEvent(const AppEvent * aEvent)
{
if (sAppEventQueue != NULL)
Expand Down
18 changes: 16 additions & 2 deletions examples/platform/efr32/BaseApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
#include <lib/core/CHIPError.h>
#include <platform/CHIPDeviceLayer.h>

#ifdef DISPLAY_ENABLED
#include "demo-ui.h"
#include "lcd.h"
#ifdef QR_CODE_ENABLED
#include "qrcodegen.h"
#endif // QR_CODE_ENABLED
#endif // DISPLAY_ENABLED

/**********************************************************
* Defines
*********************************************************/
Expand Down Expand Up @@ -73,6 +81,13 @@ class BaseApplication
*/
static void PostEvent(const AppEvent * event);

#ifdef DISPLAY_ENABLED
/**
* @brief Return LCD object
*/
static SilabsLCD & GetLCD(void);
#endif

/**
* @brief Event handler when a button is pressed
* Function posts an event for button processing
Expand Down Expand Up @@ -165,8 +180,7 @@ class BaseApplication
static void LightEventHandler();

/**********************************************************
* Private Attributes declaration
* Protected Attributes declaration
*********************************************************/

bool mSyncClusterToButtonAction;
};
Loading

0 comments on commit 74a17d5

Please sign in to comment.