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.
Dependencies: mbed
Fork of METRIX_2 by
Diff: metrix.cpp
- Revision:
- 5:616b5894b610
- Parent:
- 4:78194ed9ff6b
- Child:
- 6:f4489f28da4a
--- a/metrix.cpp Fri Oct 12 04:03:49 2018 +0000
+++ b/metrix.cpp Wed Oct 17 18:36:09 2018 +0000
@@ -1,20 +1,24 @@
#include "mbed.h"
#include "moggo.h" //agrega la libreria que contiene las figuras.
-SPI deviceM(PB_15, PB_14, PB_13);
-DigitalOut ssel (PB_12);
-//SPI deviceM(PB_5, PB_4, PB_3); //define el Clock, Dato salida (miso) y Dato de entrada (mosi).
-//DigitalOut ssel (PB_9); //Chip Select para el controlador.
-Serial command(USBTX,USBRX); //habilitar la comunicacion serial a traves del puerto usb.
+//SPI deviceM(PB_15, PB_14, PB_13);
+//DigitalOut ssel (PB_12);
+SPI deviceM(PB_5, PB_4, PB_3); //define el Clock, Dato salida (miso) y Dato de entrada (mosi).
+DigitalOut ssel (PB_9); //Chip Select para el controlador.
+Serial command(USBTX,USBRX); //habilitar la comunicacion serial a traves del puerto usb.
+Serial com_tar(PC_10,PC_11,9600); //habilitar la comunicacion serial a traves del puerto usb.
+//Serial com_tar(PC_12,PD_2); //F446RE PC_10 TX; PC_11 RX;PC_12 TX; PD_2 RX.
+//Serial com_tar(PC_6,PC_5); //F446RE PC_6 TX; PC_5 RX;
+//Serial com_tar(PA_15,PB_7); //F411R PA_15 TX; PB_7 RX;
-#define VEL 30 //Velocidad de actualizacion de dato en el controlador.
+#define VEL 120 //Velocidad de actualizacion de dato en el controlador.
uint8_t mat_act[11]={0,0,0,0,0,0,0,0,0,0,0}; //Matriz para mostrar en pantalla.
-uint8_t mat_tmp[8]={0,0,0,0,0,0,0,0}; //Matriz temporal para arrojar las fichas.
+uint8_t mat_tmp[8]={0,0,0,0,0,0,0,0}; //Matriz temporal para arrojar las fichas.
uint8_t mat_tmp1[8]={0,0,0,0,0,0,0,0};
uint8_t cont=0,ncolumna=1,grados=1,ficha=0;
int fila=0;
-
+
void sendSPI(uint8_t d1, uint8_t d2)
{
deviceM.unlock();
@@ -25,10 +29,10 @@
deviceM.lock();
}
-void test() //test
+void test() //test
{
sendSPI(0x09,0); //no decodificacion
- sendSPI(0x0A,0x00); //intensidad
+ sendSPI(0x0A,0x00); //intensidad
sendSPI(0x0B,0x07); //usa 7 leds
sendSPI(0x0C,1); //no apaga
sendSPI(0x0F,0); //operacion normal
@@ -97,19 +101,21 @@
void correr_fig(){
uint8_t correr;
- /*
+
char t=1;
while (t==1 && command.readable()==0){
wait_ms(0.1);
t=0;
}
- if (command.readable())
+ if (command.readable()){
correr=command.getc();
+ com_tar.putc(correr);
+ wait_ms(100);
+ }
else
- correr=5;
- */
+ correr=0;
- correr=command.getc();
+ //correr=command.getc();
if(correr==30) //Arriba, voltear figura.
correr=1;
@@ -177,7 +183,7 @@
void dibujar(char type_fig,char grados,char columna)
{
- switch (type_fig){ //Se envia el vector que contiene la figura a la funcion copiar matriz.
+ switch (type_fig){ //Se envia el vector que contiene la figura a la funcion copiar matriz.
case 1: if(columna>7)
columna=7;
cop_mat(5,1,1,FIG_ALL,columna); break; //1: cuadro;
@@ -209,7 +215,7 @@
break;
case 5: if(grados==1 || grados==3)
- cop_mat(5,4,1,FIG_ALL,columna); //5: S;
+ cop_mat(5,4,1,FIG_ALL,columna); //5: S;
if(grados==2 || grados==4)
cop_mat(0,1,3,FIG_ALL,columna);
break;
@@ -236,10 +242,12 @@
int main() {
test();
borrar();
+
while(1){
fichas();
buscar_fil();
cont=0;
+
while (cont<fila){
correr_fig();
dibujar(ficha,grados,ncolumna);
