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 VmRecorderV1dot1 by
Revision 2:e818c80e6d5c, committed 2015-07-14
- Comitter:
- JuanManuelAmador
- Date:
- Tue Jul 14 08:34:11 2015 +0000
- Parent:
- 1:a3c9b672b8e2
- Commit message:
- Funciones de memoria RAM introducidas.
Changed in this revision
diff -r a3c9b672b8e2 -r e818c80e6d5c FileManager/ParametrosCalibracion.cpp
--- a/FileManager/ParametrosCalibracion.cpp Mon Jun 15 15:44:11 2015 +0000
+++ b/FileManager/ParametrosCalibracion.cpp Tue Jul 14 08:34:11 2015 +0000
@@ -3,7 +3,6 @@
extern ScreenManager SC;
extern SelecManager SM;
-
void ParametrosCalibracion::leerValores(float* valores){ // Esta función guarda en un array de 6 float los valores de calibración
// Se lee el archivo de valores de calibracion
FILE* file;
diff -r a3c9b672b8e2 -r e818c80e6d5c FileManager/SistemaArchivos.cpp
--- a/FileManager/SistemaArchivos.cpp Mon Jun 15 15:44:11 2015 +0000
+++ b/FileManager/SistemaArchivos.cpp Tue Jul 14 08:34:11 2015 +0000
@@ -3,8 +3,6 @@
extern ScreenManager SC;
extern MSCFileSystem msc;
-extern DigitalOut myled;
-
SistemaArchivos::SistemaArchivos(){
nViajes = 0;
}
diff -r a3c9b672b8e2 -r e818c80e6d5c Pantallas/FechaHoraConf.cpp
--- a/Pantallas/FechaHoraConf.cpp Mon Jun 15 15:44:11 2015 +0000
+++ b/Pantallas/FechaHoraConf.cpp Tue Jul 14 08:34:11 2015 +0000
@@ -12,8 +12,6 @@
extern DigitalIn boton4;
extern DigitalIn boton5;
-extern DigitalOut myled;
-
extern Timer t;
FechaHoraConf::FechaHoraConf(char newAdvice[], char newAdvice2[], char newAdvice3[], char newdateTitle[], char newtimeTitle[]){
diff -r a3c9b672b8e2 -r e818c80e6d5c Pantallas/GuardarOtroNombre.cpp
--- a/Pantallas/GuardarOtroNombre.cpp Mon Jun 15 15:44:11 2015 +0000
+++ b/Pantallas/GuardarOtroNombre.cpp Tue Jul 14 08:34:11 2015 +0000
@@ -15,8 +15,6 @@
extern Mensaje nombreExistente;
extern Mensaje nombreExistenteEN;
-extern DigitalOut myled;
-
GuardarOtroNombre::GuardarOtroNombre(char nextScreen[], char newAdvice[], char newWaitMsg[]):Mensaje(nextScreen, newAdvice){
nombreAntiguo = NULL;
strcpy(waitMsg, newWaitMsg);
diff -r a3c9b672b8e2 -r e818c80e6d5c Pantallas/GuardarViaje.cpp
--- a/Pantallas/GuardarViaje.cpp Mon Jun 15 15:44:11 2015 +0000
+++ b/Pantallas/GuardarViaje.cpp Tue Jul 14 08:34:11 2015 +0000
@@ -12,8 +12,6 @@
extern GuardarOtroNombre guardadoCorrect;
extern GuardarOtroNombre guardadoCorrectEN;
-extern DigitalOut myled;
-
void GuardarViaje::button5pressed(DogMLCD* lcd){
bool llamarRaiz = true; // Se usa para llamar o no a la función padre (para controlar los cambios de pantalla)
// Se cambia el idioma actual y se guarda tambien en el fichero de configuracion
diff -r a3c9b672b8e2 -r e818c80e6d5c Pantallas/NuevoViaje.cpp
--- a/Pantallas/NuevoViaje.cpp Mon Jun 15 15:44:11 2015 +0000
+++ b/Pantallas/NuevoViaje.cpp Tue Jul 14 08:34:11 2015 +0000
@@ -1,6 +1,8 @@
#include "NuevoViaje.h"
/// ACELEROMETRO DIGITAL///
-KXR94 kionix(p11,p12,p13,p21);
+//KXR94 kionix(p11,p12,p13,p21);
+
+extern KXR94 kionix;
extern ScreenManager SC;
extern SistemaArchivos SA;
@@ -9,9 +11,13 @@
extern FechaHora FH;
extern DigitalOut myled;
+extern DigitalOut myled4;
+
extern DigitalIn boton5;
extern DigitalIn boton6;
+extern AccelRAM *mRAM;
+
extern Timer t; // Temporizador usado para controlar la animación de la pantalla
NuevoViaje::NuevoViaje(char newtitle[], char newsubtitle[], char newmsg11[], char newmsg12[], char newmsg2[]){
@@ -23,6 +29,32 @@
}
void NuevoViaje::initialize(DogMLCD* lcd){
+
+ /* PRUEBA AccelRAM */
+ /*SPI spi(p5, p6, p7); //mosi, miso, sclk
+ AccelRAM *mRAM = new AccelRAM(spi);
+ unsigned int i = 12;
+ int16_t envio[3];
+
+ for(i = 0; i <= mRAM->getMaxAddressPaquetes(); i++){
+ envio[0] = i;
+ envio[1] = i+1;
+ envio[2] = i+2;
+ mRAM->putData(i, envio);
+ myled = 1;
+ }
+ myled = 1;
+ // Se leen los caracteres guardados en las memorias y se guardan en un USB
+ FILE* fp = fopen("/local/pruebaRAMs.txt","w");
+ int16_t recibido[3];
+ for(i = 0; i <= mRAM->getMaxAddressPaquetes(); i++){
+ mRAM->readData(i, recibido);
+ fprintf(fp, "%d, %d, %d\n", recibido[0], recibido[1], recibido[2]);
+ }
+ fclose(fp);
+ myled = 0;*/
+ /* FIN PRUEBA AccelRAM */
+
// Inicilización de las variables
aXanterior = 0;
aYanterior = 0;
@@ -215,6 +247,60 @@
delete buff_aY;
delete buff_aZ;
+ /********************* DEBUG ********************************/
+ // Se comprueba que los datos en RAM son los mismos que los guardados en el USB
+ myled4 = 1;
+ FILE* fp = fopen("/local/pruebaRAMs.txt","w");
+ int16_t recibido[3];
+ int i;
+ float tiempo; //Tiempo en segundos
+ //fprintf(fp,"%d\n", mRAM->getMaxAddressPaquetes());
+ for(i = 0; i <= mRAM->getMaxAddressPaquetes(); i++){
+ //for(i = 0; i <= 100; i++){
+ mRAM->readData(i, recibido);
+ aXr = recibido[0];
+ aYr = recibido[1];
+ aZr = recibido[2];
+
+ aX = (-1.0)*((float)aXr-(valoresCal[0]))*valoresCal[3];
+ aY = (-1.0)*((float)aYr-(valoresCal[1]))*valoresCal[4];
+ aZ = (-1.0)*((float)aZr-(valoresCal[2]))*valoresCal[5];
+ // Para evitar algunos fallos por saturación todo valor mayor que 20 se le da el valor del punto anterior
+ if(aX > 20.0){
+ aX = aXanterior;
+ }
+ if(aY > 20.0){
+ aY = aYanterior;
+ }
+ if(aZ > 20.0){
+ aZ = aZanterior;
+ }
+
+ // También se debe calcular la saturación en 0, por ello si un valor es menor (en valor absoluto)
+ // que la precisión del acelerómetro se le da también el valor del punto anterior
+ if(aX*1000 == 0.0000 ){
+ aX = aXanterior;
+ }
+ if(aY*1000 == 0.0000){
+ aY = aYanterior;
+ }
+ if(aZ*1000 == 0.0000){
+ aZ = aZanterior;
+ }
+
+ aXanterior = aX;
+ aYanterior = aY;
+ aZanterior = aZ;
+
+
+ tiempo = ((float)i)*((float)PasoTiempo)/1.0e6;
+
+ fprintf(fp,"%f %f %f %f\n", tiempo, aX, aY, aZ);
+ }
+ fclose(fp);
+ myled4 = 0;
+ /************************************************************/
+
// Se para el temporizador
t.stop();
@@ -285,6 +371,16 @@
aYr = buff_aY->get();
aZr = buff_aZ->get();
+ // Se guardan los datos en la RAM (si hay espacio)
+ if(ContadorDatos <= mRAM->getMaxAddressPaquetes()){
+ envioRAM[0] = aXr;
+ envioRAM[1] = aYr;
+ envioRAM[2] = aZr;
+ // Se envían las 3 acelraciones
+ mRAM->putData(ContadorDatos, envioRAM);
+ }
+
+
// Debug
// Usar las líneas de código inferiores para depurar el buffering
/*int wi = buff_aX->getWritingIndex();
@@ -342,7 +438,6 @@
delete buff_aX;
delete buff_aY;
delete buff_aZ;
- myled = 1;
SC.changeScreen("USBdesconectado");
}
}
diff -r a3c9b672b8e2 -r e818c80e6d5c Pantallas/NuevoViaje.h
--- a/Pantallas/NuevoViaje.h Mon Jun 15 15:44:11 2015 +0000
+++ b/Pantallas/NuevoViaje.h Tue Jul 14 08:34:11 2015 +0000
@@ -16,6 +16,7 @@
#include "Buffering.h"
#include <stdlib.h>
#include "ParametrosCalibracion.h"
+#include "AccelRAM.h"
#define TUSBCOLGADO 2 // tiempo en segundos que se espera a que responda el USB, en caso contrario se considera que se ha quedado colgado
@@ -73,6 +74,8 @@
bool sentidoAnimacion; // Sentido del movimiento del recuadro de la animación (true: derecha, false: izquierda)
char posXF; // Guarda la posición de la última columna del recuadro de la animación que ha sido pintado
+ int16_t envioRAM[3]; // Guarda las últimas acaleraciones enviadas a la RAM
+
// Debug
/*unsigned int llamadasTicker;
diff -r a3c9b672b8e2 -r e818c80e6d5c Pantallas/OpcionesViaje.cpp
--- a/Pantallas/OpcionesViaje.cpp Mon Jun 15 15:44:11 2015 +0000
+++ b/Pantallas/OpcionesViaje.cpp Tue Jul 14 08:34:11 2015 +0000
@@ -9,8 +9,6 @@
extern GuardarOtroNombre guardadoCorrect;
extern GuardarOtroNombre guardadoCorrectEN;
-extern DigitalOut myled;
-
void OpcionesViaje::button5pressed(DogMLCD* lcd){
bool llamarRaiz = true; // Se usa para llamar o no a la función padre (para controlar los cambios de pantalla)
// Se cambia el idioma actual y se guarda tambien en el fichero de configuracion
diff -r a3c9b672b8e2 -r e818c80e6d5c Pantallas/ViajesGuardados.cpp
--- a/Pantallas/ViajesGuardados.cpp Mon Jun 15 15:44:11 2015 +0000
+++ b/Pantallas/ViajesGuardados.cpp Tue Jul 14 08:34:11 2015 +0000
@@ -9,8 +9,6 @@
extern OpcionesViaje opcionesViaje;
extern OpcionesViaje opcionesViajeEN;
-extern DigitalOut myled;
-
ViajesGuardados::ViajesGuardados(char newNoRides[]){
strcpy(noRides, newNoRides);
}
diff -r a3c9b672b8e2 -r e818c80e6d5c RAM/23LCV1024.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RAM/23LCV1024.cpp Tue Jul 14 08:34:11 2015 +0000
@@ -0,0 +1,54 @@
+#include "mbed.h"
+#include "23LCV1024.h"
+
+SRAM23LCV1024::SRAM23LCV1024(SPI& spi, PinName cs) : _spi(spi), _cs(cs) {
+ _cs = 1; // Deselect the device so that it can initialize
+}
+
+int SRAM23LCV1024::getReadMode() {
+ /* The mode bits indicate the operating mode of the SRAM:
+ 00 = Byte mode
+ 10 = Page mode
+ 01 = Sequential mode (default)
+ 11 = Reserved
+ */
+
+ _cs = 0;
+ _spi.write(CMD_RDMR);
+ int ram_mode = _spi.write(0)>>6;
+ _cs = 1;
+
+ return ram_mode;
+}
+
+int SRAM23LCV1024::readBytes(int address, char* buffer, int length) {
+ int i;
+
+ _cs = 0;
+ _spi.write(CMD_READ);
+ _spi.write((address >> 16) & 0xff);
+ _spi.write((address >> 8) & 0xff);
+ _spi.write(address & 0xff);
+
+ for (i = 0; i < length; i++){ buffer[i] = _spi.write(0);}
+
+ _cs = 1;
+ return 0;
+}
+
+
+int SRAM23LCV1024::writeBytes(int address, char* buffer, int length) {
+ int i;
+
+ _cs = 0;
+ _spi.write(CMD_WRITE);
+ _spi.write((address >> 16) & 0xff);
+ _spi.write((address >> 8) & 0xff);
+ _spi.write(address & 0xff);
+
+ for (i = 0; i < length; i++){ _spi.write(buffer[i]);}
+
+ _cs = 1;
+ return 0;
+}
+
\ No newline at end of file
diff -r a3c9b672b8e2 -r e818c80e6d5c RAM/23LCV1024.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RAM/23LCV1024.h Tue Jul 14 08:34:11 2015 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+
+
+#define CMD_READ 0x03
+#define CMD_WRITE 0x02
+#define CMD_RDMR 0x05
+#define CMD_WRMR 0x01
+
+
+// The 23LCV1024 is a 1 Mbit Serial SRAM, with 128K * 8 bits organized into 32 byte pages
+// A 24 bit address, 00000h - 1FFFFh, is used to address the memory location
+
+// In this library, we will address the memory in blocks of 256 bytes, of which there are 512 in total
+// (2^1) (2^8 = 256 blocks) (2^8 = 256 bytes)
+// 512 blocks a 256 bytes
+
+
+class SRAM23LCV1024 {
+ public:
+ SRAM23LCV1024(SPI& spi, PinName cs);
+
+ int getReadMode();
+
+ int readBytes(int address, char* buffer, int length);
+ int writeBytes(int address, char* buffer, int length);
+
+ private:
+ SPI& _spi;
+ DigitalOut _cs;
+};
\ No newline at end of file
diff -r a3c9b672b8e2 -r e818c80e6d5c RAM/AccelRAM.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RAM/AccelRAM.cpp Tue Jul 14 08:34:11 2015 +0000
@@ -0,0 +1,87 @@
+/**
+ * @author Juan Manuel Amador Olivares (virtualmech)
+ */
+#include "AccelRAM.h"
+
+AccelRAM::AccelRAM(SPI spi) : MultipleRAM(spi) {
+ lastWriteAddress = 0;
+ lastReadAddress = 0;
+
+ maxAddressPaquetes = (getMaxAddress()+1)/BYTESPAQUETE - 1;
+
+}
+
+void AccelRAM::putData(int16_t data[]){ // Escribe en la siguiente posición el nuevo dato
+}
+
+int16_t AccelRAM::readData(){ // Lee un nuevo de dato de la siguiente posición
+}
+
+void AccelRAM::putData(int address, int16_t data[]){ // Escribe un paquete (dato) en la posición de memoria segun paquetes especificada
+ // Se calcula la primera posición de memoria de los 6 bytes a escribir
+ lastWriteAddress = address*BYTESPAQUETE;
+
+ // Se prepara el paquete a enviar (Primero se envían los bytes más significativos)
+ // Aceleración X
+ lastData[1] = data[0]; // Byte menos significativo
+ data[0] >>= 8;
+ lastData[0] = data[0]; // Byte más significativo
+ // Aceleración Y
+ lastData[3] = data[1]; // Byte menos significativo
+ data[1] >>= 8;
+ lastData[2] = data[1]; // Byte más significativo
+ // Aceleración Z
+ lastData[5] = data[2]; // Byte menos significativo
+ data[2] >>= 8;
+ lastData[4] = data[2]; // Byte más significativo
+
+ // Se envía escribe todo el paquete en la RAM (múltiple) en la posición de memoria calculada
+ //writeBytes(lastWriteAddress, lastData, BYTESPAQUETE);
+
+ // Se envñian uno a uno todos los bytes del paquete
+ writeBytes(lastWriteAddress, &lastData[0], 1);
+ writeBytes(lastWriteAddress+1, &lastData[1], 1);
+ writeBytes(lastWriteAddress+2, &lastData[2], 1);
+ writeBytes(lastWriteAddress+3, &lastData[3], 1);
+ writeBytes(lastWriteAddress+4, &lastData[4], 1);
+ writeBytes(lastWriteAddress+5, &lastData[5], 1);
+}
+
+int AccelRAM::readData(int address, int16_t data[]){ // Lee un paquete (dato) en la posición de memoria segun paquetes especificada
+ // Se calcula la primera posición de memoria de los 6 bytes a leer
+ lastReadAddress = address*BYTESPAQUETE;
+
+ // Se leen los bytes
+ //readBytes(lastReadAddress, lastData, BYTESPAQUETE);
+
+ // Se leen uno a uno los bytes
+ readBytes(lastReadAddress, &lastData[0], 1);
+ readBytes(lastReadAddress+1, &lastData[1], 1);
+ readBytes(lastReadAddress+2, &lastData[2], 1);
+ readBytes(lastReadAddress+3, &lastData[3], 1);
+ readBytes(lastReadAddress+4, &lastData[4], 1);
+ readBytes(lastReadAddress+5, &lastData[5], 1);
+
+ // Se reconstruye el paquete(Primero se leen los bytes más significativos)
+ // Aceleración X
+ data[0] = lastData[0]; // Byte más significativo
+ data[0] <<= 8;
+ data[0] += lastData[1]; // Byte menos significativo
+
+ // Aceleración Y
+ data[1] = lastData[2]; // Byte más significativo
+ data[1] <<= 8;
+ data[1] += lastData[3]; // Byte menos significativo
+
+ // Aceleración Z
+ data[2] = lastData[4]; // Byte más significativo
+ data[2] <<= 8;
+ data[2] += lastData[5]; // Byte menos significativo
+
+ return 0;
+
+}
+
+unsigned int AccelRAM::getMaxAddressPaquetes(){
+ return maxAddressPaquetes;
+}
diff -r a3c9b672b8e2 -r e818c80e6d5c RAM/AccelRAM.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RAM/AccelRAM.h Tue Jul 14 08:34:11 2015 +0000
@@ -0,0 +1,34 @@
+/**
+ * @author Juan Manuel Amador Olivares (virtualmech)
+ */
+#ifndef ACCELRAM_H
+#define ACCELRAM_H
+
+#include "MultipleRAM.h"
+
+#define BYTESPAQUETE 6
+
+// Clase que gestiona el uso de ultiples RAMs como si fueran una sola de mayor tamaño. Esta clase esta diseñada para guardar paquetes de
+// 3 datos de 2 bytes (conteniendo 6 byte en total cada paquete)
+
+class AccelRAM : public MultipleRAM{
+ public:
+ AccelRAM(SPI spi);
+
+ void putData(int16_t data[]); // Escribe en la siguiente posición el nuevo dato
+ int16_t readData(); // Lee un nuevo de dato de la siguiente posición
+
+ void putData(int address, int16_t data[]); // Escribe un paquete (dato) en la posición de memoria segun paquetes especificada
+ int readData(int address, int16_t data[]); // Lee un paquete (dato) en la posición de memoria segun paquetes especificada
+
+ unsigned int getMaxAddressPaquetes(); // Posición máxima de memoria (según número de paquetes)
+
+ private:
+ unsigned int maxAddressPaquetes; // Posición máxima de memoria (según número de paquetes)
+ unsigned int lastWriteAddress; // Última posición de memoria en la que se ha escrito (en bytes)
+ unsigned int lastReadAddress; // Última posición de memoria de la que se ha leído (en bytes)
+ char lastData[BYTESPAQUETE]; // Último paquete escrito o leído
+
+};
+
+#endif
\ No newline at end of file
diff -r a3c9b672b8e2 -r e818c80e6d5c RAM/MultipleRAM.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RAM/MultipleRAM.cpp Tue Jul 14 08:34:11 2015 +0000
@@ -0,0 +1,38 @@
+/**
+ * @author Juan Manuel Amador Olivares (virtualmech)
+ */
+#include "MultipleRAM.h"
+
+MultipleRAM::MultipleRAM(SPI spi) : _spi(spi){
+ spi.frequency(16000000); // Velocidad del puerto SPI
+ maxAddress = NRAMS*RAMBYTES - 1;
+
+ sram[0] = new SRAM23LCV1024(_spi,p20);
+ sram[1] = new SRAM23LCV1024(_spi,p19);
+ sram[2] = new SRAM23LCV1024(_spi,p18);
+}
+
+int MultipleRAM::readBytes(int address, char* buffer, int length){
+ // Se calcula la ram a la que se debe acceder y la dirección de esta
+ int index = address/RAMBYTES; // A qué memoria se va a acceder
+ int ramAddress = address - RAMBYTES*index; // Dirección real a la que se accede a la memoria
+ return sram[index]->readBytes(ramAddress, buffer, length);
+}
+
+int MultipleRAM::writeBytes(int address, char* buffer, int length){
+ // Se calcula la ram a la que se debe acceder y la dirección de esta
+ int index = address/RAMBYTES; // A qué memoria se va a acceder
+ int ramAddress = address - RAMBYTES*index; // Dirección real a la que se accede a la memoria
+ return sram[index]->writeBytes(ramAddress, buffer, length);
+}
+
+unsigned int MultipleRAM::getMaxAddress(){
+ return maxAddress;
+}
+
+MultipleRAM::~MultipleRAM() {
+ int i;
+ for (i = 0; i < NRAMS; i++){
+ delete sram[0];
+ }
+}
diff -r a3c9b672b8e2 -r e818c80e6d5c RAM/MultipleRAM.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RAM/MultipleRAM.h Tue Jul 14 08:34:11 2015 +0000
@@ -0,0 +1,38 @@
+/**
+ * @author Juan Manuel Amador Olivares (virtualmech)
+ */
+#ifndef MULTIPLERAM_H
+#define MULTIPLERAM_H
+
+#include "mbed.h"
+#include "23LCV1024.h"
+
+#define NRAMS 3 // Número de RAMs
+#define RAMBYTES 131072 // Capacidad (en bytes) de las cada RAM
+
+
+
+// Clase que gestiona el uso de ultiples RAMs como si fueran una sola de mayor tamaño. Si cambia el número e RAMS debe cambiar esta clase.
+// Todas las RAMS conectadas al mismo puerto SPI (no se van a utilizar simultáneamente)
+// Clase configurada para 3 RAMs actualmente.
+class MultipleRAM{
+ public:
+ MultipleRAM(SPI spi);
+ ~MultipleRAM();
+
+ int readBytes(int address, char* buffer, int length);
+ int writeBytes(int address, char* buffer, int length);
+
+ unsigned int getMaxAddress();
+
+ private:
+ SRAM23LCV1024 *sram[NRAMS];
+ SPI _spi;
+
+ // Deuelve la memoria total efectiva
+ unsigned int maxAddress;
+
+
+};
+
+#endif
\ No newline at end of file
diff -r a3c9b672b8e2 -r e818c80e6d5c ScreenManager/Teclado.cpp
--- a/ScreenManager/Teclado.cpp Mon Jun 15 15:44:11 2015 +0000
+++ b/ScreenManager/Teclado.cpp Tue Jul 14 08:34:11 2015 +0000
@@ -8,8 +8,6 @@
extern DigitalIn boton3;
extern DigitalIn boton4;
extern DigitalIn boton5;
-
-extern DigitalOut myled;
void Teclado::initialize(DogMLCD* lcd){
// Se inicializa la variable que guarda el último nombre introducido
diff -r a3c9b672b8e2 -r e818c80e6d5c USBHostLite/usbhost_lpc17xx.cpp
--- a/USBHostLite/usbhost_lpc17xx.cpp Mon Jun 15 15:44:11 2015 +0000
+++ b/USBHostLite/usbhost_lpc17xx.cpp Tue Jul 14 08:34:11 2015 +0000
@@ -24,7 +24,6 @@
#include "mbed.h"
#include "usbhost_lpc17xx.h"
-extern DigitalOut myled;
extern Timer t;
/*
@@ -374,7 +373,6 @@
PRINT_Log("Connect a Mass Storage device\n");
while (!HOST_RhscIntr)
__WFI();
- myled = 1;
Host_DelayMS(100); /* USB 2.0 spec says atleast 50ms delay beore port reset */
LPC_USB->HcRhPortStatus1 = OR_RH_PORT_PRS; // Initiate port reset
while (LPC_USB->HcRhPortStatus1 & OR_RH_PORT_PRS)
diff -r a3c9b672b8e2 -r e818c80e6d5c VmRecorderV1dot1.cpp
--- a/VmRecorderV1dot1.cpp Mon Jun 15 15:44:11 2015 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,428 +0,0 @@
-#include "mbed.h"
-#include "MSCFileSystem.h"
-#include "Configuracion.h"
-#include "SistemaArchivos.h"
-#include "FechaHora.h"
-#include "SelecManager.h"
-#include "ScreenManager.h"
-#include "Portada.cpp"
-#include "Menu.h"
-#include "ListaSelec.h"
-#include "IdiomaSelec.h"
-#include "FormaSelec.h"
-#include "VelAdquisicionSel.h"
-#include "RestaurarValores.h"
-#include "Mensaje.h"
-#include "NuevoViaje.h"
-#include "GuardarViaje.h"
-#include "ArchivoGuardado.h"
-#include "ViajesGuardados.h"
-#include "Teclado.h"
-#include "GuardarOtroNombre.h"
-#include "OpcionesViaje.h"
-#include "FechaHoraConf.h"
-#include "AutoCalibracion.h"
-
-//DEFINICIONES
-#define ESPANOL 0
-#define INGLES 1
-
-/// PEN DRIVE ///
-MSCFileSystem msc("usb");
-
-/// MEMORIA FLASH LOCAL DE LA MBED ///
-LocalFileSystem local("local"); // Create the local filesystem under the name "local"
-Configuracion config = Configuracion();
-SistemaArchivos SA = SistemaArchivos();
-
-// Fecha y hora
-FechaHora FH;
-
-/********************************************
- PANTALLAS
- ********************************************/
-SPI spi( p5, NC, p7 ); // MOSI, MISO, CLK
-DogMLCD dog( spi, p10, p8); // SPI, CS, A0
-
-ScreenManager SC(&dog); // Screen Manager
-SelecManager SM; // gestiona las pantallas que tienen elementos seleccionables
-
-Portada portadaVm = Portada();
-Screen* pportadaVm = &portadaVm;
-
-Menu menu = Menu();
-Screen* pmenu = &menu;
-Seleccion* psmenu = &menu;
-
-Teclado keyboard = Teclado();
-Screen* pkeyboard = &keyboard;
-Seleccion* pskeyboard = &keyboard;
-
-ViajesGuardados listaViajes = ViajesGuardados("No existen viajes");
-Screen* plistaViajes = &listaViajes;
-Seleccion* pslistaViajes = &listaViajes;
-
-ListaSelec configuracion = ListaSelec();
-Screen* pconfiguracion = &configuracion;
-Seleccion* psconfiguracion = &configuracion;
-
-RestaurarValores restaurar = RestaurarValores("\250Est\240 seguro?");
-Screen* prestaurar = &restaurar;
-Seleccion* psrestaurar = &restaurar;
-
-IdiomaSelec idioma = IdiomaSelec();
-Screen* pidioma = &idioma;
-Seleccion* psidioma = &idioma;
-
-FormaSelec formaSelec = FormaSelec();
-Screen* pformaSelec = &formaSelec;
-Seleccion* psformaSelec = &formaSelec;
-
-VelAdquisicionSel velAdquisionSel = VelAdquisicionSel();
-Screen* pvelAdquisionSel = &velAdquisionSel;
-Seleccion* psvelAdquisionSel = &velAdquisionSel;
-
-NuevoViaje nuevoViaje = NuevoViaje("Adquiriendo datos", "Frecuencia: ", "OK para comenzar.", "OK para finalizar.", "Pulse atr\240s para cancelar.");
-Screen* pnuevoViaje = &nuevoViaje;
-
-Mensaje noUSB = Mensaje("menu", "Pulse OK para volver.");
-Screen* pnoUSB = &noUSB;
-
-GuardarOtroNombre guardadoCorrect = GuardarOtroNombre("menu", "Pulse OK para continuar.", "Espere por favor"); //warten sie bitte
-Screen* pguardadoCorrect = &guardadoCorrect;
-
-GuardarViaje guardaViaje = GuardarViaje();
-Screen* pguardaViaje = &guardaViaje;
-Seleccion* psguardaViaje = &guardaViaje;
-
-OpcionesViaje opcionesViaje = OpcionesViaje();
-Screen* popcionesViaje = &opcionesViaje;
-Seleccion* psopcionesViaje = &opcionesViaje;
-
-ArchivoGuardado archivoGuardado = ArchivoGuardado("guardaViaje", "Pulse OK para continuar.", "Archivo guardado:", "Fecha:", "Hora:");
-Screen* parchivoGuardado = &archivoGuardado;
-
-Mensaje archivoBorrado = Mensaje("menu", "Pulse OK para continuar.");
-Screen* parchivoBorrado = &archivoBorrado;
-
-Mensaje nombreExistente = Mensaje("guardaViaje", "Pulse OK para volver.");
-Screen* pnombreExistente = &nombreExistente;
-
-FechaHoraConf fechaHoraConf = FechaHoraConf("Pulse las teclas arriba y", "abajo para cambiar los", "valores.", "Fecha:", "Hora:");
-Screen* pfechaHoraConf = &fechaHoraConf;
-Seleccion* psfechaHoraConf = &fechaHoraConf;
-
-AutoCalibracion calibrando = AutoCalibracion();
-Screen* pcalibrando = &calibrando;
-
-// Inglés
-Menu menuEN = Menu();
-Screen* pmenuEN = &menuEN;
-Seleccion* psmenuEN = &menuEN;
-
-ViajesGuardados listaViajesEN = ViajesGuardados("No travels");
-Screen* plistaViajesEN = &listaViajesEN;
-Seleccion* pslistaViajesEN = &listaViajesEN;
-
-ListaSelec configuracionEN = ListaSelec();
-Screen* pconfiguracionEN = &configuracionEN;
-Seleccion* psconfiguracionEN = &configuracionEN;
-
-RestaurarValores restaurarEN = RestaurarValores("Are you sure?");
-Screen* prestaurarEN = &restaurarEN;
-Seleccion* psrestaurarEN = &restaurarEN;
-
-IdiomaSelec idiomaEN = IdiomaSelec();
-Screen* pidiomaEN = &idiomaEN;
-Seleccion* psidiomaEN = &idiomaEN;
-
-FormaSelec formaSelecEN = FormaSelec();
-Screen* pformaSelecEN = &formaSelecEN;
-Seleccion* psformaSelecEN = &formaSelecEN;
-
-NuevoViaje nuevoViajeEN = NuevoViaje("Acquiring data", "Frecuency: ", "Press OK to start.", "Press OK to finish.", "Press back to cancel.");
-Screen* pnuevoViajeEN = &nuevoViajeEN;
-
-Mensaje noUSBEN = Mensaje("menu", "Press OK to back.");
-Screen* pnoUSBEN = &noUSBEN;
-
-GuardarOtroNombre guardadoCorrectEN = GuardarOtroNombre("menu", "Press OK to continue.", "Please wait");
-Screen* pguardadoCorrectEN = &guardadoCorrectEN;
-
-GuardarViaje guardaViajeEN = GuardarViaje();
-Screen* pguardaViajeEN = &guardaViajeEN;
-Seleccion* psguardaViajeEN = &guardaViajeEN;
-
-OpcionesViaje opcionesViajeEN = OpcionesViaje();
-Screen* popcionesViajeEN = &opcionesViajeEN;
-Seleccion* psopcionesViajeEN = &opcionesViajeEN;
-
-ArchivoGuardado archivoGuardadoEN = ArchivoGuardado("guardaViaje", "Press OK to continue.", "Saved file:", "date:", "Time:");
-Screen* parchivoGuardadoEN = &archivoGuardadoEN;
-
-Mensaje archivoBorradoEN = Mensaje("menu", "Press OK to continue.");
-Screen* parchivoBorradoEN = &archivoBorradoEN;
-
-Mensaje nombreExistenteEN = Mensaje("guardaViaje", "Press OK to back.");
-Screen* pnombreExistenteEN = &nombreExistenteEN;
-
-FechaHoraConf fechaHoraConfEN = FechaHoraConf("Press the up and down keys to change values.", "", "", "Date:", "Time:");
-Screen* pfechaHoraConfEN = &fechaHoraConfEN;
-Seleccion* psfechaHoraConfEN = &fechaHoraConfEN;
-
-/********************************************/
-
-/********************************************
- BOTONES
- ********************************************/
-DigitalIn boton1(p30);
-DigitalIn boton2(p29);
-DigitalIn boton3(p28);
-DigitalIn boton4(p27);
-DigitalIn boton5(p26);
-DigitalIn boton6(p14);
-/********************************************/
-
-DigitalOut myled(LED2);
-
-Timer t;
-
-int main()
-{
- /********************************************
- PANTALLAS
- ********************************************/
- /******************* Se añaden las pantallas al ScreenManager ******************************/
-
- // Portada inicial
- SC.addScreen(pportadaVm, "portada", ESPANOL);
- SC.addScreen(pportadaVm, "portada", INGLES);
-
- // Menu principal
- menu.addElement("Nuevo viaje", "viaje");
- menu.addElement("Viajes guardados", "listadoViajes");
- menu.addElement("Configuraci\242n", "configuracion");
- menu.setSelect(0);
- SC.addScreen(pmenu, "menu", ESPANOL);
- SM.addScreen(psmenu);
-
- menuEN.addElement("New ride", "viaje");
- menuEN.addElement("Saved rides", "listadoViajes");
- menuEN.addElement("Settings", "configuracion");
- menuEN.setSelect(0);
- SC.addScreen(pmenuEN, "menu", INGLES);
- SM.addScreen(psmenuEN);
-
- // Pantalla teclado
- keyboard.setSelect(0);
- SC.addScreen(pkeyboard, "teclado", ESPANOL); // El teclado es el mismo para todos los idiomas
- SC.addScreen(pkeyboard, "teclado", INGLES);
- SM.addScreen(pskeyboard);
-
- // Pantalla de autocalibración
- SC.addScreen(pcalibrando, "calibrate", ESPANOL); // La pantalla de calibración es la misma para todos los idiomas (el idioma se controla en el propio código de la pantalla)
- SC.addScreen(pcalibrando, "calibrate", INGLES);
-
- // Lista de viajes guardados
- listaViajes.setBackScreen("menu");
- SC.addScreen(plistaViajes, "listadoViajes", ESPANOL);
- SM.addScreen(pslistaViajes);
-
- listaViajesEN.setBackScreen("menu");
- SC.addScreen(plistaViajesEN, "listadoViajes", INGLES);
- SM.addScreen(pslistaViajesEN);
-
- // Lista de configuración
- configuracion.addElement("Velocidad de adquisici\242n", "velAdquisionSel");
- configuracion.addElement("Idioma", "idioma");
- configuracion.addElement("Visualizaci\242n", "formaSelec");
- configuracion.addElement("Ajustar fecha y hora", "confFecha");
- configuracion.addElement("Autocalibraci\242n", "calibrate");
- configuracion.addElement("Valores de f\240brica", "restaurar");
- configuracion.setBackScreen("menu");
- SC.addScreen(pconfiguracion, "configuracion", 0);
- SM.addScreen(psconfiguracion);
-
- configuracionEN.addElement("Sample Rate", "velAdquisionSel");
- configuracionEN.addElement("Languaje", "idioma");
- configuracionEN.addElement("Visualization", "formaSelec");
- configuracionEN.addElement("Set date and time", "confFecha");
- configuracionEN.addElement("Autocalibration", "calibrate");
- configuracionEN.addElement("Restore default settings", "restaurar");
- configuracionEN.setBackScreen("menu");
- SC.addScreen(pconfiguracionEN, "configuracion", 1);
- SM.addScreen(psconfiguracionEN);
-
- // Pantalla de restauración de datos de fábrica
- restaurar.addElement("No restaurar", "configuracion");
- restaurar.addElement("resturar", "configuracion");
- restaurar.setBackScreen("configuracion");
- SC.addScreen(prestaurar, "restaurar", 0);
- SM.addScreen(psrestaurar);
-
- restaurarEN.addElement("do not restore", "configuracion");
- restaurarEN.addElement("restore", "configuracion");
- restaurarEN.setBackScreen("configuracion");
- SC.addScreen(prestaurarEN, "restaurar", 1);
- SM.addScreen(psrestaurarEN);
-
- // pantalla de selección de idioma
- idioma.addElement("Espa\244ol", "configuracion");
- idioma.addElement("Ingl\202s", "configuracion");
- idioma.setBackScreen("configuracion");
- SC.addScreen(pidioma, "idioma", 0);
- SM.addScreen(psidioma);
-
- idiomaEN.addElement("Spanish", "configuracion");
- idiomaEN.addElement("English", "configuracion");
- idiomaEN.setBackScreen("configuracion");
- SC.addScreen(pidiomaEN, "idioma", 1);
- SM.addScreen(psidiomaEN);
-
- // Pantalla de selección de la forma de selección
- formaSelec.addElement("Sombreado", "configuracion");
- formaSelec.addElement("Encuadrado", "configuracion");
- formaSelec.setBackScreen("configuracion");
- SC.addScreen(pformaSelec, "formaSelec", 0);
- SM.addScreen(psformaSelec);
-
- formaSelecEN.addElement("Shading", "configuracion");
- formaSelecEN.addElement("Framing", "configuracion");
- formaSelecEN.setBackScreen("configuracion");
- SC.addScreen(pformaSelecEN, "formaSelec", 1);
- SM.addScreen(psformaSelecEN);
-
- // Pantalla de selección de la velocidad de adquisición
- velAdquisionSel.addElement("1000 Hz", "configuracion");
- velAdquisionSel.addElement("320 Hz", "configuracion");
- velAdquisionSel.setBackScreen("configuracion");
- SC.addScreen(pvelAdquisionSel, "velAdquisionSel", ESPANOL);
- SC.addScreen(pvelAdquisionSel, "velAdquisionSel", INGLES); // Como sólo se muestran valores y sus unidades no es necesaria esta pantalla en otros idiomas
- SM.addScreen(psvelAdquisionSel);
-
- // Pantalla de cambio de fecha y hora
- fechaHoraConf.setSelect(0);
- fechaHoraConf.setBackScreen("configuracion");
- SC.addScreen(pfechaHoraConf, "confFecha", ESPANOL);
- SM.addScreen(psfechaHoraConf);
-
- fechaHoraConfEN.setSelect(0);
- fechaHoraConfEN.setBackScreen("configuracion");
- SC.addScreen(pfechaHoraConfEN, "confFecha", INGLES);
- SM.addScreen(psfechaHoraConfEN);
-
- // Pantalla de nuevo viaje
- SC.addScreen(pnuevoViaje, "viaje", 0);
- SC.addScreen(pnuevoViajeEN, "viaje", 1);
-
- // Mensaje de USB lleno o desconectado
- noUSB.addElement("USB desconectado");
- noUSB.addElement("o lleno");
- noUSB.setBackScreen("menu");
- SC.addScreen(pnoUSB, "USBdesconectado", 0);
-
- noUSBEN.addElement("USB disconected");
- noUSBEN.addElement("or full");
- noUSBEN.setBackScreen("menu");
- SC.addScreen(pnoUSBEN, "USBdesconectado", 1);
-
- // Archivo guardado correctamente (Mensaje)
- guardadoCorrect.addElement("Archivo guardado");
- guardadoCorrect.addElement("correctamente");
- guardadoCorrect.setBackScreen("menu");
- SC.addScreen(pguardadoCorrect, "fileSaved", ESPANOL);
-
- guardadoCorrectEN.addElement("File saved");
- guardadoCorrectEN.addElement("correctly");
- guardadoCorrectEN.setBackScreen("menu");
- SC.addScreen(pguardadoCorrectEN, "fileSaved", INGLES);
-
- // Pantalla de guardado de viaje
- guardaViaje.addElement("Volver al men\243", "menu");
- //guardaViaje.addElement("Postprocesado", "menu");
- guardaViaje.addElement("Cambiar nombre", "teclado");
- guardaViaje.addElement("Borrar", "archivoBorrado");
- guardaViaje.setSelect(0);
- SC.addScreen(pguardaViaje, "guardaViaje", ESPANOL);
- SM.addScreen(psguardaViaje);
-
- guardaViajeEN.addElement("Back to menu", "menu");
- //guardaViajeEN.addElement("Postprocessing", "menu");
- guardaViajeEN.addElement("Rename", "teclado");
- guardaViajeEN.addElement("Delete", "archivoBorrado");
- guardaViajeEN.setSelect(0);
- SC.addScreen(pguardaViajeEN, "guardaViaje", INGLES);
- SM.addScreen(psguardaViajeEN);
-
- // Pantalla de las opciones de un viaje cuando accedes a él mediante la lista de viajes
- opcionesViaje.addElement("Cambiar nombre", "teclado");
- opcionesViaje.addElement("Borrar", "listadoViajes");
- opcionesViaje.setSelect(0);
- opcionesViaje.setBackScreen("listadoViajes");
- SC.addScreen(popcionesViaje, "rOptions", ESPANOL);
- SM.addScreen(psopcionesViaje);
-
- opcionesViajeEN.addElement("Rename", "teclado");
- opcionesViajeEN.addElement("Delete", "listadoViajes");
- opcionesViajeEN.setSelect(0);
- opcionesViajeEN.setBackScreen("listadoViajes");
- SC.addScreen(popcionesViajeEN, "rOptions", INGLES);
- SM.addScreen(psopcionesViajeEN);
-
- // Mensaje de archivo guardado
- SC.addScreen(parchivoGuardado, "archivoGuardado", ESPANOL);
- SC.addScreen(parchivoGuardadoEN, "archivoGuardado", INGLES);
-
- // Mensaje de archivo borrado
- archivoBorrado.addElement("Viaje borrado");
- archivoBorrado.addElement("correctamente");
- archivoBorrado.setBackScreen("menu");
- SC.addScreen(parchivoBorrado, "archivoBorrado", ESPANOL);
-
- archivoBorradoEN.addElement("Deleted file");
- archivoBorradoEN.addElement("corretly");
- archivoBorradoEN.setBackScreen("menu");
- SC.addScreen(parchivoBorradoEN, "archivoBorrado", INGLES);
-
- // Mensade de existencia de un viaje con el mismo nombre
- nombreExistente.addElement("Ya existe un");
- nombreExistente.addElement("viaje con el");
- nombreExistente.addElement("nombre introducido.");
- nombreExistente.setBackScreen("guardaViaje");
- SC.addScreen(pnombreExistente, "alredyExist", ESPANOL);
-
- nombreExistenteEN.addElement("Alredy exist a");
- nombreExistenteEN.addElement("ride with the");
- nombreExistenteEN.addElement("entered name");
- nombreExistenteEN.setBackScreen("guardaViaje");
- SC.addScreen(pnombreExistenteEN, "alredyExist", INGLES);
-
- /****************************************/
-
- /********************************************
- CARGA DE LA CONFIGURACIÓN
- ********************************************/
- char aux[16];
- // Se selecciona el idioma
- config.getIdioma(aux);
- if(strcmp(aux, "spanish") == 0){
- SC.selectGroup(0);
- }else if(strcmp(aux, "english") == 0){
- SC.selectGroup(1);
- }
-
- // Se selecciona el modo de selección
- config.getFormaSeleccion(aux);
- if(strcmp(aux, "shading") == 0){
- SM.setInverterSelection();
- }else if(strcmp(aux, "framing") == 0){
- SM.setRectSelection();
- }
-
- /****************************************/
-
- SC.initialize();
- while(1){
- SC.update();
- }
-}
\ No newline at end of file
diff -r a3c9b672b8e2 -r e818c80e6d5c VmRecorderV1dot8.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VmRecorderV1dot8.cpp Tue Jul 14 08:34:11 2015 +0000
@@ -0,0 +1,440 @@
+#include "mbed.h"
+#include "MSCFileSystem.h"
+#include "Configuracion.h"
+#include "SistemaArchivos.h"
+#include "FechaHora.h"
+#include "SelecManager.h"
+#include "ScreenManager.h"
+#include "Portada.cpp"
+#include "Menu.h"
+#include "ListaSelec.h"
+#include "IdiomaSelec.h"
+#include "FormaSelec.h"
+#include "VelAdquisicionSel.h"
+#include "RestaurarValores.h"
+#include "Mensaje.h"
+#include "NuevoViaje.h"
+#include "GuardarViaje.h"
+#include "ArchivoGuardado.h"
+#include "ViajesGuardados.h"
+#include "Teclado.h"
+#include "GuardarOtroNombre.h"
+#include "OpcionesViaje.h"
+#include "FechaHoraConf.h"
+#include "AutoCalibracion.h"
+
+//DEFINICIONES
+#define ESPANOL 0
+#define INGLES 1
+
+// Acelerómetro
+KXR94 kionix(p11,p12,p13,p21);
+
+
+/// PEN DRIVE ///
+MSCFileSystem msc("usb");
+
+/// MEMORIA FLASH LOCAL DE LA MBED ///
+LocalFileSystem local("local"); // Create the local filesystem under the name "local"
+Configuracion config = Configuracion();
+SistemaArchivos SA = SistemaArchivos();
+
+// Fecha y hora
+FechaHora FH;
+
+// RAM
+SPI spi(p5, p6, p7); //mosi, miso, sclk
+AccelRAM *mRAM = new AccelRAM(spi);
+
+/********************************************
+ PANTALLAS
+ ********************************************/
+SPI spiRAM( p5, NC, p7 ); // MOSI, MISO, CLK
+DogMLCD dog( spiRAM, p10, p8); // SPI, CS, A0
+
+ScreenManager SC(&dog); // Screen Manager
+SelecManager SM; // gestiona las pantallas que tienen elementos seleccionables
+
+Portada portadaVm = Portada();
+Screen* pportadaVm = &portadaVm;
+
+Menu menu = Menu();
+Screen* pmenu = &menu;
+Seleccion* psmenu = &menu;
+
+Teclado keyboard = Teclado();
+Screen* pkeyboard = &keyboard;
+Seleccion* pskeyboard = &keyboard;
+
+ViajesGuardados listaViajes = ViajesGuardados("No existen viajes");
+Screen* plistaViajes = &listaViajes;
+Seleccion* pslistaViajes = &listaViajes;
+
+ListaSelec configuracion = ListaSelec();
+Screen* pconfiguracion = &configuracion;
+Seleccion* psconfiguracion = &configuracion;
+
+RestaurarValores restaurar = RestaurarValores("\250Est\240 seguro?");
+Screen* prestaurar = &restaurar;
+Seleccion* psrestaurar = &restaurar;
+
+IdiomaSelec idioma = IdiomaSelec();
+Screen* pidioma = &idioma;
+Seleccion* psidioma = &idioma;
+
+FormaSelec formaSelec = FormaSelec();
+Screen* pformaSelec = &formaSelec;
+Seleccion* psformaSelec = &formaSelec;
+
+VelAdquisicionSel velAdquisionSel = VelAdquisicionSel();
+Screen* pvelAdquisionSel = &velAdquisionSel;
+Seleccion* psvelAdquisionSel = &velAdquisionSel;
+
+NuevoViaje nuevoViaje = NuevoViaje("Adquiriendo datos", "Frecuencia: ", "OK para comenzar.", "OK para finalizar.", "Pulse atr\240s para cancelar.");
+Screen* pnuevoViaje = &nuevoViaje;
+
+Mensaje noUSB = Mensaje("menu", "Pulse OK para volver.");
+Screen* pnoUSB = &noUSB;
+
+GuardarOtroNombre guardadoCorrect = GuardarOtroNombre("menu", "Pulse OK para continuar.", "Espere por favor"); //warten sie bitte
+Screen* pguardadoCorrect = &guardadoCorrect;
+
+GuardarViaje guardaViaje = GuardarViaje();
+Screen* pguardaViaje = &guardaViaje;
+Seleccion* psguardaViaje = &guardaViaje;
+
+OpcionesViaje opcionesViaje = OpcionesViaje();
+Screen* popcionesViaje = &opcionesViaje;
+Seleccion* psopcionesViaje = &opcionesViaje;
+
+ArchivoGuardado archivoGuardado = ArchivoGuardado("guardaViaje", "Pulse OK para continuar.", "Archivo guardado:", "Fecha:", "Hora:");
+Screen* parchivoGuardado = &archivoGuardado;
+
+Mensaje archivoBorrado = Mensaje("menu", "Pulse OK para continuar.");
+Screen* parchivoBorrado = &archivoBorrado;
+
+Mensaje nombreExistente = Mensaje("guardaViaje", "Pulse OK para volver.");
+Screen* pnombreExistente = &nombreExistente;
+
+FechaHoraConf fechaHoraConf = FechaHoraConf("Pulse las teclas arriba y", "abajo para cambiar los", "valores.", "Fecha:", "Hora:");
+Screen* pfechaHoraConf = &fechaHoraConf;
+Seleccion* psfechaHoraConf = &fechaHoraConf;
+
+AutoCalibracion calibrando = AutoCalibracion();
+Screen* pcalibrando = &calibrando;
+
+// Inglés
+Menu menuEN = Menu();
+Screen* pmenuEN = &menuEN;
+Seleccion* psmenuEN = &menuEN;
+
+ViajesGuardados listaViajesEN = ViajesGuardados("No travels");
+Screen* plistaViajesEN = &listaViajesEN;
+Seleccion* pslistaViajesEN = &listaViajesEN;
+
+ListaSelec configuracionEN = ListaSelec();
+Screen* pconfiguracionEN = &configuracionEN;
+Seleccion* psconfiguracionEN = &configuracionEN;
+
+RestaurarValores restaurarEN = RestaurarValores("Are you sure?");
+Screen* prestaurarEN = &restaurarEN;
+Seleccion* psrestaurarEN = &restaurarEN;
+
+IdiomaSelec idiomaEN = IdiomaSelec();
+Screen* pidiomaEN = &idiomaEN;
+Seleccion* psidiomaEN = &idiomaEN;
+
+FormaSelec formaSelecEN = FormaSelec();
+Screen* pformaSelecEN = &formaSelecEN;
+Seleccion* psformaSelecEN = &formaSelecEN;
+
+NuevoViaje nuevoViajeEN = NuevoViaje("Acquiring data", "Frecuency: ", "Press OK to start.", "Press OK to finish.", "Press back to cancel.");
+Screen* pnuevoViajeEN = &nuevoViajeEN;
+
+Mensaje noUSBEN = Mensaje("menu", "Press OK to back.");
+Screen* pnoUSBEN = &noUSBEN;
+
+GuardarOtroNombre guardadoCorrectEN = GuardarOtroNombre("menu", "Press OK to continue.", "Please wait");
+Screen* pguardadoCorrectEN = &guardadoCorrectEN;
+
+GuardarViaje guardaViajeEN = GuardarViaje();
+Screen* pguardaViajeEN = &guardaViajeEN;
+Seleccion* psguardaViajeEN = &guardaViajeEN;
+
+OpcionesViaje opcionesViajeEN = OpcionesViaje();
+Screen* popcionesViajeEN = &opcionesViajeEN;
+Seleccion* psopcionesViajeEN = &opcionesViajeEN;
+
+ArchivoGuardado archivoGuardadoEN = ArchivoGuardado("guardaViaje", "Press OK to continue.", "Saved file:", "date:", "Time:");
+Screen* parchivoGuardadoEN = &archivoGuardadoEN;
+
+Mensaje archivoBorradoEN = Mensaje("menu", "Press OK to continue.");
+Screen* parchivoBorradoEN = &archivoBorradoEN;
+
+Mensaje nombreExistenteEN = Mensaje("guardaViaje", "Press OK to back.");
+Screen* pnombreExistenteEN = &nombreExistenteEN;
+
+FechaHoraConf fechaHoraConfEN = FechaHoraConf("Press the up and down keys to change values.", "", "", "Date:", "Time:");
+Screen* pfechaHoraConfEN = &fechaHoraConfEN;
+Seleccion* psfechaHoraConfEN = &fechaHoraConfEN;
+
+/********************************************/
+
+/********************************************
+ BOTONES
+ ********************************************/
+DigitalIn boton1(p30);
+DigitalIn boton2(p29);
+DigitalIn boton3(p28);
+DigitalIn boton4(p27);
+DigitalIn boton5(p26);
+DigitalIn boton6(p14);
+/********************************************/
+
+DigitalOut myled(LED1);
+DigitalOut myled4(LED4);
+
+Timer t;
+
+int main()
+{
+ /********************************************
+ PANTALLAS
+ ********************************************/
+ /******************* Se añaden las pantallas al ScreenManager ******************************/
+
+ // Portada inicial
+ SC.addScreen(pportadaVm, "portada", ESPANOL);
+ SC.addScreen(pportadaVm, "portada", INGLES);
+
+ // Menu principal
+ menu.addElement("Nuevo viaje", "viaje");
+ menu.addElement("Viajes guardados", "listadoViajes");
+ menu.addElement("Configuraci\242n", "configuracion");
+ menu.setSelect(0);
+ SC.addScreen(pmenu, "menu", ESPANOL);
+ SM.addScreen(psmenu);
+
+ menuEN.addElement("New ride", "viaje");
+ menuEN.addElement("Saved rides", "listadoViajes");
+ menuEN.addElement("Settings", "configuracion");
+ menuEN.setSelect(0);
+ SC.addScreen(pmenuEN, "menu", INGLES);
+ SM.addScreen(psmenuEN);
+
+ // Pantalla teclado
+ keyboard.setSelect(0);
+ SC.addScreen(pkeyboard, "teclado", ESPANOL); // El teclado es el mismo para todos los idiomas
+ SC.addScreen(pkeyboard, "teclado", INGLES);
+ SM.addScreen(pskeyboard);
+
+ // Pantalla de autocalibración
+ SC.addScreen(pcalibrando, "calibrate", ESPANOL); // La pantalla de calibración es la misma para todos los idiomas (el idioma se controla en el propio código de la pantalla)
+ SC.addScreen(pcalibrando, "calibrate", INGLES);
+
+ // Lista de viajes guardados
+ listaViajes.setBackScreen("menu");
+ SC.addScreen(plistaViajes, "listadoViajes", ESPANOL);
+ SM.addScreen(pslistaViajes);
+
+ listaViajesEN.setBackScreen("menu");
+ SC.addScreen(plistaViajesEN, "listadoViajes", INGLES);
+ SM.addScreen(pslistaViajesEN);
+
+ // Lista de configuración
+ configuracion.addElement("Velocidad de adquisici\242n", "velAdquisionSel");
+ configuracion.addElement("Idioma", "idioma");
+ configuracion.addElement("Visualizaci\242n", "formaSelec");
+ configuracion.addElement("Ajustar fecha y hora", "confFecha");
+ configuracion.addElement("Autocalibraci\242n", "calibrate");
+ configuracion.addElement("Valores de f\240brica", "restaurar");
+ configuracion.setBackScreen("menu");
+ SC.addScreen(pconfiguracion, "configuracion", 0);
+ SM.addScreen(psconfiguracion);
+
+ configuracionEN.addElement("Sample Rate", "velAdquisionSel");
+ configuracionEN.addElement("Languaje", "idioma");
+ configuracionEN.addElement("Visualization", "formaSelec");
+ configuracionEN.addElement("Set date and time", "confFecha");
+ configuracionEN.addElement("Autocalibration", "calibrate");
+ configuracionEN.addElement("Restore default settings", "restaurar");
+ configuracionEN.setBackScreen("menu");
+ SC.addScreen(pconfiguracionEN, "configuracion", 1);
+ SM.addScreen(psconfiguracionEN);
+
+ // Pantalla de restauración de datos de fábrica
+ restaurar.addElement("No restaurar", "configuracion");
+ restaurar.addElement("resturar", "configuracion");
+ restaurar.setBackScreen("configuracion");
+ SC.addScreen(prestaurar, "restaurar", 0);
+ SM.addScreen(psrestaurar);
+
+ restaurarEN.addElement("do not restore", "configuracion");
+ restaurarEN.addElement("restore", "configuracion");
+ restaurarEN.setBackScreen("configuracion");
+ SC.addScreen(prestaurarEN, "restaurar", 1);
+ SM.addScreen(psrestaurarEN);
+
+ // pantalla de selección de idioma
+ idioma.addElement("Espa\244ol", "configuracion");
+ idioma.addElement("Ingl\202s", "configuracion");
+ idioma.setBackScreen("configuracion");
+ SC.addScreen(pidioma, "idioma", 0);
+ SM.addScreen(psidioma);
+
+ idiomaEN.addElement("Spanish", "configuracion");
+ idiomaEN.addElement("English", "configuracion");
+ idiomaEN.setBackScreen("configuracion");
+ SC.addScreen(pidiomaEN, "idioma", 1);
+ SM.addScreen(psidiomaEN);
+
+ // Pantalla de selección de la forma de selección
+ formaSelec.addElement("Sombreado", "configuracion");
+ formaSelec.addElement("Encuadrado", "configuracion");
+ formaSelec.setBackScreen("configuracion");
+ SC.addScreen(pformaSelec, "formaSelec", 0);
+ SM.addScreen(psformaSelec);
+
+ formaSelecEN.addElement("Shading", "configuracion");
+ formaSelecEN.addElement("Framing", "configuracion");
+ formaSelecEN.setBackScreen("configuracion");
+ SC.addScreen(pformaSelecEN, "formaSelec", 1);
+ SM.addScreen(psformaSelecEN);
+
+ // Pantalla de selección de la velocidad de adquisición
+ velAdquisionSel.addElement("1000 Hz", "configuracion");
+ velAdquisionSel.addElement("320 Hz", "configuracion");
+ velAdquisionSel.setBackScreen("configuracion");
+ SC.addScreen(pvelAdquisionSel, "velAdquisionSel", ESPANOL);
+ SC.addScreen(pvelAdquisionSel, "velAdquisionSel", INGLES); // Como sólo se muestran valores y sus unidades no es necesaria esta pantalla en otros idiomas
+ SM.addScreen(psvelAdquisionSel);
+
+ // Pantalla de cambio de fecha y hora
+ fechaHoraConf.setSelect(0);
+ fechaHoraConf.setBackScreen("configuracion");
+ SC.addScreen(pfechaHoraConf, "confFecha", ESPANOL);
+ SM.addScreen(psfechaHoraConf);
+
+ fechaHoraConfEN.setSelect(0);
+ fechaHoraConfEN.setBackScreen("configuracion");
+ SC.addScreen(pfechaHoraConfEN, "confFecha", INGLES);
+ SM.addScreen(psfechaHoraConfEN);
+
+ // Pantalla de nuevo viaje
+ SC.addScreen(pnuevoViaje, "viaje", 0);
+ SC.addScreen(pnuevoViajeEN, "viaje", 1);
+
+ // Mensaje de USB lleno o desconectado
+ noUSB.addElement("USB desconectado");
+ noUSB.addElement("o lleno");
+ noUSB.setBackScreen("menu");
+ SC.addScreen(pnoUSB, "USBdesconectado", 0);
+
+ noUSBEN.addElement("USB disconected");
+ noUSBEN.addElement("or full");
+ noUSBEN.setBackScreen("menu");
+ SC.addScreen(pnoUSBEN, "USBdesconectado", 1);
+
+ // Archivo guardado correctamente (Mensaje)
+ guardadoCorrect.addElement("Archivo guardado");
+ guardadoCorrect.addElement("correctamente");
+ guardadoCorrect.setBackScreen("menu");
+ SC.addScreen(pguardadoCorrect, "fileSaved", ESPANOL);
+
+ guardadoCorrectEN.addElement("File saved");
+ guardadoCorrectEN.addElement("correctly");
+ guardadoCorrectEN.setBackScreen("menu");
+ SC.addScreen(pguardadoCorrectEN, "fileSaved", INGLES);
+
+ // Pantalla de guardado de viaje
+ guardaViaje.addElement("Volver al men\243", "menu");
+ //guardaViaje.addElement("Postprocesado", "menu");
+ guardaViaje.addElement("Cambiar nombre", "teclado");
+ guardaViaje.addElement("Borrar", "archivoBorrado");
+ guardaViaje.setSelect(0);
+ SC.addScreen(pguardaViaje, "guardaViaje", ESPANOL);
+ SM.addScreen(psguardaViaje);
+
+ guardaViajeEN.addElement("Back to menu", "menu");
+ //guardaViajeEN.addElement("Postprocessing", "menu");
+ guardaViajeEN.addElement("Rename", "teclado");
+ guardaViajeEN.addElement("Delete", "archivoBorrado");
+ guardaViajeEN.setSelect(0);
+ SC.addScreen(pguardaViajeEN, "guardaViaje", INGLES);
+ SM.addScreen(psguardaViajeEN);
+
+ // Pantalla de las opciones de un viaje cuando accedes a él mediante la lista de viajes
+ opcionesViaje.addElement("Cambiar nombre", "teclado");
+ opcionesViaje.addElement("Borrar", "listadoViajes");
+ opcionesViaje.setSelect(0);
+ opcionesViaje.setBackScreen("listadoViajes");
+ SC.addScreen(popcionesViaje, "rOptions", ESPANOL);
+ SM.addScreen(psopcionesViaje);
+
+ opcionesViajeEN.addElement("Rename", "teclado");
+ opcionesViajeEN.addElement("Delete", "listadoViajes");
+ opcionesViajeEN.setSelect(0);
+ opcionesViajeEN.setBackScreen("listadoViajes");
+ SC.addScreen(popcionesViajeEN, "rOptions", INGLES);
+ SM.addScreen(psopcionesViajeEN);
+
+ // Mensaje de archivo guardado
+ SC.addScreen(parchivoGuardado, "archivoGuardado", ESPANOL);
+ SC.addScreen(parchivoGuardadoEN, "archivoGuardado", INGLES);
+
+ // Mensaje de archivo borrado
+ archivoBorrado.addElement("Viaje borrado");
+ archivoBorrado.addElement("correctamente");
+ archivoBorrado.setBackScreen("menu");
+ SC.addScreen(parchivoBorrado, "archivoBorrado", ESPANOL);
+
+ archivoBorradoEN.addElement("Deleted file");
+ archivoBorradoEN.addElement("corretly");
+ archivoBorradoEN.setBackScreen("menu");
+ SC.addScreen(parchivoBorradoEN, "archivoBorrado", INGLES);
+
+ // Mensade de existencia de un viaje con el mismo nombre
+ nombreExistente.addElement("Ya existe un");
+ nombreExistente.addElement("viaje con el");
+ nombreExistente.addElement("nombre introducido.");
+ nombreExistente.setBackScreen("guardaViaje");
+ SC.addScreen(pnombreExistente, "alredyExist", ESPANOL);
+
+ nombreExistenteEN.addElement("Alredy exist a");
+ nombreExistenteEN.addElement("ride with the");
+ nombreExistenteEN.addElement("entered name");
+ nombreExistenteEN.setBackScreen("guardaViaje");
+ SC.addScreen(pnombreExistenteEN, "alredyExist", INGLES);
+
+ /****************************************/
+
+ /********************************************
+ CARGA DE LA CONFIGURACIÓN
+ ********************************************/
+ char aux[16];
+ // Se selecciona el idioma
+ config.getIdioma(aux);
+ if(strcmp(aux, "spanish") == 0){
+ SC.selectGroup(0);
+ }else if(strcmp(aux, "english") == 0){
+ SC.selectGroup(1);
+ }
+
+ // Se selecciona el modo de selección
+ config.getFormaSeleccion(aux);
+ if(strcmp(aux, "shading") == 0){
+ SM.setInverterSelection();
+ }else if(strcmp(aux, "framing") == 0){
+ SM.setRectSelection();
+ }
+
+ myled = 0;
+ myled4 = 0;
+
+ /****************************************/
+
+ SC.initialize();
+ while(1){
+ SC.update();
+ }
+}
\ No newline at end of file
