|
| template<uint8_t N> |
| constexpr uint8_t | calibrationShift (const float(&cal)[N]) |
| | Largest shift that keeps every calibration value within 16 bits.
|
| |
| int32_t | contribution (const int32_t averagePower, const uint16_t calFixed, const uint8_t shift) |
| | Contribution of one mains cycle of one phase to the bucket.
|
| |
| constexpr int32_t | fromWatts (const int32_t watts) |
| | A power in watts, in bucket units per mains cycle.
|
| |
| constexpr uint16_t | gcd (const uint16_t a, const uint16_t b) |
| | Greatest common divisor, to reduce fractions at compile time.
|
| |
| template<uint8_t N> |
| constexpr bool | isValidCalibration (const float(&cal)[N]) |
| | Check that the calibration values can be represented.
|
| |
| template<uint8_t N> |
| constexpr float | largestOf (const float(&cal)[N]) |
| | Largest of the calibration values.
|
| |
| constexpr uint8_t | shiftFor (const float largest) |
| | Largest shift that keeps a value within 16 bits once scaled by 2^shift.
|
| |
| constexpr uint16_t | toFixed (const float cal, const uint8_t shift) |
| | A calibration value as a 16-bit fixed-point constant.
|
| |
| template<uint8_t NMin, uint8_t NMax, uint8_t SumShift = 0, uint8_t N> |
| constexpr PerSampleCalibration< NMin, NMax, N > | toFixedPerSample (const float(&cal)[N]) |
| | Build the per-sample calibration table at compile time.
|
| |
| template<uint8_t SUPPLY_FREQUENCY> |
| constexpr int32_t | toHundredthsOfJoule (const int32_t units) |
| | An energy in bucket units, in hundredths of a joule (for the datalog).
|
| |
template<uint8_t NMin, uint8_t NMax, uint8_t SumShift = 0, uint8_t N>
Build the per-sample calibration table at compile time.
Beyond 64 sample sets per cycle, sumP may exceed 24 bits: the ISR then hands over sumP >> SumShift, and the table holds cal x 2^SumShift / n to make up for it.
- Template Parameters
-
| SumShift | The shift the ISR applies to sumP before contribution() (0: none). |
- Parameters
-
| cal | The power calibration values, one per phase. |
Definition at line 119 of file energy_bucket.h.
template<uint8_t SUPPLY_FREQUENCY>
| int32_t Energy::toHundredthsOfJoule |
( |
const int32_t | units | ) |
|
|
constexpr |
An energy in bucket units, in hundredths of a joule (for the datalog).
units * 100 / (SUPPLY_FREQUENCY * 2^FRACTION_BITS), with the fraction reduced at compile time (1/8 at 50 Hz, 5/48 at 60 Hz) so that it cannot overflow, rounded half away from zero as Print::print(float) did. No float code.
- Template Parameters
-
| SUPPLY_FREQUENCY | mains frequency in Hz |
Definition at line 227 of file energy_bucket.h.