claude done anims

This commit is contained in:
2026-02-11 08:35:46 +01:00
parent 74d6b01f1b
commit 6b8cd676a2
4 changed files with 76 additions and 1 deletions
+2
View File
@@ -11,6 +11,8 @@
#define MAX_MULTI_COLOR_TEXT_NODES_COUNT $ #define MAX_MULTI_COLOR_TEXT_NODES_COUNT $
#define MAX_TEXT_NODES_COUNT 4 #define MAX_TEXT_NODES_COUNT 4
#define MAX_IMAGES_SAVED 2 #define MAX_IMAGES_SAVED 2
#define MAX_ANIMATION_FRAME_COUNT 32
#define MAX_ANIMATIONS_COUNT 2
#define SMALL_TEXT_HEIGHT 7 #define SMALL_TEXT_HEIGHT 7
#define SMALL_TEXT_WIDTH 5 #define SMALL_TEXT_WIDTH 5
+60 -1
View File
@@ -29,6 +29,9 @@ Image saved_images[MAX_IMAGES_SAVED] = {
{},{} {},{}
}; };
const RGB animation_data[MAX_ANIMATIONS_COUNT][MAX_ANIMATION_FRAME_COUNT][PANEL_PIXEL_COUNT][DISPLAY_MAX_X + 1] = {};
Animation animations[MAX_ANIMATIONS_COUNT];
short getTextNodeY2(TextNode *node) short getTextNodeY2(TextNode *node)
{ {
@@ -338,6 +341,62 @@ void drawImageFromMemoryByIndex(unsigned char image_index, short pos_x, short po
} }
} }
void displayAnimationFrame(unsigned char animation_index)
{
unsigned short frame = animations[animation_index].current_frame;
for (unsigned char y = 0; y < PANEL_PIXEL_COUNT; y++)
{
for (unsigned char x = 0; x <= DISPLAY_MAX_X; x++)
{
const RGB& px = animation_data[animation_index][frame][y][x];
setPixel(x, y, pixels.Color(px.r * brightness / 100, px.g * brightness / 100, px.b * brightness / 100));
}
}
}
void tickAnimations()
{
for (unsigned char i = 0; i < MAX_ANIMATIONS_COUNT; i++)
{
if (!animations[i].is_playing) continue;
animations[i].frame_progress++;
if (animations[i].frame_progress > animations[i].frame_delay)
{
animations[i].frame_progress = 0;
animations[i].current_frame++;
if (animations[i].current_frame >= animations[i].frame_count)
{
if (animations[i].is_looping)
{
animations[i].current_frame = 0;
}
else
{
animations[i].current_frame = animations[i].frame_count - 1;
animations[i].is_playing = false;
}
}
}
}
}
void playAnimation(unsigned char index, unsigned char frame_delay, bool loop)
{
animations[index].current_frame = 0;
animations[index].frame_progress = 0;
animations[index].frame_delay = frame_delay;
animations[index].is_playing = true;
animations[index].is_looping = loop;
}
void stopAnimation(unsigned char index)
{
animations[index].is_playing = false;
}
void handleDisappearTimers() void handleDisappearTimers()
{ {
for (unsigned char i = 0; i < MAX_TEXT_NODES_COUNT; i++) for (unsigned char i = 0; i < MAX_TEXT_NODES_COUNT; i++)
@@ -429,7 +488,7 @@ void loop()
TextNode* node = nullptr; TextNode* node = nullptr;
if (bottom_text_state == 0) if (bottom_text_state == 0)
{ {
node = addNewTextNode("Technik informatyk", node = addNewTextNode("Technik informatyk + ai, robotyka",
pixels.Color(0, 0, 50), // blue (dimmed) pixels.Color(0, 0, 50), // blue (dimmed)
false, DISPLAY_MAX_X, 9, 1, true, true, -1, false); false, DISPLAY_MAX_X, 9, 1, true, true, -1, false);
} }
+5
View File
@@ -10,7 +10,12 @@ extern TextNode text_nodes[MAX_TEXT_NODES_COUNT];
extern MultiColorTextNode multi_color_text_node[MAX_TEXT_NODES_COUNT]; extern MultiColorTextNode multi_color_text_node[MAX_TEXT_NODES_COUNT];
extern Cursor cursor; extern Cursor cursor;
extern unsigned char brightness; extern unsigned char brightness;
extern Animation animations[MAX_ANIMATIONS_COUNT];
void displayAnimationFrame(unsigned char animation_index);
void tickAnimations();
void playAnimation(unsigned char index, unsigned char frame_delay, bool loop);
void stopAnimation(unsigned char index);
void drawImageFromMemoryByIndex(unsigned char image_index, short pos_x, short pos_y, unsigned char brightness = 100); void drawImageFromMemoryByIndex(unsigned char image_index, short pos_x, short pos_y, unsigned char brightness = 100);
void setPixel(short x, short y, uint32_t color); void setPixel(short x, short y, uint32_t color);
+9
View File
@@ -92,5 +92,14 @@ struct Image
unsigned short height; unsigned short height;
}; };
struct Animation {
unsigned short frame_count;
unsigned short current_frame;
unsigned char frame_delay;
unsigned char frame_progress;
bool is_playing;
bool is_looping;
};
#endif // STRUCTS_H #endif // STRUCTS_H