class::ev::PinButton

class ev::PinButton
  : public ev::Button
  : public hal::Pin

This class implements a button using a hal::Pin object.

This class samples the pin during the ui::EventLoop. If the ui::EventLoop is sluggish at times, the button presses might not be responsive (or may be missed).

If this is the case, it is better to use DeviceButton because DeviceButton samples in the the background and will queue button presses if the ui::EventLoop is being slow.

Members

PinButton(

const arg::PortNumber port,
const arg::PinNumber pin,
const arg::IsPinActiveHigh is_active_high
)

bool active_value() const
virtual enum ev::Event::button_id event_id() const
virtual bool get_actuated()
virtual chrono::MicroTime get_duration()
virtual bool get_held()
virtual bool get_pressed()
virtual bool get_released()
virtual bool is_active() const
virtual void reset()
void set_event_id(

enum ev::Event::button_id v
)

static const chrono::MicroTime & actuation_duration()
static chrono::MicroTime held_duration()
static void set_actuation_duration(

const chrono::MicroTime & duration
)

static void set_held_duration(

const chrono::MicroTime & duration
)

protected virtual bool get_is_active() const
protected virtual void update()

Details

PinButton(

const arg::PortNumber port,
const arg::PinNumber pin,
const arg::IsPinActiveHigh is_active_high
)

Construct a new ButtonPin

The pin must be initialized using Pin::init()


bool active_value() const

Accesses the active value.

Returns

True for active high and false for active low.


virtual enum ev::Event::button_id event_id() const

Access the event ID of the button


virtual bool get_actuated()

Returns true if the button was pressed then released This will return true only once per button press.


virtual chrono::MicroTime get_duration()

Returns the duration of the last button press. This method will only return a non-zero value once per button press.


virtual bool get_held()

Returns true if the button has been held for the specified duration This will only return true once per button press.


virtual bool get_pressed()

Returns true if the button has been pressed. This will only return true once per button press.


virtual bool get_released()

Returns true if the button has been released. This will only return true one time for each button press.


virtual bool is_active() const

Returns true if the button is currently in the active state. The active state is updated each time Button::update() is called.


virtual void reset()

Reset the state of the button


void set_event_id(

enum ev::Event::button_id v
)

Sets the ID of the button for Events


static const chrono::MicroTime & actuation_duration()

Returns the actuation duration (amount of time button is pressed before triggering an acutation.


static chrono::MicroTime held_duration()

Accesses how long the user must hold the button in the application before the ui::Event::BUTTON_HELD is triggered when calling event()

Returns

The duration in milliseconds


static void set_actuation_duration(

const chrono::MicroTime & duration
)

Sets the duration of a button press before a actuation is trigger.

This can be used to debounce the button.


static void set_held_duration(

const chrono::MicroTime & duration
)

Sets the duration of the hold event.


protected virtual bool get_is_active() const

protected virtual void update()

This will update the state of the button. This method should be called periodically.


X

Thanks for Coming!

Subscribe to news and updates