Skip to content

Commit

Permalink
Delete duplicate led and button implementations, all move to examples…
Browse files Browse the repository at this point in the history
…/platform/asr
  • Loading branch information
asriot committed Jul 5, 2023
1 parent a9773c9 commit 0ce834e
Show file tree
Hide file tree
Showing 52 changed files with 220 additions and 969 deletions.
2 changes: 1 addition & 1 deletion examples/all-clusters-app/asr/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ asr_executable("clusters_app") {
sources = [
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",
"${examples_plat_dir}/ButtonHandler.cpp",
"${examples_plat_dir}/CHIPDeviceManager.cpp",
"${examples_plat_dir}/LEDWidget.cpp",
"${examples_plat_dir}/init_Matter.cpp",
"${examples_plat_dir}/init_asrPlatform.cpp",
"${examples_plat_dir}/shell/matter_shell.cpp",
"src/AppTask.cpp",
"src/ButtonHandler.cpp",
"src/DeviceCallbacks.cpp",
"src/main.cpp",
]
Expand Down
12 changes: 0 additions & 12 deletions examples/all-clusters-app/asr/include/AppConfig.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@

#define MATTER_DEVICE_NAME "ASR-Clusters"

#define GPIO_TASK_NAME "gpio"
#define GPIO_TASK_STACK_SIZE 1024

#define APP_BUTTON_PRESSED 0
#define APP_BUTTON_RELEASED 1

#define SWITCH1_BUTTON GPIO12_INDEX
#define SWITCH2_BUTTON GPIO13_INDEX

#define LIGHT1_LED PWM_OUTPUT_CH4
#define LIGHT2_LED PWM_OUTPUT_CH6

// Time it takes in ms for the simulated actuator to move from one
// state to another.
#define ACTUATOR_MOVEMENT_PERIOS_MS 2000
Expand Down
2 changes: 1 addition & 1 deletion examples/all-clusters-app/asr/include/AppTask.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AppTask
CHIP_ERROR StartAppTask();
static void AppTaskMain(void * pvParameter);
static void AppEventHandler(AppEvent * aEvent);
void PostButtonEvent(uint8_t btnIdx, uint8_t btnAction);
void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction);
void PostEvent(const AppEvent * event);
/**
* Use internally for registration of the ChipDeviceEvents
Expand Down
53 changes: 0 additions & 53 deletions examples/all-clusters-app/asr/include/ButtonHandler.h

This file was deleted.

15 changes: 8 additions & 7 deletions examples/all-clusters-app/asr/src/AppTask.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ using namespace ::chip::DeviceManager;
using namespace ::chip::DeviceLayer;
using namespace ::chip::System;

LEDWidget sStatusLED;
LEDWidget sLightLED;

namespace {
Expand Down Expand Up @@ -119,7 +118,11 @@ CHIP_ERROR AppTask::Init()
ConfigurationMgr().LogDeviceConfig();

// Print setup info
#if CONFIG_NETWORK_LAYER_BLE
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
#else
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kOnNetwork));
#endif /* CONFIG_NETWORK_LAYER_BLE */

return CHIP_NO_ERROR;
}
Expand All @@ -131,8 +134,7 @@ void AppTask::AppTaskMain(void * pvParameter)

ButtonHandler::Init();

sLightLED.Init(LIGHT1_LED); // embedded board light
sStatusLED.Init(LIGHT2_LED);
sLightLED.Init(LIGHT_LED);

lega_rtos_start_timer(&sAppTimer);

Expand Down Expand Up @@ -186,7 +188,6 @@ void AppTask::AppEventHandler(AppEvent * aEvent)
if (lightState)
{
sLightLED.Set(1);
sLightLED.SetBrightness(100);
}
else
{
Expand All @@ -213,9 +214,9 @@ void AppTask::AppTimerCallback(void * params)
sAppTask.PostEvent(&timer_event);
}

void AppTask::PostButtonEvent(uint8_t btnIdx, uint8_t btnAction)
void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction)
{
ASR_LOG("%s %s\n", btnIdx == SWITCH1_BUTTON ? "btn1" : "btn2", btnAction == APP_BUTTON_PRESSED ? "Pressed" : "Released");
ASR_LOG("%s %s\n", btnIdx == SWITCH1_BUTTON ? "btn1" : "btn2", btnAction == BUTTON_PRESSED ? "Pressed" : "Released");

if (btnIdx != SWITCH1_BUTTON && btnIdx != SWITCH2_BUTTON)
{
Expand All @@ -227,7 +228,7 @@ void AppTask::PostButtonEvent(uint8_t btnIdx, uint8_t btnAction)
button_event.ButtonEvent.ButtonIdx = btnIdx;
button_event.ButtonEvent.Action = btnAction;

if (btnAction == APP_BUTTON_RELEASED)
if (btnAction == BUTTON_RELEASED)
{
button_event.Handler = AppEventHandler;
sAppTask.PostEvent(&button_event);
Expand Down
117 changes: 0 additions & 117 deletions examples/all-clusters-app/asr/src/ButtonHandler.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions examples/all-clusters-app/asr/src/DeviceCallbacks.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ using namespace ::chip::DeviceManager;
using namespace ::chip::Logging;

extern LEDWidget sLightLED;
extern LEDWidget sStatusLED;

uint32_t identifyTimerCount;
constexpr uint32_t kIdentifyTimerDelayMS = 250;
Expand Down Expand Up @@ -191,7 +190,6 @@ void DeviceCallbacks::OnLevelPostAttributeChangeCallback(EndpointId endpointId,
{
uint8_t tmp = *value;
ChipLogProgress(Zcl, "New level: %u ", tmp);
sLightLED.SetBrightness(tmp);
}
else
{
Expand Down
11 changes: 0 additions & 11 deletions examples/all-clusters-minimal-app/asr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ control on ASR platform.
- [Supported Chips](#supported-chips)
- [Building and Commissioning](#building-and-commissioning)
- [Cluster Control](#cluster-control)
- [Light switch press button and light status LED](#light-switch-press-button-and-light-status-led)

---

Expand Down Expand Up @@ -42,13 +41,3 @@ For example,control the OnOff Cluster attribute:
./chip-tool onoff off <NODE ID> 1
./chip-tool onoff toggle <NODE ID> 1
```

## Light switch press button and light status LED

This demo uses button to test changing the light states and LED to show the
state of these changes.

| Name | Pin |
| :----: | :---: |
| LED | PAD6 |
| BUTTON | PAD12 |
6 changes: 0 additions & 6 deletions examples/all-clusters-minimal-app/asr/include/AppConfig.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@

#define MATTER_DEVICE_NAME "ASR-Clusters-m"

#define APP_LIGHT_BUTTON_IDX 0
#define APP_BUTTON_DEBOUNCE_PERIOD_MS 50

#define APP_BUTTON_PRESSED 0
#define APP_BUTTON_RELEASED 1

// Time it takes in ms for the simulated actuator to move from one
// state to another.
#define ACTUATOR_MOVEMENT_PERIOS_MS 2000
Expand Down
13 changes: 9 additions & 4 deletions examples/all-clusters-minimal-app/asr/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "AppTask.h"
#include "AppConfig.h"
#include "AppEvent.h"
#include "ButtonHandler.h"
#include "CHIPDeviceManager.h"
#include "DeviceCallbacks.h"
#include "LEDWidget.h"
Expand Down Expand Up @@ -50,9 +51,7 @@ using namespace ::chip::DeviceManager;
using namespace ::chip::DeviceLayer;
using namespace ::chip::System;

LEDWidget sStatusLED;
LEDWidget sLightLED;
LEDWidget sClusterLED;

namespace {
TaskHandle_t sAppTaskHandle;
Expand Down Expand Up @@ -112,7 +111,13 @@ CHIP_ERROR AppTask::Init()
ConfigurationMgr().LogDeviceConfig();

// Print setup info
#if CONFIG_NETWORK_LAYER_BLE
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
#else
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kOnNetwork));
#endif /* CONFIG_NETWORK_LAYER_BLE */

sLightLED.Init(LIGHT_LED);

return CHIP_NO_ERROR;
}
Expand Down Expand Up @@ -150,7 +155,7 @@ void AppTask::LightActionEventHandler(AppEvent * aEvent)

void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction)
{
if (btnIdx != APP_LIGHT_BUTTON_IDX)
if (btnIdx != SWITCH1_BUTTON)
{
return;
}
Expand All @@ -160,7 +165,7 @@ void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction)
button_event.ButtonEvent.ButtonIdx = btnIdx;
button_event.ButtonEvent.Action = btnAction;

if ((btnIdx == APP_LIGHT_BUTTON_IDX) && (btnAction == APP_BUTTON_RELEASED))
if (btnAction == BUTTON_RELEASED)
{
button_event.Handler = LightActionEventHandler;
sAppTask.PostEvent(&button_event);
Expand Down
Loading

0 comments on commit 0ce834e

Please sign in to comment.