-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Silabs] Adds LCD timeouts for ICD applications #34703
base: master
Are you sure you want to change the base?
Changes from all commits
aa356e7
95f2ca6
be25f80
505387e
989df66
25258c4
3eb6356
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -35,6 +35,8 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#include "sl_board_control.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#include <lib/support/logging/CHIPLogging.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#define LCD_SIZE 128 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#define QR_CODE_VERSION 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#define QR_CODE_MODULE_SIZE 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -75,7 +77,7 @@ CHIP_ERROR SilabsLCD::Init(uint8_t * name, bool initialState) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SILABS_LOG("Board Display enable fail %d", status); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
err = CHIP_ERROR_INTERNAL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#endif // SLI_SI91X_MCU_INTERFACE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/* Initialize the DMD module for the DISPLAY device driver. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
status = DMD_init(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -126,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; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+131
to
+154
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use #if rather than #ifdef and make sure the define always exist (1/0)
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
void SilabsLCD::WriteDemoUI(bool state) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -151,6 +176,7 @@ void SilabsLCD::WriteDemoUI() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
demoUIClearMainScreen(mName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
demoUIDisplayApp(dState.mainState); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SilabsLCD::Update(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
void SilabsLCD::WriteStatus() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -195,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) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -214,7 +240,6 @@ void SilabsLCD::SetScreen(Screen_e screen) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
switch (screen) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
case DemoScreen: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -257,6 +282,64 @@ void SilabsLCD::SetStatus(DisplayStatus_t & status) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mStatus = status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CHIP_ERROR SilabsLCD::TurnOn(void) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sl_status_t status = SL_STATUS_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#if (SLI_SI91X_MCU_INTERFACE) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sl_memlcd_display_enable(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sl_memlcd_power_on(sl_memlcd_get(), true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sl_memlcd_clear(sl_memlcd_get()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
status = sl_board_enable_display(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#endif // SLI_SI91X_MCU_INTERFACE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (status != SL_STATUS_OK) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ChipLogError(DeviceLayer, "sl_board_enable_display failed: %ld", status); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return CHIP_ERROR_INTERNAL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return CHIP_NO_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CHIP_ERROR SilabsLCD::TurnOff(void) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sl_status_t status = SL_STATUS_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
status = SilabsLCD::Clear(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (status != SL_STATUS_OK) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ChipLogError(DeviceLayer, "SilabsLCD::Clear failed: %ld", status); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return CHIP_ERROR_INTERNAL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#if (SLI_SI91X_MCU_INTERFACE) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sl_memlcd_power_on(sl_memlcd_get(), false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sl_memlcd_display_disable(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
status = sl_board_disable_display(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#endif // SLI_SI91X_MCU_INTERFACE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (status != SL_STATUS_OK) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ChipLogError(DeviceLayer, "sl_board_disable_display failed: %ld", status); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return CHIP_ERROR_INTERNAL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return CHIP_NO_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#ifdef SL_ENABLE_ICD_LCD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CHIP_ERROR SilabsLCD::TurnOff(uint32_t delayInMs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sl_sleeptimer_restart_timer(&lcdTimerHandle, sl_sleeptimer_ms_to_tick(delayInMs), LcdTimeoutCallback, this, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SL_SLEEPTIMER_NO_HIGH_PRECISION_HF_CLOCKS_REQUIRED_FLAG); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return CHIP_NO_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+326
to
+332
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
void SilabsLCD::LcdTimeoutCallback(sl_sleeptimer_timer_handle_t * handle, void * data) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Perform the desired task when the timer expires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(void) handle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SilabsLCD * sLCD = reinterpret_cast<SilabsLCD *>(data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sLCD->TurnOff(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#endif // SL_ENABLE_ICD_LCD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#ifdef QR_CODE_ENABLED | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
void SilabsLCD::WriteQRCode() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,11 @@ | |
#endif // QR_CODE_ENABLED | ||
|
||
#include "demo-ui.h" | ||
#ifdef SL_ENABLE_ICD_LCD | ||
#include <sl_sleeptimer.h> | ||
#endif // SL_ENABLE_ICD_LCD | ||
|
||
#include <lib/core/CHIPError.h> | ||
#include <platform/internal/DeviceNetworkInfo.h> | ||
|
||
class SilabsLCD | ||
|
@@ -58,6 +63,12 @@ class SilabsLCD | |
ICDMode_e icdMode = NotICD; | ||
} DisplayStatus_t; | ||
|
||
#ifdef SL_ENABLE_ICD_LCD | ||
static const uint32_t kDefaultLCDTimeout = 3000; | ||
static const uint32_t kActivityLCDTimeout = 5000; | ||
static const uint32_t kQRCodeScreenTimeout = 10000; | ||
#endif // SL_ENABLE_ICD_LCD | ||
|
||
typedef void (*customUICB)(GLIB_Context_t * context); | ||
CHIP_ERROR Init(uint8_t * name = nullptr, bool initialState = false); | ||
void * Context(); | ||
|
@@ -74,6 +85,12 @@ class SilabsLCD | |
void SetStatus(DisplayStatus_t & status); | ||
void WriteStatus(); | ||
|
||
CHIP_ERROR TurnOn(void); | ||
CHIP_ERROR TurnOff(void); | ||
#ifdef SL_ENABLE_ICD_LCD | ||
CHIP_ERROR TurnOff(uint32_t delayInMs); | ||
#endif // SL_ENABLE_ICD_LCD | ||
|
||
#ifdef QR_CODE_ENABLED | ||
void SetQRCode(uint8_t * str, uint32_t size); | ||
void ShowQRCode(bool show); | ||
|
@@ -95,13 +112,18 @@ 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the advantage of using the sleepTimer vs a cmsisosTimer or a ScheduleWork? |
||
static void LcdTimeoutCallback(sl_sleeptimer_timer_handle_t * handle, void * data); | ||
#endif // SL_ENABLE_ICD_LCD | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see where this is defined But I'd also suggest a more specific name to what it enables.
SL_MATTER_TIMED_SCREEN_DISPLAY