Sygaldry
Loading...
Searching...
No Matches
sygse-button.hpp
1#pragma once
2/*
3Copyright 2023 Travis J. West, https://traviswest.ca, 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#include "sygse-gpio.hpp"
13
14namespace sygaldry { namespace sygse {
19
20template<gpio_num_t pin_number, sygsp::ButtonActive active_level = sygsp::ButtonActive::Low>
21struct Button
22: name_<"Button">
23, author_<"Travis J. West">
24, copyright_<"Travis J. West (C) 2023">
25, description_<"A single button attached to a GPIO">
27{
28 using gpio = GPIO<pin_number>;
29
30 void init()
31 {
32 gpio::init();
33 gpio::input_mode();
34 if constexpr (active_level == sygsp::ButtonActive::Low) gpio::enable_pullup();
35 else gpio::enable_pulldown();
36 }
37
38 void operator()()
39 {
40 inputs.button_state = (char)gpio::level() == (char)active_level;
41 ButtonGestureModel::operator()();
42 }
43};
44
47} }
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 name of an entity, e.g. an endpoint, component, or binding.
Definition sygah-metadata.hpp:33
Definition sygse-button.hpp:27
Definition sygse-gpio.hpp:29
Component modelling gestures performed with a single bi-state push button.
Definition sygsp-button.hpp:40