2018 revision to classic DataBus AVC code.
Dependencies: LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell
Logger.cpp@24:a7f92dfc5310, 2018-12-21 (annotated)
- Committer:
- shimniok
- Date:
- Fri Dec 21 20:04:09 2018 +0000
- Revision:
- 24:a7f92dfc5310
- Child:
- 29:cb2f55fbfe9c
thread changes, added stats command, added sd filesystem, other minor changes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 24:a7f92dfc5310 | 1 | #include "Logger.h" |
shimniok | 24:a7f92dfc5310 | 2 | |
shimniok | 24:a7f92dfc5310 | 3 | Logger::Logger(const char *file) { |
shimniok | 24:a7f92dfc5310 | 4 | _file = file; |
shimniok | 24:a7f92dfc5310 | 5 | } |
shimniok | 24:a7f92dfc5310 | 6 | |
shimniok | 24:a7f92dfc5310 | 7 | |
shimniok | 24:a7f92dfc5310 | 8 | void Logger::log_gps(GpsData gd) { |
shimniok | 24:a7f92dfc5310 | 9 | _open(); |
shimniok | 24:a7f92dfc5310 | 10 | fprintf(_fp, "G,%3.7f,%3.7f,%3.1f,%2.1f,%2.1f,%d\n", |
shimniok | 24:a7f92dfc5310 | 11 | gd.latitude, |
shimniok | 24:a7f92dfc5310 | 12 | gd.longitude, |
shimniok | 24:a7f92dfc5310 | 13 | gd.course, |
shimniok | 24:a7f92dfc5310 | 14 | gd.speed, |
shimniok | 24:a7f92dfc5310 | 15 | gd.hdop, |
shimniok | 24:a7f92dfc5310 | 16 | gd.svcount |
shimniok | 24:a7f92dfc5310 | 17 | ); |
shimniok | 24:a7f92dfc5310 | 18 | _close(); |
shimniok | 24:a7f92dfc5310 | 19 | } |
shimniok | 24:a7f92dfc5310 | 20 | |
shimniok | 24:a7f92dfc5310 | 21 | |
shimniok | 24:a7f92dfc5310 | 22 | void Logger::log_estimation() { |
shimniok | 24:a7f92dfc5310 | 23 | _open(); |
shimniok | 24:a7f92dfc5310 | 24 | |
shimniok | 24:a7f92dfc5310 | 25 | _close(); |
shimniok | 24:a7f92dfc5310 | 26 | } |
shimniok | 24:a7f92dfc5310 | 27 | |
shimniok | 24:a7f92dfc5310 | 28 | |
shimniok | 24:a7f92dfc5310 | 29 | void Logger::_open() { |
shimniok | 24:a7f92dfc5310 | 30 | _fp = fopen(_file, "a"); |
shimniok | 24:a7f92dfc5310 | 31 | } |
shimniok | 24:a7f92dfc5310 | 32 | |
shimniok | 24:a7f92dfc5310 | 33 | |
shimniok | 24:a7f92dfc5310 | 34 | void Logger::_close() { |
shimniok | 24:a7f92dfc5310 | 35 | if (_fp) { |
shimniok | 24:a7f92dfc5310 | 36 | fclose(_fp); |
shimniok | 24:a7f92dfc5310 | 37 | } |
shimniok | 24:a7f92dfc5310 | 38 | } |