Skip to content

Commit

Permalink
chore: Update SilabsLCD::TurnOn and SilabsLCD::TurnOff functions
Browse files Browse the repository at this point in the history
  • Loading branch information
rosahay-silabs committed Feb 7, 2025
1 parent 505387e commit 989df66
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
9 changes: 0 additions & 9 deletions examples/lock-app/silabs/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,6 @@ CHIP_ERROR AppTask::Init()
GetLCD().ShowQRCode(true);
}
#endif // QR_CODE_ENABLED
#ifdef SL_ENABLE_ICD_LCD
GetLCD().TurnOff(SilabsLCD::kDefaultLCDTimeout);
#endif // SL_ENABLE_ICD_LCD
#endif // DISPLAY_ENABLED

chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast<intptr_t>(nullptr));
Expand Down Expand Up @@ -350,13 +347,7 @@ void AppTask::ActionInitiated(LockManager::Action_t aAction, int32_t aActor)
sLockLED.Set(!locked);

#ifdef DISPLAY_ENABLED
#ifdef SL_ENABLE_ICD_LCD
sAppTask.GetLCD().TurnOn();
#endif // SL_ENABLE_ICD_LCD
sAppTask.GetLCD().WriteDemoUI(locked);
#ifdef SL_ENABLE_ICD_LCD
sAppTask.GetLCD().TurnOff(SilabsLCD::kActivityLCDTimeout);
#endif // SL_ENABLE_ICD_LCD
#endif // DISPLAY_ENABLED
}
else if (aAction == LockManager::UNLATCH_ACTION)
Expand Down
40 changes: 26 additions & 14 deletions examples/platform/silabs/display/lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,30 @@ int SilabsLCD::DrawPixel(void * pContext, int32_t x, int32_t y)

int SilabsLCD::Update(void)
{
return updateDisplay();
int status = 0;
#ifdef SL_ENABLE_ICD_LCD
SilabsLCD::TurnOn();
#endif // SL_ENABLE_ICD_LCD
status = updateDisplay();
#ifdef SL_ENABLE_ICD_LCD
switch (mCurrentScreen)
{
case DemoScreen:
SilabsLCD::TurnOff(kActivityLCDTimeout);
break;
case StatusScreen:
SilabsLCD::TurnOff(kActivityLCDTimeout);
break;
#ifdef QR_CODE_ENABLED
case QRCodeScreen:
SilabsLCD::TurnOff(kQRCodeScreenTimeout);
break;
#endif // QR_CODE_ENABLED
default:
break;
}
#endif // SL_ENABLE_ICD_LCD
return status;
}

void SilabsLCD::WriteDemoUI(bool state)
Expand All @@ -153,6 +176,7 @@ void SilabsLCD::WriteDemoUI()
demoUIClearMainScreen(mName);
demoUIDisplayApp(dState.mainState);
}
SilabsLCD::Update();
}

void SilabsLCD::WriteStatus()
Expand Down Expand Up @@ -197,7 +221,7 @@ void SilabsLCD::WriteStatus()
GLIB_drawStringOnLine(&glibContext, str, lineNb++, GLIB_ALIGN_LEFT, 0, 0, true);
}

updateDisplay();
SilabsLCD::Update();
}

void SilabsLCD::SetCustomUI(customUICB cb)
Expand All @@ -216,29 +240,17 @@ void SilabsLCD::SetScreen(Screen_e screen)
{
return;
}
#ifdef SL_ENABLE_ICD_LCD
TurnOn();
#endif // SL_ENABLE_ICD_LCD
switch (screen)
{
case DemoScreen:
WriteDemoUI();
#ifdef SL_ENABLE_ICD_LCD
TurnOff(kActivityLCDTimeout);
#endif // SL_ENABLE_ICD_LCD
break;
case StatusScreen:
WriteStatus();
#ifdef SL_ENABLE_ICD_LCD
TurnOff(kActivityLCDTimeout);
#endif // SL_ENABLE_ICD_LCD
break;
#ifdef QR_CODE_ENABLED
case QRCodeScreen:
WriteQRCode();
#ifdef SL_ENABLE_ICD_LCD
TurnOff(kQRCodeScreenTimeout);
#endif // SL_ENABLE_ICD_LCD
break;
#endif
default:
Expand Down
5 changes: 3 additions & 2 deletions examples/platform/silabs/display/lcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,16 @@ class SilabsLCD
GLIB_Context_t glibContext;

#ifdef SL_DEMO_NAME
uint8_t mName[] = SL_DEMO_NAME
uint8_t mName[] = SL_DEMO_NAME;
#else
uint8_t mName[APP_NAME_MAX_LENGTH + 1];
#endif
customUICB customUI = nullptr;
customUICB customUI = nullptr;
DemoState_t dState;

DisplayStatus_t mStatus;
uint8_t mCurrentScreen = DemoScreen;

#ifdef SL_ENABLE_ICD_LCD
sl_sleeptimer_timer_handle_t lcdTimerHandle;
static void LcdTimeoutCallback(sl_sleeptimer_timer_handle_t * handle, void * data);
Expand Down

0 comments on commit 989df66

Please sign in to comment.