Skip to content

Class Mycila::DFRobotDimmer

ClassList > Mycila > DFRobotDimmer

DFRobot DFR1071/DFR1073/DFR0971 I2C controlled 0-10V/0-5V dimmer implementation for voltage regulators controlled by a 0-10V/0-5V analog signal.

  • #include <MycilaDimmerDFRobot.h>

Inherits the following classes: Mycila::PhaseControlDimmer

Public Types

Type Name
enum Output
enum SKU

Public Functions

Type Name
virtual bool begin () override
Enable a dimmer on a specific GPIO pin.
virtual void end () override
Disable the dimmer.
uint8_t getChannel () const
uint8_t getDeviceAddress () const
Output getOutput () const
uint8_t getResolution () const
Get the PWM resolution in bits.
SKU getSKU () const
TwoWire & getWire () const
void setChannel (uint8_t channel)
Set channel number.
void setDeviceAddress (uint8_t deviceAddress)
I2C address of the device.
void setOutput (Output output)
Set output mode of the device: 0-5V or 0-10V.
void setSKU (SKU sku)
void setWire (TwoWire & wire)
virtual const char * type () override const
virtual ~DFRobotDimmer ()

Public Functions inherited from Mycila::PhaseControlDimmer

See Mycila::PhaseControlDimmer

Type Name
void enablePowerLUT (bool enable)
Enable or disable the use of power LUT for this phase-control dimmer The power LUT provides a non-linear dimming curve that is more aligned with human perception of brightness. If disabled, a linear dimming curve will be used.
virtual float getPowerRatio () override const
virtual bool isOnline () override const
Returns true if the dimmer is online.
bool isPowerLUTEnabled () const
Check if the power LUT is enabled.
virtual bool setDutyCycle (float dutyCycle) override
Set the power duty, eventually remapped by the power LUT if enabled.
virtual ~PhaseControlDimmer ()

Public Functions inherited from Mycila::Dimmer

See Mycila::Dimmer

Type Name
virtual bool begin ()
bool calculateHarmonics (float * array, size_t n) const
bool calculateMetrics (Metrics & metrics, float gridVoltage, float loadResistance) const
virtual void end ()
float getDutyCycle () const
Get the power duty cycle configured for the dimmer by the user.
float getDutyCycleFire () const
Get the real firing duty cycle (conduction duty cycle) applied to the dimmer in the range [0, 1].
float getDutyCycleLimit () const
Get the power duty cycle limit of the dimmer.
float getDutyCycleMapped () const
Get the remapped power duty cycle from the currently user set duty cycle.
float getDutyCycleMax () const
Get the remapped "1" of the dimmer duty cycle.
float getDutyCycleMin () const
Get the remapped "0" of the dimmer duty cycle.
virtual float getPowerRatio () const
bool isEnabled () const
Check if the dimmer is enabled (if it was able to initialize correctly)
bool isOff () const
Check if the dimmer is off.
bool isOn () const
Check if the dimmer is on.
bool isOnAtFullPower () const
Check if the dimmer is on at full power.
virtual bool isOnline () const
Returns true if the dimmer is online.
void off ()
Turn off the dimmer.
void on ()
Turn on the dimmer at full power.
virtual bool setDutyCycle (float dutyCycle)
Set the power duty.
void setDutyCycleLimit (float limit)
Set the power duty cycle limit of the dimmer. The duty cycle will be clamped to this limit.
void setDutyCycleMax (float max)
Duty remapping (equivalent to Shelly Dimmer remapping feature). Useful to calibrate the dimmer when using for example a PWM signal to 0-10V analog convertor connected to a voltage regulator which is only working in a specific voltage range like 1-8V.
void setDutyCycleMin (float min)
Duty remapping (equivalent to Shelly Dimmer remapping feature). Useful to calibrate the dimmer when using for example a PWM signal to 0-10V analog convertor connected to a voltage regulator which is only working in a specific voltage range like 1-8V.
void setOnline (bool online)
Set the online status of the dimmer.
virtual const char * type () const
virtual ~Dimmer ()

Public Static Functions inherited from Mycila::Dimmer

See Mycila::Dimmer

Type Name
uint16_t getSemiPeriod ()
Get the semi-period in us used for the power LUT calculations. If LUT is disabled, returns 0.
void setSemiPeriod (uint16_t semiPeriod)
Set the semi-period of the grid frequency in us for this dimmer. This is mandatory when using power LUT.

Protected Attributes inherited from Mycila::PhaseControlDimmer

See Mycila::PhaseControlDimmer

Type Name
bool _powerLUTEnabled = false

Protected Attributes inherited from Mycila::Dimmer

See Mycila::Dimmer

Type Name
float _dutyCycle = 0.0f
float _dutyCycleFire = 0.0f
float _dutyCycleLimit = 1.0f
float _dutyCycleMax = 1.0f
float _dutyCycleMin = 0.0f
bool _enabled = false
bool _online = false

Protected Static Attributes inherited from Mycila::Dimmer

See Mycila::Dimmer

Type Name
uint16_t _semiPeriod = 0

Protected Functions

Type Name
virtual bool _apply () override

Protected Functions inherited from Mycila::PhaseControlDimmer

See Mycila::PhaseControlDimmer

Type Name
virtual bool _calculateDimmerHarmonics (float * array, size_t n) override const

Protected Functions inherited from Mycila::Dimmer

See Mycila::Dimmer

Type Name
virtual bool _apply ()
virtual bool _calculateDimmerHarmonics (float * array, size_t n) const

Protected Static Functions inherited from Mycila::PhaseControlDimmer

See Mycila::PhaseControlDimmer

Type Name
uint16_t _lookupFiringDelay (float dutyCycle)

Protected Static Functions inherited from Mycila::Dimmer

See Mycila::Dimmer

Type Name
float _contrain (float amt, float low, float high)

Public Types Documentation

enum Output

enum Mycila::DFRobotDimmer::Output {
    RANGE_0_5V,
    RANGE_0_10V
};

enum SKU

enum Mycila::DFRobotDimmer::SKU {
    UNKNOWN,
    DFR1071_GP8211S,
    DFR1073_GP8413,
    DFR0971_GP8403
};

Public Functions Documentation

function begin

Enable a dimmer on a specific GPIO pin.

virtual bool Mycila::DFRobotDimmer::begin () override

Warning:

Dimmer won't be enabled if pin is invalid

Warning:

Dimmer won't be activated until the ZCD is enabled

Implements Mycila::Dimmer::begin


function end

Disable the dimmer.

virtual void Mycila::DFRobotDimmer::end () override

Warning:

Dimmer won't be destroyed but won't turn on anymore even is a duty cycle is set.

Implements Mycila::Dimmer::end


function getChannel

inline uint8_t Mycila::DFRobotDimmer::getChannel () const

function getDeviceAddress

inline uint8_t Mycila::DFRobotDimmer::getDeviceAddress () const

function getOutput

inline Output Mycila::DFRobotDimmer::getOutput () const

function getResolution

Get the PWM resolution in bits.

inline uint8_t Mycila::DFRobotDimmer::getResolution () const


function getSKU

inline SKU Mycila::DFRobotDimmer::getSKU () const

function getWire

inline TwoWire & Mycila::DFRobotDimmer::getWire () const

function setChannel

Set channel number.

inline void Mycila::DFRobotDimmer::setChannel (
    uint8_t channel
) 

Parameters:

  • channel output channel 0: Channel 0 (valid when PWM0 output is configured) 1: Channel 1 (valid when PWM1 output is configured) 2: All channels (valid when configuring dual channel output)

function setDeviceAddress

I2C address of the device.

inline void Mycila::DFRobotDimmer::setDeviceAddress (
    uint8_t deviceAddress
) 

Parameters:

  • deviceAddress I2C address

function setOutput

Set output mode of the device: 0-5V or 0-10V.

inline void Mycila::DFRobotDimmer::setOutput (
    Output output
) 

Parameters:

  • output output mode

function setSKU

inline void Mycila::DFRobotDimmer::setSKU (
    SKU sku
) 

function setWire

inline void Mycila::DFRobotDimmer::setWire (
    TwoWire & wire
) 

function type

inline virtual const char * Mycila::DFRobotDimmer::type () override const

Implements Mycila::Dimmer::type


function ~DFRobotDimmer

inline virtual Mycila::DFRobotDimmer::~DFRobotDimmer () 

Protected Functions Documentation

function _apply

inline virtual bool Mycila::DFRobotDimmer::_apply () override

Implements Mycila::Dimmer::_apply



The documentation for this class was generated from the following file src/MycilaDimmerDFRobot.h