Skip to content

Commit 24b9ecd

Browse files
committed
add trmnl example and gif support
1 parent 451fea3 commit 24b9ecd

124 files changed

Lines changed: 7994 additions & 59 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

components/inkplate/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1+
set(GIF_SRCS "")
2+
set(GIF_INCLUDES "")
3+
14
if(CONFIG_INKPLATE_BOARD_INKPLATE10)
25
set(BOARD_SRC "src/boards/Inkplate10.cpp")
36
set(IMAGE_SRCS "src/graphics/Image.cpp")
7+
set(GIF_SRCS "src/graphics/decoders/GIF.cpp" "src/graphics/decoders/animatedgif/AnimatedGIF.cpp")
8+
set(GIF_INCLUDES "include/graphics/decoders/animatedgif")
49
elseif(CONFIG_INKPLATE_BOARD_INKPLATE6)
510
set(BOARD_SRC "src/boards/Inkplate6.cpp" "src/features/I2S.cpp")
611
set(IMAGE_SRCS "src/graphics/Image.cpp")
12+
set(GIF_SRCS "src/graphics/decoders/GIF.cpp" "src/graphics/decoders/animatedgif/AnimatedGIF.cpp")
13+
set(GIF_INCLUDES "include/graphics/decoders/animatedgif")
714
elseif(CONFIG_INKPLATE_BOARD_INKPLATE6FLICK)
815
set(BOARD_SRC "src/boards/Inkplate6.cpp" "src/features/I2S.cpp")
916
set(IMAGE_SRCS "src/graphics/Image.cpp")
17+
set(GIF_SRCS "src/graphics/decoders/GIF.cpp" "src/graphics/decoders/animatedgif/AnimatedGIF.cpp")
18+
set(GIF_INCLUDES "include/graphics/decoders/animatedgif")
1019
elseif(CONFIG_INKPLATE_BOARD_INKPLATE6COLOR)
1120
set(BOARD_SRC "src/boards/Inkplate6Color.cpp" "src/features/SPI.cpp")
1221
set(IMAGE_SRCS "src/graphics/ImageColor.cpp")
@@ -16,9 +25,13 @@ elseif(CONFIG_INKPLATE_BOARD_INKPLATE13)
1625
elseif(CONFIG_INKPLATE_BOARD_INKPLATE5)
1726
set(BOARD_SRC "src/boards/Inkplate5.cpp" "src/features/I2S.cpp")
1827
set(IMAGE_SRCS "src/graphics/Image.cpp")
28+
set(GIF_SRCS "src/graphics/decoders/GIF.cpp" "src/graphics/decoders/animatedgif/AnimatedGIF.cpp")
29+
set(GIF_INCLUDES "include/graphics/decoders/animatedgif")
1930
elseif(CONFIG_INKPLATE_BOARD_INKPLATE4)
2031
set(BOARD_SRC "src/boards/Inkplate4.cpp")
2132
set(IMAGE_SRCS "src/graphics/Image.cpp")
33+
set(GIF_SRCS "src/graphics/decoders/GIF.cpp" "src/graphics/decoders/animatedgif/AnimatedGIF.cpp")
34+
set(GIF_INCLUDES "include/graphics/decoders/animatedgif")
2235
set(SENSOR_SRCS
2336
"src/features/APDS9960/APDS9960.cpp"
2437
"src/features/APDS9960/libs/APDS9960Driver.cpp"
@@ -47,11 +60,13 @@ set(DECODER_SRCS
4760
"src/graphics/decoders/JPEG.cpp"
4861
"src/graphics/decoders/PNG.cpp"
4962
"src/graphics/decoders/pngle/pngle.c"
63+
${GIF_SRCS}
5064
)
5165

5266
set(DECODER_INCLUDES
5367
"include/graphics/decoders"
5468
"include/graphics/decoders/pngle"
69+
${GIF_INCLUDES}
5570
)
5671

5772
set(GRAPHICS_SRCS
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
3+
project(template)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# GIF From SD
2+
3+
Play a GIF animation from a microSD card on Soldered Inkplate 10.
4+
5+
## Overview
6+
7+
Loads a GIF file from a FAT-formatted microSD card and plays it back on the Inkplate 10 e-paper screen using partial updates.
8+
9+
## Hardware Required
10+
11+
- Soldered Inkplate 10
12+
- USB cable
13+
- MicroSD card (FAT32 formatted) with a GIF file
14+
15+
## Setup
16+
17+
1. Copy the `cat_gif.gif` file bundled with this example (in `main/`) to the root of a FAT32-formatted microSD card.
18+
2. Insert the microSD card into the Inkplate.
19+
20+
Run `idf.py menuconfig` and navigate to:
21+
**Inkplate Boards → Inkplate10**
22+
23+
## Build and Flash
24+
25+
```
26+
idf.py build
27+
idf.py -p PORT flash monitor
28+
```
29+
30+
## Expected Output
31+
32+
`cat_gif.gif` loops forever on the display, centered on the screen.
33+
34+
## Notes
35+
36+
- Partial update (and therefore GIF playback) only works in BLACK_AND_WHITE display mode.
37+
- e-paper partial refresh takes far longer than a typical GIF frame delay, so actual playback speed is limited by the panel, not by the file.
38+
- MicroSD card must be FAT or FAT32 formatted.
39+
40+
## Resources
41+
42+
- Docs: https://docs.soldered.com/inkplate
43+
- Support: https://forum.soldered.com/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
solderedelectronics/inkplate:
3+
version: ">=1.0.0"
4+
idf:
5+
version: ">=6.0.0"
6+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
idf_component_register(SRCS "main.cpp"
2+
REQUIRES "inkplate"
3+
INCLUDE_DIRS ".")
22 KB
Loading
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
* @file main.cpp
3+
* @author Fran Fodor for Soldered
4+
* @brief Play a GIF animation from the SD card on Soldered Inkplate 10.
5+
*
6+
* @details Demonstrates loading a GIF file from a FAT-formatted SD card
7+
* and playing it back on the Inkplate 10 e-paper display using
8+
* partial updates. Each pixel is converted to black/white with
9+
* a fixed threshold (no dithering) since dithering noise would
10+
* flicker differently frame to frame.
11+
*
12+
* Requirements:
13+
* - Board: Soldered Inkplate 10
14+
* - Framework: ESP-IDF v6.x
15+
* - Hardware: Inkplate 10, USB cable, microSD card
16+
* - Extra: SD card containing a GIF file named "cat_gif.gif"
17+
*
18+
* Configuration:
19+
* - Menuconfig -> Inkplate Boards -> Inkplate10
20+
* - SD card format: FAT / FAT32
21+
*
22+
* How to use:
23+
* 1) Copy the cat_gif.gif file bundled with this example to the root of
24+
* a FAT-formatted SD card.
25+
* 2) Insert the SD card into the Inkplate.
26+
* 3) Build and flash to Inkplate 10.
27+
* 4) The GIF plays back on the e-paper screen.
28+
*
29+
* Expected output:
30+
* - "cat_gif.gif" loops forever on the display, centered on the screen.
31+
*
32+
* Notes:
33+
* - Partial update (and therefore GIF playback) only works in
34+
* BLACK_AND_WHITE display mode, hence setDisplayMode(BLACK_AND_WHITE)
35+
* below.
36+
* - e-paper partial refresh takes far longer than a typical GIF frame delay
37+
* (tens to hundreds of ms per refresh vs ~100ms/frame in the file), so
38+
* actual playback speed is limited by the panel, not by the GIF itself.
39+
* - The driver forces a full refresh every N partial updates
40+
* (fullRefreshEveryFrames argument, defaults to 20 here) to clear
41+
* partial-update ghosting; pass 0 to disable forced full refreshes
42+
* entirely.
43+
* - leaveOn (last argument, defaults to true) keeps the panel powered
44+
* between frames instead of power-cycling it on every partialUpdate()
45+
* call; pass false to power the panel down after each frame instead.
46+
*
47+
* Docs: https://docs.soldered.com/inkplate
48+
* Support: https://forum.soldered.com/
49+
*/
50+
51+
#include "sdkconfig.h"
52+
53+
#ifndef CONFIG_INKPLATE_BOARD_INKPLATE10
54+
#error \
55+
"Wrong board selection for this example, please select Inkplate10 in the boards menu."
56+
#endif
57+
58+
#include "esp_log.h"
59+
#include "freertos/FreeRTOS.h"
60+
#include "freertos/task.h"
61+
62+
#include "Inkplate.h"
63+
64+
// GIF file on the SD card root
65+
#define GIF_PATH "cat_gif.gif"
66+
67+
static const char *TAG = "MAIN";
68+
69+
extern "C" void app_main(void) {
70+
Inkplate display;
71+
display.setDisplayMode(BLACK_AND_WHITE);
72+
display.clearDisplay();
73+
display.display();
74+
75+
// Init SD card. Display if SD card is init properly or not.
76+
if (display.sdCardInit() != ESP_OK) {
77+
ESP_LOGE(TAG, "SD card init failed");
78+
display.setTextColor(0);
79+
display.setTextSize(3);
80+
display.print("SD Card error!");
81+
display.display();
82+
return;
83+
}
84+
85+
// Play "cat_gif.gif" from the SD card root, centered on the screen.
86+
// loop = true: keep replaying the file forever.
87+
if (!display.gif.play(GIF_PATH, E_INK_WIDTH / 2 - 125,
88+
E_INK_HEIGHT / 2 - 125, false, true, 20, true)) {
89+
display.setTextColor(0);
90+
display.setTextSize(3);
91+
display.println("GIF open error");
92+
display.display();
93+
}
94+
95+
display.sdCardSleep();
96+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
2+
CONFIG_SPIRAM=y
3+
CONFIG_SPIRAM_SPEED_40M=y
4+
CONFIG_SPIRAM_BOOT_INIT=y
5+
CONFIG_ESP_MAIN_TASK_STACK_SIZE=16384
6+
CONFIG_ESP_TLS_INSECURE=y
7+
CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY=y
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
3+
project(template)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# GIF From Web
2+
3+
Download and play a GIF animation from the web on Soldered Inkplate 10.
4+
5+
## Overview
6+
7+
Connects Inkplate 10 to WiFi, downloads a GIF file from a configured URL, and plays it back on the e-paper display using partial updates.
8+
9+
## Hardware Required
10+
11+
- Soldered Inkplate 10
12+
- USB cable
13+
- Stable WiFi connection
14+
15+
## Setup
16+
17+
### 1. Set the GIF URL
18+
19+
In `main.cpp`, set `GIF_URL` to a direct link to a GIF file (no HTML redirect pages).
20+
21+
### 2. Configure WiFi and board
22+
23+
Run `idf.py menuconfig` and navigate to:
24+
- **Inkplate Boards → Inkplate10**
25+
- **WiFi Configuration → Enter your SSID and password**
26+
27+
## Build and Flash
28+
29+
```
30+
idf.py build
31+
idf.py -p PORT flash monitor
32+
```
33+
34+
## Expected Output
35+
36+
The GIF from `GIF_URL` plays on the display, centered on the screen, looping until reset/power-cycled.
37+
38+
## Notes
39+
40+
- Partial update (and therefore GIF playback) only works in BLACK_AND_WHITE display mode.
41+
- The whole GIF file is held in memory at once - make sure the file is small enough to fit.
42+
- e-paper partial refresh takes far longer than a typical GIF frame delay, so actual playback speed is limited by the panel, not by the file.
43+
44+
## Resources
45+
46+
- Docs: https://docs.soldered.com/inkplate
47+
- Support: https://forum.soldered.com/

0 commit comments

Comments
 (0)