Mercurial > code > home > repos > front-door-display
annotate esp/update_lcd_block.h @ 7:b46679798c51
mv esp code to this repo. still trying to get correct refreshes
author | drewp@bigasterisk.com |
---|---|
date | Sun, 10 Mar 2024 15:03:53 -0700 |
parents | |
children | 47795c3121f1 |
rev | line source |
---|---|
7
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
1 #include <string> |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
2 |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
3 #include "esphome.h" |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
4 #include "esphome/components/ili9xxx/ili9xxx_display.h" |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
5 void update_lcd_block(esphome::ili9xxx::ILI9XXXDisplay *lcd, std::string &x) { |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
6 id(lcd).update(); |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
7 |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
8 #if 1 |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
9 std::string localPayload = x; |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
10 const char *buf = localPayload.data(); |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
11 #else |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
12 const char *buf = x.data(); |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
13 #endif |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
14 uint16_t seq, xp, yp, w, h; |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
15 #define readu16() \ |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
16 (static_cast<const uint16_t>(*(buf++)) | \ |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
17 (static_cast<const uint16_t>(*(buf++)) << 8)) |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
18 seq = readu16(); |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
19 xp = readu16(); |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
20 yp = readu16(); |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
21 w = readu16(); |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
22 h = readu16(); |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
23 char seqDia[] = " "; |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
24 seqDia[seq % 10] = '%'; |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
25 ESP_LOGD("dbg", |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
26 "seq=%hu%s xp=%hu, yp=%hu, w=%hu, h=%hu, full payload=%d bytes", seq, |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
27 seqDia, xp, yp, w, h, x.size()); |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
28 #if 1 |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
29 ///// v1 |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
30 id(lcd).draw_pixels_at(320+w-1-xp, yp, w, h, |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
31 reinterpret_cast<const uint8_t*>(buf), |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
32 COLOR_ORDER_BGR, |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
33 COLOR_BITNESS_888, |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
34 /*big_endian=*/false, |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
35 /*x_offset=*/0, |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
36 /*y_offset=*/0, |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
37 /*x_pad=*/0); |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
38 #elif 0 |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
39 ///// v2 |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
40 for (uint16_t y = 0; y < h; y++) { |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
41 uint16_t row = yp + y; |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
42 for (uint16_t x = 0; x < w; x++) { |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
43 id(lcd).draw_pixel_at(320-1-(xp + w-1 - x), row, Color(*buf++, *buf++, *buf++)); |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
44 } |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
45 // App.feed_wdt(); |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
46 } |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
47 #else |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
48 |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
49 #endif |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
50 id(lcd).update(); |
b46679798c51
mv esp code to this repo. still trying to get correct refreshes
drewp@bigasterisk.com
parents:
diff
changeset
|
51 } |