aboutsummaryrefslogtreecommitdiff
path: root/software/effects.ino
blob: ed4a0b132ca3443e814b543e901daa32dbd6214e (plain)
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
#include "consts.h"
#include "effects.h"
#include "animation.h"

// #define FX_LEN_ROUNDABOUT (unsigned long) 5e3
#define FX_LEN_ROUNDABOUT (unsigned long) 0
void fx_roundabout (unsigned long relative_time) {
	memset(led_state, 0, sizeof(led_state));
	unsigned long tick = relative_time / 300;
	unsigned int roundabout_coordinates[12] = {
		0x0, 0x1, 0x2, 0x3, 0x7, 0xb,
		0xf, 0xe, 0xd, 0xc, 0x8, 0x4
	};
	
	for(int trail = 0; trail < 4; trail++) {
		unsigned int xy_coords = roundabout_coordinates[(tick + trail) % 12];
		for(int z = 0; z < 4; z++) led_state[led_map[xy_coords + z * 0x10]] = 1;
	}

	return;
}

#define FX_LEN_WIPEXYZ (unsigned long) 6e3
void fx_wipexyz (unsigned long relative_time) {
	memset(led_state, 0, sizeof(led_state));
	unsigned long tick = relative_time / 200;
	unsigned int  direction = (tick / 6) % 3;

	fill_plane(direction, zigzag(4, tick));
	// fill_plane(0, 2);

	return;
}

// #define FX_LEN_RAINFALL (unsigned long) 7e3
#define FX_LEN_RAINFALL (unsigned long) 0
#define FX_FPS_RAINFALL (double) 10
unsigned long last_frame;
void fx_rainfall (unsigned long relative_time) {
	unsigned long frame = get_frame(relative_time, FX_FPS_RAINFALL);
	// only update on new frame
	if (last_frame != frame) {
		for (int i = 0x00; i < 0x30; i++) led_state[led_map[i]] = led_state[led_map[i + 0x10]];
		for (int i = 0x30; i < 0x40; i++) led_state[led_map[i]] = random(0xff) < 0x10;
	}
	last_frame = frame;
	return;
}

/* #define FX_LEN_TEST_LEDS_IN_ORDER (unsigned long) 10e3
void test_leds_inorder (unsigned long relative_time) {
	memset(led_state, 0, sizeof(led_state));
	unsigned long segment_time = FX_LEN_TEST_LEDS_IN_ORDER / 64;
	led_state[(relative_time / segment_time) % 64] = 1;

	return;
} */

void ( * slideshow_effects [SLIDESHOW_SIZE] )( unsigned long relative_time ) = {
	fx_roundabout,
	fx_wipexyz,
	fx_rainfall,
	// test_leds_inorder,
};

#ifndef SLIDESHOW_DURATION
unsigned long slideshow_lengths[SLIDESHOW_SIZE] = {
	FX_LEN_ROUNDABOUT,
	FX_LEN_WIPEXYZ,
	FX_LEN_RAINFALL,
	// FX_LEN_TEST_LEDS_IN_ORDER,
};
#endif