Quellcode durchsuchen

Implemented temperature reading and logging

tags/v1.2.0
Bertrand Lemasle vor 7 Jahren
Ursprung
Commit
c0107ab80e
6 geänderte Dateien mit 20 neuen und 10 gelöschten Zeilen
  1. +1
    -1
      GpsTracker/Core.cpp
  2. +3
    -3
      GpsTracker/Debug.cpp
  3. +5
    -5
      GpsTracker/Positions.cpp
  4. +2
    -1
      GpsTracker/Positions.h
  5. +8
    -0
      GpsTracker/Rtc.cpp
  6. +1
    -0
      GpsTracker/Rtc.h

+ 1
- 1
GpsTracker/Core.cpp Datei anzeigen

@@ -20,7 +20,7 @@ namespace core {
gps::getTime(time);
rtc::setTime(time);

positions::appendLast(battery, gpsStatus);
positions::appendLast(battery, gpsStatus, rtc::getTemperature());

uint8_t velocity;
gps::getVelocity(velocity);


+ 3
- 3
GpsTracker/Debug.cpp Datei anzeigen

@@ -6,7 +6,7 @@

#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(SEPARATOR, "----");
@@ -107,7 +107,7 @@ namespace debug {

namespace details {
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();
hardware::sim808::powerOff();

positions::appendLast(status, SIM808_GPS_STATUS::OFF);
positions::appendLast(status, SIM808_GPS_STATUS::OFF, rtc::getTemperature());
}

void setRtcTime() {


+ 5
- 5
GpsTracker/Positions.cpp Datei anzeigen

@@ -19,11 +19,11 @@ namespace positions {
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");

uint16_t entryAddress;
PositionEntry entry = { battery, gpsStatus };
PositionEntry entry = { battery, temperature, gpsStatus };
strlcpy(entry.position, gps::lastPosition, POSITION_SIZE);

hardware::i2c::powerOn();
@@ -36,8 +36,8 @@ namespace positions {

entryAddress = getEntryAddress(config.lastEntry);
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);
hardware::i2c::powerOff();
@@ -53,7 +53,7 @@ namespace positions {
hardware::i2c::eeprom.readBlock(entryAddress, entry);
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;
}



+ 2
- 1
GpsTracker/Positions.h Datei anzeigen

@@ -6,12 +6,13 @@

struct PositionEntry {
SIM808ChargingStatus battery; //sizeof = 4
float temperature; //sizeof = 4
SIM808_GPS_STATUS status; //sizeof = 1
char position[POSITION_SIZE]; //sizeof = 115
}; //sizeof = 119

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 moveNext(uint16_t &index);


+ 8
- 0
GpsTracker/Rtc.cpp Datei anzeigen

@@ -43,6 +43,14 @@ namespace rtc {
hardware::i2c::powerOff();
}

float getTemperature() {
hardware::i2c::powerOn();
float temperature = RTC.readTempRegister();
hardware::i2c::powerOff();

return temperature;
}

void getTime(tmElements_t &time) {
hardware::i2c::powerOn();
RTC.readTime();


+ 1
- 0
GpsTracker/Rtc.h Datei anzeigen

@@ -6,6 +6,7 @@
namespace rtc {
void setup();

float getTemperature();
void getTime(tmElements_t &time);
void setTime(tmElements_t &time);



Laden…
Abbrechen
Speichern