diff --git a/src/globals.h b/src/globals.h index cb7b720f..04ef15d7 100644 --- a/src/globals.h +++ b/src/globals.h @@ -51,8 +51,8 @@ typedef struct { #ifdef HAS_GPS typedef struct { - float latitude; - float longitude; + uint32_t latitude; + uint32_t longitude; uint8_t satellites; uint16_t hdop; uint16_t altitude; diff --git a/src/gpsread.cpp b/src/gpsread.cpp index 99c3b02e..4747f7a6 100644 --- a/src/gpsread.cpp +++ b/src/gpsread.cpp @@ -7,8 +7,8 @@ static const char TAG[] = "main"; // read GPS data and cast to global struct void gps_read(){ - gps_status.latitude = (float) gps.location.lat(); - gps_status.longitude = (float) gps.location.lng(); + gps_status.latitude = (uint32_t) gps.location.lat() * 100; + gps_status.longitude = (uint32_t) gps.location.lng() * 100; gps_status.satellites = (uint8_t) gps.satellites.value(); gps_status.hdop = (uint16_t) gps.hdop.value(); gps_status.altitude = (uint16_t) gps.altitude.meters(); @@ -25,18 +25,29 @@ void gps_loop(void * pvParameters) { if (cfg.gpsmode) { - // if GPS function is enabled try serial connect to GPS device - GPS_Serial.begin(HAS_GPS); - - while(cfg.gpsmode) { - // feed GPS decoder with serial NMEA data from GPS device - while (GPS_Serial.available()) { - gps.encode(GPS_Serial.read()); - vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog - } - } - // after GPS function was disabled, close connect to GPS device - GPS_Serial.end(); + #ifdef GPS_SERIAL + // serial connect to GPS device + GPS_Serial.begin(GPS_SERIAL); + + while(cfg.gpsmode) { + // feed GPS decoder with serial NMEA data from GPS device + while (GPS_Serial.available()) { + gps.encode(GPS_Serial.read()); + vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog + } + } + // after GPS function was disabled, close connect to GPS device + GPS_Serial.end(); + #endif + + #ifdef GPS_I2C + // I2C connect to GPS device + + /* + to be done + */ + + #endif } vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog diff --git a/src/hal/lopy.h b/src/hal/lopy.h index 137c8e53..dd5a0b7b 100644 --- a/src/hal/lopy.h +++ b/src/hal/lopy.h @@ -4,6 +4,11 @@ #define HAS_LED NOT_A_PIN // LoPy4 has no on board LED, so we use RGB LED on LoPy4 #define HAS_RGB_LED GPIO_NUM_0 // WS2812B RGB LED on GPIO0 +// use only if your LoPy lives on a Pytrack expansion board +//#define HAS_GPS 1 +//#define GPS_I2C GPIO_NUM_9, GPIO_NUM_8 // SDA, SCL +//#define HAS_BUTTON GPIO_NUM_4 + // Hardware pin definitions for Pycom LoPy board #define PIN_SPI_SS GPIO_NUM_17 #define PIN_SPI_MOSI GPIO_NUM_27 diff --git a/src/hal/lopy4.h b/src/hal/lopy4.h index 586f1bb2..721b11ef 100644 --- a/src/hal/lopy4.h +++ b/src/hal/lopy4.h @@ -4,6 +4,11 @@ #define HAS_LED NOT_A_PIN // LoPy4 has no on board LED, so we use RGB LED on LoPy4 #define HAS_RGB_LED GPIO_NUM_0 // WS2812B RGB LED on GPIO0 +// use only if your LoPy lives on a Pytrack expansion board +//#define HAS_GPS 1 +//#define GPS_I2C GPIO_NUM_9, GPIO_NUM_8 // SDA, SCL +//#define HAS_BUTTON GPIO_NUM_4 + // Hardware pin definitions for Pycom LoPy4 board #define PIN_SPI_SS GPIO_NUM_18 #define PIN_SPI_MOSI GPIO_NUM_27 diff --git a/src/hal/ttgobeam.h b/src/hal/ttgobeam.h index fb5dae8b..aafbb3a9 100644 --- a/src/hal/ttgobeam.h +++ b/src/hal/ttgobeam.h @@ -6,7 +6,8 @@ //#define HAS_BUTTON GPIO_NUM_39 // on board button "BOOT" (next to reset button) !! seems not to work!! #define HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7 #define BATT_FACTOR 2 // voltage divider 100k/100k on board -#define HAS_GPS 9600, SERIAL_8N1, GPIO_NUM_12, GPIO_NUM_15 // UBlox NEO 6M or 7M +#define HAS_GPS 1 // use on board GPS +#define GPS_SERIAL 9600, SERIAL_8N1, GPIO_NUM_12, GPIO_NUM_15 // UBlox NEO 6M or 7M with default configuration // re-define pin definitions of pins_arduino.h #define PIN_SPI_SS GPIO_NUM_18 // ESP32 GPIO18 (Pin18) -- HPD13A NSS/SEL (Pin4) SPI Chip Select Input