BuGUI
BUtton Grid User Interface
Loading...
Searching...
No Matches
hardware.hpp
1#pragma once
2#include "common.hpp"
3#include "components/init.hpp"
4#include "components/clear.hpp"
5#include "components/grid.hpp"
6#include "components/buttons.hpp"
7
8namespace bugui
9{
13template <typename Device, typename Controller>
14struct hardware final
15 : virtual init<Device>
16 , virtual clear<Device>
17 , grid<Device, Controller>
18 , buttons<Device, Controller>
19{
20 explicit hardware(Controller* ctrlr)
21 : common<Controller>{ctrlr}
22 { }
23
24 ~hardware() { reset(); }
25
26 void setup() override
27 {
28 if constexpr(has_init<Device>)
30
31 if constexpr(has_grid<Device>)
33 this->grid<Device, Controller>::component_setup();
34
35 if constexpr(has_buttons<Device>)
37 this->buttons<Device, Controller>::component_setup();
38
39 reset();
40 };
41
42 void reset() override
43 {
44 if constexpr(has_clear<Device>)
46
47 if constexpr(has_clear<Device>)
49 this->grid<Device, Controller>::component_reset();
50
51 if constexpr(has_buttons<Device>)
53 this->buttons<Device, Controller>::component_reset();
54 }
55};
56
57} // namespace bugui
Definition device.hpp:31
Definition device.hpp:41
Definition device.hpp:22
Definition device.hpp:34
Empty struct for devices or componants that do not provide a command to clear all feedback (LED's,...
Definition clear.hpp:10
Inherits from all type of hardware components like grid, buttons... Provides the hardware type with t...
Definition common.hpp:13
void setup() override
Sends any preliminary commands needed by the device ie. initialising to a particular mode like XY (La...
Definition hardware.hpp:26
void reset() override
Turns off all diplays (LEDs, screens, visual feedback).
Definition hardware.hpp:42
Empty struct for devices that do not provide an initialisation command.
Definition init.hpp:10