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.
Fork of RA8875 by
main.cpp
- Committer:
- gstedile
- Date:
- 2016-12-04
- Revision:
- 112:b2ce766d095d
File content as of revision 112:b2ce766d095d:
#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>
int Counter=1234;
LocalFileSystem local("local"); // Because I want <PrintScreen>
Serial pc(USBTX, USBRX); // And a little feedback
int main()
{
RA8875 lcd(p5, p6, p7, p12, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name
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);
*/
lcd.SetTextCursor(0,0); // Pongo cursor en posicion
lcd.puts("Proyecto SNOCC\r\n");
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);
int count=0;
int old_pb=0;
int new_pb;
// Use internal pullup for pushbutton
pb.mode(PullUp);
// Delay for initial pullup to take effect
wait(.001);
//----------------------------------------------------
while(1) {
// Sensor de flujo:
//-----------------------------------------------------
new_pb = pb;
if ((new_pb==0) && (old_pb==1)) count++;
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", count);
//-----------------------------------------------------
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);
lcd.SetTextCursor(0,100);
if(gps.sample()) { // Si es exitosa la obtencion de datos del gps.
lcd.printf("Posicion: %f, %f\r\n", gps.longitude, gps.latitude);
lcd.printf("Velocidad %f km/h", gps.speed);
} else {
lcd.printf("No hay datos disponibles :(\n");
}
}
/*
while(1) {
; // end
}
*/
}
