Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:2ac3cf92c198, committed 2018-11-02
- Comitter:
- sanchezzbrahian
- Date:
- Fri Nov 02 15:43:31 2018 +0000
- Parent:
- 0:ef627c2ce25b
- Commit message:
- Tetrix;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 18 23:40:53 2018 +0000
+++ b/main.cpp Fri Nov 02 15:43:31 2018 +0000
@@ -1,6 +1,9 @@
#include "mbed.h"
#include "algo.h"
#define MAXDAT 3
+AnalogIn vrx(A0);
+AnalogIn vry(A1);
+
SPI deviceM(PB_15, PB_14, PB_13);
DigitalOut ssel (PB_12);
@@ -12,6 +15,10 @@
uint8_t mat_tmp1[8]={0,0,0,0,0,0,0,0}; //Matriz temporal de las fichas.
uint8_t dat[MAXDAT]={0,0,0};
uint8_t fila=0,save=0,i=0,cont=0,mcol=0,num=0,grad=0;
+float mx;
+float msx;
+float my;
+float msy;
void sendSPI(uint8_t d1, uint8_t d2)
{
@@ -74,9 +81,15 @@
mat_tmp1[i]= mat_tmp[i];
}
}
+void d_ale()
+ {
+ num=rand()%5+1;
+ mcol=4;
+ }
void ingred_d() //Tipo de figuras
{
uint8_t tf=dat[0];
+//uint8_t tf=num;
switch(tf)
{
@@ -98,21 +111,26 @@
}
}
- void d_ale()
+ void analogo()
{
- num=rand()%5+1;
- mcol=4;
- }
+ mx=vrx.read();
+ msx=mx*3300;
+ my=vry.read();
+ msy=my*3300;
+ printf("Datosx = %f",msx);
+ }
void move_fig()//mueve la figura por medio de botones
{
- int mfig=0;
- mfig=pc.getc();
- if(mfig==30){
+ analogo();
+ int mfig;
+
+ if(msx>1800){
mfig=1;}
- if(mfig==29){//mover figura a la derecha
+ if(msy<25){//mover figura a la derecha
mfig=2;}
- if(mfig==28){//mover figura a la izquierda
+ if(msy>1800){//mover figura a la izquierda
mfig=3;}
+
switch(mfig)
{
case 0:
@@ -156,6 +174,7 @@
for(i=0;i<3;i++)
{
mat_tmp[i]=mat_tmp[i]>>mcol; //mover derecha
+
}
for(i=0;i<7;i++){
mat_tmp1[i]=mat_tmp1[i]>>mcol;
@@ -218,7 +237,8 @@
ingred_d();
act_matrix(mat_tmp);
for (cont=0;cont<fila;cont++)
- {
+ {
+ analogo();
move_fig();
act_matrix(mat_tmp);
imp_mat(mat_tmp);