Implemented tt_gps

This commit is contained in:
Ken Van Hoeylandt 2025-06-08 15:16:58 +02:00
parent ea88165b08
commit 5071c390d4
3 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,21 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
bool tt_gps_has_coordinates();
bool tt_gps_get_coordinates(
float& longitude,
float& latitude,
float& speed,
float& course,
int& day,
int& month,
int& year
);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,45 @@
#include "tt_gps.h"
#include <Tactility/service/gps/GpsService.h>
using namespace tt::service;
extern "C" {
bool tt_gps_has_coordinates() {
auto service = gps::findGpsService();
return service != nullptr && service->hasCoordinates();
}
bool tt_gps_get_coordinates(
float& longitude,
float& latitude,
float& speed,
float& course,
int& day,
int& month,
int& year
) {
auto service = gps::findGpsService();
if (service == nullptr) {
return false;
}
minmea_sentence_rmc rmc;
if (!service->getCoordinates(rmc)) {
return false;
}
longitude = minmea_tocoord(&rmc.longitude);
latitude = minmea_tocoord(&rmc.latitude);
speed = minmea_tocoord(&rmc.speed);
course = minmea_tocoord(&rmc.course);
day = rmc.date.day;
month = rmc.date.month;
year = rmc.date.year;
return true;
}
}

View File

@ -5,6 +5,7 @@
#include "tt_app_manifest.h"
#include "tt_app_selectiondialog.h"
#include "tt_bundle.h"
#include "tt_gps.h"
#include "tt_hal_i2c.h"
#include "tt_lvgl_keyboard.h"
#include "tt_lvgl_spinner.h"
@ -42,6 +43,8 @@ const struct esp_elfsym elf_symbols[] {
ESP_ELFSYM_EXPORT(tt_bundle_put_bool),
ESP_ELFSYM_EXPORT(tt_bundle_put_int32),
ESP_ELFSYM_EXPORT(tt_bundle_put_string),
ESP_ELFSYM_EXPORT(tt_gps_has_coordinates),
ESP_ELFSYM_EXPORT(tt_gps_get_coordinates),
ESP_ELFSYM_EXPORT(tt_hal_i2c_start),
ESP_ELFSYM_EXPORT(tt_hal_i2c_stop),
ESP_ELFSYM_EXPORT(tt_hal_i2c_is_started),