summaryrefslogtreecommitdiffstats
path: root/Matrix_5x6/Charlie/Charlie.pde
blob: ee7f5dd01b7d4e87dbacb349c96311ae9f6a4a67 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <Charlieplex.h>

#define NUMBER_OF_PINS 6
byte pins[] = {2,3,4,5,6,7};
Charlieplex charlieplex = Charlieplex(pins,NUMBER_OF_PINS);

charliePin ledi[] = { {0, 1} , {1, 0} , {2, 0} , {3, 0} , {4, 0} , {5, 0},
                      {0, 2} , {1, 2} , {2, 1} , {3, 1} , {4, 1} , {5, 1},
                      {0, 3} , {1, 3} , {2, 3} , {3, 2} , {4, 2} , {5, 2},
                      {0, 4} , {1, 4} , {2, 4} , {3, 4} , {4, 3} , {5, 3},
                      {0, 5} , {1, 5} , {2, 5} , {3, 5} , {4, 5} , {5, 4},
                    };

int scr[6][5];

void clrscr() {
  int x, y;
  for (x=0; x<6; x++) 
    for (y=0; y<5; y++)
      scr[x][y] = 0;
}

void drawscr(int c) {
  int x, y;
  int s;
  while (c--) {
    s = 20;
    while(s--)
      for (x=0; x<6; x++)
         for (y=0; y<5; y++) {
           charlieplex.charlieWrite(ledi[x+y*6], scr[x][y]>s?HIGH:LOW);
           charlieplex.clear();
         }
  
  }
}

void fadescr_down() {
  int x, y;
  for (x=0; x<6; x++) 
    for (y=0; y<5; y++)
      if (scr[x][y])
        scr[x][y] -= 1;
}

void fadescr_up() {
  int x, y;
  for (x=0; x<6; x++) 
    for (y=0; y<5; y++)
      if (scr[x][y] < 30)
        scr[x][y] += 1;
}


int an  = 2;
int aus = 10;

void setup(){ /*nothing*/ }
 
void zufall_fading() {
  clrscr();
  int x, y;
  for (x=0; x<6; x++)
    for (y=0; y<5; y++)
      scr[x][y] = random(30) + 2;

  int i=30;

  while (i--) {
  drawscr(2); 
  fadescr_down();
  }  

}

void zufall_fading2() {
  clrscr();
  int x, y;
  for (x=0; x<6; x++)
    for (y=0; y<5; y++)
      scr[x][y] = - random(30) - 2;

  int i=50;

  while (i--) {
  drawscr(2); 
  fadescr_up();
  }  

 
}

void loop() {
  zufall_fading2();
}