SpaIot Library
Loading...
Searching...
No Matches
button.h
1/*
2 SpaIot Library (c) by epsilonrt - epsilonrt@epsilonrt.fr
3 This file is part of SpaIot library <https://github.com/epsilonrt/spaiot-lib>
4
5 SPDX-License-Identifier: BSD-3-Clause
6
7 SpaIot library is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY;
9*/
10#pragma once
11
12#include "buttonsettings.h"
13#include "buttoncontroller.h"
14#include "multiplexer.h"
15#include "pcf8574mux.h"
16
17namespace SpaIot {
18
26 class Button {
27
28 public:
33
37 virtual ~Button();
38
43
47 Button (const Button &other);
48
53 Button (Button &&other);
54
58 Button &operator= (const Button &other);
59
65
70 void clear();
71
75 bool isNull() const;
76
80 bool isEmpty() const;
81
85 bool operator== (const Button &other) const;
86
90 bool operator!= (const Button &other) const;
91
95 int id() const;
96
100 const ButtonController &ctrl() const;
101
106
110 const ButtonSettings &settings() const;
111
115 void begin();
116
120 void press();
121
125 void release();
126
130 void push();
131
135 bool isOpen() const;
136
140 bool isPressed() const;
141
142 protected:
143 class Private;
144 Button (Private &dd);
145 std::unique_ptr<Private> d_ptr;
146 private:
147 PIMPL_DECLARE_PRIVATE (Button)
148 };
149}
This class is the base class of all button controllers.
Definition buttoncontroller.h:26
This class represents a button.
Definition button.h:26
void release()
Releases the button.
Button(const ButtonSettings &settings)
The constructor for the Button class with settings.
bool isPressed() const
Checks if the button is pressed.
void push()
Presses and releases the button, HoldPressedMs milliseconds is the time the button is pressed.
ButtonController & ctrl()
Returns the button controller used by the button.
const ButtonSettings & settings() const
Returns the settings of the button.
int id() const
Returns the button identification key in the possible values of SpaIot::Key.
bool isEmpty() const
Checks if all attributes are set to their default values (same as the default constructor)
Button & operator=(const Button &other)
Sets the Button object to be equal to other.
const ButtonController & ctrl() const
Returns the button controller used by the button.
bool operator!=(const Button &other) const
Checks if the two objects are not equal.
virtual ~Button()
Destructor.
Button(const Button &other)
Copy Constructor.
Button(Button &&other)
Move Constructor after the move, other is null, other.clear() must be called if it is to be used agai...
bool operator==(const Button &other) const
Checks if the two objects are equal.
bool isOpen() const
Checks if the button is opened.
Button()
The default constructor.
bool isNull() const
Returns true if the object is null (i.e. it has not been initialized, d_ptr is null)
void begin()
Initializes the button, if its controller is not initialized, it is initialized.
void press()
Presses the button, it is not released automatically.
void clear()
Clears the Button object After the call to this function, the Button object is the same as one that h...
This class represents the settings of a button.
Definition buttonsettings.h:27
SpaIot name space.
Definition bussettings.h:15