-
Notifications
You must be signed in to change notification settings - Fork 99
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
10 changed files
with
136 additions
and
81 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
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,64 @@ | ||
#include "dpt2.h" | ||
|
||
#include "dptconvert.h" | ||
|
||
Knx::Dpt2::Dpt2(unsigned short subgroup /* = 0*/) : Dpt(2, subgroup) {} | ||
|
||
Knx::Dpt2::Dpt2(Dpt2Value value) : Dpt2() | ||
{ | ||
_value = value; | ||
} | ||
|
||
Knx::Go_SizeCode Knx::Dpt2::size() const | ||
{ | ||
return Go_2_Bit; | ||
} | ||
|
||
void Knx::Dpt2::encode(uint8_t* data) const | ||
{ | ||
if (_value == NoControl) | ||
{ | ||
bitToPayload(data, 6, false); | ||
return; | ||
} | ||
|
||
bitToPayload(data, 6, true); | ||
bitToPayload(data, 7, _value == Control_Function1); | ||
} | ||
|
||
void Knx::Dpt2::decode(uint8_t* data) | ||
{ | ||
bool c = bitFromPayload(data, 6); | ||
|
||
if (!c) | ||
{ | ||
_value = NoControl; | ||
return; | ||
} | ||
|
||
bool v = bitFromPayload(data, 7); | ||
|
||
_value = v ? Control_Function1 : Control_Function0; | ||
} | ||
|
||
void Knx::Dpt2::value(Dpt2Value value) | ||
{ | ||
_value = value; | ||
} | ||
|
||
Knx::Dpt2::Dpt2Value Knx::Dpt2::value() const | ||
{ | ||
return _value; | ||
} | ||
|
||
Knx::Dpt2::operator Dpt2Value() const | ||
{ | ||
return _value; | ||
} | ||
|
||
|
||
Knx::Dpt2& Knx::Dpt2::operator=(const Dpt2Value value) | ||
{ | ||
_value = value; | ||
return *this; | ||
} |
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,40 @@ | ||
#pragma once | ||
#include "dpt.h" | ||
namespace Knx | ||
{ | ||
class Dpt2: public Dpt | ||
{ | ||
public: | ||
enum Dpt2Value | ||
{ | ||
NoControl, Control_Function0, Control_Function1 | ||
}; | ||
|
||
Dpt2(unsigned short subgroup = 0); | ||
Dpt2(Dpt2Value value); | ||
Go_SizeCode size() const override; | ||
|
||
virtual void encode(uint8_t* data) const override; | ||
virtual void decode(uint8_t* data) override; | ||
|
||
void value(Dpt2Value value); | ||
Dpt2Value value() const; | ||
operator Dpt2Value() const; | ||
Dpt2& operator=(const Dpt2Value value); | ||
private: | ||
Dpt2Value _value; | ||
}; | ||
|
||
#define DPT_Switch_Control Dpt2(1) | ||
#define DPT_Bool_Control Dpt2(2) | ||
#define DPT_Enable_Control Dpt2(3) | ||
#define DPT_Ramp_Control Dpt2(4) | ||
#define DPT_Alarm_Control Dpt2(5) | ||
#define DPT_BinaryValue_Control Dpt2(6) | ||
#define DPT_Step_Control Dpt2(7) | ||
#define DPT_Direction1_Control Dpt2(8) | ||
#define DPT_Direction2_Control Dpt2(9) | ||
#define DPT_Start_Control Dpt2(10) | ||
#define DPT_State_Control Dpt2(11) | ||
#define DPT_Invert_Control Dpt2(12) | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#pragma once | ||
|
||
#include "dpt1.h" | ||
#include "dpt2.h" | ||
#include "dpt9.h" |