-
Notifications
You must be signed in to change notification settings - Fork 32
[SL-ONLY] LCD, LED and Button implementation for Oven-app. #700
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
base: feature/oven_app_bindings_implementation
Are you sure you want to change the base?
Changes from all commits
2741937
e09e9d8
9da4bbe
b1c2fee
c02a272
32ef895
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 |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * | ||
| * Copyright (c) 2025 Project CHIP Authors | ||
| * All rights reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "demo-ui-bitmaps.h" | ||
| #include "dmd.h" | ||
| #include "glib.h" | ||
| #include "lcd.h" | ||
|
|
||
| class OvenUI | ||
| { | ||
|
|
||
| public: | ||
| static void DrawUI(GLIB_Context_t * glibContext); | ||
|
|
||
| private: | ||
| static void DrawHeader(GLIB_Context_t * glibContext); | ||
| static void DrawCookTopState(GLIB_Context_t * glibContext); | ||
| static void DrawOvenMode(GLIB_Context_t * glibContext); | ||
| static void DrawFont(GLIB_Context_t * glibContext, uint8_t initial_x, uint8_t initial_y, uint8_t width, uint8_t * data, | ||
| uint32_t size); | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -21,6 +21,8 @@ | |||||
| #include "AppConfig.h" | ||||||
| #include "AppEvent.h" | ||||||
| #include "LEDWidget.h" | ||||||
| #include "OvenBindingHandler.h" | ||||||
| #include "OvenUI.h" | ||||||
|
|
||||||
| #ifdef DISPLAY_ENABLED | ||||||
| #include "lcd.h" | ||||||
|
|
@@ -36,6 +38,7 @@ | |||||
| #include <app-common/zap-generated/ids/Clusters.h> | ||||||
| #include <app/ConcreteAttributePath.h> | ||||||
| #include <app/clusters/network-commissioning/network-commissioning.h> | ||||||
| #include <app/clusters/on-off-server/on-off-server.h> | ||||||
| #include <app/server/Server.h> | ||||||
| #include <app/util/attribute-storage.h> | ||||||
| #include <app/util/endpoint-config-api.h> | ||||||
|
|
@@ -48,6 +51,12 @@ | |||||
| #include <setup_payload/QRCodeSetupPayloadGenerator.h> | ||||||
| #include <setup_payload/SetupPayload.h> | ||||||
|
|
||||||
| #ifdef SL_CATALOG_SIMPLE_LED_LED1_PRESENT | ||||||
| #define LIGHT_LED 1 | ||||||
| #else | ||||||
| #define LIGHT_LED 0 | ||||||
| #endif | ||||||
|
|
||||||
| #define APP_FUNCTION_BUTTON 0 | ||||||
| #define APP_ACTION_BUTTON 1 | ||||||
|
|
||||||
|
|
@@ -59,6 +68,8 @@ using namespace ::chip::DeviceLayer::Silabs; | |||||
| using namespace ::chip::DeviceLayer::Internal; | ||||||
| using namespace chip::TLV; | ||||||
|
|
||||||
| LEDWidget sLightLED; // Use LEDWidget for basic LED functionality | ||||||
|
|
||||||
| AppTask AppTask::sAppTask; | ||||||
|
|
||||||
| CHIP_ERROR AppTask::AppInit() | ||||||
|
|
@@ -68,19 +79,20 @@ CHIP_ERROR AppTask::AppInit() | |||||
|
|
||||||
| #ifdef DISPLAY_ENABLED | ||||||
| GetLCD().Init((uint8_t *) "Oven-App"); | ||||||
| GetLCD().SetCustomUI(OvenUI::DrawUI); | ||||||
| #endif | ||||||
|
|
||||||
| // Initialization of Oven Manager and endpoints of oven. | ||||||
| OvenManager::GetInstance().Init(); | ||||||
|
|
||||||
| sLightLED.Init(LIGHT_LED); | ||||||
| UpdateLED(OvenManager::GetInstance().GetCookTopState() == OvenManager::kCookTopState_On); | ||||||
|
|
||||||
| // Update the LCD with the Stored value. Show QR Code if not provisioned | ||||||
| #ifdef DISPLAY_ENABLED | ||||||
| GetLCD().WriteDemoUI(false); | ||||||
| UpdateLCD(); | ||||||
| #ifdef QR_CODE_ENABLED | ||||||
| #ifdef SL_WIFI | ||||||
| if (!ConnectivityMgr().IsWiFiStationProvisioned()) | ||||||
| #else | ||||||
| if (!ConnectivityMgr().IsThreadProvisioned()) | ||||||
| #endif /* !SL_WIFI */ | ||||||
| if (!BaseApplication::GetProvisionStatus()) | ||||||
| { | ||||||
| GetLCD().ShowQRCode(true); | ||||||
| } | ||||||
|
|
@@ -107,6 +119,10 @@ void AppTask::AppTaskMain(void * pvParameter) | |||||
| appError(err); | ||||||
| } | ||||||
|
|
||||||
| #if !(defined(CHIP_CONFIG_ENABLE_ICD_SERVER) && CHIP_CONFIG_ENABLE_ICD_SERVER) | ||||||
| sAppTask.StartStatusLEDTimer(); | ||||||
| #endif | ||||||
|
|
||||||
| ChipLogProgress(AppServer, "App Task started"); | ||||||
|
|
||||||
| while (true) | ||||||
|
|
@@ -125,6 +141,81 @@ void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction) | |||||
| AppEvent button_event = {}; | ||||||
| button_event.Type = AppEvent::kEventType_Button; | ||||||
| button_event.ButtonEvent.Action = btnAction; | ||||||
| button_event.Handler = BaseApplication::ButtonHandler; | ||||||
|
|
||||||
| // Handle button1 specifically for oven functionality | ||||||
| if (button == APP_ACTION_BUTTON) | ||||||
| { | ||||||
| button_event.Handler = OvenButtonHandler; | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| button_event.Handler = BaseApplication::ButtonHandler; | ||||||
| } | ||||||
|
|
||||||
| AppTask::GetAppTask().PostEvent(&button_event); | ||||||
| } | ||||||
|
|
||||||
| void AppTask::OvenButtonHandler(AppEvent * aEvent) | ||||||
| { | ||||||
| // Handle button press to toggle cooktop and cook surface | ||||||
| if (aEvent->ButtonEvent.Action == static_cast<uint8_t>(SilabsPlatform::ButtonAction::ButtonPressed)) | ||||||
| { | ||||||
| ChipLogProgress(AppServer, "Oven button pressed - starting toggle action"); | ||||||
| return; // Only handle button release | ||||||
| } | ||||||
|
|
||||||
| if (aEvent->ButtonEvent.Action == static_cast<uint8_t>(SilabsPlatform::ButtonAction::ButtonReleased)) | ||||||
| { | ||||||
| ChipLogProgress(AppServer, "Oven button released - toggling cooktop and cook surface"); | ||||||
|
|
||||||
| // Determine new state (toggle current state) | ||||||
| OvenManager::Action_t action = (OvenManager::GetInstance().GetCookTopState() == OvenManager::kCookTopState_On) | ||||||
| ? OvenManager::COOK_TOP_OFF_ACTION | ||||||
| : OvenManager::COOK_TOP_ON_ACTION; | ||||||
|
|
||||||
| // Toggle CookTop | ||||||
| chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast<intptr_t>(nullptr)); | ||||||
|
||||||
| chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast<intptr_t>(nullptr)); | |
| chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, 0); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,11 +47,6 @@ void OvenManager::Init() | |
| { | ||
| DeviceLayer::PlatformMgr().LockChipStack(); | ||
|
|
||
| // Initialize states | ||
| mCookTopState = kCookTopState_Off; | ||
| mCookSurfaceState1 = kCookSurfaceState_Off; | ||
| mCookSurfaceState2 = kCookSurfaceState_Off; | ||
|
|
||
| // Endpoint initializations | ||
| VerifyOrReturn(mTemperatureControlledCabinetEndpoint.Init() == CHIP_NO_ERROR, | ||
| ChipLogError(AppServer, "TemperatureControlledCabinetEndpoint Init failed")); | ||
|
|
@@ -84,6 +79,29 @@ void OvenManager::Init() | |
|
|
||
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(AppServer, "RegisterSupportedLevels failed for CookSurfaceEndpoint2")); | ||
|
|
||
| // Get CookTop On/Off value | ||
| <<<<<<< HEAD | ||
|
Contributor
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. looks like a conflict wasn't resolved... this shouldn't compile as well... |
||
| bool currentState = false; | ||
| chip::Protocols::InteractionModel::Status status = OnOffServer::Instance().getOnOffValue(kCookTopEndpoint, ¤tState); | ||
| ======= | ||
| bool currentLedState = false; | ||
| chip::Protocols::InteractionModel::Status status = OnOffServer::Instance().getOnOffValue(kCookTopEndpoint, ¤tLedState); | ||
| >>>>>>> 3c958a2913 (Restyled by clang-format) | ||
| VerifyOrReturn(status == Status::Success, ChipLogError(AppServer, "Failed to get CookTop OnOff value")); | ||
| mCookTopState = currentState ? kCookTopState_On : kCookTopState_Off; | ||
|
|
||
| status = OnOffServer::Instance().getOnOffValue(kCookSurfaceEndpoint1, ¤tState); | ||
| VerifyOrReturn(status == Status::Success, ChipLogError(AppServer, "Failed to get CookSurface OnOff value")); | ||
| mCookSurfaceState1 = currentState ? kCookSurfaceState_On : kCookSurfaceState_Off; | ||
|
|
||
| status = OnOffServer::Instance().getOnOffValue(kCookSurfaceEndpoint2, ¤tState); | ||
| VerifyOrReturn(status == Status::Success, ChipLogError(AppServer, "Failed to get CookSurface OnOff value")); | ||
| mCookSurfaceState2 = currentState ? kCookSurfaceState_On : kCookSurfaceState_Off; | ||
|
|
||
| // Get current oven mode | ||
| status = OvenMode::Attributes::CurrentMode::Get(kTemperatureControlledCabinetEndpoint, &mCurrentOvenMode); | ||
| VerifyOrReturn(status == Status::Success, ChipLogError(AppServer, "Unable to get the current oven mode")); | ||
|
|
||
| DeviceLayer::PlatformMgr().UnlockChipStack(); | ||
|
|
||
| // Initialize binding manager (after stack unlock to avoid long hold) | ||
|
|
@@ -164,6 +182,8 @@ void OvenManager::OnOffAttributeChangeHandler(EndpointId endpointId, AttributeId | |
|
|
||
| CookTopOnOffBindingTrigger(context); | ||
| } | ||
| AppTask::GetAppTask().UpdateLED(*value); | ||
| AppTask::GetAppTask().UpdateLCD(); | ||
| break; | ||
| case kCookSurfaceEndpoint1: | ||
| case kCookSurfaceEndpoint2: | ||
|
|
@@ -193,6 +213,7 @@ void OvenManager::OnOffAttributeChangeHandler(EndpointId endpointId, AttributeId | |
| void OvenManager::OvenModeAttributeChangeHandler(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value, | ||
| uint16_t size) | ||
| { | ||
| mCurrentOvenMode = *value; | ||
| AppEvent event = {}; | ||
| event.Type = AppEvent::kEventType_Oven; | ||
| event.OvenEvent.Action = OVEN_MODE_UPDATE_ACTION; | ||
|
|
||
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.
Is this intended? Seems like double inclusion
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.
yes, OvenUI.h should be removed