Skip to content

Commit 0556b0a

Browse files
committed
upd gps nmea
1 parent 91a93bd commit 0556b0a

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

base_pack/gps_nmea_uart/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This is a single-screen app, and a few interactions are provided via the
1111
hardware buttons:
1212

1313
- Long press the up button to change the **baud rate**. The default baud rate
14-
is 9600, but 19200, 38400, 57600, and 115200 baud are also supported.
14+
is 9600, but 4800, 19200, 38400, 57600, and 115200 baud are also supported.
1515
- Long press the right button to change **speed units** from knots to
1616
kilometers per hour.
1717
- Press the OK button to set the **backlight** to always on mode. Press it

base_pack/gps_nmea_uart/gps.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "constants.h"
33

44
#include <furi.h>
5+
#include <furi_hal_power.h>
56
#include <gui/gui.h>
67
#include <string.h>
78
#include <expansion/expansion.h>
@@ -38,7 +39,7 @@ static void render_callback(Canvas* const canvas, void* context) {
3839
32,
3940
AlignCenter,
4041
AlignBottom,
41-
gps_uart->backlight_enabled ? "Backlight enabled" : "Backlight disabled");
42+
gps_uart->backlight_on ? "Backlight enabled" : "Backlight disabled");
4243
break;
4344
case CHANGE_DEEPSLEEP:
4445
canvas_set_font(canvas, FontPrimary);
@@ -182,16 +183,16 @@ int32_t gps_app(void* p) {
182183
processing = false;
183184
break;
184185
case InputKeyOk:
185-
if(!gps_uart->backlight_enabled) {
186+
if(!gps_uart->backlight_on) {
186187
notification_message_block(
187188
gps_uart->notifications, &sequence_display_backlight_enforce_on);
188-
gps_uart->backlight_enabled = true;
189+
gps_uart->backlight_on = true;
189190
} else {
190191
notification_message_block(
191192
gps_uart->notifications, &sequence_display_backlight_enforce_auto);
192193
notification_message(
193194
gps_uart->notifications, &sequence_display_backlight_off);
194-
gps_uart->backlight_enabled = false;
195+
gps_uart->backlight_on = false;
195196
}
196197

197198
gps_uart->view_state = CHANGE_BACKLIGHT;
@@ -217,7 +218,6 @@ int32_t gps_app(void* p) {
217218

218219
gps_uart_init_thread(gps_uart);
219220
gps_uart->view_state = CHANGE_BAUDRATE;
220-
221221
furi_mutex_release(gps_uart->mutex);
222222
view_port_update(view_port);
223223
furi_delay_ms(1000);
@@ -259,7 +259,6 @@ int32_t gps_app(void* p) {
259259
}
260260
}
261261
}
262-
263262
if(gps_uart->view_state == NORMAL) {
264263
furi_mutex_release(gps_uart->mutex);
265264
view_port_update(view_port);

base_pack/gps_nmea_uart/gps_uart.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@ typedef enum {
1111
#define WORKER_ALL_RX_EVENTS (WorkerEvtStop | WorkerEvtRxDone)
1212

1313
static void
14-
gps_uart_on_irq_cb(FuriHalSerialHandle* handle, FuriHalSerialRxEvent event, void* context) {
14+
gps_uart_on_irq_cb(FuriHalSerialHandle* handle, FuriHalSerialRxEvent ev, void* context) {
1515
GpsUart* gps_uart = (GpsUart*)context;
1616

17-
if(event == FuriHalSerialRxEventData) {
17+
if(ev == FuriHalSerialRxEventData) {
1818
uint8_t data = furi_hal_serial_async_rx(handle);
1919
furi_stream_buffer_send(gps_uart->rx_stream, &data, 1, 0);
2020
furi_thread_flags_set(furi_thread_get_id(gps_uart->thread), WorkerEvtRxDone);
2121
}
2222
}
2323

2424
static void gps_uart_serial_init(GpsUart* gps_uart) {
25+
furi_assert(!gps_uart->serial_handle);
26+
2527
gps_uart->serial_handle = furi_hal_serial_control_acquire(UART_CH);
2628
furi_check(gps_uart->serial_handle);
2729
furi_hal_serial_init(gps_uart->serial_handle, gps_uart->baudrate);
@@ -32,10 +34,11 @@ static void gps_uart_serial_init(GpsUart* gps_uart) {
3234
}
3335

3436
static void gps_uart_serial_deinit(GpsUart* gps_uart) {
35-
UNUSED(gps_uart);
37+
furi_assert(gps_uart->serial_handle);
3638
furi_hal_serial_async_rx_stop(gps_uart->serial_handle);
3739
furi_hal_serial_deinit(gps_uart->serial_handle);
3840
furi_hal_serial_control_release(gps_uart->serial_handle);
41+
gps_uart->serial_handle = NULL;
3942
}
4043

4144
static void gps_uart_parse_nmea(GpsUart* gps_uart, char* line) {
@@ -209,8 +212,8 @@ GpsUart* gps_uart_enable() {
209212
gps_uart->notifications = furi_record_open(RECORD_NOTIFICATION);
210213

211214
gps_uart->baudrate = gps_baudrates[current_gps_baudrate];
215+
gps_uart->backlight_on = false;
212216
gps_uart->speed_units = KNOTS;
213-
gps_uart->backlight_enabled = false;
214217
gps_uart->deep_sleep_enabled = false;
215218
gps_uart->view_state = NORMAL;
216219

base_pack/gps_nmea_uart/gps_uart.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@ typedef struct {
4040
FuriThread* thread;
4141
FuriStreamBuffer* rx_stream;
4242
uint8_t rx_buf[RX_BUF_SIZE];
43-
FuriHalSerialHandle* serial_handle;
4443

4544
NotificationApp* notifications;
4645
uint32_t baudrate;
47-
bool backlight_enabled;
46+
bool backlight_on;
4847
bool deep_sleep_enabled;
4948
SpeedUnit speed_units;
5049
ViewState view_state;
5150

51+
FuriHalSerialHandle* serial_handle;
52+
5253
GpsStatus status;
5354
} GpsUart;
5455

0 commit comments

Comments
 (0)