Skip to content
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

samples: matter: Unification of events, buttons and LEDs #10

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions samples/matter/common/src/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#pragma once

#include <zephyr/devicetree.h>
#include <dk_buttons_and_leds.h>

/* Override application configuration */
#include "app_config.h"

#define LEDS_NODE_ID DT_PATH(leds)
#define BUTTONS_NODE_ID DT_PATH(buttons)
#define INCREMENT_BY_ONE(button_or_led) +1
#define NUMBER_OF_LEDS (0 DT_FOREACH_CHILD(LEDS_NODE_ID, INCREMENT_BY_ONE))
#define NUMBER_OF_BUTTONS (0 DT_FOREACH_CHILD(BUTTONS_NODE_ID, INCREMENT_BY_ONE))

/* Basic Identify Endpoint */
#ifndef IDENTIFY_ENDPOINT
#define IDENTIFY_ENDPOINT 1
ArekBalysNordic marked this conversation as resolved.
Show resolved Hide resolved
#endif

/* User configurable BUTTONS */
#ifndef FUNCTION_BUTTON
#define FUNCTION_BUTTON DK_BTN1
#endif
#ifndef APPLICATION_BUTTON
#define APPLICATION_BUTTON DK_BTN2
#endif
/* User buttons 1 & 2 are available only on DKs that have 4 buttons located on the board */
#if NUMBER_OF_BUTTONS == 4
#ifndef USER_BUTTON_1
#define USER_BUTTON_1 DK_BTN3
#endif
#ifndef USER_BUTTON_2
#define USER_BUTTON_2 DK_BTN4
#endif
#endif

/* User configurable LEDS */
#ifndef SYSTEM_STATE_LED
#define SYSTEM_STATE_LED DK_LED1
#endif
#ifndef APPLICATION_STATE_LED
#define APPLICATION_STATE_LED DK_LED2
#endif
/* User leds 1 & 2 are available only on DKs that have 4 buttons located on the board */
#if NUMBER_OF_LEDS == 4
#ifndef USER_LED_1
#define USER_LED_1 DK_LED3
#endif
#ifndef USER_LED_2
#define USER_LED_2 DK_LED4
#endif
#endif

/* Non-configurable Consts */
#define FUNCTION_BUTTON_MASK BIT(FUNCTION_BUTTON)
#define APPLICATION_BUTTON_MASK BIT(APPLICATION_BUTTON)
#if NUMBER_OF_LEDS == 4
#define USER_BUTTON_1_MASK BIT(USER_BUTTON_1)
#define USER_BUTTON_2_MASK BIT(USER_BUTTON_2)
#endif

#if NUMBER_OF_BUTTONS == 4
#define BLUETOOTH_ADV_BUTTON USER_BUTTON_2
#else
#define BLUETOOTH_ADV_BUTTON APPLICATION_BUTTON
#endif
#define BLUETOOTH_ADV_BUTTON_MASK BIT(BLUETOOTH_ADV_BUTTON)
42 changes: 42 additions & 0 deletions samples/matter/common/src/board_consts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#pragma once

#include <cstdint>

namespace FactoryResetConsts
{
constexpr uint32_t kFactoryResetTriggerTimeout = 3000;
constexpr uint32_t kFactoryResetCancelWindowTimeout = 3000;
} /* namespace FactoryResetConsts */

namespace AdvertisingConsts
{
#if NUMBER_OF_BUTTONS == 2
ArekBalysNordic marked this conversation as resolved.
Show resolved Hide resolved
constexpr uint32_t kAdvertisingTriggerTimeout = 3000;
#endif
} // namespace AdvertisingConsts

namespace LedConsts
{
constexpr uint32_t kBlinkRate_ms{ 500 };
constexpr uint32_t kIdentifyBlinkRate_ms{ 500 };
namespace StatusLed
{
namespace BleConnected
{
constexpr uint32_t kOn_ms{ 100 };
constexpr uint32_t kOff_ms{ kOn_ms };
} /* namespace BleConnected */
namespace Disconnected
{
constexpr uint32_t kOn_ms{ 50 };
constexpr uint32_t kOff_ms{ 950 };
} /* namespace Disconnected */

} /* namespace StatusLed */
} /* namespace LedConsts */
Loading
Loading