From d1a37a60b7f83e981d7121d78f9dde80f3b3eb04 Mon Sep 17 00:00:00 2001 From: Holger Steinhaus Date: Tue, 5 Dec 2017 10:54:11 +0100 Subject: [PATCH] DataFlash: log consumed energy (Wh) --- libraries/DataFlash/LogFile.cpp | 1 + libraries/DataFlash/LogStructure.h | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libraries/DataFlash/LogFile.cpp b/libraries/DataFlash/LogFile.cpp index 054010dce5..94006df856 100644 --- a/libraries/DataFlash/LogFile.cpp +++ b/libraries/DataFlash/LogFile.cpp @@ -1562,6 +1562,7 @@ void DataFlash_Class::Log_Write_Current_instance(const uint64_t time_us, voltage_resting : battery.voltage_resting_estimate(battery_instance), current_amps : battery.current_amps(battery_instance), current_total : battery.current_total_mah(battery_instance), + consumed_wh : battery.consumed_wh(battery_instance), temperature : (int16_t)(has_temp ? (temp * 100) : 0), resistance : battery.get_resistance(battery_instance) }; diff --git a/libraries/DataFlash/LogStructure.h b/libraries/DataFlash/LogStructure.h index 6e6d0a7418..0a8031ea5f 100644 --- a/libraries/DataFlash/LogStructure.h +++ b/libraries/DataFlash/LogStructure.h @@ -84,6 +84,7 @@ const struct UnitStructure log_Units[] = { { 'G', "Gauss" }, // Gauss is not an SI unit, but 1 tesla = 10000 gauss so a simple replacement is not possible here { 'h', "degheading" }, // 0.? to 359.? { 'i', "A.s" }, // Ampere second + { 'J', "W.s" }, // Joule (Watt second) // { 'l', "l" }, // litres { 'L', "rad/s/s" }, // radians per second per second { 'm', "m" }, // metres @@ -126,6 +127,7 @@ const struct MultiplierStructure log_Multipliers[] = { { 'G', 1e-7 }, // { '!', 3.6 }, // (ampere*second => milliampere*hour) and (km/h => m/s) + { '/', 3600 }, // (ampere*second => ampere*hour) }; struct PACKED log_Parameter { @@ -666,6 +668,7 @@ struct PACKED log_Current { float voltage_resting; float current_amps; float current_total; + float consumed_wh; int16_t temperature; // degrees C * 100 float resistance; }; @@ -1110,10 +1113,10 @@ struct PACKED log_DSTL { #define QUAT_UNITS "s????" #define QUAT_MULTS "F????" -#define CURR_LABELS "TimeUS,Volt,VoltR,Curr,CurrTot,Temp,Res" -#define CURR_FMT "Qffffcf" -#define CURR_UNITS "sv?A?Ow" -#define CURR_MULTS "F??????" +#define CURR_LABELS "TimeUS,Volt,VoltR,Curr,CurrTot,EnrgTot,Temp,Res" +#define CURR_FMT "Qfffffcf" +#define CURR_UNITS "sv?A?JOw" +#define CURR_MULTS "F????/??" #define CURR_CELL_LABELS "TimeUS,Volt,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10" #define CURR_CELL_FMT "QfHHHHHHHHHH"