Skip to content

Commit 989df66

Browse files
chore: Update SilabsLCD::TurnOn and SilabsLCD::TurnOff functions
1 parent 505387e commit 989df66

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

examples/lock-app/silabs/src/AppTask.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,6 @@ CHIP_ERROR AppTask::Init()
234234
GetLCD().ShowQRCode(true);
235235
}
236236
#endif // QR_CODE_ENABLED
237-
#ifdef SL_ENABLE_ICD_LCD
238-
GetLCD().TurnOff(SilabsLCD::kDefaultLCDTimeout);
239-
#endif // SL_ENABLE_ICD_LCD
240237
#endif // DISPLAY_ENABLED
241238

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

352349
#ifdef DISPLAY_ENABLED
353-
#ifdef SL_ENABLE_ICD_LCD
354-
sAppTask.GetLCD().TurnOn();
355-
#endif // SL_ENABLE_ICD_LCD
356350
sAppTask.GetLCD().WriteDemoUI(locked);
357-
#ifdef SL_ENABLE_ICD_LCD
358-
sAppTask.GetLCD().TurnOff(SilabsLCD::kActivityLCDTimeout);
359-
#endif // SL_ENABLE_ICD_LCD
360351
#endif // DISPLAY_ENABLED
361352
}
362353
else if (aAction == LockManager::UNLATCH_ACTION)

examples/platform/silabs/display/lcd.cpp

+26-14
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,30 @@ int SilabsLCD::DrawPixel(void * pContext, int32_t x, int32_t y)
128128

129129
int SilabsLCD::Update(void)
130130
{
131-
return updateDisplay();
131+
int status = 0;
132+
#ifdef SL_ENABLE_ICD_LCD
133+
SilabsLCD::TurnOn();
134+
#endif // SL_ENABLE_ICD_LCD
135+
status = updateDisplay();
136+
#ifdef SL_ENABLE_ICD_LCD
137+
switch (mCurrentScreen)
138+
{
139+
case DemoScreen:
140+
SilabsLCD::TurnOff(kActivityLCDTimeout);
141+
break;
142+
case StatusScreen:
143+
SilabsLCD::TurnOff(kActivityLCDTimeout);
144+
break;
145+
#ifdef QR_CODE_ENABLED
146+
case QRCodeScreen:
147+
SilabsLCD::TurnOff(kQRCodeScreenTimeout);
148+
break;
149+
#endif // QR_CODE_ENABLED
150+
default:
151+
break;
152+
}
153+
#endif // SL_ENABLE_ICD_LCD
154+
return status;
132155
}
133156

134157
void SilabsLCD::WriteDemoUI(bool state)
@@ -153,6 +176,7 @@ void SilabsLCD::WriteDemoUI()
153176
demoUIClearMainScreen(mName);
154177
demoUIDisplayApp(dState.mainState);
155178
}
179+
SilabsLCD::Update();
156180
}
157181

158182
void SilabsLCD::WriteStatus()
@@ -197,7 +221,7 @@ void SilabsLCD::WriteStatus()
197221
GLIB_drawStringOnLine(&glibContext, str, lineNb++, GLIB_ALIGN_LEFT, 0, 0, true);
198222
}
199223

200-
updateDisplay();
224+
SilabsLCD::Update();
201225
}
202226

203227
void SilabsLCD::SetCustomUI(customUICB cb)
@@ -216,29 +240,17 @@ void SilabsLCD::SetScreen(Screen_e screen)
216240
{
217241
return;
218242
}
219-
#ifdef SL_ENABLE_ICD_LCD
220-
TurnOn();
221-
#endif // SL_ENABLE_ICD_LCD
222243
switch (screen)
223244
{
224245
case DemoScreen:
225246
WriteDemoUI();
226-
#ifdef SL_ENABLE_ICD_LCD
227-
TurnOff(kActivityLCDTimeout);
228-
#endif // SL_ENABLE_ICD_LCD
229247
break;
230248
case StatusScreen:
231249
WriteStatus();
232-
#ifdef SL_ENABLE_ICD_LCD
233-
TurnOff(kActivityLCDTimeout);
234-
#endif // SL_ENABLE_ICD_LCD
235250
break;
236251
#ifdef QR_CODE_ENABLED
237252
case QRCodeScreen:
238253
WriteQRCode();
239-
#ifdef SL_ENABLE_ICD_LCD
240-
TurnOff(kQRCodeScreenTimeout);
241-
#endif // SL_ENABLE_ICD_LCD
242254
break;
243255
#endif
244256
default:

examples/platform/silabs/display/lcd.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,16 @@ class SilabsLCD
112112
GLIB_Context_t glibContext;
113113

114114
#ifdef SL_DEMO_NAME
115-
uint8_t mName[] = SL_DEMO_NAME
115+
uint8_t mName[] = SL_DEMO_NAME;
116116
#else
117117
uint8_t mName[APP_NAME_MAX_LENGTH + 1];
118118
#endif
119-
customUICB customUI = nullptr;
119+
customUICB customUI = nullptr;
120120
DemoState_t dState;
121121

122122
DisplayStatus_t mStatus;
123123
uint8_t mCurrentScreen = DemoScreen;
124+
124125
#ifdef SL_ENABLE_ICD_LCD
125126
sl_sleeptimer_timer_handle_t lcdTimerHandle;
126127
static void LcdTimeoutCallback(sl_sleeptimer_timer_handle_t * handle, void * data);

0 commit comments

Comments
 (0)