Added GPSShield example
This commit is contained in:
@@ -13,6 +13,7 @@ examples
|
|||||||
├─Keyboard_T_Deck_Master # T-Deck read from keyboard
|
├─Keyboard_T_Deck_Master # T-Deck read from keyboard
|
||||||
├─Microphone # Noise detection
|
├─Microphone # Noise detection
|
||||||
├─Touchpad # Read touch coordinates
|
├─Touchpad # Read touch coordinates
|
||||||
|
├─GPSShield # GPS Shield example
|
||||||
└─UnitTest # Factory hardware unit testing
|
└─UnitTest # Factory hardware unit testing
|
||||||
|
|
||||||
````
|
````
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ examples
|
|||||||
├─Keyboard_T_Deck_Master # T-Deck read from keyboard
|
├─Keyboard_T_Deck_Master # T-Deck read from keyboard
|
||||||
├─Microphone # Noise detection
|
├─Microphone # Noise detection
|
||||||
├─Touchpad # Read touch coordinates
|
├─Touchpad # Read touch coordinates
|
||||||
|
├─GPSShield # GPS Shield example
|
||||||
└─UnitTest # Factory hardware unit testing
|
└─UnitTest # Factory hardware unit testing
|
||||||
|
|
||||||
````
|
````
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
/**
|
||||||
|
* @file GPSShield.ino
|
||||||
|
* @author Lewis He (lewishe@outlook.com)
|
||||||
|
* @license MIT
|
||||||
|
* @copyright Copyright (c) 2024 Shenzhen Xin Yuan Electronic Technology Co., Ltd
|
||||||
|
* @date 2024-03-29
|
||||||
|
* @note This sketch only applies to boards carrying GPS shields, the default is T-Deck
|
||||||
|
* It does not support GPS function. Of course, you can use an external GPS module to connect to the Gover interface.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SerialGPS
|
||||||
|
#define SerialGPS Serial1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define BOARD_GPS_TX_PIN 43
|
||||||
|
#define BOARD_GPS_RX_PIN 44
|
||||||
|
|
||||||
|
#define BOARD_POWERON 10
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <TinyGPS++.h>
|
||||||
|
|
||||||
|
TinyGPSPlus gps;
|
||||||
|
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
//!⚠️ The board peripheral power control pin needs to be set to HIGH when using the peripheral
|
||||||
|
pinMode(BOARD_POWERON, OUTPUT);
|
||||||
|
digitalWrite(BOARD_POWERON, HIGH);
|
||||||
|
|
||||||
|
//GPS Serial port
|
||||||
|
SerialGPS.begin(38400, SERIAL_8N1, BOARD_GPS_RX_PIN, BOARD_GPS_TX_PIN);
|
||||||
|
|
||||||
|
Serial.println("This sketch only applies to boards carrying GPS shields, the default is T-Deck");
|
||||||
|
|
||||||
|
Serial.println("It does not support GPS function. Of course, you can use an external GPS module to connect to the Gover interface.");
|
||||||
|
|
||||||
|
|
||||||
|
delay(2000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
while (SerialGPS.available()) {
|
||||||
|
int c = SerialGPS.read();
|
||||||
|
// Serial.write(c);
|
||||||
|
if (gps.encode(c)) {
|
||||||
|
displayInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delay(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void displayInfo()
|
||||||
|
{
|
||||||
|
Serial.print(F("Location: "));
|
||||||
|
if (gps.location.isValid()) {
|
||||||
|
Serial.print(gps.location.lat(), 6);
|
||||||
|
Serial.print(F(","));
|
||||||
|
Serial.print(gps.location.lng(), 6);
|
||||||
|
} else {
|
||||||
|
Serial.print(F("INVALID"));
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.print(F(" Date/Time: "));
|
||||||
|
if (gps.date.isValid()) {
|
||||||
|
Serial.print(gps.date.month());
|
||||||
|
Serial.print(F("/"));
|
||||||
|
Serial.print(gps.date.day());
|
||||||
|
Serial.print(F("/"));
|
||||||
|
Serial.print(gps.date.year());
|
||||||
|
} else {
|
||||||
|
Serial.print(F("INVALID"));
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.print(F(" "));
|
||||||
|
if (gps.time.isValid()) {
|
||||||
|
if (gps.time.hour() < 10) Serial.print(F("0"));
|
||||||
|
Serial.print(gps.time.hour());
|
||||||
|
Serial.print(F(":"));
|
||||||
|
if (gps.time.minute() < 10) Serial.print(F("0"));
|
||||||
|
Serial.print(gps.time.minute());
|
||||||
|
Serial.print(F(":"));
|
||||||
|
if (gps.time.second() < 10) Serial.print(F("0"));
|
||||||
|
Serial.print(gps.time.second());
|
||||||
|
Serial.print(F("."));
|
||||||
|
if (gps.time.centisecond() < 10) Serial.print(F("0"));
|
||||||
|
Serial.print(gps.time.centisecond());
|
||||||
|
} else {
|
||||||
|
Serial.print(F("INVALID"));
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println();
|
||||||
|
}
|
||||||
+3
-3
@@ -23,6 +23,7 @@ src_dir = examples/UnitTest
|
|||||||
; src_dir = examples/Microphone
|
; src_dir = examples/Microphone
|
||||||
; src_dir = examples/Touchpad
|
; src_dir = examples/Touchpad
|
||||||
; src_dir = examples/Keyboard_T_Deck_Master
|
; src_dir = examples/Keyboard_T_Deck_Master
|
||||||
|
; src_dir = examples/GPSShield
|
||||||
|
|
||||||
; src_dir = examples/LvglArduinoVNC_VGA
|
; src_dir = examples/LvglArduinoVNC_VGA
|
||||||
|
|
||||||
@@ -44,15 +45,14 @@ build_flags =
|
|||||||
-DBOARD_HAS_PSRAM
|
-DBOARD_HAS_PSRAM
|
||||||
|
|
||||||
; Enable UARDUINO_ USB_ CDC_ ON_ BOOT will start printing and wait for terminal access during startup
|
; Enable UARDUINO_ USB_ CDC_ ON_ BOOT will start printing and wait for terminal access during startup
|
||||||
; -DARDUINO_USB_CDC_ON_BOOT=1
|
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||||
|
|
||||||
; Enable UARDUINO_USB_CDC_ON_BOOT will turn off printing and will not block when using the battery
|
; Enable UARDUINO_USB_CDC_ON_BOOT will turn off printing and will not block when using the battery
|
||||||
-UARDUINO_USB_CDC_ON_BOOT
|
; -UARDUINO_USB_CDC_ON_BOOT
|
||||||
|
|
||||||
-DDISABLE_ALL_LIBRARY_WARNINGS
|
-DDISABLE_ALL_LIBRARY_WARNINGS
|
||||||
|
|
||||||
|
|
||||||
extra_scripts = ./script/pos_extra_script.py
|
|
||||||
|
|
||||||
[env:T-Deck]
|
[env:T-Deck]
|
||||||
extends = env
|
extends = env
|
||||||
|
|||||||
Reference in New Issue
Block a user