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
gps.cpp@1:c142b1682312, 2019-10-30 (annotated)
- Committer:
- KINU
- Date:
- Wed Oct 30 01:42:40 2019 +0000
- Revision:
- 1:c142b1682312
- Child:
- 2:639bfe0721a7
GPS2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
KINU | 1:c142b1682312 | 1 | #include "mbed.h" |
KINU | 1:c142b1682312 | 2 | #include "getGPS.h" |
KINU | 1:c142b1682312 | 3 | #include "math.h" |
KINU | 1:c142b1682312 | 4 | |
KINU | 1:c142b1682312 | 5 | Serial pc(USBTX,USBRX); |
KINU | 1:c142b1682312 | 6 | GPS gps (p27,p28); |
KINU | 1:c142b1682312 | 7 | |
KINU | 1:c142b1682312 | 8 | |
KINU | 1:c142b1682312 | 9 | int main() { |
KINU | 1:c142b1682312 | 10 | double a; |
KINU | 1:c142b1682312 | 11 | double b; |
KINU | 1:c142b1682312 | 12 | double c; |
KINU | 1:c142b1682312 | 13 | double d; |
KINU | 1:c142b1682312 | 14 | double distance; |
KINU | 1:c142b1682312 | 15 | |
KINU | 1:c142b1682312 | 16 | pc.printf("GPS Start\n"); |
KINU | 1:c142b1682312 | 17 | |
KINU | 1:c142b1682312 | 18 | while(1) |
KINU | 1:c142b1682312 | 19 | { |
KINU | 1:c142b1682312 | 20 | if(gps.getgps()) |
KINU | 1:c142b1682312 | 21 | { |
KINU | 1:c142b1682312 | 22 | a = gps.latitude; |
KINU | 1:c142b1682312 | 23 | b = gps.longitude; |
KINU | 1:c142b1682312 | 24 | |
KINU | 1:c142b1682312 | 25 | pc.printf("(%lf,%lf)\n\r",gps.latitude,gps.longitude);//緯度と経度を表示 |
KINU | 1:c142b1682312 | 26 | break; |
KINU | 1:c142b1682312 | 27 | } |
KINU | 1:c142b1682312 | 28 | else |
KINU | 1:c142b1682312 | 29 | { |
KINU | 1:c142b1682312 | 30 | pc.printf("NO DATA\r\n");//データ取得失敗 |
KINU | 1:c142b1682312 | 31 | wait(1); |
KINU | 1:c142b1682312 | 32 | } |
KINU | 1:c142b1682312 | 33 | } |
KINU | 1:c142b1682312 | 34 | while(1) |
KINU | 1:c142b1682312 | 35 | { |
KINU | 1:c142b1682312 | 36 | if(gps.getgps()) |
KINU | 1:c142b1682312 | 37 | { |
KINU | 1:c142b1682312 | 38 | c = gps.latitude; |
KINU | 1:c142b1682312 | 39 | d = gps.longitude; |
KINU | 1:c142b1682312 | 40 | pc.printf("(%lf,%lf)\n\r",gps.latitude,gps.longitude);//緯度と経度を表示 |
KINU | 1:c142b1682312 | 41 | distance =6370*cos(sin(a)*sin(c)+cos(a)*cos(c)*cos(b-d)); |
KINU | 1:c142b1682312 | 42 | |
KINU | 1:c142b1682312 | 43 | if (distance<5) |
KINU | 1:c142b1682312 | 44 | { |
KINU | 1:c142b1682312 | 45 | }else |
KINU | 1:c142b1682312 | 46 | { |
KINU | 1:c142b1682312 | 47 | pc.printf("5m clear!"); |
KINU | 1:c142b1682312 | 48 | break; |
KINU | 1:c142b1682312 | 49 | } |
KINU | 1:c142b1682312 | 50 | }else{ |
KINU | 1:c142b1682312 | 51 | pc.printf("NO DATA\r\n");//データ取得失敗 |
KINU | 1:c142b1682312 | 52 | wait(1); |
KINU | 1:c142b1682312 | 53 | } |
KINU | 1:c142b1682312 | 54 | } |
KINU | 1:c142b1682312 | 55 | return 0; |
KINU | 1:c142b1682312 | 56 | } |