-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtachometer.h
executable file
·112 lines (87 loc) · 2.43 KB
/
tachometer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#ifndef TACHOMETER_H
#define TACHOMETER_H
#include <QObject>
#include "qfuturewatcher.h"
#include <QPixmap>
#include <QGraphicsPixmapItem>
#include <QGraphicsScene>
#include <QGraphicsTextItem>
typedef enum tacho_range
{
PSA_TACHO_7K = 0,
PSA_TACHO_8K = 1,
} tacho_range_t;
typedef enum tacho_gear{
GEAR_R = -1,
GEAR_N = 0,
GEAR_1 = 1,
GEAR_2 = 2,
GEAR_3 = 3,
GEAR_4 = 4,
GEAR_5 = 5,
GEAR_6 = 6,
} tacho_gear_t;
class tachometer : public QObject
{
Q_OBJECT
public:
explicit tachometer(QObject *parent = nullptr);
explicit tachometer(tacho_range_t range, QObject *parent = nullptr);
~tachometer();
QGraphicsScene *get_scene();
void set_scale(float scale);
void set_rpm(int rpm);
void set_speed(float speed);
void set_gear(tacho_gear_t gear);
int get_rpm();
float get_scale();
QFutureWatcher<void> *speed_update_watcher;
QFutureWatcher<void> *rpm_update_watcher;
void set_speed_pos(int x,int y);
public slots:
void update_display();
void update_gear_display();
void set_gear(int gear);
void toggle_gear_up_display();
private:
int rpm;
float rpm_angle;
float speed; // 328, 290
QString speed_text;
tacho_range_t set_range;
int tacho_img_width;
int tacho_img_height;
int tacho_needle_offset_x;
int tacho_needle_offset_y;
int tacho_numbers_offset_x;
int tacho_numbers_offset_y;
float tacho_scale;
QPixmap *tacho_bg;
QPixmap *tacho_needle;
QPixmap *tacho_numbers;
QPixmap *gear_up_icon;
QFont *tacho_speed_font;
QFont *tacho_gear_font;
QGraphicsPixmapItem *tacho_bg_item;
QGraphicsPixmapItem *tacho_numbers_item;
QGraphicsPixmapItem *tacho_needle_item;
QGraphicsPixmapItem *gear_up_icon_item;
QGraphicsTextItem *tacho_speed_item;
QGraphicsTextItem *tacho_speed_bg_item;
QGraphicsTextItem *tacho_gear_item;
QGraphicsTextItem *tacho_gear_bg_item;
QGraphicsScene *scene;
float get_angle_from_rpm();
void create_tachometer(tacho_range_t range);
void create_tachometer_2(tacho_range_t range);
void set_speed_text(int speed);
void update_gear_up(int rpm);
enum tacho_gear old_gear = GEAR_R;
enum tacho_gear new_gear = GEAR_R;
bool gear_up_visible = false;
int gear_up_state = 0;
bool gear_up_grace = false; // If true, disable gear_up
QTimer *gear_timer;
QTimer *gear_up_blink_timer;
};
#endif // TACHOMETER_H