-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.h
More file actions
118 lines (100 loc) · 2.61 KB
/
Copy pathmain.h
File metadata and controls
118 lines (100 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef MAIN_H
#define MAIN_H
#include <MagickWand/MagickWand.h>
#include <led-matrix-c.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
#include <dirent.h>
#include <strings.h>
#include <math.h>
#include <signal.h>
#define MATRIX_WIDTH 128
#define MATRIX_HEIGHT 32
#define NUM_FRAMES 30
#define FRAME_DELAY 4
#define M_PI 3.14159265358979323846
#define MAX_LOOPS 10
#define MIN_LOOPS 5
typedef struct {
double time;
int num_particles;
} ParticleAnimation;
// typedef struct {
// FILE *file;
// uint8_t *frame_buffer;
// int width;
// int height;
// int frame_size;
// int total_frames;
// int current_frame;
// int frame_skip;
// int frame_counter;
// int loop;
// int playing;
// } VideoPlayer;
typedef struct {
FILE *file;
uint8_t *frame_buffer;
int width;
int height;
int frame_size;
int total_frames;
int current_frame;
// --- Timing ---
float frame_step; // Number of video frames to advance per project tick
float frame_accumulator; // Tracks fractional frame progress
int loop;
int playing;
} VideoPlayer;
typedef struct {
char **lines;
size_t count;
char *buffer;
} TextLines;
typedef struct
{
struct LedFont *font;
int font_width;
int font_baseline;
struct Color color;
TextLines *lines;
int x_orig;
int y_orig;
int x;
int y;
int letter_spacing;
} Text;
typedef struct
{
int text_frame_counter;
int text_frame_skip;
int particle_frame_counter;
int particle_frame_skip;
int prjct_fps;
int frame_delay_us;
} FrameController;
typedef struct
{
struct RGBLedMatrix *matrix;
struct LedCanvas *offscreen_canvas;
int width;
int height;
} MatrixContext;
int matrix_setup(MatrixContext *ctx);
void overdraw_half(struct LedCanvas *canvas, int width, int height, int left_half);
int rand_range(int min, int max);
char *load_text_from_file(const char *filename);
TextLines *load_text_lines_from_file(const char *filename);
int text_setup(MatrixContext *mctx, Text *top, Text *bottom);
void text_update(MatrixContext *mctx, Text *top, Text *bottom, int should_move);
void particle_animation_init(ParticleAnimation *anim);
void particle_animation_draw(ParticleAnimation *anim, MatrixContext *mctx, int x_offset, int width);
int video_player_init(VideoPlayer *vp, const char *filepath, int video_fps, int prjct_fps);
void video_player_draw(VideoPlayer *vp, MatrixContext *mctx, int x_offset);
void video_player_cleanup(VideoPlayer *vp);
void free_text_lines(TextLines *text_lines);
#endif