Skip to content

Commit

Permalink
Add fill QTH from GPS
Browse files Browse the repository at this point in the history
Closes #9
  • Loading branch information
gdyuldin committed Oct 22, 2024
1 parent 38c19fa commit ede1195
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
25 changes: 17 additions & 8 deletions src/dialog_gps.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@
*
* Copyright (c) 2022-2023 Belousov Oleg aka R1CBU
*/
#include "dialog_gps.h"

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <math.h>

#include "lvgl/lvgl.h"
#include "gps.h"
#include "dialog.h"
#include "dialog_gps.h"
#include "styles.h"
#include "events.h"
#include "radio.h"
#include "keyboard.h"
#include "qth.h"
#include "params/params.h"
#include "msg.h"
#include "lvgl/lvgl.h"

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <math.h>

#define HEIGHT 42
#define LABEL_WIDTH 300
Expand Down Expand Up @@ -183,7 +185,14 @@ static void gps_cb(lv_event_t * e) {
deg_to_str2(deg_type, msg->fix.longitude, str, sizeof(str), "E", "W");
lv_label_set_text(lon, str);

lv_label_set_text(qth, pos_grid(msg->fix.latitude, msg->fix.longitude));
const char * qth_val = pos_grid(msg->fix.latitude, msg->fix.longitude);
lv_label_set_text(qth, qth_val);

int saved_qth_len = strlen(params.qth.x);
if ((saved_qth_len == 0) || (strncmp(qth_val, params.qth.x, saved_qth_len) != 0)) {
params_str_set(&params.qth, qth_val);
msg_set_text_fmt("QTH updated: %s", params.qth.x);
}
} else {
lv_label_set_text(lat, "N/A");
lv_label_set_text(lon, "N/A");
Expand Down
1 change: 0 additions & 1 deletion src/dialog_gps.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#pragma once

#include "lvgl/lvgl.h"
#include "dialog.h"

extern dialog_t *dialog_gps;
Expand Down

0 comments on commit ede1195

Please sign in to comment.