Exemple #1
0
int main(void)
{
    int i = 0;

    /* Initiate IO ports and peripheral devices. */
    init_io();
	
    /* Indicate that the device has just booted. */
    boot_msg();

    /* Set the layer to start drawing at */
    current_layer = 0x00;
	
    /* 
     * Enable interrupts to start drawing the cube buffer. When interrupts
     * are enabled, ISR(TIMER2_COMP_vect) will run on timed intervals. 
     */
    sei();

    /* Main program loop. */
    while (1) {
	for (i = 0; i < NUM_ANIMATIONS + 1; ++i) {
	    launch_effect(i);
	}
	/* Comment the loop above and uncomment the line below
	 * if you want the effects in random order (produced some bugs.) */
	/* launch_effect(rand() % 13); */
    }

}
Exemple #2
0
// Main loop
// the AVR enters this function at boot time
int main (void)
{
	int effect_index = 0;
    int tempval;
    
    // This function initiates IO ports, timers, interrupts and
    // serial communications
	ioinit();

    usart_init();
    
	debug_init();

	util_init();
	
    // This variable specifies which layer is currently being drawn by the
	// cube interrupt routine. We assign a value to it to make sure it's not >7.
	current_layer = 7;
	
    // This variable specifies the starting mode, this can be changed by pushing the
    // mode button or by typing in commands in the prompt.
    current_mode = MODE_RANDOM;

	//Binary mode
	binary_mode = 0;


    // Reads a value from AD converter and uses it to seed the pseudo random number generator,
    // Not perfect since AD converter returns a value from 0 to 1023 but good enough.
    tempval = ADC_Read(7);
	srand(tempval);

	// Enable interrupts
	// This starts the routine that draws the cube content
	sei();

	// Main loop, does awesome shit forever!
	while (1)
	{
        if(current_mode == MODE_RANDOM)
        {
            effect_index = rand() % EFFECTS_TOTAL;
            
            launch_effect(effect_index);
        }
        else if(current_mode == MODE_SEQUENTIAL)
        {
            effect_index++;
            effect_index %= EFFECTS_TOTAL;
            
            launch_effect(effect_index);
        }
        else if(current_mode == MODE_SELF_TEST)
        {
            override_delay(0);
            
			SelfTest();
        }
        else if(current_mode == MODE_MUSIC_RANDOM)
        {
            
        }
        else if(current_mode == MODE_MUSIC_SEQUENTIAL)
        {
            
        }
        else if(current_mode == MODE_BINARY)
        {
            rs232();
        }
        else
        {
            current_mode = MODE_RANDOM;
        }
	}
}