SatNOGS-COMMS  4.1.0
A COMMS subsystem for CubeSats
Loading...
Searching...
No Matches
antenna_gpio.hpp
Go to the documentation of this file.
1/*
2 * SatNOGS-COMMS control library
3 *
4 * Copyright (C) 2025, Libre Space Foundation <http://libre.space>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * SPDX-License-Identifier: GNU General Public License v3.0 or later
20 */
21
22#pragma once
23
24#include <initializer_list>
27
28namespace satnogs::comms::lib
29{
30
44template <uint32_t N> class antenna_gpio : public antenna
45{
46public:
51 class elem_io
52 {
53 public:
56 };
57
64 antenna_gpio(const char *name, const elem_io (&&io)[N])
65 : antenna(name, N), m_elems(std::move(io))
66 {
67 static_assert(N > 0, "At least one IO configuration should be set");
68 }
69
70 bool
71 detect(uint32_t idx) override
72 {
73 if (idx > N - 1) {
74 throw inval_arg_exception(__FILE__, __LINE__);
75 }
76 return m_elems[idx].sense.get();
77 }
78
79 void
80 deploy(uint32_t idx, bool en) override
81 {
82 if (idx > N - 1) {
83 throw inval_arg_exception(__FILE__, __LINE__);
84 }
85 m_elems[idx].deploy.set(en);
86 }
87
88private:
89 const elem_io m_elems[N];
90};
91
93} // namespace satnogs::comms::lib
Specifies the deploy and the sensing GPIO.
bool detect(uint32_t idx) override
Returns antenna deployment status.
void deploy(uint32_t idx, bool en) override
Deploy the antenna.
antenna_gpio(const char *name, const elem_io(&&io)[N])
Construct a new antenna_gpio object.
antenna(const char *name, uint32_t nelems)
Construct a new generic antenna object.
Definition antenna.cpp:34
const char * name() const
Retrieves the name of the antenna.
Definition antenna.cpp:89
GPIO device abstraction.
Definition gpio.hpp:38
Generic exception indicating an invalid argument.