added resistance for Driver-Board
This commit is contained in:
parent
46fcc4d63c
commit
beff439810
|
@ -10,71 +10,98 @@ LightMux::LightMux()
|
|||
adaptive_brightness = false;
|
||||
fullCommonColor = ((warmest_temperature + coldest_temperature) / 2);
|
||||
qDebug("full common color: %i\n", fullCommonColor);
|
||||
|
||||
cold_resistance_range.low = 100.0;
|
||||
cold_resistance_range.high = 900.0;
|
||||
|
||||
warm_resistance_range.low = 100.0;
|
||||
warm_resistance_range.high = 900.0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LightMux::mux(){
|
||||
|
||||
struct powermix mixed;
|
||||
|
||||
if(adaptive_brightness == true){
|
||||
qDebug("adaptiv\n");
|
||||
mux_adaptiv();
|
||||
mixed = mux_adaptiv();
|
||||
} else {
|
||||
qDebug("linear\n");
|
||||
mux_linear();
|
||||
}
|
||||
}
|
||||
|
||||
void LightMux::mux_linear() {
|
||||
|
||||
if(temperatur == fullCommonColor){
|
||||
qDebug("same as full common color\n");
|
||||
power_cold = 100;
|
||||
power_warm = 100;
|
||||
} else if(temperatur < fullCommonColor) {
|
||||
qDebug("lower as full common color\n");
|
||||
// warm led dominant
|
||||
// cold led recessive
|
||||
power_warm = 100;
|
||||
double a = double(((temperatur * (power_warm/100)) - ((power_warm/100) * warmest_temperature)));
|
||||
double b = double((coldest_temperature - temperatur));
|
||||
double c = a / b * 100;
|
||||
power_cold = static_cast<int>(c + .5);
|
||||
} else if(temperatur > fullCommonColor) {
|
||||
qDebug("higher as full common color\n");
|
||||
// cold led dominant
|
||||
// warm led recessive
|
||||
power_cold = 100;
|
||||
double a = double(((temperatur * (power_cold/100)) - ((power_cold/100) * coldest_temperature)));
|
||||
double b = double((warmest_temperature - temperatur));
|
||||
double c = a / b * 100;
|
||||
power_warm = static_cast<int>(c + .5);
|
||||
mixed = mux_linear();
|
||||
}
|
||||
|
||||
power_cold = static_cast<int>(double(power_cold * (double(brightness/100.0))) + .5);
|
||||
power_warm = static_cast<int>(double(power_warm * (double(brightness/100.0))) + .5);
|
||||
power_cold = static_cast<int>(double(mixed.cold * (double(brightness/100.0))) + .5);
|
||||
power_warm = static_cast<int>(double(mixed.warm * (double(brightness/100.0))) + .5);
|
||||
|
||||
qDebug("cold color: %i\nwarm color: %i\n", power_cold, power_warm);
|
||||
|
||||
power_combined = static_cast<int>(double(power_cold+power_warm) / 2.0);
|
||||
|
||||
|
||||
resistance_cold = static_cast<int>(double(map(power_cold, 0.0, 100.0, cold_resistance_range.low, cold_resistance_range.high)));
|
||||
|
||||
resistance_warm = static_cast<int>(double(map(power_warm, 0.0, 100.0, warm_resistance_range.low, warm_resistance_range.high)));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
struct LightMux::powermix LightMux::mux_linear() {
|
||||
|
||||
struct powermix tmp;
|
||||
|
||||
if(temperatur == fullCommonColor){
|
||||
qDebug("same as full common color\n");
|
||||
tmp.cold = 100;
|
||||
tmp.warm = 100;
|
||||
|
||||
} else if(temperatur < fullCommonColor) {
|
||||
qDebug("lower as full common color\n");
|
||||
// warm led dominant
|
||||
// cold led recessive
|
||||
tmp.warm = 100;
|
||||
double a = double(((temperatur * (tmp.warm/100)) - ((tmp.warm/100) * warmest_temperature)));
|
||||
double b = double((coldest_temperature - temperatur));
|
||||
double c = a / b * 100;
|
||||
tmp.cold = static_cast<int>(c + .5);
|
||||
} else if(temperatur > fullCommonColor) {
|
||||
qDebug("higher as full common color\n");
|
||||
// cold led dominant
|
||||
// warm led recessive
|
||||
tmp.cold = 100;
|
||||
double a = double(((temperatur * (tmp.cold/100)) - ((tmp.cold/100) * coldest_temperature)));
|
||||
double b = double((warmest_temperature - temperatur));
|
||||
double c = a / b * 100;
|
||||
tmp.warm = static_cast<int>(c + .5);
|
||||
}
|
||||
|
||||
return tmp;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LightMux::mux_adaptiv(){
|
||||
struct LightMux::powermix LightMux::mux_adaptiv(){
|
||||
|
||||
struct powermix tmp;
|
||||
|
||||
if(temperatur == fullCommonColor){
|
||||
qDebug("same as full common color\n");
|
||||
power_cold = 50;
|
||||
power_warm = 50;
|
||||
tmp.cold = 50;
|
||||
tmp.warm = 50;
|
||||
|
||||
} else if(temperatur < fullCommonColor) {
|
||||
qDebug("lower as full common color\n");
|
||||
// warm led dominant
|
||||
// cold led recessive
|
||||
|
||||
double a = double((temperatur) - (warmest_temperature));
|
||||
double b = double((-warmest_temperature + coldest_temperature));
|
||||
double c = a / b * 100;
|
||||
power_cold = static_cast<int>(c + .5);
|
||||
power_warm = 100 - power_cold;
|
||||
tmp.cold = static_cast<int>(c + .5);
|
||||
tmp.warm = 100 - tmp.cold;
|
||||
} else if(temperatur > fullCommonColor) {
|
||||
qDebug("higher as full common color\n");
|
||||
// cold led dominant
|
||||
|
@ -83,16 +110,11 @@ void LightMux::mux_adaptiv(){
|
|||
double a = double((temperatur) - (coldest_temperature));
|
||||
double b = double((-coldest_temperature + warmest_temperature));
|
||||
double c = a / b * 100;
|
||||
power_warm = static_cast<int>(c + .5);
|
||||
power_cold = 100 - power_warm;
|
||||
tmp.warm = static_cast<int>(c + .5);
|
||||
tmp.cold = 100 - tmp.warm;
|
||||
}
|
||||
|
||||
power_cold = static_cast<int>(double(power_cold * (double(brightness/100.0))) + .5);
|
||||
power_warm = static_cast<int>(double(power_warm * (double(brightness/100.0))) + .5);
|
||||
|
||||
qDebug("cold color: %i\nwarm color: %i\n", power_cold, power_warm);
|
||||
|
||||
power_combined = static_cast<int>(double(power_cold+power_warm) / 2.0);
|
||||
return tmp;
|
||||
|
||||
}
|
||||
|
||||
|
@ -184,6 +206,10 @@ void LightMux::toogleAdaptiveBrightness(){
|
|||
}
|
||||
}
|
||||
|
||||
double LightMux::map(double value, double fromLow, double fromHigh, double toLow, double toHigh){
|
||||
return toLow + (toHigh - toLow) * ((value - fromLow) / (fromHigh - fromLow));
|
||||
}
|
||||
|
||||
int LightMux::getBrightness(){
|
||||
return brightness;
|
||||
}
|
||||
|
@ -211,3 +237,11 @@ int LightMux::getPowerWarm(){
|
|||
int LightMux::getPowerCombined(){
|
||||
return power_combined;
|
||||
}
|
||||
|
||||
int LightMux::getResistanceCold(){
|
||||
return resistance_cold;
|
||||
}
|
||||
|
||||
int LightMux::getResistanceWarm(){
|
||||
return resistance_warm;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,16 @@ class LightMux
|
|||
{
|
||||
private:
|
||||
|
||||
struct range {
|
||||
double low;
|
||||
double high;
|
||||
};
|
||||
|
||||
struct powermix {
|
||||
int cold;
|
||||
int warm;
|
||||
};
|
||||
|
||||
int brightness; // total power of the LED Panels (both colors) in percent
|
||||
int temperatur; // muxed color temperature of the LED Panels, from coldest to warmest in Kelvin
|
||||
|
||||
|
@ -17,10 +27,16 @@ private:
|
|||
int power_warm; // power of the warm LEDs of Panels in percent
|
||||
int power_combined; //combined power of both LEDs in percent
|
||||
|
||||
int resistance_cold; // Resistance of the DigiPot on Driver-Board
|
||||
int resistance_warm; // Resistance of the DigiPot on Driver-Board
|
||||
|
||||
int fullCommonColor; // color mix with both LED´s at same brightess
|
||||
|
||||
bool adaptive_brightness; // true indecates adaptive brightness is enabled
|
||||
|
||||
struct range cold_resistance_range;
|
||||
struct range warm_resistance_range;
|
||||
|
||||
public:
|
||||
LightMux();
|
||||
|
||||
|
@ -48,11 +64,15 @@ public:
|
|||
|
||||
int getPowerCombined();
|
||||
|
||||
int getResistanceCold();
|
||||
int getResistanceWarm();
|
||||
|
||||
void toogleAdaptiveBrightness();
|
||||
|
||||
private:
|
||||
void mux_linear(); // brightness will vary by different color temperature
|
||||
void mux_adaptiv(); // same brightness by different color temperature
|
||||
struct powermix mux_linear(); // brightness will vary by different color temperature
|
||||
struct powermix mux_adaptiv(); // same brightness by different color temperature
|
||||
double map(double value, double fromLow, double fromHigh, double toLow, double toHigh); // remaps the value
|
||||
};
|
||||
|
||||
#endif // LIGHTMUX_H
|
||||
|
|
|
@ -38,6 +38,8 @@ void MainWindow::updateUI()
|
|||
setLablePowerCold(lmux->getPowerCold());
|
||||
setLablePowerWarm(lmux->getPowerWarm());
|
||||
setLablePowerCombined(lmux->getPowerCombined());
|
||||
setLableResistanceCold(lmux->getResistanceCold());
|
||||
setLableResistanceWarm(lmux->getResistanceWarm());
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,6 +58,14 @@ void MainWindow::setLablePowerCombined(int val)
|
|||
ui->labelPowerCombined->setText("Combined Power: " + QString::number(val) + "%");
|
||||
}
|
||||
|
||||
void MainWindow::setLableResistanceCold(int val){
|
||||
ui->labelResistanceCold->setText("Resistance Cold: " + QString::number(val) + "Ω");
|
||||
}
|
||||
|
||||
void MainWindow::setLableResistanceWarm(int val){
|
||||
ui->labelResistanceWarm->setText("Resistance Warm: " + QString::number(val) + "Ω");
|
||||
}
|
||||
|
||||
void MainWindow::on_BtnIncreaseBrightness_clicked()
|
||||
{
|
||||
lmux->incBrightness();
|
||||
|
|
|
@ -19,6 +19,8 @@ public:
|
|||
void setLablePowerCold(int val);
|
||||
void setLablePowerWarm(int val);
|
||||
void setLablePowerCombined(int val);
|
||||
void setLableResistanceCold(int val);
|
||||
void setLableResistanceWarm(int val);
|
||||
|
||||
private slots:
|
||||
void on_BtnIncreaseBrightness_clicked();
|
||||
|
|
|
@ -298,6 +298,32 @@
|
|||
<string>adaptive brightness</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelResistanceCold">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<y>240</y>
|
||||
<width>161</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Resistance Cold:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelResistanceWarm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<y>270</y>
|
||||
<width>161</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Resistance Warm:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
|
|
Loading…
Reference in New Issue