端口类继承Object,提供ToString支持
数据操作通过ToString获取名称 Zigbee门窗磁测试通过
This commit is contained in:
parent
4938b8edc8
commit
1a8cee5e9d
|
@ -40,7 +40,7 @@ public:
|
||||||
public:
|
public:
|
||||||
// 构造函数。指示灯和继电器一般开漏输出,需要倒置
|
// 构造函数。指示灯和继电器一般开漏输出,需要倒置
|
||||||
Button_GrayLevel();
|
Button_GrayLevel();
|
||||||
~Button_GrayLevel();
|
virtual ~Button_GrayLevel();
|
||||||
|
|
||||||
void Set(Pin key, Pin relay = P0, bool relayInvert = true);
|
void Set(Pin key, Pin relay = P0, bool relayInvert = true);
|
||||||
void Set(Pin key, Pin relay);
|
void Set(Pin key, Pin relay);
|
||||||
|
|
|
@ -181,7 +181,10 @@ int ByteDataPort::Write(byte* data)
|
||||||
//Show(true);
|
//Show(true);
|
||||||
Object* obj = dynamic_cast<Object*>(this);
|
Object* obj = dynamic_cast<Object*>(this);
|
||||||
if(obj)
|
if(obj)
|
||||||
|
{
|
||||||
|
debug_printf(" ");
|
||||||
obj->Show(true);
|
obj->Show(true);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
debug_printf("\r\n");
|
debug_printf("\r\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -82,7 +82,7 @@ protected:
|
||||||
#include "Port.h"
|
#include "Port.h"
|
||||||
|
|
||||||
// 数据输出口
|
// 数据输出口
|
||||||
class DataOutputPort : public ByteDataPort
|
class DataOutputPort : public ByteDataPort, public Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OutputPort* Port;
|
OutputPort* Port;
|
||||||
|
@ -92,6 +92,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual int OnWrite(byte data) { Port->Write(data); return OnRead(); };
|
virtual int OnWrite(byte data) { Port->Write(data); return OnRead(); };
|
||||||
virtual byte OnRead() { return Port->Read() ? 1 : 0; };
|
virtual byte OnRead() { return Port->Read() ? 1 : 0; };
|
||||||
|
|
||||||
|
virtual String& ToStr(String& str) const { return Port->ToStr(str); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
15
Port.cpp
15
Port.cpp
|
@ -33,6 +33,21 @@ Port::~Port()
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String& Port::ToStr(String& str) const
|
||||||
|
{
|
||||||
|
str.SetAt(0, 'P');
|
||||||
|
if(_Pin == P0)
|
||||||
|
{
|
||||||
|
str.SetAt(1, '0');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str.SetAt(1, 'A' + (_Pin >> 4));
|
||||||
|
str.Append(_Pin & 0x0F);
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
// 单一引脚初始化
|
// 单一引脚初始化
|
||||||
Port& Port::Set(Pin pin)
|
Port& Port::Set(Pin pin)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue