Merge pull request #416 from p0ns/gps-uart-baudrate-array

Implements an array for baudrates on GPS UART app
This commit is contained in:
MX 2023-04-14 02:11:44 +03:00 committed by GitHub
commit 3c4cbf2a05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 17 deletions

View file

@ -139,20 +139,14 @@ int32_t gps_app(void* p) {
switch(event.input.key) {
case InputKeyUp:
gps_uart_deinit_thread(gps_uart);
switch(gps_uart->baudrate) {
case GPS_BAUDRATE_9k:
gps_uart->baudrate = GPS_BAUDRATE_57k;
break;
case GPS_BAUDRATE_57k:
gps_uart->baudrate = GPS_BAUDRATE_115k;
break;
case GPS_BAUDRATE_115k:
gps_uart->baudrate = GPS_BAUDRATE_9k;
break;
default:
break;
const int baudrate_length =
sizeof(gps_baudrates) / sizeof(gps_baudrates[0]);
current_gps_baudrate++;
if(current_gps_baudrate >= baudrate_length) {
current_gps_baudrate = 0;
}
gps_uart->baudrate = gps_baudrates[current_gps_baudrate];
gps_uart_init_thread(gps_uart);
gps_uart->changing_baudrate = true;
view_port_update(view_port);

View file

@ -169,7 +169,7 @@ GpsUart* gps_uart_enable() {
gps_uart->notifications = furi_record_open(RECORD_NOTIFICATION);
gps_uart->baudrate = GPS_BAUDRATE_57k;
gps_uart->baudrate = gps_baudrates[current_gps_baudrate];
gps_uart_init_thread(gps_uart);

View file

@ -3,11 +3,11 @@
#include <furi_hal.h>
#include <notification/notification_messages.h>
#define GPS_BAUDRATE_9k 9600
#define GPS_BAUDRATE_57k 57600
#define GPS_BAUDRATE_115k 115200
#define RX_BUF_SIZE 1024
static const int gps_baudrates[5] = {9600, 19200, 38400, 57600, 115200};
static int current_gps_baudrate = 3;
typedef struct {
bool valid;
float latitude;