diff --git a/Alarm.h b/Alarm.h index eaa799b5..1ffcd3eb 100644 --- a/Alarm.h +++ b/Alarm.h @@ -13,7 +13,7 @@ class Alarm: public Link { ~Alarm() { } public: - bool asyn :1; + bool asyn; uint32_t tick; virtual void trigger(AlarmClock&) = 0; diff --git a/Button.h b/Button.h index 2e942a13..22491463 100644 --- a/Button.h +++ b/Button.h @@ -24,8 +24,8 @@ class Button: public Alarm { }; protected: - uint8_t stat :3; - uint8_t repeat :5; + uint8_t stat; + uint8_t repeat; uint8_t pin; public: diff --git a/Channel.h b/Channel.h index 3afccdc8..8064349b 100644 --- a/Channel.h +++ b/Channel.h @@ -8,15 +8,15 @@ namespace as { class Device; -class ActionMsg; +class ActionSetMsg; class RemoteEventMsg; template class Channel { Device* dev; - bool change : 1; // the status is changed, we may need to send a status - uint8_t num : 3; // max 7 channels per device - uint16_t addr : 12; // max address 4095 + bool change; // the status is changed, we may need to send a status + uint8_t num ; // channels per device + uint16_t addr ; // start address in eeprom public: typedef List1Type List1; @@ -147,7 +147,7 @@ class Channel { return List4Type::size() > 0; } - bool process (const ActionMsg& msg) { + bool process (const ActionSetMsg& msg) { return true; } diff --git a/Message.h b/Message.h index 47086987..e1c1426f 100644 --- a/Message.h +++ b/Message.h @@ -31,7 +31,7 @@ class InfoPeerListMsg; class DeviceInfoMsg; class RemoteEventMsg; -class ActionMsg; +class ActionSetMsg; class Message { public: @@ -260,7 +260,7 @@ class Message { const ConfigWriteIndexMsg& configWriteIndex () const { return *(ConfigWriteIndexMsg*)this; } const RemoteEventMsg& remoteEvent () const { return *(RemoteEventMsg*)this; } - const ActionMsg& action () const { return *(ActionMsg*)this; } + const ActionSetMsg& action () const { return *(ActionSetMsg*)this; } // cast to write message types AckMsg& ack () { return *(AckMsg*)this; } @@ -333,9 +333,9 @@ class RemoteEventMsg : public Message { bool isLong () const { return (command() & 0x40) == 0x40; } }; -class ActionMsg : public Message { +class ActionSetMsg : public Message { protected: - ActionMsg() {} + ActionSetMsg() {} public: uint8_t channel () const { return subcommand(); } uint8_t value () const { return *data(); } diff --git a/MultiChannelDevice.h b/MultiChannelDevice.h index ea06460c..9a989c59 100644 --- a/MultiChannelDevice.h +++ b/MultiChannelDevice.h @@ -172,7 +172,7 @@ class MultiChannelDevice : public Device { } else if( msg.type() == AS_MESSAGE_ACTION ) { if( msg.command() == AS_ACTION_SET ) { - const ActionMsg& pm = msg.action(); + const ActionSetMsg& pm = msg.action(); ChannelType& c = channel(pm.channel()); c.process(pm); sendAck(msg,c); diff --git a/SwitchChannel.h b/SwitchChannel.h index 862b5105..afad4b77 100644 --- a/SwitchChannel.h +++ b/SwitchChannel.h @@ -36,7 +36,7 @@ class SwitchChannel : public Channel 0; } // get timer count in 1/10s - uint32_t byteTimeCvt(uint8_t tTime) { + static uint32_t byteTimeCvt(uint8_t tTime) { + if( tTime == 0xff ) return 0xffffffff; const uint16_t c[8] = {1,10,50,100,600,3000,6000,36000}; return (uint16_t)(tTime & 0x1F) * c[tTime >> 5]; } // get timer count in 1/10s - uint32_t intTimeCvt(uint16_t iTime) { - if (iTime == 0) return 0; + static uint32_t intTimeCvt(uint16_t iTime) { + if (iTime == 0x00) return 0x00; + if (iTime == 0xffff) return 0xffffffff; uint8_t tByte; if ((iTime & 0x1F) != 0) { @@ -97,16 +127,16 @@ class SwitchStateMachine { jumpToTarget(lst); break; case AS_CM_ACTIONTYPE_TOGGLE_TO_COUNTER: - setState((counter & 0x01) == 0x01 ? AS_CM_JT_ON : AS_CM_JT_OFF, 0xffff); + setState((counter & 0x01) == 0x01 ? AS_CM_JT_ON : AS_CM_JT_OFF, DELAY_INFINITE); break; case AS_CM_ACTIONTYPE_TOGGLE_INVERSE_TO_COUNTER: - setState((counter & 0x01) == 0x00 ? AS_CM_JT_ON : AS_CM_JT_OFF, 0xffff); + setState((counter & 0x01) == 0x00 ? AS_CM_JT_ON : AS_CM_JT_OFF, DELAY_INFINITE); break; } } void status (uint8_t stat, uint16_t delay) { - setState( stat == 0 ? AS_CM_JT_OFF : AS_CM_JT_ON, delay ); + setState( stat == 0 ? AS_CM_JT_OFF : AS_CM_JT_ON, intTimeCvt(delay) ); } uint8_t status () const {