Skip to content

Commit f587f89

Browse files
committed
Cosmetic code move
1 parent 24c3075 commit f587f89

File tree

2 files changed

+108
-108
lines changed

2 files changed

+108
-108
lines changed

Firmware/RTK_Surveyor/Buttons.ino

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -95,111 +95,3 @@ void checkSetupButton()
9595
}
9696
}
9797
}
98-
99-
//Create or close UBX/NMEA files as needed (startup or as user changes settings)
100-
//Push new UBX packets to log as needed
101-
void updateLogs()
102-
{
103-
if (online.nmeaLogging == false && settings.logNMEA == true)
104-
{
105-
beginLoggingNMEA();
106-
}
107-
else if (online.nmeaLogging == true && settings.logNMEA == false)
108-
{
109-
//Close down file
110-
nmeaFile.sync();
111-
nmeaFile.close();
112-
online.nmeaLogging = false;
113-
}
114-
115-
if (online.ubxLogging == false && settings.logUBX == true)
116-
{
117-
beginLoggingUBX();
118-
}
119-
else if (online.ubxLogging == true && settings.logUBX == false)
120-
{
121-
//Close down file
122-
ubxFile.sync();
123-
ubxFile.close();
124-
online.ubxLogging = false;
125-
}
126-
127-
if (online.ubxLogging == true)
128-
{
129-
//Check if we are inside the max time window for logging
130-
if ((systemTime_minutes - startLogTime_minutes) < settings.maxLogTime_minutes)
131-
{
132-
while (i2cGNSS.fileBufferAvailable() >= sdWriteSize) // Check to see if we have at least sdWriteSize waiting in the buffer
133-
{
134-
//Attempt to write to file system. This avoids collisions with file writing in F9PSerialReadTask()
135-
if (xSemaphoreTake(xFATSemaphore, fatSemaphore_maxWait) == pdPASS)
136-
{
137-
uint8_t myBuffer[sdWriteSize]; // Create our own buffer to hold the data while we write it to SD card
138-
139-
i2cGNSS.extractFileBufferData((uint8_t *)&myBuffer, sdWriteSize); // Extract exactly sdWriteSize bytes from the UBX file buffer and put them into myBuffer
140-
141-
int bytesWritten = ubxFile.write(myBuffer, sdWriteSize); // Write exactly sdWriteSize bytes from myBuffer to the ubxDataFile on the SD card
142-
143-
//Force sync every 1000ms
144-
if (millis() - lastUBXLogSyncTime > 1000)
145-
{
146-
lastUBXLogSyncTime = millis();
147-
digitalWrite(baseStatusLED, !digitalRead(baseStatusLED)); //Blink LED to indicate logging activity
148-
ubxFile.sync();
149-
digitalWrite(baseStatusLED, !digitalRead(baseStatusLED)); //Return LED to previous state
150-
}
151-
152-
xSemaphoreGive(xFATSemaphore);
153-
}
154-
155-
// In case the SD writing is slow or there is a lot of data to write, keep checking for the arrival of new data
156-
i2cGNSS.checkUblox(); // Check for the arrival of new data and process it.
157-
}
158-
}
159-
}
160-
161-
//Report file sizes to show recording is working
162-
if (online.nmeaLogging == true || online.ubxLogging == true)
163-
{
164-
if (millis() - lastFileReport > 5000)
165-
{
166-
lastFileReport = millis();
167-
if (online.nmeaLogging == true && online.ubxLogging == true)
168-
Serial.printf("UBX and NMEA file size: %d / %d", ubxFile.fileSize(), nmeaFile.fileSize());
169-
else if (online.nmeaLogging == true)
170-
Serial.printf("NMEA file size: %d", nmeaFile.fileSize());
171-
else if (online.ubxLogging == true)
172-
Serial.printf("UBX file size: %d", ubxFile.fileSize());
173-
174-
if ((systemTime_minutes - startLogTime_minutes) > settings.maxLogTime_minutes)
175-
Serial.printf(" reached max log time %d / System time %d",
176-
settings.maxLogTime_minutes,
177-
(systemTime_minutes - startLogTime_minutes));
178-
179-
Serial.println();
180-
}
181-
}
182-
}
183-
184-
//Once we have a fix, sync system clock to GNSS
185-
//All SD writes will use the system date/time
186-
void updateRTC()
187-
{
188-
if (online.rtc == false)
189-
{
190-
if (online.gnss == true)
191-
{
192-
if (i2cGNSS.getConfirmedDate() == true && i2cGNSS.getConfirmedTime() == true)
193-
{
194-
//For the ESP32 SD library, the date/time stamp of files is set using the internal system time
195-
//This is normally set with WiFi NTP but we will rarely have WiFi
196-
rtc.setTime(i2cGNSS.getSecond(), i2cGNSS.getMinute(), i2cGNSS.getHour(), i2cGNSS.getDay(), i2cGNSS.getMonth(), i2cGNSS.getYear()); // 17th Jan 2021 15:24:30
197-
198-
online.rtc = true;
199-
200-
Serial.print(F("System time set to: "));
201-
Serial.println(rtc.getTime("%B %d %Y %H:%M:%S")); //From ESP32Time library example
202-
}
203-
}
204-
}
205-
}

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,111 @@ void loop()
320320

321321
delay(10); //A small delay prevents panic if no other I2C or functions are called
322322
}
323+
324+
//Create or close UBX/NMEA files as needed (startup or as user changes settings)
325+
//Push new UBX packets to log as needed
326+
void updateLogs()
327+
{
328+
if (online.nmeaLogging == false && settings.logNMEA == true)
329+
{
330+
beginLoggingNMEA();
331+
}
332+
else if (online.nmeaLogging == true && settings.logNMEA == false)
333+
{
334+
//Close down file
335+
nmeaFile.sync();
336+
nmeaFile.close();
337+
online.nmeaLogging = false;
338+
}
339+
340+
if (online.ubxLogging == false && settings.logUBX == true)
341+
{
342+
beginLoggingUBX();
343+
}
344+
else if (online.ubxLogging == true && settings.logUBX == false)
345+
{
346+
//Close down file
347+
ubxFile.sync();
348+
ubxFile.close();
349+
online.ubxLogging = false;
350+
}
351+
352+
if (online.ubxLogging == true)
353+
{
354+
//Check if we are inside the max time window for logging
355+
if ((systemTime_minutes - startLogTime_minutes) < settings.maxLogTime_minutes)
356+
{
357+
while (i2cGNSS.fileBufferAvailable() >= sdWriteSize) // Check to see if we have at least sdWriteSize waiting in the buffer
358+
{
359+
//Attempt to write to file system. This avoids collisions with file writing in F9PSerialReadTask()
360+
if (xSemaphoreTake(xFATSemaphore, fatSemaphore_maxWait) == pdPASS)
361+
{
362+
uint8_t myBuffer[sdWriteSize]; // Create our own buffer to hold the data while we write it to SD card
363+
364+
i2cGNSS.extractFileBufferData((uint8_t *)&myBuffer, sdWriteSize); // Extract exactly sdWriteSize bytes from the UBX file buffer and put them into myBuffer
365+
366+
int bytesWritten = ubxFile.write(myBuffer, sdWriteSize); // Write exactly sdWriteSize bytes from myBuffer to the ubxDataFile on the SD card
367+
368+
//Force sync every 1000ms
369+
if (millis() - lastUBXLogSyncTime > 1000)
370+
{
371+
lastUBXLogSyncTime = millis();
372+
digitalWrite(baseStatusLED, !digitalRead(baseStatusLED)); //Blink LED to indicate logging activity
373+
ubxFile.sync();
374+
digitalWrite(baseStatusLED, !digitalRead(baseStatusLED)); //Return LED to previous state
375+
}
376+
377+
xSemaphoreGive(xFATSemaphore);
378+
}
379+
380+
// In case the SD writing is slow or there is a lot of data to write, keep checking for the arrival of new data
381+
i2cGNSS.checkUblox(); // Check for the arrival of new data and process it.
382+
}
383+
}
384+
}
385+
386+
//Report file sizes to show recording is working
387+
if (online.nmeaLogging == true || online.ubxLogging == true)
388+
{
389+
if (millis() - lastFileReport > 5000)
390+
{
391+
lastFileReport = millis();
392+
if (online.nmeaLogging == true && online.ubxLogging == true)
393+
Serial.printf("UBX and NMEA file size: %d / %d", ubxFile.fileSize(), nmeaFile.fileSize());
394+
else if (online.nmeaLogging == true)
395+
Serial.printf("NMEA file size: %d", nmeaFile.fileSize());
396+
else if (online.ubxLogging == true)
397+
Serial.printf("UBX file size: %d", ubxFile.fileSize());
398+
399+
if ((systemTime_minutes - startLogTime_minutes) > settings.maxLogTime_minutes)
400+
Serial.printf(" reached max log time %d / System time %d",
401+
settings.maxLogTime_minutes,
402+
(systemTime_minutes - startLogTime_minutes));
403+
404+
Serial.println();
405+
}
406+
}
407+
}
408+
409+
//Once we have a fix, sync system clock to GNSS
410+
//All SD writes will use the system date/time
411+
void updateRTC()
412+
{
413+
if (online.rtc == false)
414+
{
415+
if (online.gnss == true)
416+
{
417+
if (i2cGNSS.getConfirmedDate() == true && i2cGNSS.getConfirmedTime() == true)
418+
{
419+
//For the ESP32 SD library, the date/time stamp of files is set using the internal system time
420+
//This is normally set with WiFi NTP but we will rarely have WiFi
421+
rtc.setTime(i2cGNSS.getSecond(), i2cGNSS.getMinute(), i2cGNSS.getHour(), i2cGNSS.getDay(), i2cGNSS.getMonth(), i2cGNSS.getYear()); // 17th Jan 2021 15:24:30
422+
423+
online.rtc = true;
424+
425+
Serial.print(F("System time set to: "));
426+
Serial.println(rtc.getTime("%B %d %Y %H:%M:%S")); //From ESP32Time library example
427+
}
428+
}
429+
}
430+
}

0 commit comments

Comments
 (0)