PropWare
C++ objects and CMake build system for Parallax Propeller
Home
Download
Getting Started
Documentation
Reference
About
Related Links
Namespace List
Class List
File List
Examples
Build System
File List
File Members
propsideworkspace
Learn
Simple Libraries
Sensor
libgps
libgps.c
1
17
#include "simpletools.h"
// Include simple tools
18
#include "gps.h"
19
#include <unistd.h>
// included for usleep
20
21
22
//#define ENABLE_LCD
23
#define ENABLE_PC
24
25
#define GPS_RXIN_PIN 0
26
#define GPS_TXOUT_PIN 1
27
#define GPS_BAUD 9600
28
29
#define LCD_PIN 14
30
#define LCD_BAUD 9600
31
32
33
int
main
()
// main() function
34
{
35
36
pause(1000);
37
38
#ifdef ENABLE_LCD
39
serial
*lcd = serial_open(LCD_PIN, LCD_PIN, 0, LCD_BAUD);
40
41
writeChar(lcd, 22);
//LCD on, Cursor Off
42
writeChar(lcd, 17);
//Backlight On
43
writeChar(lcd, 12);
//Clear LCD screen of text
44
#endif
45
46
47
//Start the GPS driver
48
gps_open(GPS_RXIN_PIN, GPS_TXOUT_PIN, GPS_BAUD);
49
50
pause(100);
//give the drive a moment to start up
51
52
//Infinite loop to print GPS statistics
53
while
(1)
54
{
55
56
#ifdef ENABLE_LCD //only do this section of code if ENABLE_LCD is defined
57
writeChar(lcd, 128);
58
dprint(lcd,
"lat: %f "
, gps_latitude());
59
writeChar(lcd, 148);
60
dprint(lcd,
"lon: %f "
, gps_longitude());
61
writeChar(lcd, 168);
62
dprint(lcd,
"Deg:%d Alt:%3.1fm "
, (
int
)gps_heading(), gps_altitude());
63
writeChar(lcd, 188);
64
dprint(lcd,
"Spd:%3.1fmph sats:%d "
, gps_velocity(MPH), gps_satsTracked());
65
#endif //end ENABLE_LCD
66
67
68
#ifdef ENABLE_PC //only do this section of code if ENABLE_PC is defined
69
70
//send a "Home" character to the terminal
71
print(
"%c"
, HOME);
72
73
//begin printing all the GPS information
74
print(
"GPS Fix: "
);
75
if
(gps_fixValid())
76
print(
"Valid \n"
);
77
else
78
print(
"Not Valid \n"
);
79
80
print(
"Altitude (meters): %3.2f\n"
, gps_altitude());
81
print(
"Num Satellites: %d\n"
, gps_satsTracked());
82
print(
"Compass Heading: %3.2f\n"
, gps_heading());
83
print(
"Velocity (knots): %3.2f\n"
, gps_velocity(KNOTS));
84
85
print(
"\nLatitude Longitude\n"
);
86
print(
"%f %f"
, gps_latitude(), gps_longitude());
87
88
//sleep for 1/4 second
89
usleep(250000);
90
91
#endif //end ENABLE_PC
92
93
}
//end main loop
94
95
96
}
//end main()
97
main
int main(void)
Definition:
GraphicsTest.c:20
text_struct
Structure that contains data used by simple text device libraries.
Definition:
simpletext.h:70
Generated on Sat Aug 27 2016 00:58:09 for PropWare by
1.8.12