Add GPS data to data on flash memory

This commit is contained in:
Pierrick C 2018-08-19 00:01:23 +02:00
parent 50b73d3592
commit 4b9885d7a7

View File

@ -199,11 +199,25 @@ class Data:
"""Save the current data as csv file on SPI flash"""
try:
with open("data/data.csv", "a") as csv_file:
csv_file.write("{};{};{};{};{}\n".format(self.data['SYS']['time'],
if gps_enable:
csv_file.write("{};{};{};{};{};{};{};{};{};{}\n".format(self.data['SYS']['time'],
self.data['BME']['temp'],
self.data['BME']['hum'],
self.data['BME']['press'],
self.data['SYS']['vbat']))
self.data['SYS']['vbat'],
self.data['GPS']['time'],
self.data['GPS']['lon'],
self.data['GPS']['lat'],
self.data['GPS']['alt'],
self.data['GPS']['qual'],
))
else:
csv_file.write("{};{};{};{};{};;;;;\n".format(self.data['SYS']['time'],
self.data['BME']['temp'],
self.data['BME']['hum'],
self.data['BME']['press'],
self.data['SYS']['vbat']
))
except OSError as e:
print("Err {}: readonly".format(e))
backup_data = False #to avoid trying again till next reset