Exemplo n.º 1
0
int main(void) {
	init_timer();
  init_io();

  USART_Init();

  sei();

  fill_cube(0xFF);

  _delay_us(1500000);

  int mode = (PIND & (1<<PD3));  

  if (mode) {

    while (1) {

      random_filler(1);
      random_filler(0);
      loadbar();
      rain(100);

      send_voxels_rand_z(200);

      set_edges();
      _delay_us(5000000);
    }

  } else {

    int escape = 0;
    int counter = 0;

    while (1) {

      uint8_t byte;
      byte = USART_Receive();

      if (!escape) {
        if (byte == 0xAB) { // escape character
          escape = 1;
        } else if (counter < 64) {
          tab[counter/8][counter%8] = byte;
          counter++;
        }
      } else {
        if (byte == 0xCD) { // start character
          counter = 0;
        } else if (byte == 0xAB && counter < 64) {
          tab[counter/8][counter%8] = byte;
          counter++;
        }
        escape = 0;
      }
    }

  }
  return 0;
}
Exemplo n.º 2
0
/* Launches one of those fancy effects. */
void launch_effect(int effect)
{
    switch (effect) {
    case 0:
	/* Lights all the layers one by one. */
	load_bar(1000);
	break;
    case 1:
	/* A pixel bouncing randomly around. */
	boing_boing(150, 500, 0x03, 0x01);
	break;
    case 2:
	/* Randomly fill and empty the cube. */
	fill(0x00);
	random_filler(100, 1, 500, 1);
	random_filler(100, 1, 500, 0);
	break;
    case 3:
	/* Send voxels randomly back and forth the z-axis. */
	send_voxels_rand_z(150, 500, 2000);
	break;
    case 4:
	/* Spinning spiral */
	spiral(1, 75, 1000);
	break;
    case 5:
	/* A coordinate bounces randomly around the cube. For every position
	 * the status of that voxel is toggled. */
	boing_boing(150, 500, 0x03, 0x02);
	break;
    case 6:
	/* Random raindrops */
	rain(40, 1000, 500, 500);
	break;
		
    case 7:
	/* Snake: a snake randomly bounce around the cube. */
	boing_boing(150, 500, 0x03, 0x03);
	break;
    case 8:
	/* Spinning plane */
	spinning_plane(1, 50, 1000);
	break;
    case 9:
	/* Set x number of random voxels, delay, unset them. x increases
	 * from 1 to 32 and back to 1. */
	random_2(48);
	break;
    case 10:
	/* Set then unset all 64 voxels in a random order. */
	random_filler2(200, 1);
	delay_ms(2000);
	random_filler2(200, 0);
	delay_ms(1000);
	break;
    case 11:
	/* Bounce a plane up and down all the directions. */
	fly_plane('z', 1, 1000);
	delay_ms(2000);
	fly_plane('y', 1, 1000);
	delay_ms(2000);
	fly_plane('x', 1, 1000);
	delay_ms(2000);
	fly_plane('z', 0, 1000);
	delay_ms(2000);
	fly_plane('y', 0, 1000);
	delay_ms(2000);
	fly_plane('x', 0, 1000);
	delay_ms(2000);
	break;
    case 12:
	/* Fade in and out at low framerate. */
	blinky2();
	break;
    case 13:
	/* Random walk */
	random_walk(4, 250, 1000);
	break;
    case 14:
	/* Spinning square */
	spinning_square(1, 50, 1000);
	break;
    }
}