Skip to content

Commit

Permalink
Added build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shgutte committed Oct 7, 2024
1 parent 40895c3 commit 2296840
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 66 deletions.
5 changes: 2 additions & 3 deletions examples/refrigerator-app/silabs/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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",
]

Expand Down
2 changes: 1 addition & 1 deletion examples/refrigerator-app/silabs/build_for_wifi_args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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"
13 changes: 9 additions & 4 deletions examples/refrigerator-app/silabs/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#include <stdbool.h>
#include <stdint.h>

#ifdef DISPLAY_ENABLED
#include "RefrigeratorUI.h"
#endif

#include "AppEvent.h"
#include "BaseApplication.h"
#include "RefrigeratorManager.h"
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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);
};
17 changes: 11 additions & 6 deletions examples/refrigerator-app/silabs/include/RefrigeratorManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,25 @@
*/

#pragma once
#include "AppEvent.h"
#include <app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.h>
#include <app/clusters/temperature-control-server/supported-temperature-levels-manager.h>

#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/ConcreteAttributePath.h>
#include <app/util/attribute-storage.h>
#include <lib/support/logging/CHIPLogging.h>
#include <examples/refrigerator-app/refrigerator-common/include/static-supported-temperature-levels.h>
#include <stdbool.h>
#include <stdint.h>

#include "AppEvent.h"

#include <cmsis_os2.h>
#include <lib/core/CHIPError.h>

/**********************************************************
* 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;
Expand Down
2 changes: 1 addition & 1 deletion examples/refrigerator-app/silabs/openthread.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
40 changes: 5 additions & 35 deletions examples/refrigerator-app/silabs/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand All @@ -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();
Expand All @@ -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);
}

Expand Down Expand Up @@ -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 = {};
Expand Down
7 changes: 3 additions & 4 deletions examples/refrigerator-app/silabs/src/RefrigeratorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -71,6 +69,7 @@ CHIP_ERROR RefrigeratorManager::Init()
SetTagList(kFreezeCabinetEndpointId, Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(freezerTagList));

app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate);
return CHIP_NO_ERROR;
}

int8_t RefrigeratorManager::ConvertToPrintableTemp(int16_t temperature)
Expand Down
25 changes: 13 additions & 12 deletions examples/refrigerator-app/silabs/src/RefrigeratorUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<RefrigeratorUI::SUPPORTED_MODES>(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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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' };

Expand All @@ -241,7 +242,7 @@ void ThermostatUI::DrawSetPoint(GLIB_Context_t * glibContext, int8_t setPoint, b
}

// Update SetPoint string
if (static_cast<ThermostatUI::HVACMode>(mMode) == ThermostatUI::HVACMode::MODE_OFF)
if (static_cast<RefrigeratorUI::SUPPORTED_MODES>(mMode) == RefrigeratorUI::SUPPORTED_MODES::ENERGY_SAVE)
{
setPointLine[0] = '-';
setPointLine[1] = '-';
Expand Down

0 comments on commit 2296840

Please sign in to comment.