1+ /* *
2+ **************************************************
3+ *
4+ * @file ImageFromBuffer.ino
5+ * @brief Example showing an 8-bit grayscale JPG from buffer
6+ * on a standard Inkplate 6FLICK (1024x758)
7+ *
8+ * The image was converted with:
9+ * https://notisrac.github.io/FileToCArray/
10+ *
11+ * Used options:
12+ * - Code format: Hex (0x00)
13+ * - Palette mod: 8bit grayscale (1byte/pixel)
14+ * - Multi line
15+ * - Separate bytes of pixels
16+ * - static + const + unsigned + PROGMEM
17+ *
18+ * The resulting header (cat.h) contains:
19+ * - #define CAT_WIDTH 1024
20+ * - #define CAT_HEIGHT 758
21+ * - static const unsigned char cat[] PROGMEM = { ... };
22+ *
23+ ***************************************************/
24+ #include < Inkplate-LVGL.h>
25+
26+ // Image data
27+ #include " cat.h"
28+
29+ // Inkplate object
30+ Inkplate inkplate (INKPLATE_1BIT);
31+
32+ lv_obj_t *screen;
33+
34+ // LVGL image descriptor for 8-bit grayscale (L8)
35+ const lv_image_dsc_t my_image = {
36+ .header = {
37+ .cf = LV_COLOR_FORMAT_L8, // 8-bit luminance / grayscale
38+ .w = CAT_WIDTH,
39+ .h = CAT_HEIGHT,
40+ },
41+ .data_size = CAT_WIDTH * CAT_HEIGHT, // 1 byte per pixel
42+ .data = cat, // buffer from cat.h
43+ };
44+
45+ // LVGL task that ticks the timer every 5 ms
46+ void lvgl_task (void *arg) {
47+ for (;;) {
48+ lv_tick_inc (5 );
49+ lv_timer_handler ();
50+ vTaskDelay (pdMS_TO_TICKS (5 ));
51+ }
52+ }
53+
54+ void setup () {
55+ Serial.begin (115200 );
56+ delay (1000 );
57+ Serial.println (" Starting LVGL grayscale image example on Inkplate 6..." );
58+
59+ // Initialize Inkplate + LVGL in full render mode
60+ inkplate.begin (LV_DISP_RENDER_MODE_FULL);
61+
62+ // Enable dithering (useful for grayscale on BW e-paper)
63+ inkplate.enableDithering (1 );
64+
65+ // LVGL task on core 1
66+ xTaskCreatePinnedToCore (
67+ lvgl_task,
68+ " lvgl_tick" ,
69+ 16000 ,
70+ nullptr ,
71+ 2 ,
72+ nullptr ,
73+ 1 );
74+
75+ delay (100 );
76+
77+ // Get the active screen
78+ screen = lv_scr_act ();
79+ lv_obj_set_style_bg_color (screen, lv_color_white (), 0 );
80+ lv_obj_set_style_bg_opa (screen, LV_OPA_COVER, 0 );
81+
82+ // LVGL image object
83+ lv_obj_t *img = lv_image_create (screen);
84+ lv_image_set_src (img, &my_image);
85+ lv_obj_center (img);
86+
87+ // Manually call timer a few times so everything renders
88+ for (int i = 0 ; i < 5 ; i++) {
89+ lv_timer_handler ();
90+ delay (10 );
91+ }
92+
93+ // Send framebuffer to Inkplate 6FLICK
94+ inkplate.display ();
95+ Serial.println (" Display updated with 8-bit grayscale (L8) image" );
96+ }
97+
98+ void loop () {
99+ // Nothing needed in loop
100+ }
0 commit comments