arduino-audio-tools
Loading...
Searching...
No Matches
OutputTFT_eSPI.h
Go to the documentation of this file.
1#pragma once
2#include <TFT_eSPI.h> // https://github.com/Bodmer/TFT_eSPI
3
5
6namespace audio_tools {
7
18 public:
19 OutputTFT_eSPI(TFT_eSPI& tft) : tft_(tft) {}
20
21 bool begin() {
22 tft_.init();
23 tft_.setRotation(1);
24 tft_.fillScreen(TFT_BLACK);
25 return true;
26 }
27
29 void setVideoInfoSource(VideoInfoSource& source) override {
30 p_info = &source;
31 }
32
35 info_ = info;
36 }
37
38 size_t write(const uint8_t* data, size_t len) override {
39 auto start = millis();
40 if (p_info != nullptr) {
42 }
43 if (info_.width == 0 || info_.height == 0) {
44 LOGE("OutputTFT: invalid video size: %d x %d", (int)info_.width,
45 (int)info_.height);
46 return 0;
47 }
48 tft_.pushImage(0, 0, info_.width, info_.height, (uint16_t*)data);
49 write_time_ms = millis() - start;
50 return len;
51 }
52
53 uint32_t getWriteTimeMs() const { return write_time_ms; }
54
55
56 protected:
57 TFT_eSPI& tft_;
60 uint32_t write_time_ms = 0;
61};
62
63} // namespace audio_tools
#define LOGE(...)
Definition AudioLoggerIDF.h:30
Bridges VideoDecoder's write() calls to the TFT - VideoDecoder always hands over one complete frame p...
Definition OutputTFT_eSPI.h:17
uint32_t write_time_ms
Definition OutputTFT_eSPI.h:60
VideoInfoSource * p_info
Definition OutputTFT_eSPI.h:58
VideoInfo info_
Definition OutputTFT_eSPI.h:59
uint32_t getWriteTimeMs() const
Optional: returns the time (ms) spent in the last write() call.
Definition OutputTFT_eSPI.h:53
bool begin()
Definition OutputTFT_eSPI.h:21
size_t write(const uint8_t *data, size_t len) override
Definition OutputTFT_eSPI.h:38
OutputTFT_eSPI(TFT_eSPI &tft)
Definition OutputTFT_eSPI.h:19
TFT_eSPI & tft_
Definition OutputTFT_eSPI.h:57
void setVideoInfo(VideoInfo info)
Defines the video format and dimensions - call before begin() if you.
Definition OutputTFT_eSPI.h:34
void setVideoInfoSource(VideoInfoSource &source) override
Defines the source of the video information (width, height, fps, format)
Definition OutputTFT_eSPI.h:29
Provider of VideoInfo (width/height/fps/format) for whoever needs to size buffers/panel setup against...
Definition VideoOutput.h:92
virtual VideoInfo videoInfo()=0
Abstract class for video playback. This class is used to assemble a complete video frame in memory....
Definition VideoOutput.h:107
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition LMSEchoCancellationStream.h:6
uint32_t millis()
Returns the milliseconds since the start.
Definition Arduino.h:260
Basic video information (width/height/codec/frame size), analogous to AudioInfo - common to both Demu...
Definition VideoOutput.h:49
uint16_t height
Frame height in pixels.
Definition VideoOutput.h:53
uint16_t width
Frame width in pixels.
Definition VideoOutput.h:51