Ejemplo n.º 1
0
int main()
{
    // Turn off miniblip buzzer
    PwmOut speaker(P0_8);
    speaker=0.0;
    // Create a temporary DigitalIn so we can configure the pull-down resistor.
    DigitalIn(DATA_PIN, PullDown);

    // The pixel array control class.
    neopixel::PixelArray array(DATA_PIN);

    neopixel::Pixel vector[25];
    void_matrix(vector);
    

    
    
    
    while (1) {
        float pot = ain.read() * 100.0f;
        if(pot<50){
            drawVector(sonrisa,vector,255,0,0);
        }else{
            drawVector(sonrisaTriste,vector,0,0,255);
        }
        
        array.update(vector, 64);
        wait_ms(500);
        
    }
}
Ejemplo n.º 2
0
int main()
{
    // Turn off miniblip buzzer
    PwmOut speaker(P0_8);
    speaker=0.0;
    // Create a temporary DigitalIn so we can configure the pull-down resistor.
    DigitalIn(DATA_PIN, PullDown);

    // The pixel array control class.
    neopixel::PixelArray array(DATA_PIN);

    neopixel::Pixel vector[25];
    void_matrix(vector);
    

    
    
    
    while (1) {
        float pot = ain.read() * 100.0f;
        if(pot<25)
            drawVector(sonrisaTriste,vector,0,0,255);
        else 
            if(pot >=25 && pot <75)
                drawVector(sonrisaRegular,vector,0,255,0);
            else
                drawVector(sonrisa,vector,255,0,0);
        float pushed = din.read();
        if(pushed>0.5)
            drawVector(bocaAbierta,vector,255,255,0);
        array.update(vector, 64);
        wait_ms(75);
        
    }
}
Ejemplo n.º 3
0
int main()
{
    // Turn off miniblip buzzer
    PwmOut speaker(P0_8);
    speaker=0.0;
    // Create a temporary DigitalIn so we can configure the pull-down resistor.
    DigitalIn(DATA_PIN, PullDown);
    // The pixel array control class.
    neopixel::PixelArray array(DATA_PIN);    

    //Genero la variable que representa el potenciometro
    AnalogIn   ain(POTEN);

    
    for(int j=0;j<NLEDS;j++){
        tablero[j]= EMPTY;   
    }
    tablero[bird]=BIRD;   
     
    
    while (1) {
        if(ciclos==0){
            ciclos = NUMEROCICLOSPORJUEGADA;
            if(!lose)generarTablero();            
        }
        pintarTablero();
        colorbrigthness::calculatecolorMatrix(lista,NLEDS,255*ain);
        array.update(lista,NLEDS);
        ciclos--;
        wait_ms(100);        
    }
}
Ejemplo n.º 4
0
int main()
{
    // Turn off miniblip buzzer
    PwmOut speaker(P0_8);
    speaker=0.0;
    // Create a temporary DigitalIn so we can configure the pull-down resistor.
    DigitalIn(DATA_PIN, PullDown);

    // The pixel array control class.
    neopixel::PixelArray array(DATA_PIN);

    // Generamos el array y lo vaciamos
    neopixel::Pixel vector[25];
    void_matrix(vector);
    //Introducimos varios colores de prueba
    fill_pixel(vector,0,0,255,0,0);
    fill_pixel(vector,1,1,255,0,0);
    fill_pixel(vector,2,2,0,255,0);
    fill_pixel(vector,3,3,255,0,0);
    fill_pixel(vector,4,4,255,0,0);
    fill_pixel(vector,0,4,0,0,255);
    fill_pixel(vector,1,3,0,0,255);
    fill_pixel(vector,3,1,0,0,255);
    fill_pixel(vector,4,0,0,0,255);
    
    
    while (1) {
        array.update(vector, 64);
        
    }
}
Ejemplo n.º 5
0
void LowPowerPrep(void) {
    Radio.DisableRadioIRQs(); // Disable radio IRQs to prevent them from waking the MCU
    Radio.Sleep();
    DigitalIn(PA_9, PullUp); // Radio reset
    // Disable GPIO clocks for all ports
    RCC->AHBENR &= ~(RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN |RCC_AHBENR_GPIOCEN | RCC_AHBENR_GPIODEN | RCC_AHBENR_GPIOEEN | RCC_AHBENR_GPIOHEN);
   // LowPowerPins();
}
Ejemplo n.º 6
0
void LowPowerPins(void)
{
        // Enable All GPIO clocks to be able to initialise pins
        RCC->AHBENR |= (RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN | RCC_AHBENR_GPIOCEN | RCC_AHBENR_GPIODEN | RCC_AHBENR_GPIOEEN | RCC_AHBENR_GPIOHEN);
                            
         GPIO_InitTypeDef GPIO_InitStruct;
         // All other ports are analog input mode
         GPIO_InitStruct.Pin = GPIO_PIN_All;
         GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
         GPIO_InitStruct.Pull = GPIO_PULLDOWN;
         GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
         //HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
         //HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
         //HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
         HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); 
         HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); 
         HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); 

         /* Set unused Port A pins to analogue input, low speed, pull down */
         /* PA_1 - trigger, PA_3 - receive, PA_9 - reset, PA_10 - dio3 */
         GPIO_InitStruct.Pin = (GPIO_PIN_0 | /* GPIO_PIN_1 | */  GPIO_PIN_2 | /* GPIO_PIN_3 | */ GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | /* GPIO_PIN_9 |  GPIO_PIN_10 | */
                                   GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15 );
         HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

         DigitalIn(PA_1, PullUp); // ultrasonic trigger
         DigitalIn(PA_9, PullUp); // Radio reset

         /* Set unused Port B pins to analogue input, low speed, pull down */
         /* PB_0 - dio0, PB_1 - dio1, PB_3 - sclk, PB_4 - miso, PB_5 - mosi, PB_10 - USBTX, PB_11 - USBRX */
         GPIO_InitStruct.Pin = (/*GPIO_PIN_0 | GPIO_PIN_1 | */GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 |GPIO_PIN_9 | GPIO_PIN_10 |
                                   GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15 );
         HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

         /* Set unused Port C pins to analogue input, low speed, pull down */
         /* PC_6 - dio2, PC_8 - nss, PC_13 - vswitch */
         GPIO_InitStruct.Pin = (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | /* GPIO_PIN_6 | */ GPIO_PIN_7 | /* GPIO_PIN_8 | */ GPIO_PIN_9 | GPIO_PIN_10 |
                                   GPIO_PIN_11 | GPIO_PIN_12 |  GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15 );
         HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

         DigitalIn(PC_8, PullUp); // radio spi nss
   
         // Disable GPIO clocks for all ports
         RCC->AHBENR &= ~(RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN |RCC_AHBENR_GPIOCEN | RCC_AHBENR_GPIODEN | RCC_AHBENR_GPIOEEN | RCC_AHBENR_GPIOHEN);

}
Ejemplo n.º 7
0
int main() {
    int i;
    DigitalIn(DATA_PIN, PullDown);
    neopixel::Pixel vector[25];
    
    neopixel::PixelArray array(DATA_PIN);
    
    clear(vector);
    array.update(vector,25);
    
    while(true){
        float pot = ain.read() * 100.0f;
        if(pot == 0){
        
            ejemplo(vector,1);
            array.update(vector,25);
       
        
             
            
        }else if(pot > 0 && pot <50){
            
            ejemplo(vector,2);
            array.update(vector,25);
           
            
                
        }else{
            
            ejemplo(vector,3);
            array.update(vector,25);
            
                
            
            }
            
            wait_ms(500);
    
    }
    
    
    
    
    
}
Ejemplo n.º 8
0
int main()
{
    // setup
    DigitalIn(MATRIX_PIN, PullDown);
    neopixel::PixelArray array(MATRIX_PIN);

    // Turn off miniblip buzzer
    PwmOut speaker(P0_8);
    speaker=0.0;
    
    pinta(0,0,0);
    
    wait(1);
    
    for (int i = 0; i < TOUCH_N; i++) {
        p_touch_io[i] = new DigitalInOut(touch_pin[i]);
        p_touch_io[i]->mode(PullDown);
        p_touch_io[i]->output();
        p_touch_io[i]->write(1);
    }
    
    tick.attach(detect, 1.0 / 64.0);
    
    while(1) {
        // do something
        
        switch (mode){
            case 1:
                pinta(20,0,0);
                break;
            case 2:
                pinta(0,20,0);
                break;
            case 3:
                pinta(0,0,20);
                break;
            case 4:
                pinta(20,20,0);
                break;
            }
        array.update(buffer, NLEDS); 
                
    }
}