Exemplo n.º 1
0
void setup() 
{
	memset(rgb, 0, sizeof rgb);
	
	Serial.begin(9600);
	
	strip.begin();
	strip.show();
}
Exemplo n.º 2
0
/****************************************
* main
*
* sets up the communication between the  main mbed
* inits the leds to check if the leds are working properly
* continuously checks for a command from the main mbed
* if new command received, then executes the appropriate function
*
****************************************/
int main()
{
    uint8_t R,G,B;
    pc.baud(9600);
    strip.begin();
    init_grid();

    /*Shutting down the leds*/
    clear_strip();    
    getColor(&R,&G,&B,"G");
    wait_ms(10);
    //clear_strip();
//    show_pixel(&pixel_grid[0][0], R, G, B, 500);
//    wait_ms(1000);

    pixel_grid[0][0].selected = 1;
    pixel_grid[1][1].selected = 1;
    pixel_grid[2][2].selected = 1;
    pixel_grid[2][0].selected = 1;
    pixel_grid[0][2].selected = 1;

    //pixel_grid[0][0].selected = 1;
//    pixel_grid[1][1].selected = 1;
//    pixel_grid[2][2].selected = 1;
//    pixel_grid[3][3].selected = 1;
//    pixel_grid[4][2].selected = 1;
//    pixel_grid[5][1].selected = 1;
//    pixel_grid[6][0].selected = 1;

//    select_all_pixels();
    
    create_pattern(P_WAVE_FLOW, DIR_RIGHT, R, G, B, 50, 5000);
    
//    pixel_grid[10][0].selected = 1;
//    pixel_grid[10][1].selected = 1;
//    pixel_grid[10][2].selected = 1;
//    pixel_grid[10][3].selected = 1;
//    pixel_grid[9][1].selected = 1;
//    pixel_grid[9][2].selected = 1;
//    pixel_grid[9][3].selected = 1;
//    pixel_grid[8][2].selected = 1;
//    pixel_grid[8][3].selected = 1;
//    pixel_grid[7][3].selected = 1;
    
//
//    create_pattern(P_CUSTOM, DIR_UP, 150, 80, 200, 50, 1000);
//    
    //pixel_grid[0][0].selected = 1;
//    pixel_grid[1][1].selected = 1;
//    pixel_grid[2][2].selected = 1;
//    pixel_grid[2][0].selected = 1;
//    pixel_grid[0][2].selected = 1;
//    
//    getColor(&R,&G,&B,"G");
//    
//    create_pattern(P_CUSTOM, DIR_UP, R, G, B, 25, 1000);
//    
//    pixel_grid[2][0].selected = 1;
//    pixel_grid[2][1].selected = 1;
//    pixel_grid[2][2].selected = 1;
//    pixel_grid[2][3].selected = 1;
//    
//    getColor(&R,&G,&B,"B");
//    
//    create_pattern(P_CUSTOM, DIR_UP, R, G, B, 50, 1000);
    
//    wait(0.1);
    
    clear_strip();
        
    while(1)
    {
        //wait for messages
        rxLen = rf_receive(rxBuffer, 128);
        if(rxLen > 0)
        {
            if(rxBuffer[0] == ID) 
            {
                char* rxBuffer1 = &rxBuffer[1];
                pc.printf("Received string %s \r\n",rxBuffer);
                parser(rxBuffer1);
            }
        }
    }
}