Hola urueña

Dependencies:   DS1302 HCSR04 SSD1306_128x64_I2C Servo mbed stop

Fork of DisplayOled1 by Juan Abril

Files at this revision

API Documentation at this revision

Comitter:
Gustavo_Guerrero
Date:
Sun May 06 23:49:39 2018 +0000
Parent:
2:5d1c146e04d4
Commit message:
hola urue?a

Changed in this revision

DS1302.lib Show annotated file Show diff for this revision Revisions of this file
GameOver.lib Show diff for this revision Revisions of this file
HCSR04.lib Show annotated file Show diff for this revision Revisions of this file
MikeWachowski.lib Show diff for this revision Revisions of this file
Servo.lib Show annotated file Show diff for this revision Revisions of this file
flechaarriba.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
sobrepeso.lib Show diff for this revision Revisions of this file
diff -r 5d1c146e04d4 -r de4b6b2e0202 DS1302.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DS1302.lib	Sun May 06 23:49:39 2018 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/users/Sissors/code/DS1302/#9a746f303e59
diff -r 5d1c146e04d4 -r de4b6b2e0202 GameOver.lib
--- a/GameOver.lib	Fri Sep 22 23:00:52 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/users/Abril1030/code/GameOver/#bfdc7ede55b6
diff -r 5d1c146e04d4 -r de4b6b2e0202 HCSR04.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HCSR04.lib	Sun May 06 23:49:39 2018 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/teams/TVZ-Mechatronics-Team/code/HCSR04/#cf3e4e307d15
diff -r 5d1c146e04d4 -r de4b6b2e0202 MikeWachowski.lib
--- a/MikeWachowski.lib	Fri Sep 22 23:00:52 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/users/Abril1030/code/MikeWachowski/#cd694606e7a2
diff -r 5d1c146e04d4 -r de4b6b2e0202 Servo.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Sun May 06 23:49:39 2018 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/users/simon/code/Servo/#36b69a7ced07
diff -r 5d1c146e04d4 -r de4b6b2e0202 flechaarriba.lib
--- a/flechaarriba.lib	Fri Sep 22 23:00:52 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/users/Abril1030/code/flechaarriba/#874c365e9483
diff -r 5d1c146e04d4 -r de4b6b2e0202 main.cpp
--- a/main.cpp	Fri Sep 22 23:00:52 2017 +0000
+++ b/main.cpp	Sun May 06 23:49:39 2018 +0000
@@ -1,74 +1,102 @@
- #include "mbed.h"
- #include "flechaabajo.h"
- #include "flechaarriba.h"
- #include "stop.h"
- #include "sobrepeso.h"
- #include "GameOver.h"
- #include "Mike.h"
- #include "SSD1306.h"
+#include "mbed.h"
+#include "SSD1306.h"
+#include "Servo.h"
+#include "HCSR04.h"
+
+#define SCLK    PTC5
+#define IO      PTC4
+#define CE      PTC3
+#include "DS1302.h"
+
+Servo myservo(PTD4);
+Timer timer;
+AnalogIn   ain(A0);
+DS1302 clk(SCLK, IO, PTC3);
+
+#define D_SDA                  PTC11
+#define D_SCL                  PTC10
+I2C i2c(D_SDA, D_SCL);
+
+SPI spi(PTD2, PTD3, PTD1); //MOSI MISO Y SCLK
+//DigitalOut K(PTD5);
+Serial pc(USBTX, USBRX);
 
- #define D_SDA                  PTC11
- #define D_SCL                  PTC10
- I2C i2c(D_SDA, D_SCL);
- //Serial pc(USBTX, USBRX); // tx, rx
- //Serial device(PTE0, PTE1);
- char x;
+char x[10];
+int i=0,cs2=0;
+int dato3;
+uint16_t adcvalue ;
+float  voltaje ;
+
+SSD1306 oled = SSD1306(i2c, SSD1308_SA0);
+
+
+int main()
+{
+
+#ifdef INITIAL_RUN
+    clk.set_time(1512485768);
+#endif
+
+    char storedByte = clk.recallByte(0);
+    printf("Stored byte was %d, now increasing by one\r\n", storedByte);
+    clk.storeByte(0, storedByte + 2);
+
+    HCSR04 sensor(PTD5, PTA13);
+    sensor.setRanges(10, 110);
+    pc.printf("Min. range = %g cm\n\rMax. range = %g cm\n\r",
+              sensor.getMinRange(), sensor.getMaxRange());
 
- 
- SSD1306 oled = SSD1306(i2c, SSD1308_SA0);
- 
- int main() {
-       // if(device.readable()) {
-          //  pc.putc(device.getc());
-           //oled.writeString(0,3,"Andres perra");
-             // }
-        
-        oled.writeBitmap((uint8_t*) Pikachu);
-        /*oled.setDisplayOff();
-        wait(0.2);
-        oled.setDisplayOn();
-        wait(0.2);
-        oled.writeBitmap((uint8_t*) sobrepeso);
-        oled.setDisplayOff();
-        wait(0.2);   
-        oled.setDisplayOn();
-        wait(0.2);
-        oled.writeBitmap((uint8_t*) sobrepeso);
-        oled.setDisplayOff();
-        wait(0.2);   
-        oled.setDisplayOn();
-        wait(0.2);
-        oled.writeBitmap((uint8_t*) sobrepeso);
-        oled.setDisplayOff();
-        wait(0.2);   
-        oled.setDisplayOn();
-        wait(0.2);
-        oled.writeBitmap((uint8_t*) sobrepeso);
-        oled.setDisplayOff();
-        wait(0.2);   
-        oled.setDisplayOn();*/
-        
-        
-        
-        while(1){
-             
-        
-            /*device.getc();
-            if (x=='a'){
-                oled.writeString(1, 3, "Primer Piso");
-                }
-            if (x=='b'){
-                oled.writeString(1, 3, "Segundo Piso");
-                }
-            if (x=='c'){
-                oled.writeString(1, 3, "Tercer Piso");
-                }
-            if (x=='d'){
-                oled.writeString(1, 3, "Cuarto Piso");
-                }*/
- }
+    while(1) {
+        time_t seconds = clk.time(NULL);
+        sprintf(x,"%s\r", ctime(&seconds));
+        oled.writeString(0, 5, x);//Fecha publicada
+
+        //Inicio termocupla
+        DigitalOut (PTD0, 1);
+        spi.format(8,3);
+        spi.frequency(1000000);
+        wait_ms(700);
+        DigitalOut (PTD0, 0);
+        spi.write(0x00);
+        int dato = spi.write(0xFF);
+        int dato2 = spi.write(0xFF);
+        dato3 = (((dato2*256 + dato)/8)/4);
+        //pc.printf("%d\n", dato3);
+
+        DigitalOut (PTD0, 1);
+        oled.writeProgressBar(2,4,dato3*2);
+        oled.writeString(2, 8, "Temp.");
+        //Fin termocupla
 
- }
+        //inicio servo
+        adcvalue = ain.read_u16();
+        voltaje = ((adcvalue*100)/65536);
+        myservo = voltaje/100.0;
+        oled.writeLevelBar(6,4,voltaje);
+        oled.writeString(6, 8, "Ang.");
+        //fin servo
+
+
+        //INICIO ULTRASÓNICO
+        timer.reset();
+        timer.start();
+        sensor.startMeasurement();
+        while(!sensor.isNewDataReady()) {
+            // wait for new data
+            // waiting time depends on the distance
+
+        }
+        //pc.printf("Distance: %5.1f cm\r\n", sensor.getDistance_cm());
+        pc.printf("%u\n", sensor.getDistance_cm());
+        timer.stop();
+        wait_ms(500 - timer.read_ms());
+        oled.writeProgressBar(4,4,sensor.getDistance_cm());
+        oled.writeString(4, 8, "Dist.");
+        //FIN ULTRASONICO
+        wait_ms(1000);
 
 
 
+    }
+
+}
\ No newline at end of file
diff -r 5d1c146e04d4 -r de4b6b2e0202 sobrepeso.lib
--- a/sobrepeso.lib	Fri Sep 22 23:00:52 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/users/Abril1030/code/sobrepeso/#07d45a05b8eb