Cambios

Dependencies:   mbed Adafruit_GFX SeeedShieldBot BluetoothSerial

Files at this revision

API Documentation at this revision

Comitter:
arturodeusto
Date:
Tue Dec 22 11:02:59 2020 +0000
Parent:
4:5182de07691c
Commit message:
final

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Dec 22 10:51:27 2020 +0000
+++ b/main.cpp	Tue Dec 22 11:02:59 2020 +0000
@@ -3,7 +3,7 @@
 #include "Adafruit_SSD1306.h"
 
 
-/*class I2CPreInit : public I2C
+class I2CPreInit : public I2C
 {
 public:
     I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl)
@@ -14,7 +14,7 @@
 };
 
 I2CPreInit gI2C(PB_9,PB_8);
-Adafruit_SSD1306_I2c gOled(gI2C,NC,0x78,64,128);*/
+Adafruit_SSD1306_I2c gOled(gI2C,NC,0x78,64,128);
 
 Serial pc(USBTX, USBRX); // tx, rx
 Serial bt(A5, A4); // tx, rx
@@ -59,12 +59,10 @@
         if (dato=='1') {            //Si el dato es un 1 comienza el proceso
 
             estado = movder;
-          /*  gOled.printf("Fabricando\n");*/
             bt.printf("Transportando a calentador\n");
 
 
         } else {   
-        /*bt.printf("Reposo\n");*/   //Si el dato es cualquier otra cosa no empieza a hacer nada
         }
     }
 }
@@ -92,7 +90,6 @@
 void estadocalentar()
 {
     float tension=Vout.read()*3.3;
-    //pc.printf("Valor voltios %.4f leido flat\n",tension);
 
     float resistencia= ((3.3*100000.0)/tension)-100000.0;
 
@@ -113,10 +110,9 @@
 
 void estadomovizq1()
 {
-    unsigned int dist;
     usensor.start();
     wait(0.01);
-    dist=usensor.get_dist_cm();
+    dist=0.9*dist +0.1*usensor.get_dist_cm();
 
     if(dist>20) {
         enable=1; //activar el motor
@@ -186,9 +182,12 @@
     dirAMotor=0;
     dirBMotor=0;
     estado=inicio;
+    piezas= piezas+1;
 
-   /* gOled.printf("Reposo\n");*/
     bt.printf("Reposo\n");
+    gOled.printf("Nº de piezas:%d\n",piezas);
+    gOled.display();
+    gOled.setTextCursor(0,0);
     
 
 }
@@ -197,9 +196,12 @@
 
 int main()
 {
+    int piezas=0;
+    float dist;
     pc.baud(115200);
     estado = inicio;
-  /*  gOled.begin();*/
+    gOled.begin();
+    gOled.clearDisplay();
 
     repeticion.attach(&medir_corriente, 10.0); //Medir la intensidad cada tres segundos