-
Notifications
You must be signed in to change notification settings - Fork 0
/
patterns.h
62 lines (53 loc) · 1.48 KB
/
patterns.h
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
#ifndef _VVC_PATTERNS_H
#define _VVC_PATTERNS_H
#include <stdint.h>
#include <string.h>
#ifdef VVC_STM32
#include "stm32f1xx.h"
#elif VVC_GD32V
#include "gd32vf103.h"
#include "n200_func.h"
#include "riscv_encoding.h"
#endif
// SPI timing values for color bits. (One SPI byte = one color bit)
#define WS2812_ON ( 0xFC )
#define WS2812_OFF ( 0xC0 )
// Number of LEDs per star.
#define STAR_LEDS ( 24 )
// Number of stars in the string.
#define NUM_STARS ( 8 )
// Duration of each lighting 'step', in ms.
#define STEP_DUR ( 2000 )
// Number of 'substeps' or 'cycles' in each lighting 'step'
#define STEP_CYC ( 5 )
// Values declared elsewhere.
extern volatile uint32_t systick;
// Enumeration for lighting patterns.
typedef enum {
ls_min = 0,
rainbow_lp = 0,
ls_max, /* (Move pattern names below this line to disable them.) */
rainbow,
xmas_odd,
xmas_even,
breathe_r,
breathe_g,
breathe_b,
} light_steps;
// Star struct.
typedef struct {
uint8_t* my_colors;
int cur_pattern;
int last_step;
int next_step;
} star_t;
// Helper methods for getting / setting colors.
// Get a 'pulsing rainbow' color based on temporal progress.
uint32_t rainbow_cycle( uint32_t prg, uint32_t max );
// Lower-power 'pulsing rainbow' color getter.
uint32_t rainbow_lp_cycle( uint32_t prg, uint32_t max );
// Set a 24-byte GRB pixel color from 3 RGB bytes.
void set_px_rgb( uint8_t* px, uint8_t r, uint8_t g, uint8_t b );
// Step one star's lighting pattern.
void step_star( star_t* star );
#endif