aa
Dependencies: GPS TextLCD mbed
main.cpp@0:dfd102afb417, 2015-05-04 (annotated)
- Committer:
- narongdet
- Date:
- Mon May 04 04:38:21 2015 +0000
- Revision:
- 0:dfd102afb417
GPS_classroom
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
narongdet | 0:dfd102afb417 | 1 | #include "mbed.h" |
narongdet | 0:dfd102afb417 | 2 | #include "GPS.h" |
narongdet | 0:dfd102afb417 | 3 | #include "TextLCD.h" |
narongdet | 0:dfd102afb417 | 4 | GPS gps(PA_11,PA_12); |
narongdet | 0:dfd102afb417 | 5 | I2C i2c_lcd(D14,D15); |
narongdet | 0:dfd102afb417 | 6 | TextLCD_I2C lcd(&i2c_lcd, 0x4E, TextLCD::LCD16x2); |
narongdet | 0:dfd102afb417 | 7 | int main() |
narongdet | 0:dfd102afb417 | 8 | { |
narongdet | 0:dfd102afb417 | 9 | lcd.setMode(TextLCD::DispOn); |
narongdet | 0:dfd102afb417 | 10 | lcd.setBacklight(TextLCD::LightOff); |
narongdet | 0:dfd102afb417 | 11 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
narongdet | 0:dfd102afb417 | 12 | lcd.setAddress(0,0); |
narongdet | 0:dfd102afb417 | 13 | lcd.printf("Initial GPS...\n"); |
narongdet | 0:dfd102afb417 | 14 | |
narongdet | 0:dfd102afb417 | 15 | while(1){ |
narongdet | 0:dfd102afb417 | 16 | if(gps.sample()) |
narongdet | 0:dfd102afb417 | 17 | { |
narongdet | 0:dfd102afb417 | 18 | lcd.setAddress(0,1); |
narongdet | 0:dfd102afb417 | 19 | lcd.printf("%6.3f,%7.3f",gps.latitude,gps.longitude); |
narongdet | 0:dfd102afb417 | 20 | } |
narongdet | 0:dfd102afb417 | 21 | else |
narongdet | 0:dfd102afb417 | 22 | { |
narongdet | 0:dfd102afb417 | 23 | lcd.setAddress(0,1); |
narongdet | 0:dfd102afb417 | 24 | lcd.printf("GPS not valid"); |
narongdet | 0:dfd102afb417 | 25 | } |
narongdet | 0:dfd102afb417 | 26 | wait(0.5); |
narongdet | 0:dfd102afb417 | 27 | } |
narongdet | 0:dfd102afb417 | 28 | } |
narongdet | 0:dfd102afb417 | 29 |