Vivoe Lite 0.5.0
Lightweight GVA like HMI for military displays.
Loading...
Searching...
No Matches
screen_gva.h
Go to the documentation of this file.
1//
2// Copyright (c) 2023, DefenceX PTY LTD
3//
4// This file is part of the VivoeX project developed by DefenceX.
5//
6// Licensed under the Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
7// License. See the LICENSE file in the project root for full license details.
8//
13
14#ifndef HMICORE_SCREEN_GVA_H_
15#define HMICORE_SCREEN_GVA_H_
16#include <cairo.h>
17#include <pthread.h>
18
19#include <map>
20#include <memory>
21#include <string>
22
23#include "hmicore/gva.h"
25#include "nmea/nmea.h"
26#include "updater/updater.h"
27#include "widgets/table/table.h"
28#include "widgets/widget.h"
30#include "widgets/widgets.h"
31
32namespace gva {
33
35struct Canvas {
37 bool visible;
39 unsigned char *buffer;
41 cairo_surface_t *surface;
43 bool blackout = false;
44};
45
47struct Label {
49 bool visible;
51 std::string text;
53 uint32_t x;
55 uint32_t y;
57 uint32_t fontSize;
58};
59
61struct Message {
63 bool visible;
65 uint32_t width;
69 struct {
71 std::string text;
73 uint32_t fontSize;
76 struct {
78 std::string text;
80 uint32_t fontSize;
82};
83
114
115class ScreenGva;
116
118struct ClockArgs {
120 std::string clock_string;
122 std::string location_format;
124 std::string location_string;
128 int *gps;
130 nmeaINFO *info;
132 nmeaPARSER *parser;
134 bool active;
136 std::shared_ptr<WidgetStatusBar> status_bar;
139};
140
142class ScreenGva : public RendererGva {
143 public:
151 ScreenGva(Screen *screen, uint32_t width, uint32_t height);
152
159 ScreenGva &operator=(const ScreenGva &a) = delete;
160
166 ScreenGva(const ScreenGva &Other) = default;
167
172 ~ScreenGva() final;
173
180
186 void StartClock(std::shared_ptr<WidgetX> status_bar_widget);
187
193 void ResetWidgets() const;
194
201 WidgetX *GetWidget(widget::WidgetEnum widget);
202
209 static void ClockUpdateThread(ClockArgs *arg);
210
216
217 private:
225 char *PosDegrees(float lon, float lat);
226
228 Screen *screen_ = nullptr;
230 std::map<widget::WidgetEnum, std::shared_ptr<WidgetX>> widget_list_;
232 int gps_ = 0;
234 uint32_t handle_;
236 Screen last_screen_;
238 std::thread clock_thread_;
240 nmeaINFO info_;
242 nmeaPARSER parser_;
244 ConfigData *config_ = nullptr;
246 Updater updater_ = Updater(0);
247};
248
249} // namespace gva
250
251#endif // HMICORE_SCREEN_GVA_H_
Class definition of the CommonTaskKeys.
Definition gva.h:465
Class defining the config data.
Definition config_reader.h:256
These are the labels on the left and right of the screen.
Definition gva.h:324
Class definition of the GVA renderer.
Definition renderer_gva.h:29
Class definition of the ScreenGva.
Definition screen_gva.h:142
~ScreenGva() final
Definition screen_gva.cc:152
WidgetX * GetWidget(widget::WidgetEnum widget)
Definition screen_gva.cc:224
GvaStatusTypes Update()
Definition screen_gva.cc:189
void ResetWidgets() const
Definition screen_gva.cc:217
ScreenGva(const ScreenGva &Other)=default
Construct a new Screen Gva object.
void StartClock(std::shared_ptr< WidgetX > status_bar_widget)
Definition screen_gva.cc:172
ScreenGva & operator=(const ScreenGva &a)=delete
Construct a new Screen Gva object.
static void ClockUpdateThread(ClockArgs *arg)
Definition screen_gva.cc:161
static ClockArgs args_
The arguments for the clock thread.
Definition screen_gva.h:215
Class defining the updater.
Definition updater.h:27
Class defining the base widget.
Definition widget.h:27
GvaFunctionEnum
This is where you define all your screens, these are just the defaults.
Definition gva.h:218
LabelModeEnum
Enum for the label mode.
Definition gva.h:39
ScreenMode
Enum for the screen mode.
Definition gva.h:37
GvaStatusTypes
HMI erro types, can be extended if needed.
Definition gva.h:186
Struct definition of the Canvas.
Definition screen_gva.h:35
cairo_surface_t * surface
The cairo surface.
Definition screen_gva.h:41
bool blackout
Set if in blackout mode.
Definition screen_gva.h:43
bool visible
flag indicating if the canvas is visible
Definition screen_gva.h:37
unsigned char * buffer
A pointer to the buffer.
Definition screen_gva.h:39
The clock arguments.
Definition screen_gva.h:118
LocationType location
The location type.
Definition screen_gva.h:138
nmeaINFO * info
NMEA info.
Definition screen_gva.h:130
int * gps
GPS handle.
Definition screen_gva.h:128
bool active
true if active
Definition screen_gva.h:134
std::string location_format
Location string format.
Definition screen_gva.h:122
std::string location_string
Location string.
Definition screen_gva.h:124
nmeaPARSER * parser
NMEA parser.
Definition screen_gva.h:132
ScreenGva * screen
The screen to update.
Definition screen_gva.h:126
std::shared_ptr< WidgetStatusBar > status_bar
The status bar widget.
Definition screen_gva.h:136
std::string clock_string
Clock string.
Definition screen_gva.h:120
These are at the top of the screen.
Definition gva.h:386
Struct definition of the Labels.
Definition screen_gva.h:47
std::string text
Label text.
Definition screen_gva.h:51
uint32_t x
The label X position in pixels.
Definition screen_gva.h:53
uint32_t y
The label Y position in pixels.
Definition screen_gva.h:55
uint32_t fontSize
The label font size.
Definition screen_gva.h:57
bool visible
Label is visible.
Definition screen_gva.h:49
Enum for the location type.
Definition gva.h:543
Struct definition of the Message.
Definition screen_gva.h:61
struct gva::Message::@0 brief
The brief message.
struct gva::Message::@1 detail
The detail message.
widget::IconType icon
The icon to display instead of text.
Definition screen_gva.h:67
uint32_t width
The message X position in pixels.
Definition screen_gva.h:65
bool visible
Message is visible.
Definition screen_gva.h:63
Struct definition of the Screen.
Definition screen_gva.h:85
struct gva::Screen::@2 info
Screen information.
Message message
The message if any.
Definition screen_gva.h:110
FunctionSelect * function_top
The function select widget.
Definition screen_gva.h:100
GvaFunctionEnum currentFunction
The current function.
Definition screen_gva.h:96
FunctionKeys function_left
The function select widget.
Definition screen_gva.h:104
CommonTaskKeys * control
The function select widget.
Definition screen_gva.h:102
FunctionKeys function_right
The function select widget.
Definition screen_gva.h:106
LabelModeEnum labels
The label enum.
Definition screen_gva.h:112
Canvas canvas
The canvas.
Definition screen_gva.h:98
Label label
The labels.
Definition screen_gva.h:108
Manage the touch screen events.
IconType
All available types of icon.
Definition widget_types.h:83