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: NAVDATA RA8875 mbed VCODATA
Diff: main.cpp
- Revision:
- 0:d92271b032c7
- Child:
- 3:0c9ee19fb976
diff -r 000000000000 -r d92271b032c7 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Mar 19 21:09:11 2017 +0000
@@ -0,0 +1,238 @@
+
+#include "mbed.h" // v112
+#include "RA8875.h" // v102
+#include "MyFont18x32.h"
+#include "BPG_Arial08x08.h"
+#include "BPG_Arial10x10.h"
+#include "BPG_Arial20x20.h"
+#include "BPG_Arial31x32.h"
+#include "BPG_Arial63x63.h"
+
+// Agrego includes para uso en la comunicacion con el gps.
+ #include "GPS.h"
+
+ // Agrego includes para medicion de pulsos del sensor de flujo
+ //#include "DebounceIn.h"
+
+ #include <sstream> //include this to use string streams
+ #include <string>
+
+float Counter=0; //Contador de pulsos del sensor de flujo.
+float LCounter=0; //Consumo en litros
+float Consumo_km=0; //Consumo en litros/km.
+
+
+
+
+LocalFileSystem local("local"); // Because I want <PrintScreen>
+Serial pc(USBTX, USBRX); // And a little feedback
+
+ RA8875 lcd(p5, p6, p7, p12, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name
+
+ void trigger() { //Función para la interrupción
+ Counter++;
+ LCounter=Counter/2500;
+ //point_t p_cursor = lcd.GetTextCursor();
+ //lcd.SetTextCursor(0,200);
+ //lcd.printf("Flujo %d pulsos", Counter);
+ //lcd.SetTextCursor(p_cursor);
+ }
+ // float getConsumo(int , int velocidad){
+
+int main()
+{
+
+
+ pc.baud(460800); // I like a snappy terminal, so crank it up!
+ pc.printf("\r\nRA8875 Soft Fonts - Build " __DATE__ " " __TIME__ "\r\n");
+
+ lcd.init();
+
+
+
+
+
+
+
+ // **************************
+ //RunTestSet(lcd, pc); // If the library was compiled for test mode...
+
+ lcd.foreground(RGB(255,255,0)); // Seteo del color de las letras.
+
+
+
+ //lcd.puts(0,0, "RA8875 Soft Fonts - Build " __DATE__ " " __TIME__ "\r\n");
+
+ //lcd.SelectUserFont(Dave_Smart18x32);
+ //lcd.puts("**** ! Soft Fonts ! **** 0123456789\r\n");
+ //lcd.puts("ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n");
+ //lcd.puts("abcdefghijklmnopqrstuvwxyz\r\n");
+ //lcd.SelectUserFont();
+ //lcd.puts("Back to normal\r\n");
+ //lcd.SelectUserFont(BPG_Arial08x08);
+ //lcd.puts("BPG_Arial08x08 ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n");
+ //lcd.puts("BPG_Arial08x08 abcdefghijklmnopqrstuvwxyz\r\n");
+ //lcd.SelectUserFont(BPG_Arial10x10);
+ //lcd.puts("BPG_Arial10x10 ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n");
+ //lcd.puts("BPG_Arial10x10 abcdefghijklmnopqrstuvwxyz\r\n");
+ //lcd.SelectUserFont(BPG_Arial20x20);
+ //lcd.puts("BPG_Arial20x20 ");
+ //lcd.SelectUserFont(BPG_Arial31x32);
+ //lcd.puts("BPG_Arial31x32\r\n");
+
+ // lcd.init();
+ //lcd.printf("printing 3 x 2 = %d", 3*2);
+ /*lcd.circle( 400,25, 25, BrightRed);
+ lcd.fillcircle( 400,25, 15, RGB(128,255,128));
+ lcd.ellipse( 440,75, 35,20, BrightBlue);
+ lcd.fillellipse( 440,75, 25,10, Blue);
+ */
+
+ /*
+ lcd.SelectUserFont(BPG_Arial63x63);
+ //lcd.puts("BPG_Arial63x63");
+ lcd.puts(" FIUBA\r\n");
+
+ lcd.puts("------------------------\r\n");
+ lcd.puts("Proyecto SNOCC\r\n");
+ */
+
+ /*lcd.triangle( 440,100, 475,110, 450,125, Magenta);
+ lcd.filltriangle( 445,105, 467,111, 452,120, Cyan);
+ //lcd.rect( 400,130, 475,155, Brown);
+ lcd.rect( 170,210, 55,235, Brown);
+ //lcd.fillrect( 405,135, 470,150, Pink);
+ lcd.fillrect( 165,215, 60,230, Pink);
+ //lcd.roundrect( 410,160, 475,190, 10,8, Yellow);
+ lcd.roundrect( 210,200, 275,230, 10,8, Green);
+ //lcd.fillroundrect(415,165, 470,185, 5,3, Orange);
+ lcd.fillroundrect(215,205, 270,225, 5,3, Yellow);
+ lcd.line( 330,200, 360,230, RGB(0,255,255));
+ for (int i=0; i<=30; i+=5)
+ lcd.pixel(335+i,200+i, White);
+ */
+
+
+
+
+
+
+
+ lcd.SelectUserFont(BPG_Arial20x20); // Seleccion de tipo y tamaño de letras
+ //lcd.puts("BPG_Arial63x63");
+/* lcd.puts("\t\tFIUBA\r\n");
+ lcd.puts("---------------------\r\n");
+ lcd.printf("Contador = %d", Counter);
+ lcd.puts("Proyecto SNOCC");
+
+ pc.printf("PrintScreen activated ...\r\n");
+ RetCode_t r = lcd.PrintScreen(0,0,480,272,"/sd/file.bmp");
+ pc.printf(" PrintScreen returned %d\r\n", r);
+*/
+
+ GPS gps(p9, p10); // Agrego para comunicacion con el GPS
+
+ //Inicializo variables para el sensor de flujo
+ //----------------------------------------------------
+ DigitalOut myled(LED1);
+ DigitalOut myled2(LED2);
+ DigitalOut myled3(LED3);
+ DigitalOut myled4(LED4);
+
+
+ //DebounceIn pb(p8);
+ /*DigitalIn pb(p11);
+ int count=0; //Comento esto porque voy a usar interrupciones
+ int old_pb=0;
+ int new_pb;
+ // Use internal pullup for pushbutton
+ pb.mode(PullUp);
+ //pb.mode(PullNone);
+ // Delay for initial pullup to take effect
+ wait(.001);*/
+
+ //----------------------------------------------------
+
+
+ // Sensor de flujo:
+//-----------------------------------------------------
+ InterruptIn pulse_sensor(p11); // Defino pulse_sensor como una entrada de interrupción en p11.
+ pulse_sensor.mode(PullUp); // PullUp para esa entrada.
+ //DigitalOut led(LED1);
+ pulse_sensor.rise(&trigger); // Dispara interrupción con flanco ascendente. (Podría tambien ser desecendente--> fall)
+
+ while(1) {
+
+
+ lcd.SetTextCursor(0,0); // Pongo cursor en posicion
+ lcd.puts("Proyecto SNOCC\r\n");
+
+
+
+//int main() {
+
+ // }
+
+
+
+
+
+
+
+
+ //new_pb = pb;
+/* new_pb = pb.read();
+ //if ((new_pb==0) && (old_pb==1)) count++;
+ if ((!new_pb) && (old_pb)) Counter++;
+ //myled4 = count & 0x01;
+ //myled3 = (count & 0x02)>>1;
+ //myled2 = (count & 0x04)>>2;
+ //myled = (count & 0x08)>>3;
+ old_pb = new_pb;
+ lcd.SetTextCursor(0,200);
+ lcd.printf("Flujo %d pulsos", Counter);
+*/
+//-----------------------------------------------------
+
+ lcd.SetTextCursor(0,20);
+ //lcd.printf("M0: %s \r\n\r\n", gps.msg); //Imprimo el mensaje crudo proveniente de la uart
+ //lcd.printf("M1: %s \r\n", gps.mensaje1);
+ //lcd.printf("M2: %s \r\n", gps.mensaje2);
+ //lcd.printf("M3: %s \r\n", gps.mensaje3);
+ //lcd.printf("M4: %s \r\n", gps.mensaje4);
+ //lcd.printf("Posicion actual_0: %f, %f \r\n", gps.longitude, gps.latitude);
+ //lcd.printf("Contador = %d", Counter);
+
+ if(gps.sample()) { // Si es exitosa la obtencion de datos del gps.
+ //lcd.cls();
+ lcd.SetTextCursor(0,0); // Pongo cursor en posicion
+ lcd.puts("Proyecto SNOCC\r\n");
+ lcd.SetTextCursor(0,100);
+ lcd.printf("Posicion: %f, %f\r\n", gps.longitude, gps.latitude);
+ lcd.printf("Velocidad %f km/h", gps.speed);
+ // lcd.printf("Consumo %f l/km", getConsumo(Count; gps.speed);
+ lcd.SetTextCursor(0,200);
+ lcd.printf("Flujo %f Litros", LCounter);
+
+ } else {
+ lcd.cls();
+ lcd.SetTextCursor(0,0); // Pongo cursor en posicion
+ lcd.puts("Proyecto SNOCC\r\n");
+ lcd.SetTextCursor(0,100);
+ lcd.printf("No hay datos disponibles :(\n");
+ lcd.SetTextCursor(0,200);
+ lcd.printf("Flujo %f Litros", LCounter);
+ }
+
+ }
+
+
+
+
+/*
+ while(1) {
+ ; // end
+ }
+*/
+
+}
\ No newline at end of file