implementação do sgam_mdw baseado na placa NUCLEO FZ429ZI para ser testada

Dependencies:   MPU6050 Grove_temperature

Dependents:   sgam_mdw_test

sensor/gps/GPS.cpp

Committer:
AndersonIctus
Date:
2019-07-20
Revision:
17:8789ab4067a6

File content as of revision 17:8789ab4067a6:

#include "sgam_mdw.h"
#include "mbed.h"

#include "GPS.h"
#include <stdlib.h>

// FAKE DATA !!
static float LATITUDE[] = {   -3.729082,  -3.729681,  -3.737186,  -3.749637,  -3.744262,  -3.727500,  -3.734366,  -3.716379,  -3.708595,  -3.716506 };
static float LONGITUDE[] = { -38.527864, -38.522864, -38.506823, -38.518743, -38.493957, -38.485239, -38.502019, -38.593300, -38.557838, -38.565691 };
static float METERS[] = { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 };

GPS::GPS() { 
    D_LOG("GPS Initialized !!\r\n");
    value = new GPSData();
}

GPS::~GPS() {
    value->~GPSData();
}

int GPS::initialize() { D_LOG("INITIALIZE %s! \r\n", this->getName() ); return 1; }
int GPS::finalize() { D_LOG("FINALIZE %s! \r\n", this->getName() ); return 1; }

// Pega valorews FAKE para latitude, longitude e metros !!
void GPS::getLocation(GPSData* data) {
    int pos = rand() % 10; // pega um valor randomico !!
    data->latitude  = LATITUDE[pos];
    data->longitude = LONGITUDE[pos];
    data->meters    = METERS[pos];
}

GPSData* GPS::getValue() {
    getLocation(value);
    return value;
}

const char* GPS::getName() { 
    return "GPS"; 
}