10 #include "ChannelList.h"
17 DEFREGISTER(RemoteReg1,CREG_LONGPRESSTIME,CREG_AES_ACTIVE,CREG_DOUBLEPRESSTIME)
18 class RemoteList1 :
public RegList1<RemoteReg1> {
20 RemoteList1 (uint16_t addr) : RegList1<RemoteReg1>(addr) {}
29 template<
class HALTYPE,
int PEERCOUNT,
class List0Type=List0,
class List1Type=RemoteList1>
45 uint8_t status ()
const {
49 uint8_t flags ()
const {
53 virtual void state(uint8_t s) {
54 DHEX(BaseChannel::number());
57 msg.init(this->device().nextcount(),this->number(),repeatcnt,(s==longreleased || s==longpressed),this->device().battery().low());
58 if( s == released || s == longreleased) {
60 this->device().sendPeerEvent(msg,*
this);
63 else if (s == longpressed) {
65 this->device().broadcastPeerEvent(msg,*
this);
69 uint8_t state()
const {
70 return Button::state();
73 bool pressed ()
const {
75 return s == Button::pressed || s == Button::debounce || s == Button::longpressed;
78 bool configChanged() {
80 uint16_t _longpressTime = 300 + (this->getList1().longPressTime() * 100);
82 setLongPressTime(millis2ticks(_longpressTime));
87 template<
class DeviceType,
int DownChannel,
int UpChannel>
98 if( dir < 0 ) dir = -1;
100 sysclock.cancel(*
this);
101 if( last != 0 && last != dir ) {
105 set(millis2ticks(400));
111 virtual void trigger (__attribute__((unused))
AlarmClock& clock) {
120 #define remoteISR(device,chan,pin) class device##chan##ISRHandler { \
122 static void isr () { device.channel(chan).irq(); } \
124 device.channel(chan).button().init(pin); \
125 if( digitalPinToInterrupt(pin) == NOT_AN_INTERRUPT ) \
126 enableInterrupt(pin,device##chan##ISRHandler::isr,CHANGE); \
128 attachInterrupt(digitalPinToInterrupt(pin),device##chan##ISRHandler::isr,CHANGE);
130 #define remoteChannelISR(chan,pin) class __##pin##ISRHandler { \
132 static void isr () { chan.irq(); } \
134 chan.button().init(pin); \
135 if( digitalPinToInterrupt(pin) == NOT_AN_INTERRUPT ) \
136 enableInterrupt(pin,__##pin##ISRHandler::isr,CHANGE); \
138 attachInterrupt(digitalPinToInterrupt(pin),__##pin##ISRHandler::isr,CHANGE);