Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class RemoteChannel : public Channel<Hal, RemoteList1, EmptyList, DefList4, PEERS_PER_RemoteChannel, SwList0>, public StateButton<LOW,HIGH,INPUT> {
- private:
- uint8_t repeatcnt;
- public:
- typedef Channel<Hal, RemoteList1, EmptyList, DefList4, PEERS_PER_RemoteChannel, SwList0> BaseChannel;
- RemoteChannel () : BaseChannel() {}
- virtual ~RemoteChannel () {}
- StateButton& button () {
- return *(StateButton*)this;
- }
- uint8_t status () const {
- return 0;
- }
- uint8_t flags () const {
- return 0;
- }
- virtual void state(uint8_t s) {
- DHEX(BaseChannel::number());
- StateButton::state(s);
- RemoteEventMsg& msg = (RemoteEventMsg&)this->device().message();
- DPRINT("BATTERY IS LOW? "); DDECLN(this->device().battery().low());
- msg.init(this->device().nextcount(), this->number(), repeatcnt, (s == longreleased || s == longpressed), this->device().battery().low());
- if ( s == released || s == longreleased) {
- this->device().sendPeerEvent(msg, *this);
- repeatcnt++;
- }
- else if (s == longpressed) {
- this->device().broadcastPeerEvent(msg, *this);
- }
- }
- uint8_t state() const {
- return StateButton::state();
- }
- bool pressed () const {
- uint8_t s = state();
- return s == StateButton::pressed || s == StateButton::debounce || s == StateButton::longpressed;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment