aboutsummaryrefslogtreecommitdiff
path: root/include/pattern.h
blob: f5d0a1bce95e075f71e3c3e63baf6d42d0f1ba8a (plain) (blame)
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
#pragma once

#include <stdint.h>

#include "ws2812b.h"

#define DEFINE_PATTERN        \
  __attribute__((__section__( \
      ".patterns"))) volatile static pattern_t __FILE__ = 

typedef struct {
  /* Name of the pattern. */
  const char* name;

  /* Return the rgb for the pixel at the given offset 'x' and time 't' */
  rgb_t (*get_rgb)(uint32_t t, size_t x);

  /* Resets the pattern to the beginning. */
  void (*reset)(void);
} pattern_t;

extern pattern_t PATTERNS_START;
extern pattern_t PATTERNS_END;

#define patterns (&PATTERNS_START)
#define n_patterns (&PATTERNS_END - &PATTERNS_START)