BuGUI
BUtton Grid User Interface
Loading...
Searching...
No Matches
init.hpp
1#pragma once
2#include <bugui/hardware/protocol/protocol.hpp>
3#include <bugui/concepts/device.hpp>
4
5namespace bugui
6{
9template <typename T>
10struct init { };
11
14template <has_init Device>
15struct init<Device>
16 : virtual protocol<component<Device, class Device::init>>
17{
18protected:
19 void component_setup()
20 {
21 this->send([](auto& formater)
22 {
23 if constexpr
24 (array_like<decltype(Device::init::message())>)
25 for (const auto& m : Device::init::message())
26 formater.add(m);
27 else
28 formater.add(Device::init::message());
29 });
30 }
31};
32
35template <init_component Component>
36struct init<Component>
37 : virtual protocol<Component>
38{
39protected:
40 void component_setup()
41 {
42 this->send([](auto& formater)
43 {
44 if constexpr
45 (array_like<decltype(Component::init_t::message())>)
46 for (const auto& m : Component::init_t::message())
47 formater.add(m);
48 else
49 formater.add(Component::init_t::message());
50 });
51 }
52};
53
54} // namespace bugui
Definition common.hpp:26
Empty struct for devices that do not provide an initialisation command.
Definition init.hpp:10
Inherits from different protocols, depending on the device's specification.
Definition protocol.hpp:13