mirror of
https://github.com/thelsing/knx.git
synced 2024-12-18 19:08:18 +01:00
Added support for DPT 251.600 RGBW (#167)
* Added support for DPT 251.600 RGBW * style fix
This commit is contained in:
parent
f5feefb0f2
commit
71e8607f43
@ -357,6 +357,7 @@
|
||||
#define DPT_FlaggedScaling Dpt(239, 1)
|
||||
#define DPT_CombinedPosition Dpt(240, 800)
|
||||
#define DPT_StatusSAB Dpt(241, 800)
|
||||
#define DPT_Colour_RGBW Dpt(251, 600)
|
||||
|
||||
class Dpt
|
||||
{
|
||||
|
@ -126,6 +126,9 @@ int KNX_Decode_Value(uint8_t* payload, size_t payload_length, const Dpt& datatyp
|
||||
// DPT 239.* - Flagged Scaling
|
||||
if (datatype.mainGroup == 239 && datatype.subGroup == 1 && datatype.index <= 1)
|
||||
return busValueToFlaggedScaling(payload, payload_length, datatype, value);
|
||||
// DPT 251.600 - RGBW
|
||||
if (datatype.mainGroup == 251 && datatype.subGroup == 600 && datatype.index <= 1)
|
||||
return busValueToRGBW(payload, payload_length, datatype, value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -243,6 +246,9 @@ int KNX_Encode_Value(const KNXValue& value, uint8_t* payload, size_t payload_len
|
||||
// DPT 239.* - Flagged Scaling
|
||||
if (datatype.mainGroup == 239 && datatype.subGroup == 1 && datatype.index <= 1)
|
||||
return valueToBusValueFlaggedScaling(value, payload, payload_length, datatype);
|
||||
// DPT 251.600 - RGBW
|
||||
if (datatype.mainGroup == 251 && datatype.subGroup == 600 && datatype.index <= 1)
|
||||
return valueToBusValueRGBW(value, payload, payload_length, datatype);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -801,6 +807,24 @@ int busValueToRGB(const uint8_t* payload, size_t payload_length, const Dpt& data
|
||||
return true;
|
||||
}
|
||||
|
||||
int busValueToRGBW(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value)
|
||||
{
|
||||
ASSERT_PAYLOAD(6);
|
||||
switch (datatype.index) {
|
||||
case 0: // The RGBW value
|
||||
{
|
||||
uint32_t rgbw = (unsigned32FromPayload(payload, 0) >> 8)
|
||||
+ (unsigned8FromPayload(payload, 3) << 24);
|
||||
value = rgbw;
|
||||
}
|
||||
return true;
|
||||
case 1: // The mask bits only
|
||||
value = unsigned8FromPayload(payload,5);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int busValueToFlaggedScaling(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value)
|
||||
{
|
||||
ASSERT_PAYLOAD(2);
|
||||
@ -1517,6 +1541,26 @@ int valueToBusValueRGB(const KNXValue& value, uint8_t* payload, size_t payload_l
|
||||
return true;
|
||||
}
|
||||
|
||||
int valueToBusValueRGBW(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype)
|
||||
{
|
||||
switch(datatype.index)
|
||||
{
|
||||
case 0: // RGBW
|
||||
{
|
||||
uint32_t rgbw = (uint32_t)value;
|
||||
unsigned16ToPayload(payload, payload_length, 0, rgbw >> 8, 0xffff); // RG
|
||||
unsigned8ToPayload(payload, payload_length, 2, rgbw, 0xff); // B
|
||||
unsigned8ToPayload(payload, payload_length, 3, rgbw >> 24, 0xff); // W
|
||||
}
|
||||
break;
|
||||
case 1: // Mask bits
|
||||
unsigned8ToPayload(payload, payload_length, 5, (uint8_t)value, 0xff);
|
||||
break;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int valueToBusValueFlaggedScaling(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype)
|
||||
{
|
||||
switch (datatype.index)
|
||||
@ -1545,7 +1589,6 @@ int valueToBusValueActiveEnergy(const KNXValue& value, uint8_t* payload, size_t
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
|
||||
if ((int64_t)value < INT64_C(-2147483648) || (int64_t)value > INT64_C(2147483647))
|
||||
return false;
|
||||
ENSURE_PAYLOAD(6);
|
||||
|
@ -78,6 +78,7 @@ int busValueToScaling(const uint8_t* payload, size_t payload_length, const Dpt&
|
||||
int busValueToTariff(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value);
|
||||
int busValueToLocale(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value);
|
||||
int busValueToRGB(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value);
|
||||
int busValueToRGBW(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value);
|
||||
int busValueToFlaggedScaling(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value);
|
||||
int busValueToActiveEnergy(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value);
|
||||
|
||||
@ -116,6 +117,7 @@ int valueToBusValueScaling(const KNXValue& value, uint8_t* payload, size_t paylo
|
||||
int valueToBusValueTariff(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype);
|
||||
int valueToBusValueLocale(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype);
|
||||
int valueToBusValueRGB(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype);
|
||||
int valueToBusValueRGBW(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype);
|
||||
int valueToBusValueFlaggedScaling(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype);
|
||||
int valueToBusValueActiveEnergy(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user