![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
mbed os 5?
Dependencies: GYSFDMAXB_Mbed_OS Vector3
main.cpp@1:d299835a8259, 2021-04-23 (annotated)
- Committer:
- cocorlow
- Date:
- Fri Apr 23 12:04:06 2021 +0000
- Revision:
- 1:d299835a8259
- Parent:
- 0:19a43a10f6c0
Mbed OS 5? no warranty
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cocorlow | 0:19a43a10f6c0 | 1 | #include "mbed.h" |
cocorlow | 1:d299835a8259 | 2 | #include "BufferedSerial.h" |
cocorlow | 0:19a43a10f6c0 | 3 | #include <string.h> |
cocorlow | 0:19a43a10f6c0 | 4 | #include "GYSFDMAXB.hpp" |
cocorlow | 0:19a43a10f6c0 | 5 | |
cocorlow | 0:19a43a10f6c0 | 6 | |
cocorlow | 1:d299835a8259 | 7 | BufferedSerial pc(USBTX, USBRX, 115200); |
cocorlow | 0:19a43a10f6c0 | 8 | GYSFDMAXB gps(PC_12, PD_2); |
cocorlow | 0:19a43a10f6c0 | 9 | DigitalOut led(LED1); |
cocorlow | 0:19a43a10f6c0 | 10 | |
cocorlow | 0:19a43a10f6c0 | 11 | void Display() |
cocorlow | 0:19a43a10f6c0 | 12 | { |
cocorlow | 0:19a43a10f6c0 | 13 | pc.printf("################################\r\n"); |
cocorlow | 0:19a43a10f6c0 | 14 | pc.printf("%d h %d m %d s %d ms\r\n", gps.Hours, gps.Minutes, gps.Seconds, gps.Milliseconds); |
cocorlow | 0:19a43a10f6c0 | 15 | pc.printf("%d / %d / %d\r\n", gps.Year, gps.Month, gps.Day); |
cocorlow | 0:19a43a10f6c0 | 16 | pc.printf("Latitude : %c %f\r\n", gps.N_S, gps.Latitude); |
cocorlow | 0:19a43a10f6c0 | 17 | pc.printf("Longitude : %c %f\r\n", gps.E_W, gps.Longitude); |
cocorlow | 0:19a43a10f6c0 | 18 | pc.printf("Elevation : %f\r\n", gps.Elevation); |
cocorlow | 0:19a43a10f6c0 | 19 | gps.Calcurate(); |
cocorlow | 0:19a43a10f6c0 | 20 | pc.printf("Local N : %f\r\n", gps.Position.x); |
cocorlow | 0:19a43a10f6c0 | 21 | pc.printf("Local E : %f\r\n", gps.Position.y); |
cocorlow | 0:19a43a10f6c0 | 22 | pc.printf("Local D : %f\r\n", gps.Position.z); |
cocorlow | 0:19a43a10f6c0 | 23 | pc.printf("Satellites : %d\r\n", gps.Satellites); |
cocorlow | 0:19a43a10f6c0 | 24 | /* |
cocorlow | 0:19a43a10f6c0 | 25 | pc.printf("start_index : %d\r\n", gps.start_index); |
cocorlow | 0:19a43a10f6c0 | 26 | pc.printf("uart_index : %d\r\n", gps.uart_index); |
cocorlow | 0:19a43a10f6c0 | 27 | |
cocorlow | 0:19a43a10f6c0 | 28 | pc.printf("UniversalZero X : %f\r\n", gps.UniversalZeroPosition.x); |
cocorlow | 0:19a43a10f6c0 | 29 | pc.printf("UniversalZero Y : %f\r\n", gps.UniversalZeroPosition.y); |
cocorlow | 0:19a43a10f6c0 | 30 | pc.printf("UniversalZero Z : %f\r\n", gps.UniversalZeroPosition.z); |
cocorlow | 0:19a43a10f6c0 | 31 | pc.printf("Universal X : %f\r\n", gps.UniversalPosition.x); |
cocorlow | 0:19a43a10f6c0 | 32 | pc.printf("Universal Y : %f\r\n", gps.UniversalPosition.y); |
cocorlow | 0:19a43a10f6c0 | 33 | pc.printf("Universal Z : %f\r\n", gps.UniversalPosition.z); |
cocorlow | 0:19a43a10f6c0 | 34 | */ |
cocorlow | 0:19a43a10f6c0 | 35 | } |
cocorlow | 0:19a43a10f6c0 | 36 | |
cocorlow | 0:19a43a10f6c0 | 37 | |
cocorlow | 0:19a43a10f6c0 | 38 | int main() |
cocorlow | 0:19a43a10f6c0 | 39 | { |
cocorlow | 0:19a43a10f6c0 | 40 | Ticker ticker; |
cocorlow | 0:19a43a10f6c0 | 41 | |
cocorlow | 0:19a43a10f6c0 | 42 | ticker.attach(&Display, 0.3); |
cocorlow | 0:19a43a10f6c0 | 43 | |
cocorlow | 0:19a43a10f6c0 | 44 | led = 1; |
cocorlow | 0:19a43a10f6c0 | 45 | gps.Initialize(); |
cocorlow | 0:19a43a10f6c0 | 46 | led = 0; |
cocorlow | 0:19a43a10f6c0 | 47 | |
cocorlow | 0:19a43a10f6c0 | 48 | while (1) |
cocorlow | 0:19a43a10f6c0 | 49 | { |
cocorlow | 1:d299835a8259 | 50 | gps.Update(); |
cocorlow | 1:d299835a8259 | 51 | pc.printf(" MbedOS v %d.%d.%d\r\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); |
cocorlow | 0:19a43a10f6c0 | 52 | } |
cocorlow | 0:19a43a10f6c0 | 53 | } |
cocorlow | 0:19a43a10f6c0 | 54 | |
cocorlow | 0:19a43a10f6c0 | 55 | |
cocorlow | 0:19a43a10f6c0 | 56 | // GPS baud rate |
cocorlow | 0:19a43a10f6c0 | 57 | /* |
cocorlow | 0:19a43a10f6c0 | 58 | Serial gps(PC_12, PD_2); |
cocorlow | 0:19a43a10f6c0 | 59 | int main() |
cocorlow | 0:19a43a10f6c0 | 60 | { |
cocorlow | 0:19a43a10f6c0 | 61 | gps.baud(9600); |
cocorlow | 0:19a43a10f6c0 | 62 | while (1) |
cocorlow | 0:19a43a10f6c0 | 63 | { |
cocorlow | 0:19a43a10f6c0 | 64 | gps.printf("$PMTK251,57600*2C\r\n"); |
cocorlow | 0:19a43a10f6c0 | 65 | } |
cocorlow | 0:19a43a10f6c0 | 66 | } |
cocorlow | 0:19a43a10f6c0 | 67 | |
cocorlow | 0:19a43a10f6c0 | 68 | |
cocorlow | 0:19a43a10f6c0 | 69 | |
cocorlow | 0:19a43a10f6c0 | 70 | $PMTK251,115200*1F\r\n |
cocorlow | 0:19a43a10f6c0 | 71 | $PMTK251,57600*2C\r\n |
cocorlow | 0:19a43a10f6c0 | 72 | $PMTK251,9600*17\r\n |
cocorlow | 0:19a43a10f6c0 | 73 | */ |
cocorlow | 0:19a43a10f6c0 | 74 | |
cocorlow | 0:19a43a10f6c0 | 75 | /* |
cocorlow | 0:19a43a10f6c0 | 76 | Serial pc(USBTX, USBRX); |
cocorlow | 0:19a43a10f6c0 | 77 | Serial gps(PC_12, PD_2); |
cocorlow | 0:19a43a10f6c0 | 78 | |
cocorlow | 0:19a43a10f6c0 | 79 | void gps_receive() |
cocorlow | 0:19a43a10f6c0 | 80 | { |
cocorlow | 0:19a43a10f6c0 | 81 | while (gps.readable()) |
cocorlow | 0:19a43a10f6c0 | 82 | { |
cocorlow | 0:19a43a10f6c0 | 83 | char c; |
cocorlow | 0:19a43a10f6c0 | 84 | c = gps.getc(); |
cocorlow | 0:19a43a10f6c0 | 85 | pc.putc(c); |
cocorlow | 0:19a43a10f6c0 | 86 | } |
cocorlow | 0:19a43a10f6c0 | 87 | } |
cocorlow | 0:19a43a10f6c0 | 88 | |
cocorlow | 0:19a43a10f6c0 | 89 | int main() |
cocorlow | 0:19a43a10f6c0 | 90 | { |
cocorlow | 0:19a43a10f6c0 | 91 | pc.baud(115200); |
cocorlow | 0:19a43a10f6c0 | 92 | gps.baud(57600); |
cocorlow | 0:19a43a10f6c0 | 93 | gps.attach(gps_receive, Serial::RxIrq); |
cocorlow | 0:19a43a10f6c0 | 94 | while (1) |
cocorlow | 0:19a43a10f6c0 | 95 | { |
cocorlow | 0:19a43a10f6c0 | 96 | } |
cocorlow | 0:19a43a10f6c0 | 97 | } |
cocorlow | 0:19a43a10f6c0 | 98 | */ |
cocorlow | 0:19a43a10f6c0 | 99 | /* |
cocorlow | 0:19a43a10f6c0 | 100 | $GPGLL,3542.8886,N,13945.7717,E,071533.000,A,A*58 |
cocorlow | 0:19a43a10f6c0 | 101 | $GPGSA,A,3,21,22,08,194,195,01,,,,,,,2.14,1.90,1.00*07 |
cocorlow | 0:19a43a10f6c0 | 102 | $GPGSV,4,1,14,195,85,343,35,01,79,276,33,21,69,028,29,194,59,191,33*73 |
cocorlow | 0:19a43a10f6c0 | 103 | $GPGSV,4,2,14,08,48,067,32,22,47,142,34,14,34,314,16,28,29,316,16*7C |
cocorlow | 0:19a43a10f6c0 | 104 | $GPGSV,4,3,14,30,28,267,,07,23,224,,27,16,087,,10,03,033,*7C |
cocorlow | 0:19a43a10f6c0 | 105 | $GPGSV,4,4,14,193,,,,38,,,*4C |
cocorlow | 0:19a43a10f6c0 | 106 | $GPRMC,071533.000,A,3542.8886,N,13945.7717,E,0.10,53.89,080421,,,A*56 |
cocorlow | 0:19a43a10f6c0 | 107 | $GPVTG,53.89,T,,M,0.10,N,0.19,K,A*03 |
cocorlow | 0:19a43a10f6c0 | 108 | $GPZDA,071533.000,08,04,2021,,*58 |
cocorlow | 0:19a43a10f6c0 | 109 | $GPGGA,071534.000,3542.8886,N,13945.7717,E,1,6,1.90,95.8,M,39.3,M,,*69 |
cocorlow | 0:19a43a10f6c0 | 110 | $GPGLL,3542.8886,N,13945.7717,E,071534.000,A,A*5F |
cocorlow | 0:19a43a10f6c0 | 111 | $GPGSA,A,3,21,22,08,194,195,01,,,,,,,2.14,1.90,1.00*07 |
cocorlow | 0:19a43a10f6c0 | 112 | $GPGSV,4,1,14,195,85,343,35,01,79,276,33,21,69,028,29,194,59,191,33*73 |
cocorlow | 0:19a43a10f6c0 | 113 | $GPGSV,4,2,14,08,48,067,32,22,47,142,34,14,34,314,16,28,29,316,16*7C |
cocorlow | 0:19a43a10f6c0 | 114 | $GPGSV,4,3,14,30,28,267,,07,23,224,,27,16,087,,10,03,033,*7C |
cocorlow | 0:19a43a10f6c0 | 115 | $GPGSV,4,4,14,193,,,,41,,,*42 |
cocorlow | 0:19a43a10f6c0 | 116 | */ |