-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidget.h
More file actions
65 lines (53 loc) · 1.43 KB
/
widget.h
File metadata and controls
65 lines (53 loc) · 1.43 KB
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
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QTcpSocket>
#include <QTcpServer>
#include "ipc_helper.h"
#define HAL_DIS_DOTS_X (14)
#define HAL_DIS_DOTS_Y (8)
#define MID_DIS_DOTS_X (HAL_DIS_DOTS_X * 2)
#define MID_DIS_DOTS_Y (HAL_DIS_DOTS_Y * 2)
#define MID_DIS_BYTE_X ((MID_DIS_DOTS_X + 7) >> 3)
#define MID_DIS_BUFFER_SIZE (MID_DIS_BYTE_X * MID_DIS_DOTS_Y)
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = nullptr);
~Widget();
QSize sizeHint() const override {
return QSize(674, 386);
}
protected:
void paintEvent(QPaintEvent *) override;
private:
uint8_t g_drawCache[MID_DIS_BUFFER_SIZE];
uint8_t MID_LCD_CacheGetBit(uint32_t x, uint32_t y, uint8_t *cache)
{
uint32_t i;
uint8_t v;
i = y * MID_DIS_BYTE_X + x / 8;
v = (cache[i] & (1 << x % 8)) > 0 ? 1 : 0;
return v;
}
void MID_LCD_CachePrint(uint8_t *drawBuff)
{
uint32_t i, j;
for(i = 0; i < MID_DIS_DOTS_Y; i++)
{
for(j = 0; j < MID_DIS_DOTS_X; j++)
{
printf("%c ", MID_LCD_CacheGetBit(j, i, drawBuff) + 0x30);
}
printf("\r\n");
}
printf("\r\n");
}
public slots:
void socketRead(QTcpSocket *socket);
private:
QTcpServer *server_;
ipc::BinaryFormat message_;
};
#endif // WIDGET_H