16
16
17
17
#include < modm/architecture/interface/delay.hpp>
18
18
#include < modm/architecture/interface/register.hpp>
19
- // #include <modm/platform/gpio/base.hpp> ???
20
19
#include < modm/processing/resumable.hpp>
21
20
22
21
#include < modm/ui/graphic/display.hpp>
30
29
#include " ili9341_interface_parallel.hpp"
31
30
#include " ili9341_interface_spi.hpp"
32
31
33
- using namespace modm ::shape;
34
- using namespace modm ::color;
35
- using namespace modm ::graphic;
36
32
namespace modm
37
33
{
38
34
39
35
// / @ingroup modm_driver_ili9341
40
36
41
- template <class Interface , class Reset , size_t BC = 512 >
37
+ template <class Transport , class Reset , size_t BC = 512 >
42
38
// requires std::derived_from<Painter, RemotePainter<R>>
43
- class Ili9341 : public Interface ,
44
- public Display<color::Rgb565, Size (320 , 240 ), true >
39
+ class Ili9341 : public Transport , public graphic ::Display<color::Rgb565, shape::Size (320 , 240 ), true >
45
40
{
46
41
// OPTIMIZE determine good contraints
47
42
static_assert (BC >= 32 , " Conversion Buffer < 64 pixels produces too much overhead." );
48
- static_assert (BC <= 4096 , " Conversion Buffer > 4048 pixels doesn't make it better." );
43
+ static_assert (BC <= 2048 , " Conversion Buffer > 2048 pixels doesn't make it any better." );
49
44
50
45
using Toggle = ili9341_register::Toggle;
51
46
using ReadWrite = ili9341_register::ReadWrite;
52
47
using Command = ili9341_register::Command;
53
48
using ReadCommand = ili9341_register::ReadCommand;
54
49
55
50
public:
56
- using ColorType = Rgb565;
57
- using BufferLandscape = Buffer<Rgb565 , ResolutionVector>;
58
- using BufferPortrait = Buffer<Rgb565 , ResolutionVector.swapped()>;
51
+ using ColorType = color:: Rgb565;
52
+ using BufferLandscape = graphic:: Buffer<ColorType , ResolutionVector>;
53
+ using BufferPortrait = graphic:: Buffer<ColorType , ResolutionVector.swapped()>;
59
54
60
55
ColorType color;
61
56
ColorType* colormap;
62
57
63
58
template <typename ... Args>
64
59
Ili9341 (Args &&...args)
65
- : Interface (std::forward<Args>(args)...)
60
+ : Transport (std::forward<Args>(args)...)
66
61
{ Reset::setOutput (modm::Gpio::High); }
67
62
68
63
~Ili9341 (){};
69
64
70
- modm:: ResumableResult<void >
65
+ ResumableResult<void >
71
66
initialize ();
72
67
73
- modm:: ResumableResult<void >
68
+ ResumableResult<void >
74
69
reset (bool hardReset = false );
75
70
76
- modm:: ResumableResult<uint16_t >
71
+ ResumableResult<uint16_t >
77
72
getIcModel ();
78
73
79
- /* modm:: ResumableResult<uint32_t>
74
+ /* ResumableResult<uint32_t>
80
75
getStatus(); // 5 bytes, Datasheet P92
81
76
82
- modm:: ResumableResult<uint16_t>
77
+ ResumableResult<uint16_t>
83
78
getPowerMode(); // 2 bytes, Datasheet P94
84
79
85
- modm:: ResumableResult<uint16_t>
80
+ ResumableResult<uint16_t>
86
81
getMadCtl(); // 2 bytes, Datasheet P95
87
82
88
- modm:: ResumableResult<uint16_t>
83
+ ResumableResult<uint16_t>
89
84
getPixelFormat(); // 2 bytes, Datasheet P96 */
90
85
91
- modm:: ResumableResult<void >
86
+ ResumableResult<void >
92
87
set (Toggle toggle, bool state);
93
88
94
- modm:: ResumableResult<void >
89
+ ResumableResult<void >
95
90
set (ReadWrite reg, uint8_t value);
96
91
97
- modm:: ResumableResult<uint8_t >
92
+ ResumableResult<uint8_t >
98
93
get (ReadWrite reg);
99
94
100
- modm:: ResumableResult<void >
101
- setOrientation (Orientation orientation);
95
+ ResumableResult<void >
96
+ setOrientation (graphic:: Orientation orientation);
102
97
103
- modm:: ResumableResult<void >
98
+ ResumableResult<void >
104
99
setScrollArea (uint16_t topFixedRows, uint16_t firstRow, uint16_t bottomFixedRows);
105
100
106
- modm:: ResumableResult<void >
101
+ ResumableResult<void >
107
102
scrollTo (uint16_t row);
108
103
109
- template <ColorPattern P>
110
- modm:: ResumableResult<void >
111
- writePattern (Rectangle rectangle, P pattern);
104
+ template <graphic:: ColorPattern P>
105
+ ResumableResult<void >
106
+ writePattern (shape:: Rectangle rectangle, P pattern);
112
107
113
- modm:: ResumableResult<void >
114
- clear (ColorType color = html::Black );
108
+ ResumableResult<void >
109
+ clear (ColorType color = 0 );
115
110
private:
116
111
// Static variables for resumable functions
117
- Section section;
118
- Point cursor;
112
+ shape:: Section section;
113
+ shape:: Point cursor;
119
114
// ##################################################################
120
115
121
116
protected:
122
- modm:: ResumableResult<void >
117
+ ResumableResult<void >
123
118
updateClipping ();
124
119
125
- modm:: ResumableResult<void >
126
- setClipping (Point point);
120
+ ResumableResult<void >
121
+ setClipping (shape:: Point point);
127
122
128
123
/* *
129
124
* Write Image with foreign Color
@@ -132,8 +127,8 @@ class Ili9341 : public Interface,
132
127
* @param placement Placement for the image
133
128
*/
134
129
template <Color CO, template <typename > class Accessor >
135
- modm:: ResumableResult<void >
136
- writeImage (ImageAccessor<CO, Accessor> accessor);
130
+ ResumableResult<void >
131
+ writeImage (graphic:: ImageAccessor<CO, Accessor> accessor);
137
132
138
133
/* *
139
134
* Write Image with same Color
@@ -142,16 +137,16 @@ class Ili9341 : public Interface,
142
137
* @param placement Placement for the image
143
138
*/
144
139
template <template <typename > class Accessor >
145
- modm:: ResumableResult<void >
146
- writeImage (ImageAccessor<ColorType, Accessor> accessor);
140
+ ResumableResult<void >
141
+ writeImage (graphic:: ImageAccessor<ColorType, Accessor> accessor);
147
142
148
- modm:: ResumableResult<void > drawBlind (const Point & point);
149
- modm:: ResumableResult<void > drawBlind (const Section& section);
150
- modm:: ResumableResult<void > drawBlind (const HLine& hline);
151
- modm:: ResumableResult<void > drawBlind (const VLine& vline);
143
+ ResumableResult<void > drawBlind (const shape:: Point & point);
144
+ ResumableResult<void > drawBlind (const shape:: Section& section);
145
+ ResumableResult<void > drawBlind (const shape:: HLine& hline);
146
+ ResumableResult<void > drawBlind (const shape:: VLine& vline);
152
147
153
- modm:: ResumableResult<Rgb565 >
154
- getBlind (const Point & point) const ;
148
+ ResumableResult<ColorType >
149
+ getBlind (const shape:: Point & point) const ;
155
150
156
151
private:
157
152
// Static variables for resumable functions
@@ -168,14 +163,14 @@ class Ili9341 : public Interface,
168
163
{
169
164
uint16_t buff_cmd_clipping[2 ];
170
165
171
- Rgb565 buffer[BC]; // Conversion buffer
166
+ ColorType buffer[BC]; // Conversion buffer
172
167
size_t i; // index in conversion buffer
173
168
Point scanner; // index on display
174
169
175
- size_t pixels; // Number of remaining pixels of transaction
170
+ uint64_t pixels; // Must fit R.x * R.y = 76800
176
171
size_t pixels_bulk; // Number of pixels of current bulk
177
172
178
- Rgb565 temp_color; // Temporary storage for a color
173
+ ColorType temp_color; // Temporary storage for a color
179
174
} p; // p for parallel
180
175
};
181
176
};
0 commit comments