-
Notifications
You must be signed in to change notification settings - Fork 98
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
8 changed files
with
157 additions
and
174 deletions.
There are no files selected for viewing
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
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
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
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,109 @@ | ||
#include "dpt6.h" | ||
|
||
#include "dptconvert.h" | ||
|
||
Knx::Go_SizeCode Knx::Dpt6::size() const | ||
{ | ||
return Go_1_Octet; | ||
} | ||
|
||
void Knx::Dpt6::encode(uint8_t* data) const | ||
{ | ||
signed8ToPayload(data, 0, value(), 0xFF); | ||
} | ||
|
||
bool Knx::Dpt6::decode(uint8_t* data) | ||
{ | ||
value(signed8FromPayload(data, 0)); | ||
return true; | ||
} | ||
|
||
bool Knx::DPT_Status_Mode3::decode(uint8_t* data) | ||
{ | ||
int8_t val = signed8FromPayload(data, 0); | ||
|
||
int8_t mode = val & 0x7; | ||
|
||
if ( mode != (1 << 0) && mode != (1 << 1) && mode != (1 << 2) ) | ||
return false; | ||
|
||
value(val); | ||
return true; | ||
} | ||
|
||
Knx::DPT_Status_Mode3::SetClearValue Knx::DPT_Status_Mode3::A() | ||
{ | ||
return ( _value & (1 << 7) ) > 0 ? Clear : Set; | ||
} | ||
|
||
void Knx::DPT_Status_Mode3::A(SetClearValue value) | ||
{ | ||
if (value == Set) | ||
_value &= ~ (1 << 7); | ||
else | ||
_value |= (1 << 7); | ||
} | ||
|
||
|
||
Knx::DPT_Status_Mode3::SetClearValue Knx::DPT_Status_Mode3::B() | ||
{ | ||
return ( _value & (1 << 6) ) > 0 ? Clear : Set; | ||
} | ||
|
||
void Knx::DPT_Status_Mode3::B(SetClearValue value) | ||
{ | ||
if (value == Set) | ||
_value &= ~ (1 << 6); | ||
else | ||
_value |= (1 << 6); | ||
} | ||
|
||
Knx::DPT_Status_Mode3::SetClearValue Knx::DPT_Status_Mode3::C() | ||
{ | ||
return ( _value & (1 << 5) ) > 0 ? Clear : Set; | ||
} | ||
|
||
void Knx::DPT_Status_Mode3::C(SetClearValue value) | ||
{ | ||
if (value == Set) | ||
_value &= ~ (1 << 5); | ||
else | ||
_value |= (1 << 5); | ||
} | ||
|
||
Knx::DPT_Status_Mode3::SetClearValue Knx::DPT_Status_Mode3::D() | ||
{ | ||
return ( _value & (1 << 4) ) > 0 ? Clear : Set; | ||
} | ||
|
||
void Knx::DPT_Status_Mode3::D(SetClearValue value) | ||
{ | ||
if (value == Set) | ||
_value &= ~ (1 << 4); | ||
else | ||
_value |= (1 << 4); | ||
} | ||
|
||
Knx::DPT_Status_Mode3::SetClearValue Knx::DPT_Status_Mode3::E() | ||
{ | ||
return ( _value & (1 << 3) ) > 0 ? Clear : Set; | ||
} | ||
|
||
void Knx::DPT_Status_Mode3::E(SetClearValue value) | ||
{ | ||
if (value == Set) | ||
_value &= ~ (1 << 3); | ||
else | ||
_value |= (1 << 3); | ||
} | ||
|
||
Knx::DPT_Status_Mode3::ActiveModeValue Knx::DPT_Status_Mode3::activeMode() | ||
{ | ||
return (ActiveModeValue) (_value & 0x7); | ||
} | ||
|
||
void Knx::DPT_Status_Mode3::activeMode(ActiveModeValue value) | ||
{ | ||
_value &= ~ (0x7); | ||
_value |= (int8_t)value; | ||
} |
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 @@ | ||
#pragma once | ||
#include "dpt.h" | ||
namespace Knx | ||
{ | ||
class Dpt6: public DPT<int8_t> | ||
{ | ||
public: | ||
Go_SizeCode size() const override; | ||
|
||
void encode(uint8_t* data) const override; | ||
bool decode(uint8_t* data) override; | ||
}; | ||
|
||
typedef Dpt6 DPT_Percent_V8; | ||
typedef Dpt6 DPT_Value_1_Count; | ||
|
||
class DPT_Status_Mode3: public Dpt6 | ||
{ | ||
public: | ||
bool decode(uint8_t* data) override; | ||
enum SetClearValue { Set = 0, Clear = 1}; | ||
enum ActiveModeValue { Mode0Active = 0x1, Mode1Active = 0x2, Mode2Active = 0x4}; | ||
|
||
SetClearValue A(); | ||
void A(SetClearValue value); | ||
|
||
SetClearValue B(); | ||
void B(SetClearValue value); | ||
|
||
SetClearValue C(); | ||
void C(SetClearValue value); | ||
|
||
SetClearValue D(); | ||
void D(SetClearValue value); | ||
|
||
SetClearValue E(); | ||
void E(SetClearValue value); | ||
|
||
ActiveModeValue activeMode(); | ||
void activeMode(ActiveModeValue value); | ||
}; | ||
} |
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
Oops, something went wrong.