Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 49c6f35

Browse files
committed
fixed background display modify flush qrcode
1 parent 419e360 commit 49c6f35

File tree

1 file changed

+62
-26
lines changed
  • examples/get-started/ipslcd/components/lcd

1 file changed

+62
-26
lines changed

examples/get-started/ipslcd/components/lcd/lcd.c

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,11 @@ void lcd_clear(uint16_t color)
290290
}
291291

292292
void draw_qrcode(void)
293+
#if 0
293294
{
294295
uint32_t ofsbit = qrcode[0xd] << 24 | qrcode[0xc] << 16 | qrcode[0xb] << 8 | qrcode[0xa];
295-
size_t siz = (qrcode[3] << 8 | qrcode[2]) - ofsbit;
296-
uint8_t *start = &qrcode[ofsbit];
296+
size_t siz = (qrcode[5] << 24 | qrcode[4] << 16 | qrcode[3] << 8 | qrcode[2]) - ofsbit;
297+
uint8_t *start = (uint8_t *)&qrcode[ofsbit];
297298
int i, j;
298299
trans_color.bits.mosi = 16;
299300
for(i=0;i<siz;i++) {
@@ -310,14 +311,61 @@ void draw_qrcode(void)
310311
}
311312
}
312313
}
314+
#else
315+
{
316+
uint32_t ofsbit = qrcode[0xd] << 24 | qrcode[0xc] << 16 | qrcode[0xb] << 8 | qrcode[0xa];
317+
size_t siz = (qrcode[3] << 8 | qrcode[2]) - ofsbit;
318+
uint8_t *start = &qrcode[ofsbit];
319+
int i, j;
320+
trans_color.bits.mosi = 32;
321+
int x, y;
322+
for(i=0;i<siz;i+=4) {
323+
if( i%20 == 0 ) {
324+
lcd_set_position(40,200-i/20,199,200-i/20);
325+
// lcd_set_position(200-i/20,40,200,200);
326+
lcd_set_dc(1);
327+
}
328+
// Waiting for an incomplete transfer
329+
while (SPI1.cmd.usr);
330+
SPI1.user.usr_command = 0;
331+
SPI1.user.usr_addr = 0;
332+
SPI1.user.usr_mosi = 1;
333+
SPI1.user1.usr_mosi_bitlen = 511; // 16*32 - 1; // 31;
334+
for(x=0;x<4;x++) {
335+
for(j=6;j>=0;j-=2) {
336+
SPI1.data_buf[4*x+(6-j)/2] = (start[i+x] & (1<<(j+1)) ? 0xffff<<16 : 0) | (start[i+x] & (1<<(j+0)) ? 0xffff : 0);
337+
// if( start[i+x/4] & (1<<j) )
338+
// SPI1.data_buf[x] = 0xffff;
339+
// else
340+
// SPI1.data_buf[x] = 0;
341+
}
342+
343+
}
344+
SPI1.user.usr_miso = 0;
345+
SPI1.cmd.usr = 1;
346+
while (SPI1.cmd.usr);
347+
348+
for (x = 0; x < trans_color.bits.miso; x += 32) {
349+
y = x / 32;
350+
trans_color.miso[y] = SPI1.data_buf[y];
351+
}
352+
// for(j=7;j>=0;j--) {
353+
// if( start[i] & (1<<j) )
354+
// lcd_write_color(0xffff);
355+
// else
356+
// lcd_write_color(0);
357+
// }
358+
}
359+
}
360+
#endif
313361

314362
extern const uint8_t background[];
315363
void draw_background(const uint8_t table[])
316364
#if 1
317365
{
318366
uint32_t ofsbit = table[0xd] << 24 | table[0xc] << 16 | table[0xb] << 8 | table[0xa];
319367
size_t siz = (table[5] << 24 | table[4] << 16 | table[3] << 8 | table[2]) - ofsbit;
320-
uint8_t const *start = &table[ofsbit];
368+
uint8_t const *start = (uint8_t *)&table[ofsbit];
321369
int i;
322370
trans_color.bits.mosi = 32;
323371
union _double_color_t {
@@ -347,12 +395,12 @@ void draw_background(const uint8_t table[])
347395
SPI1.user1.usr_mosi_bitlen = 479; // 15*32; // 31;
348396
for(x=0;x<15;x++) {
349397
p = (union _double_color_t *)&SPI1.data_buf[x];
350-
p->r0 = start[i+6*x+0] >> 3;
351-
p->g0 = start[i+6*x+1] >> 2;
352-
p->b0 = start[i+6*x+2] >> 3;
353-
p->r1 = start[i+6*x+3] >> 3;
354-
p->g1 = start[i+6*x+4] >> 2;
355-
p->b1 = start[i+6*x+5] >> 3;
398+
p->r1 = start[i+6*x+0] >> 3;
399+
p->g1 = start[i+6*x+1] >> 2;
400+
p->b1 = start[i+6*x+2] >> 3;
401+
p->r0 = start[i+6*x+3] >> 3;
402+
p->g0 = start[i+6*x+4] >> 2;
403+
p->b0 = start[i+6*x+5] >> 3;
356404
}
357405
SPI1.user.usr_miso = 0;
358406
SPI1.cmd.usr = 1;
@@ -369,18 +417,18 @@ void draw_background(const uint8_t table[])
369417
{
370418
uint32_t ofsbit = table[0xd] << 24 | table[0xc] << 16 | table[0xb] << 8 | table[0xa];
371419
size_t siz = (table[5] << 24 | table[4] << 16 | table[3] << 8 | table[2]) - ofsbit;
372-
uint8_t *start = &table[ofsbit];
420+
uint8_t *start = (uint8_t *)&table[ofsbit];
373421
int i;
374422
trans_color.bits.mosi = 32;
375423
union _double_color_t {
376424
uint32_t data;
377425
struct {
378-
uint32_t r0:5;
379-
uint32_t g0:6;
380-
uint32_t b0:5;
381426
uint32_t r1:5;
382427
uint32_t g1:6;
383428
uint32_t b1:5;
429+
uint32_t r0:5;
430+
uint32_t g0:6;
431+
uint32_t b0:5;
384432
};
385433
};
386434
union _double_color_t *p = (union _double_color_t *)&sendbuf;
@@ -527,21 +575,9 @@ esp_err_t spilcd_init()
527575
lcd_write_cmd(0x11);
528576

529577
lcd_write_cmd(0x29);
530-
// for( int i=0;i<LCD_VER;i++ )
531-
// memset(framebuffer[i], 0xFFFF, LCD_HOR);
532-
// lcd_update();
533-
// lcd_clear32(0xf00f);
534578
draw_background(background);
535-
draw_qrcode();
536579
gpio_set_level(LCD_BACKLIGHT_PIN, 1);
537-
// backlight_listen_thread
538-
// xTaskCreate(&backlight_listen_thread, "backlight", 512, NULL, 8, NULL);
539-
// uint32_t c = 0;
540-
// uint32_t k;
541-
// for(c=0;c<0xffffffff;c+=0x10001) {
542-
// lcd_clear32(c);
543-
// lcd_delay_ms(100);
544-
// }
580+
draw_qrcode();
545581
return ESP_OK;
546582
}
547583

0 commit comments

Comments
 (0)