diff --git a/examples/refrigerator-app/silabs/BUILD.gn b/examples/refrigerator-app/silabs/BUILD.gn index 3f1e611a8e144d..f6f416b5df76f4 100644 --- a/examples/refrigerator-app/silabs/BUILD.gn +++ b/examples/refrigerator-app/silabs/BUILD.gn @@ -31,7 +31,7 @@ if (chip_enable_pw_rpc) { assert(current_os == "freertos") -silabs_project_dir = "${chip_root}/examples/refrigerator/silabs" +silabs_project_dir = "${chip_root}/examples/refrigerator-app/silabs" examples_common_plat_dir = "${chip_root}/examples/platform/silabs" if (wifi_soc) { @@ -136,8 +136,7 @@ silabs_executable("refrigerator_app") { sources = [ "${examples_common_plat_dir}/main.cpp", "src/AppTask.cpp", - "src/SensorManager.cpp", - "src/TemperatureManager.cpp", + "src/RefrigeratorManager.cpp", "src/ZclCallbacks.cpp", ] diff --git a/examples/refrigerator-app/silabs/build_for_wifi_args.gni b/examples/refrigerator-app/silabs/build_for_wifi_args.gni index 63b40dc30811ba..950db0cdf4e54a 100644 --- a/examples/refrigerator-app/silabs/build_for_wifi_args.gni +++ b/examples/refrigerator-app/silabs/build_for_wifi_args.gni @@ -18,4 +18,4 @@ silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") import("${chip_root}/src/platform/silabs/wifi_args.gni") chip_enable_wifi = true chip_enable_ota_requestor = true -app_data_model = "${chip_root}/examples/refrigerator/refrigerator-common" +app_data_model = "${chip_root}/examples/refrigerator-app/refrigerator-common" diff --git a/examples/refrigerator-app/silabs/include/AppTask.h b/examples/refrigerator-app/silabs/include/AppTask.h index b9e09385203cac..c355f6aa8faac7 100644 --- a/examples/refrigerator-app/silabs/include/AppTask.h +++ b/examples/refrigerator-app/silabs/include/AppTask.h @@ -26,6 +26,10 @@ #include #include +#ifdef DISPLAY_ENABLED +#include "RefrigeratorUI.h" +#endif + #include "AppEvent.h" #include "BaseApplication.h" #include "RefrigeratorManager.h" @@ -66,7 +70,8 @@ class AppTask : public BaseApplication static void AppTaskMain(void * pvParameter); CHIP_ERROR StartAppTask(); - + + /** * @brief Event handler when a button is pressed * Function posts an event for button processing * @@ -103,7 +108,7 @@ class AppTask : public BaseApplication */ static void RefrigeratorActionEventHandler(AppEvent * aEvent); - static void ActionInitiated(OperationalStateEnum action); - static void ActionCompleted(); - static void UpdateClusterState(intptr_t context); + // static void ActionInitiated(OperationalStateEnum action); + // static void ActionCompleted(); + // static void UpdateClusterState(intptr_t context); }; diff --git a/examples/refrigerator-app/silabs/include/RefrigeratorManager.h b/examples/refrigerator-app/silabs/include/RefrigeratorManager.h index 8e4614c33fe95c..7d2d8415171234 100644 --- a/examples/refrigerator-app/silabs/include/RefrigeratorManager.h +++ b/examples/refrigerator-app/silabs/include/RefrigeratorManager.h @@ -17,20 +17,25 @@ */ #pragma once +#include "AppEvent.h" #include -#include - +#include +#include +#include +#include +#include +#include #include #include - -#include "AppEvent.h" - #include #include +/********************************************************** + * Defines and Constants + *********************************************************/ + using namespace chip; using namespace chip::app; -using namespace chip::app::Clusters; using namespace chip::app::Clusters::RefrigeratorAlarm; using namespace chip::app::Clusters::RefrigeratorAlarm::Attributes; using namespace chip::app::Clusters::TemperatureControl; diff --git a/examples/refrigerator-app/silabs/openthread.gni b/examples/refrigerator-app/silabs/openthread.gni index d05f99426ef98d..4c56d43109e9b2 100644 --- a/examples/refrigerator-app/silabs/openthread.gni +++ b/examples/refrigerator-app/silabs/openthread.gni @@ -18,7 +18,7 @@ import("${chip_root}/src/platform/silabs/efr32/args.gni") silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") -app_data_model = "${chip_root}/examples/refrigerator/refrigerator-common" +app_data_model = "${chip_root}/examples/refrigerator-app/refrigerator-common" chip_enable_ota_requestor = true chip_enable_openthread = true diff --git a/examples/refrigerator-app/silabs/src/AppTask.cpp b/examples/refrigerator-app/silabs/src/AppTask.cpp index e033a3fe2b9144..460458653fef71 100644 --- a/examples/refrigerator-app/silabs/src/AppTask.cpp +++ b/examples/refrigerator-app/silabs/src/AppTask.cpp @@ -28,7 +28,7 @@ #include "LEDWidget.h" #ifdef DISPLAY_ENABLED -#include "ThermostatUI.h" +#include "RefrigeratorUI.h" #include "lcd.h" #ifdef QR_CODE_ENABLED #include "qrcodegen.h" @@ -54,9 +54,8 @@ *********************************************************/ #define APP_FUNCTION_BUTTON 0 -#define APP_THERMOSTAT 1 +#define APP_REFRIGERATOR 1 -#define MODE_TIMER 1000 // 1s timer period using namespace chip; using namespace chip::app; @@ -79,8 +78,7 @@ CHIP_ERROR AppTask::Init() chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(AppTask::ButtonEventHandler); #ifdef DISPLAY_ENABLED - GetLCD().Init((uint8_t *) "Thermostat-App"); - GetLCD().SetCustomUI(ThermostatUI::DrawUI); + GetLCD().Init((uint8_t *) "Refrigrator-App"); #endif err = BaseApplication::Init(); @@ -89,16 +87,10 @@ CHIP_ERROR AppTask::Init() SILABS_LOG("BaseApplication::Init() failed"); appError(err); } - err = SensorMgr().Init(); + err = RefrigeratorMgr().Init(); if (err != CHIP_NO_ERROR) { - SILABS_LOG("SensorMgr::Init() failed"); - appError(err); - } - err = TempMgr().Init(); - if (err != CHIP_NO_ERROR) - { - SILABS_LOG("TempMgr::Init() failed"); + SILABS_LOG("RefrigeratorMgr::Init() failed"); appError(err); } @@ -138,28 +130,6 @@ void AppTask::AppTaskMain(void * pvParameter) } } -void AppTask::UpdateThermoStatUI() -{ -#ifdef DISPLAY_ENABLED - ThermostatUI::SetMode(TempMgr().GetMode()); - ThermostatUI::SetHeatingSetPoint(TempMgr().GetHeatingSetPoint()); - ThermostatUI::SetCoolingSetPoint(TempMgr().GetCoolingSetPoint()); - ThermostatUI::SetCurrentTemp(TempMgr().GetCurrentTemp()); - -#ifdef SL_WIFI - if (ConnectivityMgr().IsWiFiStationProvisioned()) -#else - if (ConnectivityMgr().IsThreadProvisioned()) -#endif /* !SL_WIFI */ - { - AppTask::GetAppTask().GetLCD().WriteDemoUI(false); // State doesn't Matter - } -#else - SILABS_LOG("Thermostat Status - M:%d T:%d'C H:%d'C C:%d'C", TempMgr().GetMode(), TempMgr().GetCurrentTemp(), - TempMgr().GetHeatingSetPoint(), TempMgr().GetCoolingSetPoint()); -#endif // DISPLAY_ENABLED -} - void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction) { AppEvent aEvent = {}; diff --git a/examples/refrigerator-app/silabs/src/RefrigeratorManager.cpp b/examples/refrigerator-app/silabs/src/RefrigeratorManager.cpp index 82742f208008f2..63e4b4a2e3a8dc 100644 --- a/examples/refrigerator-app/silabs/src/RefrigeratorManager.cpp +++ b/examples/refrigerator-app/silabs/src/RefrigeratorManager.cpp @@ -26,15 +26,13 @@ #include "AppEvent.h" #include "AppTask.h" + /********************************************************** * Defines and Constants *********************************************************/ using namespace chip; using namespace ::chip::DeviceLayer; -using namespace ::chip::app::Clusters::RefrigeratorAndTemperatureControlledCabinetMode; -using namespace ::chip::app::Clusters::RefrigeratorAlarm; -using namespace ::chip::app::Clusters::TemperatureControl; namespace RefAndTempAttr = chip::app::Clusters::RefrigeratorAndTemperatureControlledCabinetMode::Attributes; namespace RefAlarmAttr = chip::app::Clusters::RefrigeratorAlarm::Attributes; @@ -46,7 +44,7 @@ EndpointId kColdCabinetEndpointId = 2; EndpointId kFreezeCabinetEndpointId = 3; namespace { - app::Clusters::TemperatureControl::AppSupportedTemperatureLevelsDelegate sAppSupportedTemperatureLevelsDelegate; + chip::app::Clusters::TemperatureControl::AppSupportedTemperatureLevelsDelegate sAppSupportedTemperatureLevelsDelegate; // Please refer to https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/namespaces constexpr const uint8_t kNamespaceRefrigerator = 0x41; @@ -71,6 +69,7 @@ CHIP_ERROR RefrigeratorManager::Init() SetTagList(kFreezeCabinetEndpointId, Span(freezerTagList)); app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate); + return CHIP_NO_ERROR; } int8_t RefrigeratorManager::ConvertToPrintableTemp(int16_t temperature) diff --git a/examples/refrigerator-app/silabs/src/RefrigeratorUI.cpp b/examples/refrigerator-app/silabs/src/RefrigeratorUI.cpp index 4f52437866ef2a..209ef67339818e 100644 --- a/examples/refrigerator-app/silabs/src/RefrigeratorUI.cpp +++ b/examples/refrigerator-app/silabs/src/RefrigeratorUI.cpp @@ -77,16 +77,17 @@ void RefrigeratorUI::DrawUI(GLIB_Context_t * glibContext) #endif // SL_LCDCTRL_MUX } -void ThermostatUI::SetCurrentTemp(int8_t temp) +void RefrigeratorUI::SetCurrentTemp(int8_t temp) { mCurrentTempCelsius = temp; } -void ThermostatUI::SetMode(uint8_t mode) + +void RefrigeratorUI::SetMode(uint8_t mode) { mMode = mode; } -void ThermostatUI::DrawHeader(GLIB_Context_t * glibContext) +void RefrigeratorUI::DrawHeader(GLIB_Context_t * glibContext) { // Draw Silabs Corner icon GLIB_drawBitmap(glibContext, SILABS_ICON_POSITION_X, STATUS_ICON_LINE, SILABS_LOGO_WIDTH, SILABS_LOGO_HEIGHT, silabsLogo); @@ -106,26 +107,26 @@ void ThermostatUI::DrawHeader(GLIB_Context_t * glibContext) #endif // SL_LCDCTRL_MUX } -void ThermostatUI::DrawFooter(GLIB_Context_t * glibContext, bool autoMode) +void RefrigeratorUI::DrawFooter(GLIB_Context_t * glibContext, bool autoMode) { switch (static_cast(mMode)) { - case HVACMode::RAPID_COOL: + case SUPPORTED_MODES::RAPID_COOL: GLIB_drawStringOnLine(glibContext, "Mode : Rapid Cool", 11, GLIB_ALIGN_LEFT, 0, 0, true); GLIB_drawBitmap(glibContext, HEATING_COOLING_X, HEATING_COOLING_Y, COOLING_WIDTH, COOLING_HEIGHT, heating_bits); DrawSetPoint(glibContext, mCurrentTempCelsius, false); break; - case HVACMode::RAPID_FREEZE: + case SUPPORTED_MODES::RAPID_FREEZE: GLIB_drawStringOnLine(glibContext, "Mode : Rapid Freeze", 11, GLIB_ALIGN_LEFT, 0, 0, true); GLIB_drawBitmap(glibContext, HEATING_COOLING_X, HEATING_COOLING_Y, COOLING_WIDTH, COOLING_HEIGHT, cooling_bits); DrawSetPoint(glibContext, mCurrentTempCelsius, false); break; - case HVACMode::NORMAL: + case SUPPORTED_MODES::NORMAL: GLIB_drawStringOnLine(glibContext, "Mode : Normal", 11, GLIB_ALIGN_LEFT, 0, 0, true); GLIB_drawBitmap(glibContext, HEATING_COOLING_X, HEATING_COOLING_Y, COOLING_WIDTH, COOLING_HEIGHT, heating_cooling_bits); DrawSetPoint(glibContext, mCurrentTempCelsius, false); break; - case HVACMode::ENERGY_SAVE: + case SUPPORTED_MODES::ENERGY_SAVE: DrawSetPoint(glibContext, 0, false); GLIB_drawStringOnLine(glibContext, "Mode : Energy save", 11, GLIB_ALIGN_LEFT, 0, 0, true); DrawSetPoint(glibContext, mCurrentTempCelsius, false); @@ -150,7 +151,7 @@ void ThermostatUI::DrawFooter(GLIB_Context_t * glibContext, bool autoMode) * @param int8_t setPoint in Celsius * @param bool isCelsius By default set to True. For future development */ -void ThermostatUI::DrawCurrentTemp(GLIB_Context_t * glibContext, int8_t temp, bool isCelsius) +void RefrigeratorUI::DrawCurrentTemp(GLIB_Context_t * glibContext, int8_t temp, bool isCelsius) { uint8_t tempArray[2]; uint8_t position_x = 10; @@ -203,7 +204,7 @@ void ThermostatUI::DrawCurrentTemp(GLIB_Context_t * glibContext, int8_t temp, bo } } -void ThermostatUI::DrawFont(GLIB_Context_t * glibContext, uint8_t initial_x, uint8_t initial_y, uint8_t width, uint8_t * data, +void RefrigeratorUI::DrawFont(GLIB_Context_t * glibContext, uint8_t initial_x, uint8_t initial_y, uint8_t width, uint8_t * data, uint32_t size) { uint8_t x = initial_x, y = initial_y; @@ -231,7 +232,7 @@ void ThermostatUI::DrawFont(GLIB_Context_t * glibContext, uint8_t initial_x, uin } } -void ThermostatUI::DrawSetPoint(GLIB_Context_t * glibContext, int8_t setPoint, bool secondLine) +void RefrigeratorUI::DrawSetPoint(GLIB_Context_t * glibContext, int8_t setPoint, bool secondLine) { char setPointLine[] = { '-', 'X', 'X', '\0' }; @@ -241,7 +242,7 @@ void ThermostatUI::DrawSetPoint(GLIB_Context_t * glibContext, int8_t setPoint, b } // Update SetPoint string - if (static_cast(mMode) == ThermostatUI::HVACMode::MODE_OFF) + if (static_cast(mMode) == RefrigeratorUI::SUPPORTED_MODES::ENERGY_SAVE) { setPointLine[0] = '-'; setPointLine[1] = '-';