Files
gateway/components/knx_dali_gw/src/dali_helper.cpp
T
Tony 449a3a801a Add KNX DALI Gateway Module and Message Queue Implementation
- Introduced KnxDaliModule class for handling DALI message queuing, commissioning, and KNX group-object dispatch.
- Implemented Message and MessageQueue classes for managing message operations.
- Removed obsolete OpenKNX IDF component files and CMake configurations.
- Updated submodule reference for KNX.

Signed-off-by: Tony <tonylu@tony-cloud.com>
2026-05-15 12:34:13 +08:00

41 lines
776 B
C++

#include "dali_helper.h"
uint8_t DaliHelper::percentToArc(uint8_t value)
{
if(value == 0)
{
return 0;
}
//Todo also include _max
uint8_t arc = roundToInt(((253/3.0)*(std::log10(value)+1)) + 1);
return arc;
}
uint8_t DaliHelper::arcToPercent(uint8_t value)
{
if(value == 0)
{
return 0;
}
//Todo also include _max
double arc = std::pow(10, ((value-1) / (253/3.0)) - 1);
return roundToInt(arc);
}
float DaliHelper::arcToPercentFloat(uint8_t value)
{
if(value == 0)
{
return 0;
}
//Todo also include _max
float arc = std::pow(10, ((value-1) / (253/3.0)) - 1);
return arc;
}
uint8_t DaliHelper::roundToInt(double input)
{
double temp = input + 0.5;
return (uint8_t)temp;
}