Anderson Cunha / sgam_mdw_NUCLEOF429ZI_impl

Dependencies:   MPU6050 Grove_temperature

Dependents:   sgam_mdw_test

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GPS.cpp Source File

GPS.cpp

00001 #include "sgam_mdw.h"
00002 #include "mbed.h"
00003 
00004 #include "GPS.h"
00005 #include <stdlib.h>
00006 
00007 // FAKE DATA !!
00008 static float LATITUDE[] = {   -3.729082,  -3.729681,  -3.737186,  -3.749637,  -3.744262,  -3.727500,  -3.734366,  -3.716379,  -3.708595,  -3.716506 };
00009 static float LONGITUDE[] = { -38.527864, -38.522864, -38.506823, -38.518743, -38.493957, -38.485239, -38.502019, -38.593300, -38.557838, -38.565691 };
00010 static float METERS[] = { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 };
00011 
00012 GPS::GPS() { 
00013     D_LOG("GPS Initialized !!\r\n");
00014     value = new GPSData();
00015 }
00016 
00017 GPS::~GPS() {
00018     value->~GPSData();
00019 }
00020 
00021 int GPS::initialize() { D_LOG("INITIALIZE %s! \r\n", this->getName() ); return 1; }
00022 int GPS::finalize() { D_LOG("FINALIZE %s! \r\n", this->getName() ); return 1; }
00023 
00024 // Pega valorews FAKE para latitude, longitude e metros !!
00025 void GPS::getLocation(GPSData* data) {
00026     int pos = rand() % 10; // pega um valor randomico !!
00027     data->latitude  = LATITUDE[pos];
00028     data->longitude = LONGITUDE[pos];
00029     data->meters    = METERS[pos];
00030 }
00031 
00032 GPSData* GPS::getValue() {
00033     getLocation(value);
00034     return value;
00035 }
00036 
00037 const char* GPS::getName() { 
00038     return "GPS"; 
00039 }