testing GPS (experimental)
This commit is contained in:
		
							parent
							
								
									485b4fb2f0
								
							
						
					
					
						commit
						600ba2bd71
					
				@ -51,8 +51,8 @@ typedef struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#ifdef HAS_GPS
 | 
					#ifdef HAS_GPS
 | 
				
			||||||
  typedef struct {
 | 
					  typedef struct {
 | 
				
			||||||
    float latitude;
 | 
					    uint32_t latitude;
 | 
				
			||||||
    float longitude;
 | 
					    uint32_t longitude;
 | 
				
			||||||
    uint8_t satellites;
 | 
					    uint8_t satellites;
 | 
				
			||||||
    uint16_t hdop;
 | 
					    uint16_t hdop;
 | 
				
			||||||
    uint16_t altitude;
 | 
					    uint16_t altitude;
 | 
				
			||||||
 | 
				
			|||||||
@ -7,8 +7,8 @@ static const char TAG[] = "main";
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// read GPS data and cast to global struct
 | 
					// read GPS data and cast to global struct
 | 
				
			||||||
void gps_read(){
 | 
					void gps_read(){
 | 
				
			||||||
    gps_status.latitude     =   (float) gps.location.lat();
 | 
					    gps_status.latitude     =   (uint32_t) gps.location.lat() * 100;
 | 
				
			||||||
    gps_status.longitude    =   (float) gps.location.lng();
 | 
					    gps_status.longitude    =   (uint32_t) gps.location.lng() * 100;
 | 
				
			||||||
    gps_status.satellites   =   (uint8_t) gps.satellites.value();
 | 
					    gps_status.satellites   =   (uint8_t) gps.satellites.value();
 | 
				
			||||||
    gps_status.hdop         =   (uint16_t) gps.hdop.value();
 | 
					    gps_status.hdop         =   (uint16_t) gps.hdop.value();
 | 
				
			||||||
    gps_status.altitude     =   (uint16_t) gps.altitude.meters(); 
 | 
					    gps_status.altitude     =   (uint16_t) gps.altitude.meters(); 
 | 
				
			||||||
@ -25,18 +25,29 @@ void gps_loop(void * pvParameters) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if (cfg.gpsmode)
 | 
					        if (cfg.gpsmode)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            // if GPS function is enabled try serial connect to GPS device
 | 
					            #ifdef GPS_SERIAL
 | 
				
			||||||
            GPS_Serial.begin(HAS_GPS);
 | 
					                // serial connect to GPS device
 | 
				
			||||||
            
 | 
					                GPS_Serial.begin(GPS_SERIAL);
 | 
				
			||||||
            while(cfg.gpsmode) {
 | 
					                
 | 
				
			||||||
                // feed GPS decoder with serial NMEA data from GPS device
 | 
					                while(cfg.gpsmode) {
 | 
				
			||||||
                while (GPS_Serial.available()) {
 | 
					                    // feed GPS decoder with serial NMEA data from GPS device
 | 
				
			||||||
                    gps.encode(GPS_Serial.read());
 | 
					                    while (GPS_Serial.available()) {
 | 
				
			||||||
                    vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog
 | 
					                        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();
 | 
					                // 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
 | 
					        vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog
 | 
				
			||||||
 | 
				
			|||||||
@ -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_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
 | 
					#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
 | 
					// Hardware pin definitions for Pycom LoPy board
 | 
				
			||||||
#define PIN_SPI_SS    GPIO_NUM_17
 | 
					#define PIN_SPI_SS    GPIO_NUM_17
 | 
				
			||||||
#define PIN_SPI_MOSI  GPIO_NUM_27
 | 
					#define PIN_SPI_MOSI  GPIO_NUM_27
 | 
				
			||||||
 | 
				
			|||||||
@ -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_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
 | 
					#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
 | 
					// Hardware pin definitions for Pycom LoPy4 board
 | 
				
			||||||
#define PIN_SPI_SS    GPIO_NUM_18
 | 
					#define PIN_SPI_SS    GPIO_NUM_18
 | 
				
			||||||
#define PIN_SPI_MOSI  GPIO_NUM_27
 | 
					#define PIN_SPI_MOSI  GPIO_NUM_27
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,8 @@
 | 
				
			|||||||
//#define HAS_BUTTON GPIO_NUM_39 // on board button "BOOT" (next to reset button) !! seems not to work!!
 | 
					//#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 HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7
 | 
				
			||||||
#define BATT_FACTOR 2 // voltage divider 100k/100k on board
 | 
					#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
 | 
					// 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
 | 
					#define PIN_SPI_SS    GPIO_NUM_18 // ESP32 GPIO18 (Pin18) -- HPD13A NSS/SEL (Pin4) SPI Chip Select Input
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user