Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0bdad7f

Browse files
authored
Merge branch 'master' into patch-1
2 parents e92e631 + ae634a9 commit 0bdad7f

File tree

8 files changed

+172
-9
lines changed

8 files changed

+172
-9
lines changed

‎cores/esp32/ColorFormat.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ espHsvColor_t espRgbColorToHsvColor(espRgbColor_t rgb) {
119119
}
120120

121121
espRgbColor_t espXYColorToRgbColor(uint8_t Level, espXyColor_t xy) {
122-
return espXYToRgbColor(Level, xy.x, xy.y);
122+
return espXYToRgbColor(Level, xy.x, xy.y, true);
123123
}
124124

125-
espRgbColor_t espXYToRgbColor(uint8_t Level, uint16_t current_X, uint16_t current_Y) {
125+
espRgbColor_t espXYToRgbColor(uint8_t Level, uint16_t current_X, uint16_t current_Y, booladdXYZScaling) {
126126
// convert xyY color space to RGB
127127

128128
// https://www.easyrgb.com/en/math.php
@@ -156,9 +156,11 @@ espRgbColor_t espXYToRgbColor(uint8_t Level, uint16_t current_X, uint16_t curren
156156
// X, Y and Z input refer to a D65/2° standard illuminant.
157157
// sR, sG and sB (standard RGB) output range = 0 ÷ 255
158158
// convert XYZ to RGB - CIE XYZ to sRGB
159-
X = X / 100.0f;
160-
Y = Y / 100.0f;
161-
Z = Z / 100.0f;
159+
if (addXYZScaling) {
160+
X = X / 100.0f;
161+
Y = Y / 100.0f;
162+
Z = Z / 100.0f;
163+
}
162164

163165
r = (X * 3.2406f) - (Y * 1.5372f) - (Z * 0.4986f);
164166
g = -(X * 0.9689f) + (Y * 1.8758f) + (Z * 0.0415f);

‎cores/esp32/ColorFormat.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#pragma once
2020

2121
#include <stdint.h>
22+
#include <stdbool.h>
2223
#ifdef __cplusplus
2324
extern "C" {
2425
#endif
@@ -49,7 +50,7 @@ typedef struct HsvColor_t espHsvColor_t;
4950
typedef struct XyColor_t espXyColor_t;
5051
typedef struct CtColor_t espCtColor_t;
5152

52-
espRgbColor_t espXYToRgbColor(uint8_t Level, uint16_t current_X, uint16_t current_Y);
53+
espRgbColor_t espXYToRgbColor(uint8_t Level, uint16_t current_X, uint16_t current_Y, booladdXYZScaling);
5354
espRgbColor_t espXYColorToRgb(uint8_t Level, espXyColor_t xy);
5455
espXyColor_t espRgbColorToXYColor(espRgbColor_t rgb);
5556
espXyColor_t espRgbToXYColor(uint8_t r, uint8_t g, uint8_t b);

‎docs/en/zigbee/ep_fan_control.rst

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
################
2+
ZigbeeFanControl
3+
################
4+
5+
About
6+
-----
7+
8+
The ``ZigbeeFanControl`` class provides a Zigbee endpoint for controlling fan devices in a Home Automation (HA) network. This endpoint implements the Fan Control cluster and allows for controlling fan modes and sequences.
9+
10+
**Features:**
11+
* Fan mode control (OFF, LOW, MEDIUM, HIGH, ON, AUTO, SMART)
12+
* Fan mode sequence configuration
13+
* State change callbacks
14+
* Zigbee HA standard compliance
15+
16+
**Use Cases:**
17+
* Smart ceiling fans
18+
* HVAC system fans
19+
* Exhaust fans
20+
* Any device requiring fan speed control
21+
22+
API Reference
23+
-------------
24+
25+
Constructor
26+
***********
27+
28+
ZigbeeFanControl
29+
^^^^^^^^^^^^^^^^
30+
31+
Creates a new Zigbee fan control endpoint.
32+
33+
.. code-block:: arduino
34+
35+
ZigbeeFanControl(uint8_t endpoint);
36+
37+
* ``endpoint`` - Endpoint number (1-254)
38+
39+
Fan Mode Enums
40+
**************
41+
42+
ZigbeeFanMode
43+
^^^^^^^^^^^^^
44+
45+
Available fan modes for controlling the fan speed and operation.
46+
47+
.. code-block:: arduino
48+
49+
enum ZigbeeFanMode {
50+
FAN_MODE_OFF, // Fan is off
51+
FAN_MODE_LOW, // Low speed
52+
FAN_MODE_MEDIUM, // Medium speed
53+
FAN_MODE_HIGH, // High speed
54+
FAN_MODE_ON, // Fan is on (full speed)
55+
FAN_MODE_AUTO, // Automatic mode
56+
FAN_MODE_SMART, // Smart mode
57+
};
58+
59+
ZigbeeFanModeSequence
60+
^^^^^^^^^^^^^^^^^^^^^
61+
62+
Available fan mode sequences that define which modes are available for the fan.
63+
64+
.. code-block:: arduino
65+
66+
enum ZigbeeFanModeSequence {
67+
FAN_MODE_SEQUENCE_LOW_MED_HIGH, // Low -> Medium -> High
68+
FAN_MODE_SEQUENCE_LOW_HIGH, // Low -> High
69+
FAN_MODE_SEQUENCE_LOW_MED_HIGH_AUTO, // Low -> Medium -> High -> Auto
70+
FAN_MODE_SEQUENCE_LOW_HIGH_AUTO, // Low -> High -> Auto
71+
FAN_MODE_SEQUENCE_ON_AUTO, // On -> Auto
72+
};
73+
74+
API Methods
75+
***********
76+
77+
setFanModeSequence
78+
^^^^^^^^^^^^^^^^^^
79+
80+
Sets the fan mode sequence and initializes the fan control.
81+
82+
.. code-block:: arduino
83+
84+
bool setFanModeSequence(ZigbeeFanModeSequence sequence);
85+
86+
* ``sequence`` - The fan mode sequence to set
87+
88+
This function will return ``true`` if successful, ``false`` otherwise.
89+
90+
getFanMode
91+
^^^^^^^^^^
92+
93+
Gets the current fan mode.
94+
95+
.. code-block:: arduino
96+
97+
ZigbeeFanMode getFanMode();
98+
99+
This function will return current fan mode.
100+
101+
getFanModeSequence
102+
^^^^^^^^^^^^^^^^^^
103+
104+
Gets the current fan mode sequence.
105+
106+
.. code-block:: arduino
107+
108+
ZigbeeFanModeSequence getFanModeSequence();
109+
110+
This function will return current fan mode sequence.
111+
112+
Event Handling
113+
**************
114+
115+
onFanModeChange
116+
^^^^^^^^^^^^^^^
117+
118+
Sets a callback function to be called when the fan mode changes.
119+
120+
.. code-block:: arduino
121+
122+
void onFanModeChange(void (*callback)(ZigbeeFanMode mode));
123+
124+
* ``callback`` - Function to call when fan mode changes
125+
126+
Example
127+
-------
128+
129+
Fan Control Implementation
130+
**************************
131+
132+
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Fan_Control/Zigbee_Fan_Control.ino
133+
:language: arduino

‎docs/en/zigbee/zigbee_core.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,19 @@ Performs a factory reset, clearing all network settings.
345345
346346
* ``restart`` - ``true`` to restart after reset (default: ``true``)
347347

348+
onGlobalDefaultResponse
349+
^^^^^^^^^^^^^^^^^^^^^^^
350+
351+
Sets a global callback for default response messages.
352+
353+
.. code-block:: arduino
354+
355+
void onGlobalDefaultResponse(void (*callback)(zb_cmd_type_t resp_to_cmd, esp_zb_zcl_status_t status, uint8_t endpoint, uint16_t cluster));
356+
357+
* ``callback`` - Function pointer to the callback function
358+
359+
This callback will be called for all endpoints when a default response is received.
360+
348361
Utility Functions
349362
*****************
350363

‎docs/en/zigbee/zigbee_ep.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,19 @@ Sets a callback function for identify events.
345345
* ``callback`` - Function to call when identify event occurs
346346
* ``time`` - Identify time in seconds
347347

348+
onDefaultResponse
349+
^^^^^^^^^^^^^^^^^
350+
351+
Sets a callback for default response messages for this endpoint.
352+
353+
.. code-block:: arduino
354+
355+
void onDefaultResponse(void (*callback)(zb_cmd_type_t resp_to_cmd, esp_zb_zcl_status_t status));
356+
357+
* ``callback`` - Function pointer to the callback function
358+
359+
This callback will be called when a default response is received for this specific endpoint.
360+
348361
Supported Endpoints
349362
-------------------
350363

‎libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,21 @@ void ZigbeeColorDimmableLight::zbAttributeSet(const esp_zb_zcl_set_attr_value_me
7676
return;
7777
} else {
7878
log_w("Received message ignored. Attribute ID: %d not supported for Level Control", message->attribute.id);
79-
//TODO: implement more attributes -> includes/zcl/esp_zigbee_zcl_level.h
8079
}
8180
} else if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL) {
8281
if (message->attribute.id == ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_X_ID && message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) {
8382
uint16_t light_color_x = (*(uint16_t *)message->attribute.data.value);
8483
uint16_t light_color_y = getCurrentColorY();
8584
//calculate RGB from XY and call setColor()
86-
_current_color = espXYToRgbColor(255, light_color_x, light_color_y); //TODO: Check if level is correct
85+
_current_color = espXYToRgbColor(255, light_color_x, light_color_y, false);
8786
lightChanged();
8887
return;
8988

9089
} else if (message->attribute.id == ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_Y_ID && message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) {
9190
uint16_t light_color_x = getCurrentColorX();
9291
uint16_t light_color_y = (*(uint16_t *)message->attribute.data.value);
9392
//calculate RGB from XY and call setColor()
94-
_current_color = espXYToRgbColor(255, light_color_x, light_color_y); //TODO: Check if level is correct
93+
_current_color = espXYToRgbColor(255, light_color_x, light_color_y, false);
9594
lightChanged();
9695
return;
9796
} else if (message->attribute.id == ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_HUE_ID && message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_U8) {

‎variants/tamc_termod_s3/pins_arduino.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define Pins_Arduino_h
33

44
#include <stdint.h>
5+
#include <stdbool.h>
56

67
#define USB_VID 0x303a
78
#define USB_PID 0x1001

‎variants/tamc_termod_s3/variant.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "Arduino.h"
2+
#include "pins_arduino.h"
23

34
float getBatteryVoltage() {
45
int analogVolt = analogReadMilliVolts(1);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /