Skip to content

Commit

Permalink
Merge 977fd70 into 4c5fa19
Browse files Browse the repository at this point in the history
  • Loading branch information
jlatusek authored Aug 30, 2024
2 parents 4c5fa19 + 977fd70 commit 2145560
Show file tree
Hide file tree
Showing 22 changed files with 10,732 additions and 1 deletion.
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",
]
}
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);
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;
}
Loading

0 comments on commit 2145560

Please sign in to comment.