
Programa de MIP
Dependencies: bloques ball mbed WS2812 PixelArray tsi_sensor TSI bloque MMA8451Q
Diff: main.cpp
- Revision:
- 8:9e69e576d1be
- Parent:
- 7:59efb2d370b3
- Child:
- 9:777b0535d3bb
--- a/main.cpp Fri May 21 19:09:00 2021 +0000 +++ b/main.cpp Sat May 22 16:46:49 2021 +0000 @@ -10,6 +10,7 @@ #define NUM_LEDS_PER_COLOR 10 #define NUM_LEDS_BARRA 4 #define ACCEL_ADRESS_I2C (0X1D<<1) +#define DIMENSION_TABLERO 16 PixelArray px(WS2812_BUF); @@ -28,6 +29,8 @@ int counter_tsi=0; int posAcelerometerTemp, posAcelerometer=0, posAcelerometerOLD=0, posAcelerometerOLD1=0, contadorReboteA=0; int posSliderTouchTemp, posSliderTouch=0, posSliderTouchOLD=0, posSliderTouchOLD1=0, contadorRebote=0; +int matrix_tablero[DIMENSION_TABLERO][DIMENSION_TABLERO]={}; +int pelota[2]={8,8}; //valor x en posicion 0 y valor y en posicion 1 //int pixel=8; @@ -38,9 +41,15 @@ void tsi_ctr_modeSlider(float tsi_newRead); void accel_ctr(); +void setPixelColor(int numPixelMatrix, int r, int g, int b){ + px.SetI(numPixelMatrix,255); + px.SetR(numPixelMatrix,r); + px.SetG(numPixelMatrix,g); + px.SetB(numPixelMatrix,b); +} int main() -{ int sel_opcio=1; +{ int sel_opcio=7; pc.baud(115200); pc.printf("\r\n\r\nHola!\r\ncompilado el " __DATE__ ", " __TIME__ "\r\n"); @@ -58,14 +67,19 @@ for(int i=0; i<NUM_LEDS_BARRA; i++){ px.Set(barra[i], 0x2f0000); } - + //px.SetR(64, 0); + //px.SetG(64, 255); + //px.SetB(64, 0); for(int i=0; i<NUM_LEDS_BARRA; i++){ - px.SetI(barra[i]%WS2812_BUF, 0xff); + px.SetI(barra[i]%WS2812_BUF, 255); //0xff + } + //px.SetI(64, 255); + + for(int i=0; i<NUM_LEDS_BARRA; i++){ + matrix_tablero[0][barra[i]]=1; } - - - + setPixelColor(64,0,255,0); // now all the colours are computed, add a fade effect using intensity scaling // compute and write the II value for each pixel /*for (int j=0; j<WS2812_BUF; j++) { @@ -161,7 +175,7 @@ posSliderTouchOLD1=posSliderTouchTemp; - if(contadorRebote>=8){ + if(contadorRebote>=70){ posSliderTouch=posSliderTouchTemp; } @@ -238,7 +252,7 @@ } px.Set(barra[led_encender], 0x2f0000); //encendemos el siguiente led - px.SetI(barra[led_encender]%WS2812_BUF, 0xff); + px.SetI(barra[led_encender]%WS2812_BUF, 255); //0xff }