ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
animation.h
Go to the documentation of this file.
1#pragma once
3
5
6namespace esphome::animation {
7
8class Animation : public image::Image {
9 public:
10 Animation(const uint8_t *data_start, int width, int height, uint32_t animation_frame_count, image::ImageType type,
11 image::Transparency transparent);
12
14 int get_current_frame() const;
15 void next_frame();
16 void prev_frame();
17
22 void set_frame(int frame);
23
24 void set_loop(uint32_t start_frame, uint32_t end_frame, int count);
25
26 protected:
27 void update_data_start_();
28
29 const uint8_t *animation_data_start_;
36};
37
38template<typename... Ts> class AnimationNextFrameAction : public Action<Ts...> {
39 public:
41 void play(const Ts &...x) override { this->parent_->next_frame(); }
42
43 protected:
45};
46
47template<typename... Ts> class AnimationPrevFrameAction : public Action<Ts...> {
48 public:
50 void play(const Ts &...x) override { this->parent_->prev_frame(); }
51
52 protected:
54};
55
56template<typename... Ts> class AnimationSetFrameAction : public Action<Ts...> {
57 public:
59 TEMPLATABLE_VALUE(uint16_t, frame)
60 void play(const Ts &...x) override { this->parent_->set_frame(this->frame_.value(x...)); }
61
62 protected:
64};
65
66} // namespace esphome::animation
virtual void play(const Ts &...x)=0
uint32_t get_animation_frame_count() const
Definition animation.cpp:24
const uint8_t * animation_data_start_
Definition animation.h:29
Animation(const uint8_t *data_start, int width, int height, uint32_t animation_frame_count, image::ImageType type, image::Transparency transparent)
Definition animation.cpp:7
void set_loop(uint32_t start_frame, uint32_t end_frame, int count)
Definition animation.cpp:17
void set_frame(int frame)
Selects a specific frame within the animation.
Definition animation.cpp:49
void play(const Ts &...x) override
Definition animation.h:41
void play(const Ts &...x) override
Definition animation.h:50
TEMPLATABLE_VALUE(uint16_t, frame) void play(const Ts &...x) override
Definition animation.h:59
uint16_t type
static void uint32_t
uint16_t x
Definition tt21100.cpp:5