forked from iNavFlight/inav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
displayport_max7456.c
161 lines (134 loc) · 3.73 KB
/
displayport_max7456.c
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
* This file is part of Cleanflight.
*
* Cleanflight is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Cleanflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdbool.h>
#include <stdint.h>
#include "platform.h"
#ifdef USE_MAX7456
#include "common/utils.h"
#include "config/parameter_group.h"
#include "config/parameter_group_ids.h"
#include "drivers/display.h"
#include "drivers/max7456.h"
#include "drivers/vcd.h"
#include "io/displayport_max7456.h"
displayPort_t max7456DisplayPort;
static uint8_t max7456Mode(textAttributes_t attr)
{
uint8_t mode = 0;
if (TEXT_ATTRIBUTES_HAVE_BLINK(attr)) {
mode |= MAX7456_MODE_BLINK;
}
if (TEXT_ATTRIBUTES_HAVE_INVERTED(attr)) {
mode |= MAX7456_MODE_INVERT;
}
if (TEXT_ATTRIBUTES_HAVE_SOLID_BG(attr)) {
mode |= MAX7456_MODE_SOLID_BG;
}
return mode;
}
static int grab(displayPort_t *displayPort)
{
UNUSED(displayPort);
return 0;
}
static int release(displayPort_t *displayPort)
{
UNUSED(displayPort);
return 0;
}
static int clearScreen(displayPort_t *displayPort)
{
UNUSED(displayPort);
max7456ClearScreen();
return 0;
}
static int drawScreen(displayPort_t *displayPort)
{
UNUSED(displayPort);
max7456DrawScreenPartial();
return 0;
}
static int screenSize(const displayPort_t *displayPort)
{
UNUSED(displayPort);
return maxScreenSize;
}
static int writeString(displayPort_t *displayPort, uint8_t x, uint8_t y, const char *s, textAttributes_t attr)
{
UNUSED(displayPort);
max7456Write(x, y, s, max7456Mode(attr));
return 0;
}
static int writeChar(displayPort_t *displayPort, uint8_t x, uint8_t y, uint8_t c, textAttributes_t attr)
{
UNUSED(displayPort);
max7456WriteChar(x, y, c, max7456Mode(attr));
return 0;
}
static bool isTransferInProgress(const displayPort_t *displayPort)
{
UNUSED(displayPort);
return false;
}
static void resync(displayPort_t *displayPort)
{
UNUSED(displayPort);
max7456RefreshAll();
displayPort->rows = max7456GetRowsCount();
displayPort->cols = 30;
}
static int heartbeat(displayPort_t *displayPort)
{
UNUSED(displayPort);
return 0;
}
static uint32_t txBytesFree(const displayPort_t *displayPort)
{
UNUSED(displayPort);
return UINT32_MAX;
}
static textAttributes_t supportedTextAttributes(const displayPort_t *displayPort)
{
UNUSED(displayPort);
textAttributes_t attr = TEXT_ATTRIBUTES_NONE;
TEXT_ATTRIBUTES_ADD_INVERTED(attr);
TEXT_ATTRIBUTES_ADD_SOLID_BG(attr);
TEXT_ATTRIBUTES_ADD_BLINK(attr);
return attr;
}
static const displayPortVTable_t max7456VTable = {
.grab = grab,
.release = release,
.clearScreen = clearScreen,
.drawScreen = drawScreen,
.screenSize = screenSize,
.writeString = writeString,
.writeChar = writeChar,
.isTransferInProgress = isTransferInProgress,
.heartbeat = heartbeat,
.resync = resync,
.txBytesFree = txBytesFree,
.supportedTextAttributes = supportedTextAttributes,
};
displayPort_t *max7456DisplayPortInit(const vcdProfile_t *vcdProfile)
{
displayInit(&max7456DisplayPort, &max7456VTable);
max7456Init(vcdProfile);
resync(&max7456DisplayPort);
return &max7456DisplayPort;
}
#endif // USE_MAX7456