Code cleanup ++
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
* -----------
|
||||
* - Arduino UNO R3
|
||||
* - Ultimate GPS logger shield
|
||||
* - 16x2 LCD Shield
|
||||
* - 9V Battery
|
||||
*/
|
||||
#include <math.h>
|
||||
@@ -23,6 +24,7 @@ const float deg2rad = 0.01745329251994;
|
||||
const float rEarth = 6371000.0; // Earths radius in meters
|
||||
float range = 9999; // Distance between src and pos
|
||||
String destination = "N46 59.776, E007 27.771";
|
||||
//String destination = "N46 55.090, E007 26.442"; // Gurten
|
||||
String position = ""; // read from GPS
|
||||
String tmp = "";
|
||||
|
||||
@@ -38,10 +40,13 @@ float lon2 = 0;
|
||||
// Prototypes
|
||||
void useInterrupt(boolean);
|
||||
void print_message(String Line1, String Line2);
|
||||
|
||||
/*******************************************/
|
||||
//String destination = "N46 55.090, W7 26.442"; // Gurten: N 46 55.090 E 7 26.442
|
||||
/*******************************************/
|
||||
void useInterrupt(boolean v);
|
||||
void print_message(String Line1, String Line2);
|
||||
float haversine (float lat1, float lon1, float lat2, float lon2);
|
||||
float string2lon(String position);
|
||||
float string2lat(String position);
|
||||
String gps2string(void);
|
||||
String int2fw(int x, int n);
|
||||
|
||||
void setup()
|
||||
{
|
||||
@@ -79,7 +84,7 @@ void loop()
|
||||
|
||||
tmp = String(range);
|
||||
tmp += " [m]";
|
||||
print_message("I wand up.", tmp);
|
||||
print_message("Me wants up!", tmp);
|
||||
|
||||
} else {
|
||||
print_message("Hello Mischa!", "Take me outside!"); // No fix available
|
||||
@@ -119,7 +124,7 @@ SIGNAL(TIMER0_COMPA_vect)
|
||||
{
|
||||
char c = GPS.read(); // Read from serial input
|
||||
|
||||
if (GPSECHO){ // If GPSECHO is enabled
|
||||
if (GPSECHO) { // If GPSECHO is enabled
|
||||
if (c) {
|
||||
UDR0 = c; // Send nmea char by char
|
||||
}
|
||||
@@ -228,7 +233,7 @@ float string2lat(String position)
|
||||
* Descr: returns the float representation of
|
||||
* the current longitude.
|
||||
**************************************************/
|
||||
float string2lon (String position)
|
||||
float string2lon(String position)
|
||||
{
|
||||
// returns radians: e.g. String position = "N38 58.892, W076 29.177";
|
||||
float lon = ((position.charAt(13) - '0') * 100.0) + \
|
||||
@@ -256,12 +261,12 @@ float string2lon (String position)
|
||||
* Descr: Calculates the distance between
|
||||
* two points given by (lat1/2 lon1/2)
|
||||
**************************************************/
|
||||
float haversine (float lat1, float lon1, float lat2, float lon2)
|
||||
float haversine(float lat1, float lon1, float lat2, float lon2)
|
||||
{
|
||||
// returns the great-circle distance between two points
|
||||
float h = sq((sin((lat1 - lat2) / 2.0))) + \
|
||||
(cos(lat1) * cos(lat2) * \
|
||||
sq((sin((lon1 - lon2) / 2.0))));
|
||||
sq((sin((lon1 - lon2) / 2.0))));
|
||||
|
||||
float d = 2.0 * rEarth * asin (sqrt(h));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user