@@ -125,68 +125,68 @@ class Gc9a01 {
125
125
}
126
126
127
127
// init the display
128
- auto init_commands = std::to_array<display_drivers::LcdInitCmd <>>({
129
- {0xEF , { 0 }, 0 },
130
- {0xEB , {0x14 }, 1 },
131
- {0xFE , { 0 }, 0 },
132
- {0xEF , { 0 }, 0 },
133
- {0xEB , {0x14 }, 1 },
134
- {0x84 , {0x40 }, 1 },
135
- {0x85 , {0xFF }, 1 },
136
- {0x86 , {0xFF }, 1 },
137
- {0x87 , {0xFF }, 1 },
138
- {0x88 , {0x0A }, 1 },
139
- {0x89 , {0x21 }, 1 },
140
- {0x8A , {0x00 }, 1 },
141
- {0x8B , {0x80 }, 1 },
142
- {0x8C , {0x01 }, 1 },
143
- {0x8D , {0x01 }, 1 },
144
- {0x8E , {0xFF }, 1 },
145
- {0x8F , {0xFF }, 1 },
146
- {0xB6 , {0x00 , 0x20 }, 2 },
128
+ auto init_commands = std::to_array<display_drivers::DisplayInitCmd <>>({
129
+ {0xEF },
130
+ {0xEB , {0x14 }},
131
+ {0xFE },
132
+ {0xEF },
133
+ {0xEB , {0x14 }},
134
+ {0x84 , {0x40 }},
135
+ {0x85 , {0xFF }},
136
+ {0x86 , {0xFF }},
137
+ {0x87 , {0xFF }},
138
+ {0x88 , {0x0A }},
139
+ {0x89 , {0x21 }},
140
+ {0x8A , {0x00 }},
141
+ {0x8B , {0x80 }},
142
+ {0x8C , {0x01 }},
143
+ {0x8D , {0x01 }},
144
+ {0x8E , {0xFF }},
145
+ {0x8F , {0xFF }},
146
+ {0xB6 , {0x00 , 0x20 }},
147
147
// call orientation
148
- {0x36 , {madctl}, 1 },
149
- {0x3A , {0x05 }, 1 },
150
- {0x90 , {0x08 , 0x08 , 0X08 , 0X08 }, 4 },
151
- {0xBD , {0x06 }, 1 },
152
- {0xBC , {0x00 }, 1 },
153
- {0xFF , {0x60 , 0x01 , 0x04 }, 3 },
154
- {0xC3 , {0x13 }, 1 },
155
- {0xC4 , {0x13 }, 1 },
156
- {0xC9 , {0x22 }, 1 },
157
- {0xBE , {0x11 }, 1 },
158
- {0xE1 , {0x10 , 0x0E }, 2 },
159
- {0xDF , {0x21 , 0x0C , 0x02 }, 3 },
160
- {0xF0 , {0x45 , 0x09 , 0x08 , 0x08 , 0x26 , 0x2A }, 6 },
161
- {0xF1 , {0x43 , 0x70 , 0x72 , 0x36 , 0x37 , 0x6F }, 6 },
162
- {0xF2 , {0x45 , 0x09 , 0x08 , 0x08 , 0x26 , 0x2A }, 6 },
163
- {0xF3 , {0x43 , 0x70 , 0x72 , 0x36 , 0x37 , 0x6F }, 6 },
164
- {0xED , {0x1B , 0x0B }, 2 },
165
- {0xAE , {0x77 }, 1 },
166
- {0xCD , {0x63 }, 1 },
167
- {0x70 , {0x07 , 0x07 , 0x04 , 0x0E , 0x0F , 0x09 , 0x07 , 0X08 , 0x03 }, 9 },
168
- {0xE8 , {0x34 }, 1 },
169
- {0x62 , {0x18 , 0x0D , 0x71 , 0xED , 0x70 , 0x70 , 0x18 , 0X0F , 0x71 , 0xEF , 0x70 , 0x70 }, 12 },
170
- {0x63 , {0x18 , 0x11 , 0x71 , 0xF1 , 0x70 , 0x70 , 0x18 , 0X13 , 0x71 , 0xF3 , 0x70 , 0x70 }, 12 },
171
- {0x64 , {0x28 , 0x29 , 0xF1 , 0x01 , 0xF1 , 0x00 , 0x07 }, 7 },
172
- {0x66 , {0x3C , 0x00 , 0xCD , 0x67 , 0x45 , 0x45 , 0x10 , 0X00 , 0x00 , 0x00 }, 10 },
173
- {0x67 , {0x00 , 0x3C , 0x00 , 0x00 , 0x00 , 0x01 , 0x54 , 0X10 , 0x32 , 0x98 }, 10 },
174
- {0x74 , {0x10 , 0x85 , 0x80 , 0x00 , 0x00 , 0x4E , 0x00 }, 7 },
175
- {0x98 , {0x3E , 0x07 }, 2 },
176
- {0x35 , { 0 }, 0 },
177
- {0x21 , { 0 }, 0 },
178
- {0x11 , {0 }, 100 },
179
- {0x29 , {0 }, 100 },
148
+ {0x36 , {madctl}},
149
+ {0x3A , {0x05 }},
150
+ {0x90 , {0x08 , 0x08 , 0X08 , 0X08 }},
151
+ {0xBD , {0x06 }},
152
+ {0xBC , {0x00 }},
153
+ {0xFF , {0x60 , 0x01 , 0x04 }},
154
+ {0xC3 , {0x13 }},
155
+ {0xC4 , {0x13 }},
156
+ {0xC9 , {0x22 }},
157
+ {0xBE , {0x11 }},
158
+ {0xE1 , {0x10 , 0x0E }},
159
+ {0xDF , {0x21 , 0x0C , 0x02 }},
160
+ {0xF0 , {0x45 , 0x09 , 0x08 , 0x08 , 0x26 , 0x2A }},
161
+ {0xF1 , {0x43 , 0x70 , 0x72 , 0x36 , 0x37 , 0x6F }},
162
+ {0xF2 , {0x45 , 0x09 , 0x08 , 0x08 , 0x26 , 0x2A }},
163
+ {0xF3 , {0x43 , 0x70 , 0x72 , 0x36 , 0x37 , 0x6F }},
164
+ {0xED , {0x1B , 0x0B }},
165
+ {0xAE , {0x77 }},
166
+ {0xCD , {0x63 }},
167
+ {0x70 , {0x07 , 0x07 , 0x04 , 0x0E , 0x0F , 0x09 , 0x07 , 0X08 , 0x03 }},
168
+ {0xE8 , {0x34 }},
169
+ {0x62 , {0x18 , 0x0D , 0x71 , 0xED , 0x70 , 0x70 , 0x18 , 0X0F , 0x71 , 0xEF , 0x70 , 0x70 }},
170
+ {0x63 , {0x18 , 0x11 , 0x71 , 0xF1 , 0x70 , 0x70 , 0x18 , 0X13 , 0x71 , 0xF3 , 0x70 , 0x70 }},
171
+ {0x64 , {0x28 , 0x29 , 0xF1 , 0x01 , 0xF1 , 0x00 , 0x07 }},
172
+ {0x66 , {0x3C , 0x00 , 0xCD , 0x67 , 0x45 , 0x45 , 0x10 , 0X00 , 0x00 , 0x00 }},
173
+ {0x67 , {0x00 , 0x3C , 0x00 , 0x00 , 0x00 , 0x01 , 0x54 , 0X10 , 0x32 , 0x98 }},
174
+ {0x74 , {0x10 , 0x85 , 0x80 , 0x00 , 0x00 , 0x4E , 0x00 }},
175
+ {0x98 , {0x3E , 0x07 }},
176
+ {0x35 },
177
+ {0x21 },
178
+ {0x11 , {}, 100 },
179
+ {0x29 , {}, 100 },
180
180
});
181
181
182
182
// send the init commands
183
183
send_commands (init_commands);
184
184
185
185
// configure the display color configuration
186
186
if (config.invert_colors ) {
187
- write_command_ (static_cast <uint8_t >(Command::invon), nullptr , 0 , 0 );
187
+ write_command_ (static_cast <uint8_t >(Command::invon), {} , 0 );
188
188
} else {
189
- write_command_ (static_cast <uint8_t >(Command::invoff), nullptr , 0 , 0 );
189
+ write_command_ (static_cast <uint8_t >(Command::invoff), {} , 0 );
190
190
}
191
191
}
192
192
@@ -233,7 +233,7 @@ class Gc9a01 {
233
233
break ;
234
234
}
235
235
std::scoped_lock lock{spi_mutex_};
236
- write_command_ (static_cast <uint8_t >(Command::madctl), &data, 1 , 0 );
236
+ write_command_ (static_cast <uint8_t >(Command::madctl), { &data, 1 } , 0 );
237
237
}
238
238
239
239
/* *
@@ -265,7 +265,7 @@ class Gc9a01 {
265
265
* @param ye Ending y coordinate of the area.
266
266
*/
267
267
static void set_drawing_area (size_t xs, size_t ys, size_t xe, size_t ye) {
268
- uint8_t data[ 4 ] = { 0 } ;
268
+ std::array< uint8_t , 4 > data ;
269
269
270
270
int offset_x = 0 ;
271
271
int offset_y = 0 ;
@@ -281,14 +281,14 @@ class Gc9a01 {
281
281
data[1 ] = start_x & 0xFF ;
282
282
data[2 ] = (end_x >> 8 ) & 0xFF ;
283
283
data[3 ] = end_x & 0xFF ;
284
- write_command_ (static_cast <uint8_t >(Command::caset), data, 4 , 0 );
284
+ write_command_ (static_cast <uint8_t >(Command::caset), data, 0 );
285
285
286
286
// Set the row (y) start / end addresses
287
287
data[0 ] = (start_y >> 8 ) & 0xFF ;
288
288
data[1 ] = start_y & 0xFF ;
289
289
data[2 ] = (end_y >> 8 ) & 0xFF ;
290
290
data[3 ] = end_y & 0xFF ;
291
- write_command_ (static_cast <uint8_t >(Command::raset), data, 4 , 0 );
291
+ write_command_ (static_cast <uint8_t >(Command::raset), data, 0 );
292
292
}
293
293
294
294
/* *
@@ -311,7 +311,7 @@ class Gc9a01 {
311
311
} else {
312
312
set_drawing_area (area);
313
313
uint32_t size = lv_area_get_width (area) * lv_area_get_height (area);
314
- write_command_ (static_cast <uint8_t >(Command::ramwr), color_map, size * 2 , flags);
314
+ write_command_ (static_cast <uint8_t >(Command::ramwr), { color_map, size * 2 } , flags);
315
315
}
316
316
}
317
317
@@ -332,22 +332,22 @@ class Gc9a01 {
332
332
uint16_t color_data[max_bytes_to_send];
333
333
memset (color_data, color, max_bytes_to_send * sizeof (uint16_t ));
334
334
for (int i = 0 ; i < size; i += max_bytes_to_send) {
335
- int num_bytes = std::min (static_cast <int >(size - i), (int )(max_bytes_to_send));
336
- write_command_ (static_cast <uint8_t >(Command::ramwr), reinterpret_cast < uint8_t *>(color_data),
337
- num_bytes * 2 , 0 );
335
+ size_t num_bytes = std::min (static_cast <int >(size - i), (int )(max_bytes_to_send));
336
+ write_command_ (static_cast <uint8_t >(Command::ramwr),
337
+ { reinterpret_cast < uint8_t *>(color_data), num_bytes * 2 } , 0 );
338
338
}
339
339
}
340
340
341
341
/* *
342
342
* @brief Send the provided commands to the display controller.
343
343
* @param commands Array of display_drivers::LcdInitCmd structures.
344
344
*/
345
- static void send_commands (std::span<display_drivers::LcdInitCmd <>> commands) {
345
+ static void send_commands (std::span<const display_drivers::DisplayInitCmd <>> commands) {
346
346
using namespace std ::chrono_literals;
347
347
348
- for (const auto &[command, data, length , delay_ms] : commands) {
348
+ for (const auto &[command, parameters , delay_ms] : commands) {
349
349
std::scoped_lock lock{spi_mutex_};
350
- write_command_ (command, data, length , 0 );
350
+ write_command_ (command, parameters , 0 );
351
351
std::this_thread::sleep_for (delay_ms * 1ms);
352
352
}
353
353
}
0 commit comments