
Programa de MIP
Dependencies: bloques ball mbed WS2812 PixelArray tsi_sensor TSI bloque MMA8451Q
Diff: main.cpp
- Revision:
- 15:706dd4761fbe
- Parent:
- 14:4adfd8e600fe
- Child:
- 16:eab9a8d27969
--- a/main.cpp Mon May 24 18:57:03 2021 +0000 +++ b/main.cpp Mon May 24 19:42:13 2021 +0000 @@ -83,12 +83,13 @@ }*/ print_pixel(255, 255, 255, m_ball.getCoordX(), m_ball.getCoordY(),-1,-1); + //print_pixel(255, 255, 255, 0, 0,-1,-1); // Now the buffer is written, rotate it // by writing it out with an increasing offset ws.write(px.getBuf()); - refresh_ball.attach(&ctr_ball, 0.2); + refresh_ball.attach(&ctr_ball, 0.4); while (1) { /*for (int z=WS2812_BUF; z >= 0 ; z--) { ws.write_offsets(px.getBuf(),z,z,z); @@ -211,7 +212,7 @@ for(int i=0; i<NUM_LEDS_BARRA; i++){ //actualizamos valor del array barra[i]=barra[i]+act_barra; - pc.printf("\r\n UPDATEEE ------- =%d", barra[i]); + //pc.printf("\r\n UPDATEEE ------- =%d", barra[i]); } px.Set(barra[led_encender], 0x2f0000); //encendemos el siguiente led @@ -316,12 +317,16 @@ bool found_barra=false; int i=0; if(old_i==15){ + direct_ball=!direct_ball; angle_rebote(); + } else{ if( (old_j==15 or old_j==0) and (angle!=1) and old_i!=1){ + pc.printf("Angle ANTES REBOTE --> %d \r\n", angle); angle_rebote(); + pc.printf("Angle DESPUES REBOTE --> %d \r\n", angle); }else{ int predict_Y=m_ball.predict_Y_axis_barra(direct_ball, angle); @@ -372,16 +377,17 @@ int j=0; if(found_blq_i){ int predict_Y=m_ball.predict_Y_axis(direct_ball, angle); + pc.printf("\r\n Coord X %d, Coord Y %d y predictY %d --> \n",m_ball.getCoordX(), m_ball.getCoordY() , predict_Y ); while(!found_blq_j and j<Bloques.getNumBloques() ){ bloque temp_blq=Bloques.getBloque(j); int blq_pos_Y=(temp_blq.getCoordY()+temp_blq.getSize()); - if((blq_pos_Y>=predict_Y and predict_Y>=temp_blq.getCoordY()) and temp_blq.getEnabled()){ + if((blq_pos_Y>predict_Y and predict_Y>=temp_blq.getCoordY()) and temp_blq.getEnabled()){ found_blq_j=true; direct_ball=!direct_ball; angle_rebote(); print_pixel(temp_blq.getColR(), temp_blq.getColG(), temp_blq.getColB(), -1, -1, temp_blq.getCoordX(), temp_blq.getCoordY(), temp_blq.getSize()); Bloques.disable_blq(j); - //pc.printf("Bloques --> %d", Bloques.getBloque(j).getEnabled()); + //pc.printf("BloqY %d, temp_bloq.CoordY %d y predictY %d --> %d", blq_pos_Y, temp_blq.getCoordY() , predict_Y ); } j++; }