21 lines
418 B
C++
21 lines
418 B
C++
#pragma once
|
|
|
|
#include <TinySensor.h>
|
|
#include <RCSwitch.h>
|
|
|
|
#define ID(value) (value & 0x1F)
|
|
#define STATE(value) ((value & 0x1) << 5)
|
|
#define VCC(value) ((value & 0x1FFF) << 6)
|
|
|
|
class ContactSensor: public TinySensor {
|
|
|
|
public:
|
|
ContactSensor(short id, short senderPin) :
|
|
TinySensor(id, senderPin) {
|
|
}
|
|
|
|
void sendStateAndVoltage(bool state) {
|
|
sendInfo(ID(id) | VCC(readVcc()) | STATE(!state) | TYPE(7));
|
|
}
|
|
};
|