Skip to content

Commit

Permalink
More dev...
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieucarbou committed Jun 11, 2024
1 parent fdd307d commit 0b4a016
Show file tree
Hide file tree
Showing 24 changed files with 369 additions and 274 deletions.
60 changes: 39 additions & 21 deletions lib/MycilaDimmer/MycilaDimmer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// #include "MycilaDimmerV2_100_LUT.h"
// #include "MycilaDimmerV2_255_LUT.h"
// #include "MycilaDimmerV3.h"
#include "MycilaDimmerV3_100_LUT.h"
// #include "MycilaDimmerV3_255_LUT.h"
// #include "MycilaDimmerV3_100_LUT.h"
#include "MycilaDimmerV3_255_LUT.h"

#define TAG "DIMMER"

Expand All @@ -22,21 +22,27 @@
#define SQRT_2 1.4142135623730950488

#ifndef GPIO_IS_VALID_OUTPUT_GPIO
#define GPIO_IS_VALID_OUTPUT_GPIO(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_OUTPUT_GPIO_MASK) != 0))
#define GPIO_IS_VALID_OUTPUT_GPIO(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_OUTPUT_GPIO_MASK) != 0))
#endif

#ifndef GPIO_IS_VALID_GPIO
#define GPIO_IS_VALID_GPIO(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_GPIO_MASK) != 0))
#define GPIO_IS_VALID_GPIO(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_GPIO_MASK) != 0))
#endif

extern Mycila::Logger logger;

void Mycila::Dimmer::begin(const int8_t pin) {
void Mycila::Dimmer::begin(const int8_t pin, const uint8_t frequency) {
if (_enabled)
return;

if (!frequency) {
logger.error(TAG, "Disable Dimmer: Frequency not set");
return;
}
_frequency = frequency;

if (GPIO_IS_VALID_OUTPUT_GPIO(pin)) {
_pin = (gpio_num_t)pin;
} else {
Expand All @@ -60,6 +66,7 @@ void Mycila::Dimmer::end() {
logger.info(TAG, "Disable Dimmer on pin %" PRId8, _pin);
_enabled = false;
_level = 0;
_vrms = 0;
_dimmer->turnOff();
delete _dimmer;
_dimmer = nullptr;
Expand All @@ -70,43 +77,54 @@ void Mycila::Dimmer::end() {

void Mycila::Dimmer::toJson(const JsonObject& root) const {
const float angle = getPhaseAngle();
const float vrmsF = _lookupVrmsFactor(_level, Thyristor::getFrequency());
root["angle_deg"] = static_cast<uint8_t>(angle * RAD_TO_DEG);
root["angle_rad"] = angle;
root["delay"] = _dimmer->getDelay();
root["enabled"] = _enabled;
root["level"] = _level;
root["state"] = _level > 0 ? "on" : "off";
root["vrms_factor"] = vrmsF;
root["vrms_230V"] = vrmsF * 230;
root["vrms"] = _vrms;
root["vrms_230V"] = _vrms * 230;
}

void Mycila::Dimmer::setLevel(uint16_t newLevel) {
if (!_enabled)
return;

// ensure newLevel is within bounds
if (newLevel > MYCILA_DIMMER_MAX_LEVEL)
newLevel = MYCILA_DIMMER_MAX_LEVEL;

// nothing to do ?
if (_level == newLevel)
return;

// save old level
const uint16_t oldLevel = _level;
_level = newLevel;

uint16_t lutLevel = map(newLevel, 0, MYCILA_DIMMER_MAX_LEVEL, 0, MYCILA_DIMMER_LUT_SIZE);
_dimmer->setDelay(_lookupFiringDelay(lutLevel, Thyristor::getFrequency()));
// map new level to firing delay
const uint8_t lutLevel = map(newLevel, 0, MYCILA_DIMMER_MAX_LEVEL, 0, MYCILA_DIMMER_LUT_MAX_LEVEL);
uint16_t vrms = _lookupVrms(lutLevel, _frequency);
uint16_t delay = _lookupFiringDelay(lutLevel, _frequency);

if (MYCILA_DIMMER_MAX_LEVEL != MYCILA_DIMMER_LUT_MAX_LEVEL && lutLevel < MYCILA_DIMMER_LUT_MAX_LEVEL) {
const uint16_t prevLevel = map(lutLevel, 0, MYCILA_DIMMER_LUT_MAX_LEVEL, 0, MYCILA_DIMMER_MAX_LEVEL);
if (newLevel != prevLevel) {
const uint16_t nextLevel = map(lutLevel + 1, 0, MYCILA_DIMMER_LUT_MAX_LEVEL, 0, MYCILA_DIMMER_MAX_LEVEL);
vrms = map(newLevel, prevLevel, nextLevel, vrms, _lookupVrms(lutLevel + 1, _frequency));
delay = map(newLevel, prevLevel, nextLevel, delay, _lookupFiringDelay(lutLevel + 1, _frequency));
}
}

// set new level
_level = newLevel;
_vrms = vrms;
_dimmer->setDelay(delay);

if (_callback && (oldLevel == 0 || oldLevel == MYCILA_DIMMER_MAX_LEVEL || newLevel == 0 || newLevel == MYCILA_DIMMER_MAX_LEVEL))
_callback(newLevel == 0 ? DimmerLevel::OFF : (newLevel == MYCILA_DIMMER_MAX_LEVEL ? DimmerLevel::FULL : DimmerLevel::DIM));
}

float Mycila::Dimmer::getPhaseAngle() const { return _delayToPhaseAngle(_dimmer->getDelay(), Thyristor::getFrequency()); }

float Mycila::Dimmer::getDimmedVoltage(float inputVrms) const {
return _level == 0 ? 0 : (_level == MYCILA_DIMMER_MAX_LEVEL ? inputVrms : inputVrms * _lookupVrmsFactor(_level, Thyristor::getFrequency()));
}

void Mycila::Dimmer::generateLUT(Print& out, size_t lutSize) {
out.print("static const uint16_t delay50HzLUT[] PROGMEM = {");
for (size_t i = 0; i <= lutSize; i++)
Expand All @@ -116,10 +134,10 @@ void Mycila::Dimmer::generateLUT(Print& out, size_t lutSize) {
out.printf("%" PRIu16 "%s", _lookupFiringDelay(i, 60), i < lutSize ? "," : "};\n");
out.print("static const float vrms50HzLUT[] PROGMEM = {");
for (size_t i = 0; i <= lutSize; i++)
out.printf("%f%s", _lookupVrmsFactor(i, 50), i < lutSize ? "," : "};\n");
out.printf("%f%s", _lookupVrms(i, 50), i < lutSize ? "," : "};\n");
out.print("static const float vrms60HzLUT[] PROGMEM = {");
for (size_t i = 0; i <= lutSize; i++)
out.printf("%f%s", _lookupVrmsFactor(i, 60), i < lutSize ? "," : "};\n");
out.printf("%f%s", _lookupVrms(i, 60), i < lutSize ? "," : "};\n");
}

float Mycila::Dimmer::_delayToPhaseAngle(uint16_t delay, float frequency) {
Expand Down
19 changes: 10 additions & 9 deletions lib/MycilaDimmer/MycilaDimmer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Some LUT Graphs and stats:
- https://docs.google.com/spreadsheets/d/1dCpAydu3WHekbXEdUZt53acCa6aSjtCBxW6lvv89Ku0/edit?usp=sharing
- https://www.desmos.com/calculator/llwqitrjck
* LUT Generation can be done using the `generateLUT` method
References:
Expand Down Expand Up @@ -46,7 +46,7 @@ namespace Mycila {
public:
~Dimmer() { end(); }

void begin(const int8_t pin);
void begin(const int8_t pin, const uint8_t frequency);
void end();

void listen(DimmerLevelCallback callback) { _callback = callback; }
Expand Down Expand Up @@ -77,20 +77,21 @@ namespace Mycila {
// Returns the dimmer phase angle in radians from 0 - PI.
// At 0% power, the phase angle is equal to PI
// At 100% power, the phase angle is equal to 0
float getPhaseAngle() const;
float getPhaseAngle() const { return _delayToPhaseAngle(_dimmer->getDelay(), _frequency); }

// Returns the dimmed RMS voltage based on the current phase angle.
// This is a theoretical value. In reality, the real Vrms value will be more or less depending on the hardware and software speed.
float getDimmedVoltage(float inputVrms) const;
// Returns the dimmed RMS voltage based on the current phase angle bewteen 0 and 1 to be multiplied with the voltage
float getVrms() const { return _vrms; }

static void generateLUT(Print& out, size_t lutSize); // NOLINT

private:
bool _enabled = false;
uint16_t _level = 0;
gpio_num_t _pin = GPIO_NUM_NC;
uint8_t _frequency;
bool _enabled = false;
DimmerLevelCallback _callback = nullptr;
Thyristor* _dimmer = nullptr;
uint16_t _level = 0;
float _vrms = 0;

private:
static float _delayToPhaseAngle(uint16_t delay, float frequency);
Expand All @@ -101,6 +102,6 @@ namespace Mycila {
// Can be implemented using algorithm or LUT table
static uint16_t _lookupFiringDelay(uint8_t level, float frequency);
// Can be implemented using algorithm or LUT table
static float _lookupVrmsFactor(uint8_t level, float frequency);
static float _lookupVrms(uint8_t level, float frequency);
};
} // namespace Mycila
4 changes: 2 additions & 2 deletions lib/MycilaDimmer/MycilaDimmerV1.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "MycilaDimmer.h"
#include <Arduino.h>

#define MYCILA_DIMMER_LUT_SIZE MYCILA_DIMMER_MAX_LEVEL
#define MYCILA_DIMMER_LUT_MAX_LEVEL MYCILA_DIMMER_MAX_LEVEL

namespace Mycila {
namespace DimmerInternal {
Expand All @@ -28,7 +28,7 @@ uint16_t Mycila::Dimmer::_lookupFiringDelay(uint8_t level, float frequency) {
return Mycila::Dimmer::_phaseAngleToDelay(Mycila::DimmerInternal::computeAngle(level), frequency);
}

float Mycila::Dimmer::_lookupVrmsFactor(uint8_t level, float frequency) {
float Mycila::Dimmer::_lookupVrms(uint8_t level, float frequency) {
if (level == 0)
return 0;

Expand Down
8 changes: 4 additions & 4 deletions lib/MycilaDimmer/MycilaDimmerV1_100_LUT.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "MycilaDimmer.h"
#include <Arduino.h>

#define MYCILA_DIMMER_LUT_SIZE 100
#define MYCILA_DIMMER_LUT_MAX_LEVEL 100

namespace Mycila {
namespace DimmerInternal {
Expand All @@ -22,17 +22,17 @@ uint16_t Mycila::Dimmer::_lookupFiringDelay(uint8_t level, float frequency) {
if (level == 0)
return 500000 / frequency; // semi-period in microseconds

if (level >= MYCILA_DIMMER_LUT_SIZE)
if (level >= MYCILA_DIMMER_LUT_MAX_LEVEL)
return 0;

return frequency == 60 ? (uint16_t)pgm_read_word(&Mycila::DimmerInternal::delay60HzLUT[level]) : (uint16_t)pgm_read_word(&Mycila::DimmerInternal::delay50HzLUT[level]);
}

float Mycila::Dimmer::_lookupVrmsFactor(uint8_t level, float frequency) {
float Mycila::Dimmer::_lookupVrms(uint8_t level, float frequency) {
if (level == 0)
return 0;

if (level >= MYCILA_DIMMER_LUT_SIZE)
if (level >= MYCILA_DIMMER_LUT_MAX_LEVEL)
return 1;

return frequency == 60 ? static_cast<float>(pgm_read_float(&Mycila::DimmerInternal::vrms60HzLUT[level])) : static_cast<float>(pgm_read_float(&Mycila::DimmerInternal::vrms50HzLUT[level]));
Expand Down
8 changes: 4 additions & 4 deletions lib/MycilaDimmer/MycilaDimmerV1_255_LUT.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "MycilaDimmer.h"
#include <Arduino.h>

#define MYCILA_DIMMER_LUT_SIZE 255
#define MYCILA_DIMMER_LUT_MAX_LEVEL 255

namespace Mycila {
namespace DimmerInternal {
Expand All @@ -22,17 +22,17 @@ uint16_t Mycila::Dimmer::_lookupFiringDelay(uint8_t level, float frequency) {
if (level == 0)
return 500000 / frequency; // semi-period in microseconds

if (level >= MYCILA_DIMMER_LUT_SIZE)
if (level >= MYCILA_DIMMER_LUT_MAX_LEVEL)
return 0;

return frequency == 60 ? (uint16_t)pgm_read_word(&Mycila::DimmerInternal::delay60HzLUT[level]) : (uint16_t)pgm_read_word(&Mycila::DimmerInternal::delay50HzLUT[level]);
}

float Mycila::Dimmer::_lookupVrmsFactor(uint8_t level, float frequency) {
float Mycila::Dimmer::_lookupVrms(uint8_t level, float frequency) {
if (level == 0)
return 0;

if (level >= MYCILA_DIMMER_LUT_SIZE)
if (level >= MYCILA_DIMMER_LUT_MAX_LEVEL)
return 1;

return frequency == 60 ? static_cast<float>(pgm_read_float(&Mycila::DimmerInternal::vrms60HzLUT[level])) : static_cast<float>(pgm_read_float(&Mycila::DimmerInternal::vrms50HzLUT[level]));
Expand Down
4 changes: 2 additions & 2 deletions lib/MycilaDimmer/MycilaDimmerV2.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "MycilaDimmer.h"
#include <Arduino.h>

#define MYCILA_DIMMER_LUT_SIZE MYCILA_DIMMER_MAX_LEVEL
#define MYCILA_DIMMER_LUT_MAX_LEVEL MYCILA_DIMMER_MAX_LEVEL

// level : | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9| 10| 11| 12| 13| 14| 15| 16| 17| 18| 19| 20| 21| 22| 23| 24| 25| 26| 27| 28| 29| 30| 31| 32| 33| 34| 35| 36| 37| 38| 39| 40| 41| 42| 43| 44| 45| 46| 47| 48| 49| 50| 51| 52| 53| 54| 55| 56| 57| 58| 59| 60| 61| 62| 63| 64| 65| 66| 67| 68| 69| 70| 71| 72| 73| 74| 75| 76| 77| 78| 79| 80| 81| 82| 83| 84| 85| 86| 87| 88| 89| 90| 91| 92| 93| 94| 95| 96| 97| 98| 99| 100| 101| 102| 103| 104| 105| 106| 107| 108| 109| 110| 111| 112| 113| 114| 115| 116| 117| 118| 119| 120| 121| 122| 123| 124| 125| 126| 127| 128| 129| 130| 131| 132| 133| 134| 135| 136| 137| 138| 139| 140| 141| 142| 143| 144| 145| 146| 147| 148| 149| 150| 151| 152| 153| 154| 155| 156| 157| 158| 159| 160| 161| 162| 163| 164| 165| 166| 167| 168| 169| 170| 171| 172| 173| 174| 175| 176| 177| 178| 179| 180| 181| 182| 183| 184| 185| 186| 187| 188| 189| 190| 191| 192| 193| 194| 195| 196| 197| 198| 199| 200| 201| 202| 203| 204| 205| 206| 207| 208| 209| 210| 211| 212| 213| 214| 215| 216| 217| 218| 219| 220| 221| 222| 223| 224| 225| 226| 227| 228| 229| 230| 231| 232| 233| 234| 235| 236| 237| 238| 239| 240| 241| 242| 243| 244| 245| 246| 247| 248| 249| 250| 251| 252| 253| 254| 255|
// dimmable_light : |10000| 9961| 9922| 9883| 9844| 9804| 9765| 9726| 9687| 9648| 9608| 9569| 9530| 9491| 9451| 9412| 9373| 9334| 9295| 9255| 9216| 9177| 9138| 9099| 9059| 9020| 8981| 8942| 8902| 8863| 8824| 8785| 8746| 8706| 8667| 8628| 8589| 8550| 8510| 8471| 8432| 8393| 8353| 8314| 8275| 8236| 8197| 8157| 8118| 8079| 8040| 8000| 7961| 7922| 7883| 7844| 7804| 7765| 7726| 7687| 7648| 7608| 7569| 7530| 7491| 7451| 7412| 7373| 7334| 7295| 7255| 7216| 7177| 7138| 7099| 7059| 7020| 6981| 6942| 6902| 6863| 6824| 6785| 6746| 6706| 6667| 6628| 6589| 6550| 6510| 6471| 6432| 6393| 6353| 6314| 6275| 6236| 6197| 6157| 6118| 6079| 6040| 6000| 5961| 5922| 5883| 5844| 5804| 5765| 5726| 5687| 5648| 5608| 5569| 5530| 5491| 5451| 5412| 5373| 5334| 5295| 5255| 5216| 5177| 5138| 5099| 5059| 5020| 4981| 4942| 4902| 4863| 4824| 4785| 4746| 4706| 4667| 4628| 4589| 4550| 4510| 4471| 4432| 4393| 4353| 4314| 4275| 4236| 4197| 4157| 4118| 4079| 4040| 4000| 3961| 3922| 3883| 3844| 3804| 3765| 3726| 3687| 3648| 3608| 3569| 3530| 3491| 3451| 3412| 3373| 3334| 3295| 3255| 3216| 3177| 3138| 3099| 3059| 3020| 2981| 2942| 2902| 2863| 2824| 2785| 2746| 2706| 2667| 2628| 2589| 2550| 2510| 2471| 2432| 2393| 2353| 2314| 2275| 2236| 2197| 2157| 2118| 2079| 2040| 2000| 1961| 1922| 1883| 1844| 1804| 1765| 1726| 1687| 1648| 1608| 1569| 1530| 1491| 1451| 1412| 1373| 1334| 1295| 1255| 1216| 1177| 1138| 1099| 1059| 1020| 981| 942| 902| 863| 824| 785| 746| 706| 667| 628| 589| 550| 510| 471| 432| 393| 353| 314| 275| 236| 197| 157| 118| 79| 40| 0|
Expand All @@ -29,7 +29,7 @@ uint16_t Mycila::Dimmer::_lookupFiringDelay(uint8_t level, float frequency) {
return semiPeriod - (uint16_t)(((uint32_t)level * semiPeriod) / MYCILA_DIMMER_MAX_LEVEL);
}

float Mycila::Dimmer::_lookupVrmsFactor(uint8_t level, float frequency) {
float Mycila::Dimmer::_lookupVrms(uint8_t level, float frequency) {
if (level == 0)
return 0;

Expand Down
8 changes: 4 additions & 4 deletions lib/MycilaDimmer/MycilaDimmerV2_100_LUT.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "MycilaDimmer.h"
#include <Arduino.h>

#define MYCILA_DIMMER_LUT_SIZE 100
#define MYCILA_DIMMER_LUT_MAX_LEVEL 100

namespace Mycila {
namespace DimmerInternal {
Expand All @@ -22,17 +22,17 @@ uint16_t Mycila::Dimmer::_lookupFiringDelay(uint8_t level, float frequency) {
if (level == 0)
return 500000 / frequency; // semi-period in microseconds

if (level >= MYCILA_DIMMER_LUT_SIZE)
if (level >= MYCILA_DIMMER_LUT_MAX_LEVEL)
return 0;

return frequency == 60 ? (uint16_t)pgm_read_word(&Mycila::DimmerInternal::delay60HzLUT[level]) : (uint16_t)pgm_read_word(&Mycila::DimmerInternal::delay50HzLUT[level]);
}

float Mycila::Dimmer::_lookupVrmsFactor(uint8_t level, float frequency) {
float Mycila::Dimmer::_lookupVrms(uint8_t level, float frequency) {
if (level == 0)
return 0;

if (level >= MYCILA_DIMMER_LUT_SIZE)
if (level >= MYCILA_DIMMER_LUT_MAX_LEVEL)
return 1;

return frequency == 60 ? static_cast<float>(pgm_read_float(&Mycila::DimmerInternal::vrms60HzLUT[level])) : static_cast<float>(pgm_read_float(&Mycila::DimmerInternal::vrms50HzLUT[level]));
Expand Down
4 changes: 2 additions & 2 deletions lib/MycilaDimmer/MycilaDimmerV2_255_LUT.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "MycilaDimmer.h"
#include <Arduino.h>

#define MYCILA_DIMMER_LUT_SIZE 255
#define MYCILA_DIMMER_LUT_MAX_LEVEL 255

namespace Mycila {
namespace DimmerInternal {
Expand All @@ -28,7 +28,7 @@ uint16_t Mycila::Dimmer::_lookupFiringDelay(uint8_t level, float frequency) {
return frequency == 60 ? (uint16_t)pgm_read_word(&Mycila::DimmerInternal::delay60HzLUT[level]) : (uint16_t)pgm_read_word(&Mycila::DimmerInternal::delay50HzLUT[level]);
}

float Mycila::Dimmer::_lookupVrmsFactor(uint8_t level, float frequency) {
float Mycila::Dimmer::_lookupVrms(uint8_t level, float frequency) {
if (level == 0)
return 0;

Expand Down
4 changes: 2 additions & 2 deletions lib/MycilaDimmer/MycilaDimmerV3.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "MycilaDimmer.h"
#include <Arduino.h>

#define MYCILA_DIMMER_LUT_SIZE MYCILA_DIMMER_MAX_LEVEL
#define MYCILA_DIMMER_LUT_MAX_LEVEL MYCILA_DIMMER_MAX_LEVEL

// level : | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9| 10| 11| 12| 13| 14| 15| 16| 17| 18| 19| 20| 21| 22| 23| 24| 25| 26| 27| 28| 29| 30| 31| 32| 33| 34| 35| 36| 37| 38| 39| 40| 41| 42| 43| 44| 45| 46| 47| 48| 49| 50| 51| 52| 53| 54| 55| 56| 57| 58| 59| 60| 61| 62| 63| 64| 65| 66| 67| 68| 69| 70| 71| 72| 73| 74| 75| 76| 77| 78| 79| 80| 81| 82| 83| 84| 85| 86| 87| 88| 89| 90| 91| 92| 93| 94| 95| 96| 97| 98| 99| 100| 101| 102| 103| 104| 105| 106| 107| 108| 109| 110| 111| 112| 113| 114| 115| 116| 117| 118| 119| 120| 121| 122| 123| 124| 125| 126| 127| 128| 129| 130| 131| 132| 133| 134| 135| 136| 137| 138| 139| 140| 141| 142| 143| 144| 145| 146| 147| 148| 149| 150| 151| 152| 153| 154| 155| 156| 157| 158| 159| 160| 161| 162| 163| 164| 165| 166| 167| 168| 169| 170| 171| 172| 173| 174| 175| 176| 177| 178| 179| 180| 181| 182| 183| 184| 185| 186| 187| 188| 189| 190| 191| 192| 193| 194| 195| 196| 197| 198| 199| 200| 201| 202| 203| 204| 205| 206| 207| 208| 209| 210| 211| 212| 213| 214| 215| 216| 217| 218| 219| 220| 221| 222| 223| 224| 225| 226| 227| 228| 229| 230| 231| 232| 233| 234| 235| 236| 237| 238| 239| 240| 241| 242| 243| 244| 245| 246| 247| 248| 249| 250| 251| 252| 253| 254| 255|
// dimmable_light_linearized: | 9984| 9837| 9695| 9557| 9425| 9297| 9173| 9054| 8939| 8827| 8720| 8617| 8517| 8421| 8329| 8240| 8154| 8071| 7992| 7915| 7841| 7770| 7702| 7636| 7573| 7512| 7454| 7397| 7343| 7291| 7241| 7193| 7147| 7102| 7060| 7018| 6979| 6941| 6904| 6869| 6834| 6802| 6770| 6739| 6710| 6681| 6654| 6627| 6601| 6576| 6552| 6529| 6506| 6484| 6462| 6441| 6420| 6400| 6380| 6361| 6342| 6323| 6305| 6287| 6269| 6251| 6234| 6216| 6199| 6182| 6165| 6148| 6131| 6114| 6097| 6080| 6063| 6046| 6029| 6012| 5995| 5977| 5960| 5942| 5925| 5907| 5889| 5870| 5852| 5834| 5815| 5796| 5777| 5758| 5738| 5719| 5699| 5679| 5659| 5639| 5618| 5597| 5576| 5555| 5534| 5513| 5491| 5469| 5447| 5425| 5403| 5381| 5358| 5336| 5313| 5290| 5267| 5244| 5221| 5198| 5175| 5151| 5128| 5104| 5081| 5057| 5034| 5010| 4987| 4963| 4940| 4916| 4893| 4869| 4846| 4822| 4799| 4776| 4753| 4730| 4707| 4684| 4661| 4638| 4616| 4594| 4571| 4549| 4527| 4506| 4484| 4463| 4441| 4420| 4399| 4379| 4358| 4338| 4318| 4298| 4278| 4258| 4239| 4219| 4200| 4181| 4163| 4144| 4126| 4108| 4090| 4072| 4054| 4036| 4019| 4001| 3984| 3967| 3950| 3933| 3916| 3899| 3882| 3865| 3848| 3831| 3814| 3796| 3779| 3762| 3744| 3726| 3709| 3690| 3672| 3653| 3634| 3615| 3595| 3575| 3554| 3533| 3511| 3489| 3466| 3442| 3418| 3393| 3367| 3341| 3313| 3284| 3255| 3224| 3193| 3160| 3126| 3090| 3053| 3015| 2975| 2934| 2891| 2847| 2800| 2752| 2702| 2650| 2596| 2540| 2481| 2420| 2357| 2291| 2223| 2152| 2078| 2001| 1921| 1839| 1753| 1664| 1571| 1475| 1375| 1272| 1165| 1053| 938| 819| 695| 567| 434| 297| 154| 7|
Expand All @@ -33,7 +33,7 @@ uint16_t Mycila::Dimmer::_lookupFiringDelay(uint8_t level, float frequency) {
return -1.5034e-7 * pow(level, 5) + 9.5843e-5 * pow(level, 4) - 2.2953e-2 * pow(level, 3) + 2.5471 * pow(level, 2) - 149.65 * level + 9984.6;
}

float Mycila::Dimmer::_lookupVrmsFactor(uint8_t level, float frequency) {
float Mycila::Dimmer::_lookupVrms(uint8_t level, float frequency) {
if (level == 0)
return 0;

Expand Down
Loading

0 comments on commit 0b4a016

Please sign in to comment.