aboutsummaryrefslogtreecommitdiffstats
path: root/instructables/cube_pc/main.c
blob: 61e4f9af2e35bc4c6e30cb60537b65923b164b7b (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
75
76
77
78
79
80
81
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "cube.h"
#include "draw.h"
#include "draw_3d.h"
#include "effect.h"
#include "gameoflife.h"
#include "launch_effect.h"

void *cube_updater (unsigned char rs232_cube[8][8]);

int main (int argc, char **argv)
{

    if (argc < 2) {
        fprintf(stderr, "Please indicate device to use.\n");
        return 1;
    }

	cube_init(argv[1]);

	pthread_t cube_thread;
	int iret, i, x;

	iret = pthread_create (&cube_thread, NULL, cube_updater, rs232_cube);


	while (1)
	{
        for (i = 0; i < 0; i++) {
			effect_blinky2();
        }
		for (i=0; i<EFFECTS_TOTAL; i++)
			launch_effect(i);

		printf("Effect: sidewaves\n");
		sidewaves(2000,50);

		printf("Effect: ripples\n");
		ripples(2000,50);

		printf("Effect: linespin\n");
		linespin(2000,50);

		printf("Effect: sinelines\n");
		sinelines(2000,50);

		printf("Effect: spheremove\n");
		spheremove(1500,50);

		printf("Effect: fireworks\n");
		fireworks(7,50,600);

        printf("Effect: gol_play\n");
        for (i=0; i<10; i++)
        {
            for (x=0; x<20; x++)
                setvoxel(rand()%4,rand()%4,rand()%4);

            gol_play(50,1000);

        }
	}

}

void *cube_updater (unsigned char rs232_cube[8][8])
{
    unsigned char pushcube[8][8];


	while (1)
    {
        memcpy(pushcube, rs232_cube, 64);
		cube_push(pushcube);
    }
}