69 infoln(present ? F(
"is present") : F(
"is NOT present"));
80inline void printCalibrationLine(
const __FlashStringHelper* name,
const uint8_t phase,
const int32_t* value,
81 const uint8_t decimals)
101template<
bool newBoard >
104 if constexpr (newBoard)
114 printCalibrationLine(F(
"\tf_voltageCalNewBoard"), phase, &voltageCalNewBoard_x1e6.value[phase], 6);
123 printCalibrationLine(F(
"\tf_voltageCalOldBoard"), phase, &voltageCalOldBoard_x1e6.value[phase], 6);
145#define PROJECT_PATH (__FILE__)
149#define BRANCH_NAME ("N/A")
152#define COMMIT_HASH ("N/A")
155#define BUILD_ENV ("N/A")
160 infoln(F(
"----------------------------------"));
161 info(F(
"Sketch ID: "));
164 info(F(
"From branch '"));
166 info(F(
"', commit "));
169 info(F(
"Build environment: "));
172 info(F(
"Build on "));
180 infoln(F(
"ADC mode: free-running"));
185 infoln(F(
"*** CALIBRATION MODE: no load will ever be switched ***"));
191 infoln(F(
"Electrical settings"));
197 info(F(
"\tf_phaseCal for all phases = "));
200 info(F(
"\tExport rate (Watts) = "));
203 info(F(
"\tzero-crossing persistence (sample sets) = "));
208 info(F(
"Temperature capability "));
211 info(F(
"Dual-tariff capability "));
218 info(F(
"Load rotation feature "));
225 info(F(
"Relay diversion feature "));
232 info(F(
"Override feature "));
239 info(F(
"RF capability "));
242 info(F(
"IS present, Freq = "));
250 info(F(
" Network ID: "));
252 info(F(
" Node ID: "));
257 info(F(
" Data logging to Gateway ID: "));
263 info(F(
" Remote loads to Node ID: "));
277 info(F(
"Datalogging capability "));
280 infoln(F(
"in Human-readable format"));
284 infoln(F(
"in IoT format"));
288 infoln(F(
"in JSON format"));
318 out.print(F(
"{\"P\":"));
323 out.print(F(
",\"R\":"));
332 out.print(F(
",\"P"));
335 out.print(
tx_data.power_L[step]);
346 out.print(F(
",\"T"));
360 out.print(
datalogOffPeak ? F(
",\"TA\":\"low\"") : F(
",\"TA\":\"high\""));
393 out.print(F(
", P:"));
410 out.print(
tx_data.power_L[step]);
444 out.print(F(
", (minSampleSets/MC "));
448 out.print(F(
", #ofSampleSets "));
454 out.print(F(
", NoED "));
487 static_assert(
RELAY_COUNT <= 16,
"the relay states are kept in 16 bits");
499 uint16_t states{ 0 };
522 return tx_data.Vrms_L_x100[idx];
542 return tx_data.temperature_x100[idx];
578 out.write(text, length);
604 static bool startup{
true };
683 extern int __heap_start, *__brkval;
685 return (
int)&v - (__brkval == 0 ? (int)&__heap_start : (int)__brkval);
constexpr float f_ctRating[NO_OF_PHASES]
constexpr float f_phaseCal
constexpr float f_powerCalPerAmp[NO_OF_PHASES]
constexpr float f_powerCalOldBoard[NO_OF_PHASES]
constexpr float f_voltageCalOldBoard[NO_OF_PHASES]
constexpr float f_voltageCalNewBoard[NO_OF_PHASES]
constexpr bool RELAY_DIVERSION
constexpr bool OVERRIDE_PIN_PRESENT
constexpr PcbVersion PCB_VERSION
constexpr bool RF_LOGGING_PRESENT
constexpr bool DUAL_TARIFF
constexpr bool CALIBRATION_MODE
constexpr SerialOutputType SERIAL_OUTPUT_TYPE
constexpr uint8_t NO_OF_DUMPLOADS
constexpr bool TEMP_SENSOR_PRESENT
The configuration as the firmware uses it: the settings, and what is built from them.
constexpr Rotation::Table rotationTable
The priority places each rotation group rotates in.
constexpr bool REMOTE_LOADS_PRESENT
constexpr uint8_t NO_OF_REMOTE_UNITS
constexpr RelayDiverter relayDiverter
constexpr TempSensors tempSensors
constexpr OverrideTable overrideTable
constexpr int16_t REQUIRED_EXPORT_IN_WATTS
constexpr conditional< DATALOG_PERIOD_IN_SECONDS *SUPPLY_FREQUENCY >=UINT8_MAX, uint16_t, uint8_t >::type DATALOG_PERIOD_IN_MAINS_CYCLES
constexpr uint8_t NO_OF_PHASES
void infoln(const Args &... args)
Print an informational message and a line end, as Serial.println() does.
void infolnDecimals_P(const int32_t *value, const uint8_t decimals)
Same as infolnDecimals(), with the value read from PROGMEM.
void statusln(const Args &... args)
Print a status message and a line end, as Serial.println() does (human-readable output only).
void info(const Args &... args)
Print an informational message, as Serial.print() does.
void status(const Args &... args)
Print a status message, as Serial.print() does (human-readable output only).
void infolnDecimals(const int32_t value, const uint8_t decimals)
Print a value given as an integer with a fixed number of decimals, and a line end.
constexpr bool isValidTemperature(int16_t temperature_x100)
Whether a temperature reading is valid, and so worth sending.
The scheduled boosts of the dual tariff, resolved at compile time.
constexpr BoostTable boostTable PROGMEM
Integer arithmetic of the energy bucket.
void printDualTariffConfiguration()
Print the settings for off-peak period.
void sendResults(bool bOffPeak)
Prints or sends telemetry data logs based on the selected output format.
void logLoadPriorities()
Prints the load priorities to the Serial output.
void printParamsForSelectedOutputMode()
Print the settings used for the selected output mode.
void printConfiguration()
Print the configuration during startup.
int freeRam()
Get the available RAM during setup.
void printRotationGroups()
Prints the rotation groups, as load numbers counted from 0 as in LOAD(n): "\tgroups { 0 1 2 }...
bool printJsonStep(Print &out, uint8_t step)
One step of the datalog in JSON format.
bool printTextStep(Print &out, uint8_t step)
One step of the datalog in text format.
bool writeTeleInfoStep(Print &out, uint8_t step)
One step of the telemetry frame, in IoT format: one line (see TeleInfo::writeFrameStep()).
constexpr int32_t toHundredthsOfJoule(const int32_t units)
An energy in bucket units, in hundredths of a joule (for the datalog).
constexpr uint8_t FREQUENCY
constexpr uint8_t ROUTER_NODE_ID
constexpr uint8_t REMOTE_NODE_ID[]
Node ID of each remote load unit, unit 1 first (only if REMOTE_LOADS_PRESENT=true)
constexpr uint8_t NETWORK_ID
constexpr uint8_t GATEWAY_ID
void printHundredths(Print &out, int16_t value_x100)
Print a value given in hundredths, in its shortest decimal form.
constexpr int32_t toDecimals(float value, uint8_t decimals)
A float constant as an integer with the given number of decimals, rounded.
constexpr uint8_t MAX_STEP_LENGTH
bool start(Step step)
Start an output, written by later calls to poll()
bool busy()
Whether an output is still in progress.
void printDecimals(Print &out, int32_t value, uint8_t decimals)
Print a value given as an integer with a fixed number of decimals (see toDecimals())
volatile uint16_t copyOf_sampleSetsDuringThisDatalogPeriod
volatile int32_t copyOf_energyInBucket_main
volatile uint8_t copyOf_lowestNoOfSampleSetsPerMainsCycle
volatile uint16_t copyOf_countLoadON[NO_OF_DUMPLOADS]
volatile uint16_t absenceOfDivertedEnergyCountInSeconds
bool writeFrameStep(const uint8_t step, char *const text, uint8_t &length)
Writes a step of the frame: one line, STX before the first one, ETX after the last.
constexpr uint8_t MAX_STEP_LENGTH
The most a step writes: STX or ETX, and the longest line, a 4-character tag ("S_MC") with a signed 16...
Public functions/variables of processing engine.
constexpr uint8_t PERSISTENCE_FOR_POLARITY_CHANGE
uint8_t loadPrioritiesAndState[NO_OF_DUMPLOADS]
PayloadTx_struct< NO_OF_PHASES, TEMP_SENSOR_PRESENT ? tempSensors.size() :0 > tx_data
Non-blocking serial output of the datalog.
The data of the IoT frame, for TeleInfo::writeFrameStep().
static constexpr uint8_t RELAY_COUNT
static constexpr bool RELAY_DIVERSION
static int16_t relayAverage()
static constexpr uint8_t TEMP_COUNT
static bool relayOn(uint8_t idx)
static uint16_t phaseVoltage(uint8_t idx)
static bool temperatureValid(uint8_t idx)
static int16_t temperature(uint8_t idx)
static int16_t loadOnPercent(uint8_t idx)
static uint16_t absenceCount()
static int16_t phasePower(uint8_t idx)
static uint8_t lowestSampleSetsPerCycle()
static constexpr uint8_t PHASE_COUNT
static uint16_t sampleSets()
static constexpr bool DUAL_TARIFF
static uint16_t absenceCountAtDatalog
static uint16_t relayStatesAtDatalog
static void snapshot()
Takes the values that change during the frame (the tariff is in datalogOffPeak).
static constexpr uint8_t LOAD_COUNT
The telemetry frame of the IoT output, written a line at a time.
void printCalibration(const uint8_t phase)
Print the calibration of a phase as calibration.h has it.
void printCalibrationLine(const __FlashStringHelper *name, const uint8_t phase, const int32_t *value, const uint8_t decimals)
Print one calibration line: "<name> for L<phase> = <value>".
void infolnPresence(const bool present)
Print "is present" or "is NOT present", and a line end.
RF module support for RFM69.
constexpr bool RF_CHIP_PRESENT
bool initialize_rf()
Initialize the shared RF module.
void send_rf_data(const PayloadType &data)
Send RF data to gateway.
Provides utilities for managing temperature sensors.