mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-11-28 02:45:45 +03:00
parent
3ea6d59c2f
commit
3d25838a53
52
applications/plugins/gps_nmea_uart/.gitignore
vendored
52
applications/plugins/gps_nmea_uart/.gitignore
vendored
@ -1,52 +0,0 @@
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
@ -1,14 +1,32 @@
|
||||
# GPS for Flipper Zero
|
||||
|
||||
[Original link](https://github.com/ezod/flipperzero-gps)
|
||||
[Adafruit Ultimate GPS Breakout].
|
||||
|
||||
A simple Flipper Zero application for NMEA 0183 serial GPS modules, such as the [Adafruit Ultimate GPS Breakout].
|
||||
![ui](ui.png)
|
||||
|
||||
Heavy lifting (NMEA parsing) provided by [minmea], which is included in this repository.
|
||||
Heavy lifting (NMEA parsing) provided by [minmea], which is included in this
|
||||
repository.
|
||||
|
||||
## Hardware Setup
|
||||
|
||||
Connect the GPS module to power and the USART using GPIO pins 9 (3.3V), 11 (GND), 13 (TX), and 14 (RX), as appropriate.
|
||||
Connect the GPS module to power and the USART using GPIO pins 9 (3.3V), 11
|
||||
(GND), 13 (TX), and 14 (RX), as appropriate.
|
||||
|
||||
![wiring](wiring.png)
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
This project was a learning exercise and is more or less "complete" from my
|
||||
perspective, but I will happily accept pull requests that improve and enhance
|
||||
the functionality for others.
|
||||
|
||||
Currently, the app only parses RMC and GGA sentences, and displays a subset of
|
||||
the data that fits on the screen. The UART is also hard-coded to 9600 baud.
|
||||
These limitations are largely driven by the GPS module I have to work with. A
|
||||
more elaborate UI with scrolling or multiple screens, as well as a configurable
|
||||
baud rate, may be useful for other GPS modules.
|
||||
|
||||
[Adafruit Ultimate GPS Breakout]: https://www.adafruit.com/product/746
|
||||
[minmea]: https://github.com/kosma/minmea
|
||||
|
@ -20,30 +20,42 @@ static void render_callback(Canvas* const canvas, void* context) {
|
||||
return;
|
||||
}
|
||||
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str_aligned(canvas, 32, 8, AlignCenter, AlignBottom, "Latitude");
|
||||
canvas_draw_str_aligned(canvas, 96, 8, AlignCenter, AlignBottom, "Longitude");
|
||||
canvas_draw_str_aligned(canvas, 21, 30, AlignCenter, AlignBottom, "Course");
|
||||
canvas_draw_str_aligned(canvas, 64, 30, AlignCenter, AlignBottom, "Speed");
|
||||
canvas_draw_str_aligned(canvas, 107, 30, AlignCenter, AlignBottom, "Altitude");
|
||||
canvas_draw_str_aligned(canvas, 32, 52, AlignCenter, AlignBottom, "Satellites");
|
||||
canvas_draw_str_aligned(canvas, 96, 52, AlignCenter, AlignBottom, "Last Fix");
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
char buffer[64];
|
||||
snprintf(buffer, 64, "LAT: %f", (double)gps_uart->status.latitude);
|
||||
canvas_draw_str_aligned(canvas, 10, 10, AlignLeft, AlignBottom, buffer);
|
||||
snprintf(buffer, 64, "LON: %f", (double)gps_uart->status.longitude);
|
||||
canvas_draw_str_aligned(canvas, 10, 20, AlignLeft, AlignBottom, buffer);
|
||||
snprintf(buffer, 64, "%f", (double)gps_uart->status.latitude);
|
||||
canvas_draw_str_aligned(canvas, 32, 18, AlignCenter, AlignBottom, buffer);
|
||||
snprintf(buffer, 64, "%f", (double)gps_uart->status.longitude);
|
||||
canvas_draw_str_aligned(canvas, 96, 18, AlignCenter, AlignBottom, buffer);
|
||||
snprintf(buffer, 64, "%.1f", (double)gps_uart->status.course);
|
||||
canvas_draw_str_aligned(canvas, 21, 40, AlignCenter, AlignBottom, buffer);
|
||||
snprintf(buffer, 64, "%.2f kn", (double)gps_uart->status.speed);
|
||||
canvas_draw_str_aligned(canvas, 64, 40, AlignCenter, AlignBottom, buffer);
|
||||
snprintf(
|
||||
buffer,
|
||||
64,
|
||||
"C/S: %.1f / %.2fkn",
|
||||
(double)gps_uart->status.course,
|
||||
(double)gps_uart->status.speed);
|
||||
canvas_draw_str_aligned(canvas, 10, 30, AlignLeft, AlignBottom, buffer);
|
||||
snprintf(
|
||||
buffer,
|
||||
64,
|
||||
"ALT: %.1f %c",
|
||||
"%.1f %c",
|
||||
(double)gps_uart->status.altitude,
|
||||
gps_uart->status.altitude_units);
|
||||
canvas_draw_str_aligned(canvas, 10, 40, AlignLeft, AlignBottom, buffer);
|
||||
snprintf(buffer, 64, "FIX: %d", gps_uart->status.fix_quality);
|
||||
canvas_draw_str_aligned(canvas, 10, 50, AlignLeft, AlignBottom, buffer);
|
||||
snprintf(buffer, 64, "SAT: %d", gps_uart->status.satellites_tracked);
|
||||
canvas_draw_str_aligned(canvas, 10, 60, AlignLeft, AlignBottom, buffer);
|
||||
tolower(gps_uart->status.altitude_units));
|
||||
canvas_draw_str_aligned(canvas, 107, 40, AlignCenter, AlignBottom, buffer);
|
||||
snprintf(buffer, 64, "%d", gps_uart->status.satellites_tracked);
|
||||
canvas_draw_str_aligned(canvas, 32, 62, AlignCenter, AlignBottom, buffer);
|
||||
snprintf(
|
||||
buffer,
|
||||
64,
|
||||
"%02d:%02d:%02d UTC",
|
||||
gps_uart->status.time_hours,
|
||||
gps_uart->status.time_minutes,
|
||||
gps_uart->status.time_seconds);
|
||||
canvas_draw_str_aligned(canvas, 96, 62, AlignCenter, AlignBottom, buffer);
|
||||
|
||||
release_mutex((ValueMutex*)context, gps_uart);
|
||||
}
|
||||
|
@ -41,6 +41,11 @@ static void gps_uart_parse_nmea(GpsUart* gps_uart, char* line) {
|
||||
gps_uart->status.longitude = minmea_tocoord(&frame.longitude);
|
||||
gps_uart->status.speed = minmea_tofloat(&frame.speed);
|
||||
gps_uart->status.course = minmea_tofloat(&frame.course);
|
||||
gps_uart->status.time_hours = frame.time.hours;
|
||||
gps_uart->status.time_minutes = frame.time.minutes;
|
||||
gps_uart->status.time_seconds = frame.time.seconds;
|
||||
|
||||
notification_message_block(gps_uart->notifications, &sequence_blink_green_10);
|
||||
}
|
||||
} break;
|
||||
|
||||
@ -53,6 +58,11 @@ static void gps_uart_parse_nmea(GpsUart* gps_uart, char* line) {
|
||||
gps_uart->status.altitude_units = frame.altitude_units;
|
||||
gps_uart->status.fix_quality = frame.fix_quality;
|
||||
gps_uart->status.satellites_tracked = frame.satellites_tracked;
|
||||
gps_uart->status.time_hours = frame.time.hours;
|
||||
gps_uart->status.time_minutes = frame.time.minutes;
|
||||
gps_uart->status.time_seconds = frame.time.seconds;
|
||||
|
||||
notification_message_block(gps_uart->notifications, &sequence_blink_magenta_10);
|
||||
}
|
||||
} break;
|
||||
|
||||
@ -135,6 +145,11 @@ GpsUart* gps_uart_enable() {
|
||||
gps_uart->status.altitude_units = ' ';
|
||||
gps_uart->status.fix_quality = 0;
|
||||
gps_uart->status.satellites_tracked = 0;
|
||||
gps_uart->status.time_hours = 0;
|
||||
gps_uart->status.time_minutes = 0;
|
||||
gps_uart->status.time_seconds = 0;
|
||||
|
||||
gps_uart->notifications = furi_record_open(RECORD_NOTIFICATION);
|
||||
|
||||
gps_uart->thread = furi_thread_alloc();
|
||||
furi_thread_set_name(gps_uart->thread, "GpsUartWorker");
|
||||
@ -151,5 +166,8 @@ void gps_uart_disable(GpsUart* gps_uart) {
|
||||
furi_thread_flags_set(furi_thread_get_id(gps_uart->thread), WorkerEvtStop);
|
||||
furi_thread_join(gps_uart->thread);
|
||||
furi_thread_free(gps_uart->thread);
|
||||
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
|
||||
free(gps_uart);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi_hal.h>
|
||||
#include <notification/notification_messages.h>
|
||||
|
||||
#define GPS_BAUDRATE 9600
|
||||
#define RX_BUF_SIZE 1024
|
||||
@ -15,6 +16,9 @@ typedef struct {
|
||||
char altitude_units;
|
||||
int fix_quality;
|
||||
int satellites_tracked;
|
||||
int time_hours;
|
||||
int time_minutes;
|
||||
int time_seconds;
|
||||
} GpsStatus;
|
||||
|
||||
typedef struct {
|
||||
@ -22,6 +26,8 @@ typedef struct {
|
||||
FuriStreamBuffer* rx_stream;
|
||||
uint8_t rx_buf[RX_BUF_SIZE];
|
||||
|
||||
NotificationApp* notifications;
|
||||
|
||||
GpsStatus status;
|
||||
} GpsUart;
|
||||
|
||||
|
BIN
applications/plugins/gps_nmea_uart/ui.png
Normal file
BIN
applications/plugins/gps_nmea_uart/ui.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 82 KiB |
BIN
applications/plugins/gps_nmea_uart/wiring.png
Normal file
BIN
applications/plugins/gps_nmea_uart/wiring.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 80 KiB |
Loading…
Reference in New Issue
Block a user