@@ -20,7 +20,7 @@ namespace core { | |||||
gps::getTime(time); | gps::getTime(time); | ||||
rtc::setTime(time); | rtc::setTime(time); | ||||
positions::appendLast(battery, gpsStatus); | |||||
positions::appendLast(battery, gpsStatus, rtc::getTemperature()); | |||||
uint8_t velocity; | uint8_t velocity; | ||||
gps::getVelocity(velocity); | gps::getVelocity(velocity); | ||||
@@ -6,7 +6,7 @@ | |||||
#define MENU_ENTRY(name, text) const char MENU_##name[] PROGMEM = text | #define MENU_ENTRY(name, text) const char MENU_##name[] PROGMEM = text | ||||
const char FAKE_GPS_ENTRY[] PROGMEM = "1,1,20170924074842.000,49.454862,1.144537,71.900,67.99,172.6,1,,1.3,2.2,1.8,,11,7,,,37,,"; | |||||
const char FAKE_GPS_ENTRY[] PROGMEM = "1,1,20170924184842.000,49.454862,1.144537,71.900,67.99,172.6,1,,1.3,2.2,1.8,,11,7,,,37,,"; | |||||
MENU_ENTRY(HEADER, "-- Debug Menu --"); | MENU_ENTRY(HEADER, "-- Debug Menu --"); | ||||
MENU_ENTRY(SEPARATOR, "----"); | MENU_ENTRY(SEPARATOR, "----"); | ||||
@@ -107,7 +107,7 @@ namespace debug { | |||||
namespace details { | namespace details { | ||||
inline void displayPosition(PositionEntry entry) { | inline void displayPosition(PositionEntry entry) { | ||||
Log.notice(F("%d%%, %dmV, %d, %s\n"), entry.battery.level, entry.battery.voltage, entry.status, entry.position); | |||||
Log.notice(F("%d%%, %dmV, %f°C, %d, %s\n"), entry.battery.level, entry.battery.voltage, entry.temperature, entry.status, entry.position); | |||||
} | } | ||||
} | } | ||||
@@ -223,7 +223,7 @@ namespace debug { | |||||
SIM808ChargingStatus status = hardware::sim808::device.getChargingState(); | SIM808ChargingStatus status = hardware::sim808::device.getChargingState(); | ||||
hardware::sim808::powerOff(); | hardware::sim808::powerOff(); | ||||
positions::appendLast(status, SIM808_GPS_STATUS::OFF); | |||||
positions::appendLast(status, SIM808_GPS_STATUS::OFF, rtc::getTemperature()); | |||||
} | } | ||||
void setRtcTime() { | void setRtcTime() { | ||||
@@ -19,11 +19,11 @@ namespace positions { | |||||
return ENTRIES_ADDR + (ENTRY_RESERVED_SIZE * index); | return ENTRIES_ADDR + (ENTRY_RESERVED_SIZE * index); | ||||
} | } | ||||
void appendLast(const SIM808ChargingStatus battery, const SIM808_GPS_STATUS gpsStatus) { | |||||
void appendLast(const SIM808ChargingStatus battery, const SIM808_GPS_STATUS gpsStatus, const float temperature) { | |||||
VERBOSE("appendLast"); | VERBOSE("appendLast"); | ||||
uint16_t entryAddress; | uint16_t entryAddress; | ||||
PositionEntry entry = { battery, gpsStatus }; | |||||
PositionEntry entry = { battery, temperature, gpsStatus }; | |||||
strlcpy(entry.position, gps::lastPosition, POSITION_SIZE); | strlcpy(entry.position, gps::lastPosition, POSITION_SIZE); | ||||
hardware::i2c::powerOn(); | hardware::i2c::powerOn(); | ||||
@@ -36,8 +36,8 @@ namespace positions { | |||||
entryAddress = getEntryAddress(config.lastEntry); | entryAddress = getEntryAddress(config.lastEntry); | ||||
hardware::i2c::eeprom.writeBlock(entryAddress, entry); | hardware::i2c::eeprom.writeBlock(entryAddress, entry); | ||||
VERBOSE_FORMAT("appendLast", "Written to EEPROM @ %X : [%d%% @ %dmV] [%d, %s]", entryAddress, battery.level, battery.voltage, gpsStatus, entry.position); | |||||
VERBOSE_FORMAT("appendLast", "Written to EEPROM @ %X : [%d%% @ %dmV] [%f°C] [%d, %s]", entryAddress, entry.battery.level, entry.battery.voltage, entry.temperature, entry.status, entry.position); | |||||
config::set(config); | config::set(config); | ||||
hardware::i2c::powerOff(); | hardware::i2c::powerOff(); | ||||
@@ -53,7 +53,7 @@ namespace positions { | |||||
hardware::i2c::eeprom.readBlock(entryAddress, entry); | hardware::i2c::eeprom.readBlock(entryAddress, entry); | ||||
hardware::i2c::powerOff(); | hardware::i2c::powerOff(); | ||||
VERBOSE_FORMAT("get", "Read from EEPROM @ %X : [%d%% @ %dmV] [%d, %s]", entryAddress, entry.battery.level, entry.battery.voltage, entry.status, entry.position); | |||||
VERBOSE_FORMAT("get", "Read from EEPROM @ %X : [%d%% @ %dmV] [%f°C] [%d, %s]", entryAddress, entry.battery.level, entry.battery.voltage, entry.temperature, entry.status, entry.position); | |||||
return true; | return true; | ||||
} | } | ||||
@@ -6,12 +6,13 @@ | |||||
struct PositionEntry { | struct PositionEntry { | ||||
SIM808ChargingStatus battery; //sizeof = 4 | SIM808ChargingStatus battery; //sizeof = 4 | ||||
float temperature; //sizeof = 4 | |||||
SIM808_GPS_STATUS status; //sizeof = 1 | SIM808_GPS_STATUS status; //sizeof = 1 | ||||
char position[POSITION_SIZE]; //sizeof = 115 | char position[POSITION_SIZE]; //sizeof = 115 | ||||
}; //sizeof = 119 | }; //sizeof = 119 | ||||
namespace positions { | namespace positions { | ||||
void appendLast(const SIM808ChargingStatus battery, const SIM808_GPS_STATUS gpsStatus); | |||||
void appendLast(const SIM808ChargingStatus battery, const SIM808_GPS_STATUS gpsStatus, const float temperature); | |||||
bool get(uint16_t index, PositionEntry &entry); | bool get(uint16_t index, PositionEntry &entry); | ||||
bool moveNext(uint16_t &index); | bool moveNext(uint16_t &index); | ||||
@@ -43,6 +43,14 @@ namespace rtc { | |||||
hardware::i2c::powerOff(); | hardware::i2c::powerOff(); | ||||
} | } | ||||
float getTemperature() { | |||||
hardware::i2c::powerOn(); | |||||
float temperature = RTC.readTempRegister(); | |||||
hardware::i2c::powerOff(); | |||||
return temperature; | |||||
} | |||||
void getTime(tmElements_t &time) { | void getTime(tmElements_t &time) { | ||||
hardware::i2c::powerOn(); | hardware::i2c::powerOn(); | ||||
RTC.readTime(); | RTC.readTime(); | ||||
@@ -6,6 +6,7 @@ | |||||
namespace rtc { | namespace rtc { | ||||
void setup(); | void setup(); | ||||
float getTemperature(); | |||||
void getTime(tmElements_t &time); | void getTime(tmElements_t &time); | ||||
void setTime(tmElements_t &time); | void setTime(tmElements_t &time); | ||||