WIP
рабочий код. отображение часов согласно часового пояса MSK на LCD. GPS(19200) и RTC работают.
This commit is contained in:
23
GPS_com.cpp
23
GPS_com.cpp
@@ -12,8 +12,8 @@
|
||||
#include "RTC_com.h" // to set the RTC
|
||||
|
||||
#define cfg_pin_GPS_PPS 2;
|
||||
#define cfg_pin_GPS_Rx 4;
|
||||
#define cfg_pin_GPS_Tx 5;
|
||||
//#define cfg_pin_GPS_Rx 4;
|
||||
//#define cfg_pin_GPS_Tx 5;
|
||||
|
||||
// add the static modifier to limit visibility of these variables to just this file
|
||||
static byte GPS_PPS_PIN = cfg_pin_GPS_PPS; // Pin 2 = NANO INT0, GPS PPS interrupt signal on this Pin
|
||||
@@ -25,17 +25,19 @@ volatile bool GPS_sec = false; // flag for GPS-PPS
|
||||
|
||||
// set interrupt flag
|
||||
void gps_interrupt() {
|
||||
Serial.println("DEBUG[INT] GPS interrupt");
|
||||
//Serial.print("DEBUG[INT] GPS interrupt "); Serial.println(micros());
|
||||
GPS_sec = true;
|
||||
}
|
||||
|
||||
NMEAGPS gps; // This parses the GPS characters
|
||||
gps_fix fix; // This holds on to the latest values
|
||||
//#include <GPSport.h> // use only for soft-serial
|
||||
#include <NeoSWSerial.h>
|
||||
NeoSWSerial gpsPort(4, 5);
|
||||
|
||||
#include <AltSoftSerial.h>
|
||||
#include <GPSport.h> // use only for soft-serial
|
||||
//#define gpsPort Serial
|
||||
#define GPS_PORT_NAME "NeoSWSerial(4, 5)"
|
||||
//#define GPS_PORT_NAME "Serial"
|
||||
#define GPS_PORT_NAME "AltSoftSerial"
|
||||
|
||||
#define DEBUG_PORT Serial
|
||||
|
||||
/***** Notice ********************************************
|
||||
@@ -64,12 +66,12 @@ NeoSWSerial gpsPort(4, 5);
|
||||
const long POSIX_Y2K_offset = 946684800; // = 10957 days = 30 years, NeoTime (GPS) & TimeLib (RTC) library use different Epoch year, 2000 & 1970
|
||||
const long offset_28y = 883612800; // = 10227 days = 28 years, simple test for 2038 bug
|
||||
const long offset_26w = 15724800; // = 182 days = 26 weeks, simple test for timezone
|
||||
|
||||
const long offset_135 = 123456; // = 135 seconds, simple test for timezone
|
||||
void GPS_setup() {
|
||||
pinMode(GPS_PPS_PIN, INPUT_PULLUP); // enable pullup on interrupt pin
|
||||
attachInterrupt(digitalPinToInterrupt(GPS_PPS_PIN), gps_interrupt, RISING); // 100ms HIGH at start of second
|
||||
GPS_sec = false;
|
||||
gpsPort.begin(9600); // set PC to same baudrate for debug messages
|
||||
gpsPort.begin(19200); // set PC to same baudrate for debug messages
|
||||
GPS_ON();
|
||||
}
|
||||
|
||||
@@ -88,6 +90,7 @@ void GPS_PPS() { // do something on the flip of the GPS second
|
||||
if (gps_seconds_t != 0) { // do only if value is set
|
||||
// gps_seconds_t += offset_28y; // debug & testing only!
|
||||
// gps_seconds_t += offset_26w; // debug & testing only!
|
||||
// gps_seconds_t += offset_135;
|
||||
SetRTC(gps_seconds_t); // sync RTC with GPS
|
||||
GPS_OFF();
|
||||
}
|
||||
@@ -112,7 +115,7 @@ void GPS_ON() {
|
||||
gps_on = true;
|
||||
gps_seconds_t = 0; // make shure GPS serial is alive before setting
|
||||
pulse_count = 0;
|
||||
Serial.println("GPS: ON"); // debug
|
||||
Serial.println("GPS: ON"); // debug
|
||||
}
|
||||
|
||||
void GPS_OFF() {
|
||||
|
||||
Reference in New Issue
Block a user