Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 12a07cf
Author: Frédéric Metrich <[email protected]>
Date:   Sun Mar 3 15:20:23 2024 +0100

    Some optimizations

commit bf73705
Author: Frédéric Metrich <[email protected]>
Date:   Sat Mar 2 13:45:14 2024 +0100

    Fix doc

commit 866f94a
Author: Frédéric Metrich <[email protected]>
Date:   Sat Mar 2 13:38:46 2024 +0100

    Refactoring temp (#84)

    * Refactoring temp

    * Fix refactoring temperature

commit af1fe84
Author: Frédéric Metrich <[email protected]>
Date:   Fri Mar 1 08:33:35 2024 +0100

    Update Readme.fr.md (#83)

    Signed-off-by: Frédéric Metrich <[email protected]>

commit c73c567
Author: Frédéric Metrich <[email protected]>
Date:   Mon Feb 26 11:11:24 2024 +0100

    Add some alias for type_trait

commit eb53c16
Author: Frédéric Metrich <[email protected]>
Date:   Mon Feb 26 11:10:55 2024 +0100

    Update color in schematic

commit eac769e
Author: Frédéric Metrich <[email protected]>
Date:   Thu Feb 15 21:29:47 2024 +0100

    Update Readme.md (#82)

commit 82d84ee
Author: Frédéric Metrich <[email protected]>
Date:   Tue Feb 13 14:37:48 2024 +0100

    Added Thermostat_tri_HC.pdf

commit fad5e19
Author: Frédéric Metrich <[email protected]>
Date:   Tue Feb 13 14:36:53 2024 +0100

    Update Thermostat_tri_HC.drawio

commit f03b4ca
Author: Frédéric Metrich <[email protected]>
Date:   Mon Feb 12 11:07:04 2024 +0100

    WIP: 1772479 Fix mvAvg

commit 5e5646a
Author: Frédéric Metrich <[email protected]>
Date:   Mon Feb 5 00:04:30 2024 +0100

    Update CodeQL

commit 4684e01
Author: Frédéric Metrich <[email protected]>
Date:   Sun Feb 4 23:35:01 2024 +0100

    Upt readme

commit d957494
Author: Frédéric Metrich <[email protected]>
Date:   Sun Feb 4 23:32:24 2024 +0100

    Try again

commit 46884f3
Author: Frédéric Metrich <[email protected]>
Date:   Sun Feb 4 23:30:21 2024 +0100

    Try fix

commit c7db21e
Author: Frédéric Metrich <[email protected]>
Date:   Sun Feb 4 23:28:09 2024 +0100

    Fix readme

commit 248a89a
Author: Frédéric Metrich <[email protected]>
Date:   Sun Feb 4 23:23:14 2024 +0100

    Reorganize readmes

commit fff68e0
Author: Frédéric Metrich <[email protected]>
Date:   Sun Feb 4 23:11:19 2024 +0100

    Fix branch name

commit 656308b
Author: Frédéric Metrich <[email protected]>
Date:   Sun Feb 4 23:10:39 2024 +0100

    Fix filenames

commit b911d8d
Author: Frédéric Metrich <[email protected]>
Date:   Sun Feb 4 23:08:55 2024 +0100

    Fix links

commit 83d5591
Author: Frédéric Metrich <[email protected]>
Date:   Sun Feb 4 23:07:18 2024 +0100

    Multilinugal readme + more details

commit 1772479
Author: Frédéric Metrich <[email protected]>
Date:   Fri Feb 2 11:39:13 2024 +0100

    Fix mvAvg

commit 90204aa
Author: Frédéric Metrich <[email protected]>
Date:   Mon Jan 22 22:02:08 2024 +0100

    Fix relay template

commit eef84ea
Author: Frédéric Metrich <[email protected]>
Date:   Mon Jan 22 16:36:28 2024 +0100

    Enhanced sliding average...
  • Loading branch information
FredM67 committed Mar 3, 2024
1 parent 769b79e commit c4b8774
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 53 deletions.
9 changes: 5 additions & 4 deletions Mk2_3phase_RFdatalog_temp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,10 @@ void loop()

if constexpr (TEMP_SENSOR_PRESENT)
{
for (uint8_t idx = 0; idx < size(tx_data.temperature_x100); ++idx)
uint8_t idx{ temperatureSensing.get_size() };
do
{
static int16_t tmp;
tmp = temperatureSensing.readTemperature(idx);
auto tmp = temperatureSensing.readTemperature(--idx);

// if read temperature is 85 and the delta with previous is greater than 5, skip the value
if (8500 == tmp && (abs(tmp - tx_data.temperature_x100[idx]) > 500))
Expand All @@ -424,7 +424,8 @@ void loop()
}

tx_data.temperature_x100[idx] = tmp;
}
} while (idx);

temperatureSensing.requestTemperatures(); // for use next time around
}

Expand Down
90 changes: 45 additions & 45 deletions Mk2_3phase_RFdatalog_temp/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ inline void printForEmonESP(const bool bOffPeak)
Serial.print(F(",L"));
Serial.print(idx + 1);
Serial.print(F(":"));
Serial.print((copyOf_countLoadON[idx] * 100) / DATALOG_PERIOD_IN_MAINS_CYCLES);
Serial.print((copyOf_countLoadON[idx] * 100) * invDATALOG_PERIOD_IN_MAINS_CYCLES);
}

if constexpr (TEMP_SENSOR_PRESENT)
{ // Current temperature
for (idx = 0; idx < size(tx_data.temperature_x100); ++idx)
for (idx = 0; idx < temperatureSensing.get_size(); ++idx)
{
if ((OUTOFRANGE_TEMPERATURE == tx_data.temperature_x100[idx])
|| (DEVICE_DISCONNECTED_RAW == tx_data.temperature_x100[idx]))
Expand All @@ -189,7 +189,7 @@ inline void printForEmonESP(const bool bOffPeak)
Serial.print(F(",T"));
Serial.print(idx + 1);
Serial.print(F(":"));
Serial.print((float)tx_data.temperature_x100[idx] / 100);
Serial.print(tx_data.temperature_x100[idx] * 0.01F);
}
}

Expand All @@ -210,7 +210,7 @@ inline void printForSerialJson()
{
uint8_t phase{ 0 };

Serial.print(copyOf_energyInBucket_main / SUPPLY_FREQUENCY);
Serial.print(copyOf_energyInBucket_main * invSUPPLY_FREQUENCY);
Serial.print(F(", P:"));
Serial.print(tx_data.power);

Expand All @@ -226,17 +226,17 @@ inline void printForSerialJson()
Serial.print(F(", V"));
Serial.print(phase + 1);
Serial.print(F(":"));
Serial.print((float)tx_data.Vrms_L_x100[phase] / 100);
Serial.print((float)tx_data.Vrms_L_x100[phase] * 0.01F);
}

if constexpr (TEMP_SENSOR_PRESENT)
{
for (uint8_t idx = 0; idx < size(tx_data.temperature_x100); ++idx)
for (uint8_t idx = 0; idx < temperatureSensing.get_size(); ++idx)
{
Serial.print(F(", T"));
Serial.print(idx + 1);
Serial.print(F(":"));
Serial.print((float)tx_data.temperature_x100[idx] / 100);
Serial.print((float)tx_data.temperature_x100[idx] * 0.01F);
}
}

Expand All @@ -251,7 +251,7 @@ inline void printForSerialText()
{
uint8_t phase{ 0 };

Serial.print(copyOf_energyInBucket_main / SUPPLY_FREQUENCY);
Serial.print(copyOf_energyInBucket_main * invSUPPLY_FREQUENCY);
Serial.print(F(", P:"));
Serial.print(tx_data.power);

Expand All @@ -273,17 +273,17 @@ inline void printForSerialText()
Serial.print(F(", V"));
Serial.print(phase + 1);
Serial.print(F(":"));
Serial.print((float)tx_data.Vrms_L_x100[phase] / 100);
Serial.print((float)tx_data.Vrms_L_x100[phase] * 0.01F);
}

if constexpr (TEMP_SENSOR_PRESENT)
{
for (uint8_t idx = 0; idx < size(tx_data.temperature_x100); ++idx)
for (uint8_t idx = 0; idx < temperatureSensing.get_size(); ++idx)
{
Serial.print(F(", T"));
Serial.print(idx + 1);
Serial.print(F(":"));
Serial.print((float)tx_data.temperature_x100[idx] / 100);
Serial.print((float)tx_data.temperature_x100[idx] * 0.01F);
}
}

Expand All @@ -301,67 +301,67 @@ inline void printForSerialText()
Serial.println(F(")"));
}

/**
/**
* @brief Prints data logs to the Serial output in text or json format
*
* @param bOffPeak true if off-peak tariff is active
*/
inline void sendResults(bool bOffPeak)
{
static bool startup{ true };
inline void sendResults(bool bOffPeak)
{
static bool startup{ true };

if (startup)
{
startup = false;
return; // reject the first datalogging which is incomplete !
}
if (startup)
{
startup = false;
return; // reject the first datalogging which is incomplete !
}

#ifdef RF_PRESENT
send_rf_data(); // *SEND RF DATA*
send_rf_data(); // *SEND RF DATA*
#endif

#if defined SERIALOUT
printForSerialJson();
printForSerialJson();
#endif // if defined SERIALOUT

if constexpr (EMONESP_CONTROL)
{
printForEmonESP(bOffPeak);
}
if constexpr (EMONESP_CONTROL)
{
printForEmonESP(bOffPeak);
}

#if defined SERIALPRINT && !defined EMONESP
printForSerialText();
printForSerialText();
#endif // if defined SERIALPRINT && !defined EMONESP
}
}

/**
/**
* @brief Prints the load priorities to the Serial output.
*
*/
inline void logLoadPriorities()
{
inline void logLoadPriorities()
{
#ifdef ENABLE_DEBUG

DBUGLN(F("Load Priorities: "));
for (const auto& loadPrioAndState : loadPrioritiesAndState)
{
DBUG(F("\tload "));
DBUGLN(loadPrioAndState);
}
DBUGLN(F("Load Priorities: "));
for (const auto& loadPrioAndState : loadPrioritiesAndState)
{
DBUG(F("\tload "));
DBUGLN(loadPrioAndState);
}

#endif
}
}

/**
/**
* @brief Get the available RAM during setup
*
* @return int The amount of free RAM
*/
inline int freeRam()
{
extern int __heap_start, *__brkval;
int v;
return (int)&v - (__brkval == 0 ? (int)&__heap_start : (int)__brkval);
}
inline int freeRam()
{
extern int __heap_start, *__brkval;
int v;
return (int)&v - (__brkval == 0 ? (int)&__heap_start : (int)__brkval);
}

#endif // _UTILS_H
2 changes: 0 additions & 2 deletions Mk2_3phase_RFdatalog_temp/utils_temp.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <Arduino.h>

#include "constants.h"
#include "config.h"

#ifdef TEMP_ENABLED
inline constexpr bool TEMP_SENSOR_PRESENT{ true }; /**< set it to 'true' if temperature sensing is needed */
Expand Down Expand Up @@ -127,7 +126,6 @@ class TemperatureSensing
{
return DEVICE_DISCONNECTED_RAW;
}

#endif

// result is temperature x16, multiply by 6.25 to convert to temperature x100
Expand Down
4 changes: 2 additions & 2 deletions dev/MathPerfTests/movingAvg.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ class movingAvg
T _sub_ar[VALUES_PER_MINUTE]{};
T _ar[DURATION_IN_MINUTES]{};

static constexpr float invD{ 1.0 / VALUES_PER_MINUTE };
static constexpr float invN{ 1.0 / DURATION_IN_MINUTES };
static constexpr float invD{ 1.0F / VALUES_PER_MINUTE };
static constexpr float invN{ 1.0F / DURATION_IN_MINUTES };
};

#endif

0 comments on commit c4b8774

Please sign in to comment.