-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
10,732 additions
and
1 deletion.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
examples/lighting-app-data-mode-no-unique-id/lighting-common/BUILD.gn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright (c) 2020 Project CHIP Authors | ||
# | ||
# 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. | ||
|
||
import("//build_overrides/chip.gni") | ||
import("${chip_root}/src/app/chip_data_model.gni") | ||
|
||
config("config") { | ||
include_dirs = [ "include" ] | ||
} | ||
|
||
chip_data_model("lighting-common") { | ||
zap_file = "lighting-app.zap" | ||
is_server = true | ||
} | ||
|
||
source_set("color-format") { | ||
public_configs = [ ":config" ] | ||
sources = [ | ||
"include/ColorFormat.h", | ||
"src/ColorFormat.cpp", | ||
] | ||
} | ||
|
||
source_set("lighting-manager") { | ||
deps = [ "${chip_root}/src/lib" ] | ||
public_configs = [ ":config" ] | ||
sources = [ | ||
"include/LightingManager.h", | ||
"src/LightingManager.cpp", | ||
] | ||
} |
50 changes: 50 additions & 0 deletions
50
examples/lighting-app-data-mode-no-unique-id/lighting-common/include/ColorFormat.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* | ||
* Copyright (c) 2021 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 <stdint.h> | ||
|
||
struct RgbColor_t | ||
{ | ||
uint8_t r; | ||
uint8_t g; | ||
uint8_t b; | ||
}; | ||
|
||
struct HsvColor_t | ||
{ | ||
uint8_t h; | ||
uint8_t s; | ||
uint8_t v; | ||
}; | ||
|
||
struct XyColor_t | ||
{ | ||
uint16_t x; | ||
uint16_t y; | ||
}; | ||
|
||
struct CtColor_t | ||
{ | ||
uint16_t ctMireds; | ||
}; | ||
|
||
RgbColor_t XYToRgb(uint8_t Level, uint16_t currentX, uint16_t currentY); | ||
RgbColor_t HsvToRgb(HsvColor_t hsv); | ||
RgbColor_t CTToRgb(CtColor_t ct); |
67 changes: 67 additions & 0 deletions
67
examples/lighting-app-data-mode-no-unique-id/lighting-common/include/LightingManager.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020 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 <stdbool.h> | ||
#include <stdint.h> | ||
|
||
#include <functional> | ||
|
||
#include <lib/core/CHIPError.h> | ||
|
||
class LightingManager | ||
{ | ||
public: | ||
enum Action_t | ||
{ | ||
ON_ACTION = 0, | ||
OFF_ACTION, | ||
INVALID_ACTION | ||
} Action; | ||
|
||
enum State_t | ||
{ | ||
kState_On = 0, | ||
kState_Off, | ||
} State; | ||
|
||
CHIP_ERROR Init(); | ||
bool IsTurnedOn(); | ||
bool InitiateAction(Action_t aAction); | ||
|
||
using LightingCallback_fn = std::function<void(Action_t)>; | ||
|
||
void SetCallbacks(LightingCallback_fn aActionInitiated_CB, LightingCallback_fn aActionCompleted_CB); | ||
|
||
private: | ||
friend LightingManager & LightingMgr(void); | ||
State_t mState; | ||
|
||
LightingCallback_fn mActionInitiated_CB; | ||
LightingCallback_fn mActionCompleted_CB; | ||
|
||
void Set(bool aOn); | ||
|
||
static LightingManager sLight; | ||
}; | ||
|
||
inline LightingManager & LightingMgr(void) | ||
{ | ||
return LightingManager::sLight; | ||
} |
Oops, something went wrong.