Просмотр исходного кода

Add color-coded LED blinks on successful NMEA message parse.

Aaron Mavrinac 3 лет назад
Родитель
Сommit
60f86aeb33
2 измененных файлов с 12 добавлено и 0 удалено
  1. 9 0
      gps_uart.c
  2. 3 0
      gps_uart.h

+ 9 - 0
gps_uart.c

@@ -53,6 +53,8 @@ static void gps_uart_parse_nmea(GpsUart* gps_uart, char* line)
         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;
 
@@ -70,6 +72,8 @@ static void gps_uart_parse_nmea(GpsUart* gps_uart, char* line)
         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;
 
@@ -164,6 +168,8 @@ GpsUart* gps_uart_enable()
   gps_uart->status.fix_quality = 0;
   gps_uart->status.satellites_tracked = 0;
 
+  gps_uart->notifications = furi_record_open(RECORD_NOTIFICATION);
+
   gps_uart->thread = furi_thread_alloc();
   furi_thread_set_name(gps_uart->thread, "GpsUartWorker");
   furi_thread_set_stack_size(gps_uart->thread, 1024);
@@ -180,5 +186,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);
 }

+ 3 - 0
gps_uart.h

@@ -1,6 +1,7 @@
 #pragma once
 
 #include <furi_hal.h>
+#include <notification/notification_messages.h>
 
 #define GPS_BAUDRATE 9600
 #define RX_BUF_SIZE 1024
@@ -27,6 +28,8 @@ typedef struct
   FuriStreamBuffer* rx_stream;
   uint8_t rx_buf[RX_BUF_SIZE];
 
+  NotificationApp* notifications;
+
   GpsStatus status;
 } GpsUart;