libstp
Robotics library for Botball
Loading...
Searching...
No Matches
button.hpp
Go to the documentation of this file.
1
//
2
// Created by eternalRose on 11/17/25.
3
//
4
5
#pragma once
6
7
#ifdef SAFETY_CHECKS_ENABLED
8
#include <set>
9
#endif
10
#include <memory>
11
#include "
hal/Digital.hpp
"
12
13
namespace
libstp::button
{
14
16
class
Button
final {
17
public
:
19
static
Button
&
instance
();
20
21
// Set up the digital sensor using a port number (creates the sensor internally).
22
void
setDigital
(
int
port);
23
// Share an already-created sensor instance (e.g. the one from robot
24
// defs). The dynamic type is preserved, so a ButtonGroup keeps its
25
// OR-over-ports behaviour — no copy, no reconstruction.
26
void
setDigital
(std::shared_ptr<hal::digital::DigitalSensor> sensor);
27
29
bool
isPressed
()
const
;
30
32
void
waitForButtonPress
()
const
;
33
34
Button
(
const
Button
&) =
delete
;
35
Button
&
operator=
(
const
Button
&) =
delete
;
36
Button
(
Button
&&) =
delete
;
37
Button
&
operator=
(
Button
&&) =
delete
;
38
39
private
:
40
Button
() =
default
;
41
~Button
();
42
43
std::shared_ptr<hal::digital::DigitalSensor> digital_sensor_;
44
};
45
}
// namespace libstp::button
Digital.hpp
libstp::button::Button::isPressed
bool isPressed() const
libstp::button::Button::operator=
Button & operator=(const Button &)=delete
libstp::button::Button::Button
Button(const Button &)=delete
libstp::button::Button::operator=
Button & operator=(Button &&)=delete
libstp::button::Button::setDigital
void setDigital(std::shared_ptr< hal::digital::DigitalSensor > sensor)
libstp::button::Button::waitForButtonPress
void waitForButtonPress() const
libstp::button::Button::Button
Button(Button &&)=delete
libstp::button::Button::setDigital
void setDigital(int port)
libstp::button::Button::instance
static Button & instance()
libstp::button
Definition
button.hpp:13
modules
libstp-button
include
button
button.hpp
Generated by
1.15.0