Ver Fonte

Merge gps_nmea from https://github.com/xMasterX/all-the-plugins

# Conflicts:
#	gps_nmea/gps.c
#	gps_nmea/gps_uart.h
Willy-JL há 1 ano atrás
pai
commit
128838dce2
2 ficheiros alterados com 13 adições e 1 exclusões
  1. 1 1
      gps_nmea/application.fam
  2. 12 0
      gps_nmea/gps.c

+ 1 - 1
gps_nmea/application.fam

@@ -16,6 +16,6 @@ App(
         ),
     ],
     fap_author="@ezod & @xMasterX",
-    fap_version="1.2",
+    fap_version="1.3",
     fap_description="Works with GPS modules via UART, using NMEA protocol.",
 )

+ 12 - 0
gps_nmea/gps.c

@@ -4,6 +4,7 @@
 #include <furi.h>
 #include <gui/gui.h>
 #include <string.h>
+#include <expansion/expansion.h>
 
 typedef enum {
     EventTypeTick,
@@ -131,6 +132,10 @@ static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queu
 int32_t gps_app(void* p) {
     UNUSED(p);
 
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));
 
     GpsUart* gps_uart = gps_uart_enable();
@@ -139,6 +144,9 @@ int32_t gps_app(void* p) {
     if(!gps_uart->mutex) {
         FURI_LOG_E("GPS", "cannot create mutex\r\n");
         free(gps_uart);
+        // Return previous state of expansion
+        expansion_enable(expansion);
+        furi_record_close(RECORD_EXPANSION);
         return 255;
     }
 
@@ -271,5 +279,9 @@ int32_t gps_app(void* p) {
         furi_hal_power_disable_otg();
     }
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }