Sygaldry
Loading...
Searching...
No Matches
sygsr-button.hpp
1#pragma once
2/*
3Copyright 2023 Travis J. West, Input Devices and Music Interaction Laboratory
4(IDMIL), Centre for Interdisciplinary Research in Music Media and Technology
5(CIRMMT), McGill University, Montréal, Canada, and Univ. Lille, Inria, CNRS,
6Centrale Lille, UMR 9189 CRIStAL, F-59000 Lille, France
7
8SPDX-License-Identifier: MIT
9*/
10
11#include "sygsp-button.hpp"
12
13namespace sygaldry { namespace sygsr {
14
17
21
27template<unsigned int pin_number, sygsp::ButtonActive active_level = sygsp::ButtonActive::Low>
29, name_<"Button">
30, description_<"A single button attached to a GPIO">
31, author_<"Travis J. West">
32, copyright_<"Copyright 2023 Sygaldry Contributors">
33, license_<"SPDX-License-Identifier: MIT">
34, version_<"0.0.0">
35{
36 static_assert(0 <= pin_number && pin_number <= 29);
37
38 void init()
39 {
40 gpio_init(pin_number);
41 gpio_set_dir(pin_number, false); // input mode
42 if constexpr (active_level == sygsp::ButtonActive::Low) gpio_pull_up(pin_number);
43 else gpio_pull_down(pin_number);
44 }
45
46 void operator()()
47 {
48 inputs.button_state = (char)gpio_get(pin_number) == (char)active_level;
49 ButtonGestureModel::operator()();
50 }
51};
52
55
56} }
Document the author of an entity, e.g. a component or binding.
Definition sygah-metadata.hpp:39
Document the copyright statement of an entity, e.g. a component or binding.
Definition sygah-metadata.hpp:47
Document a textual description of an entity, e.g. an endpoint, component or binding.
Definition sygah-metadata.hpp:35
Document the copyright license of an entity, e.g. a component or binding.
Definition sygah-metadata.hpp:45
Document the name of an entity, e.g. an endpoint, component, or binding.
Definition sygah-metadata.hpp:33
Component modelling gestures performed with a single bi-state push button.
Definition sygsp-button.hpp:40
Raspberry Pi Pico SDK Button Component.
Definition sygsr-button.hpp:35
Document a textual description of the version number of an entity, e.g. a component or binding.
Definition sygah-metadata.hpp:51