HiveMind
IUserInterface.h
Go to the documentation of this file.
1 #ifndef __IUSERINTERFACE_H_
2 #define __IUSERINTERFACE_H_
3 
4 #include <Mutex.h>
5 #include <cstdarg>
6 #include <cstdint>
7 
11 enum class RgbColor { RED = 0, GREEN, BLUE, VIOLET, TEAL, YELLOW, WHITE, OFF };
12 
16 enum class Button { BUTTON_0 = 0, BUTTON_1 };
17 constexpr uint16_t g_brButton = static_cast<uint16_t>(Button::BUTTON_1) + 1;
18 
22 enum class LED { LED_0 = 0, LED_1, LED_2 };
23 constexpr uint16_t g_nbrLED = static_cast<uint16_t>(LED::LED_2) + 1;
24 
28 typedef void (*buttonCallbackFunction_t)(void* instance);
29 
37  public:
38  virtual ~IUserInterface() = default;
39 
43  virtual Mutex& getPrintMutex() = 0;
44 
47  virtual void flush() = 0;
48 
59  virtual int print(const char* format, ...) = 0;
60 
71  virtual int print(const char* format, va_list args) = 0;
72 
82  virtual int printLine(const char* format, ...) = 0;
83 
94  virtual int printLine(const char* format, va_list args) = 0;
95 
100  virtual void setRGBLed(RgbColor color) = 0;
101 
107  virtual void setLed(LED led, bool state) = 0;
108 
113  virtual void setHexDisplay(uint8_t value) = 0;
114 
121  virtual void setButtonCallback(Button button,
122  buttonCallbackFunction_t callback,
123  void* context) = 0;
124 };
125 
126 #endif // __IUSERINTERFACE_H_
IUserInterface::flush
virtual void flush()=0
Adds a newline and flushes the input to the serial port.
IUserInterface::setButtonCallback
virtual void setButtonCallback(Button button, buttonCallbackFunction_t callback, void *context)=0
Sets the callback associated with a given button press.
Button::BUTTON_0
@ BUTTON_0
IUserInterface::printLine
virtual int printLine(const char *format,...)=0
Provides an interface to print a line to the console or serial port. Flushes the input and adds a new...
RgbColor::OFF
@ OFF
LED
LED
LED present on the board.
Definition: IUserInterface.h:22
LED::LED_0
@ LED_0
IUserInterface::setHexDisplay
virtual void setHexDisplay(uint8_t value)=0
Sets the hex display to a given 8 bit value (not available on the HiveSight)
RgbColor::YELLOW
@ YELLOW
Button
Button
Buttons present on the board.
Definition: IUserInterface.h:16
Button::BUTTON_1
@ BUTTON_1
g_nbrLED
constexpr uint16_t g_nbrLED
Definition: IUserInterface.h:23
IUserInterface::getPrintMutex
virtual Mutex & getPrintMutex()=0
get the mutex for printing. Note that the mutex is not used in any functions, the user needs to lock ...
RgbColor::RED
@ RED
RgbColor
RgbColor
Possible colors obtainable with an RGB LED.
Definition: IUserInterface.h:11
LED::LED_1
@ LED_1
RgbColor::GREEN
@ GREEN
RgbColor::VIOLET
@ VIOLET
LED::LED_2
@ LED_2
IUserInterface::setRGBLed
virtual void setRGBLed(RgbColor color)=0
Sets the RGB LED to a given color.
RgbColor::BLUE
@ BLUE
IUserInterface::~IUserInterface
virtual ~IUserInterface()=default
IUserInterface::print
virtual int print(const char *format,...)=0
Provides an interface to print to the console or serial port. The arguments and return values match t...
IUserInterface::setLed
virtual void setLed(LED led, bool state)=0
Sets an LED on or off.
IUserInterface
Manages the user interface The user interface can consist of buttons, LED, serial print ports,...
Definition: IUserInterface.h:36
g_brButton
constexpr uint16_t g_brButton
Definition: IUserInterface.h:17
RgbColor::TEAL
@ TEAL
buttonCallbackFunction_t
void(* buttonCallbackFunction_t)(void *instance)
Prototype for a callback from a button press.
Definition: IUserInterface.h:28
RgbColor::WHITE
@ WHITE