Skip to content

Commit 2e66705

Browse files
committed
RFLink: Milight finetuning
1 parent 4cf0106 commit 2e66705

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

hardware/RFLinkBase.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ bool CRFLinkBase::WriteToHardware(const char *pdata, const unsigned char length)
293293
//_log.Log(LOG_ERROR, "RFLink: subtype: %d", pLed->subtype); // rgbw/rgb/white?
294294
//_log.Log(LOG_ERROR, "RFLink: id: %d", pLed->id); // id
295295
//_log.Log(LOG_ERROR, "RFLink: unit: %d", pLed->dunit); // unit 0=All, 1=Group1,2=Group2,3=Group3,4=Group4
296-
//_log.Log(LOG_ERROR, "RFLink: command: %d", pLed->command); // command
296+
_log.Log(LOG_ERROR, "RFLink: command: %d", pLed->command); // command
297297
//_log.Log(LOG_ERROR, "RFLink: value: %d", pLed->value); // brightness/color value
298298

299299
const int m_LEDType = pLed->type;
@@ -310,12 +310,8 @@ bool CRFLinkBase::WriteToHardware(const char *pdata, const unsigned char length)
310310
break;
311311
case Limitless_SetRGBColour:
312312
{
313-
//The Hue is inverted/swifted 90 degrees
314-
int iHue = ((255 - pLed->value) + 192) & 0xFF;
315-
//_log.Log(LOG_ERROR, "RFLink: hue: %d", iHue);
316-
//RGBWSetColor[1] = (unsigned char)iHue;
317313
m_colorbright = m_colorbright & 0xff;
318-
m_colorbright = (((unsigned char) iHue) << 8) + m_colorbright;
314+
m_colorbright = (((unsigned char)pLed->value) << 8) + m_colorbright;
319315
switchcmnd = "COLOR";
320316
}
321317
break;
@@ -333,18 +329,18 @@ bool CRFLinkBase::WriteToHardware(const char *pdata, const unsigned char length)
333329
break;
334330
case Limitless_SetBrightnessLevel:
335331
{
336-
//convert brightness (0-100) to (0-50) to 0-59
337-
double dval = (59.0 / 100.0)*float(pLed->value / 2);
338-
int ival = round(dval);
339-
if (ival<2)
340-
ival = 2;
341-
if (ival>27)
342-
ival = 27;
343-
//_log.Log(LOG_ERROR, "RFLink: brightness: %d", ival);
332+
//brightness (0-100) converted to 0x00-0xff
333+
int m_brightness = (unsigned char)pLed->value;
334+
_log.Log(LOG_ERROR, "RFLink: br1: %04x", m_brightness); // command
335+
m_brightness = (m_brightness * 255) / 100;
336+
_log.Log(LOG_ERROR, "RFLink: br2: %04x", m_brightness); // command
337+
m_brightness = m_brightness & 0xff;
338+
_log.Log(LOG_ERROR, "RFLink: br3: %04x", m_brightness); // command
344339
m_colorbright = m_colorbright & 0xff00;
345-
m_colorbright = m_colorbright + (unsigned char) ival;
340+
//m_colorbright = m_colorbright + (unsigned char)pLed->value;
341+
m_colorbright = m_colorbright + (unsigned char)m_brightness;
342+
_log.Log(LOG_ERROR, "RFLink: command: %04x", m_colorbright); // command
346343
switchcmnd = "BRIGHT";
347-
//RGBWSetBrightnessLevel[1] = (unsigned char)ival;
348344
}
349345
break;
350346

0 commit comments

Comments
 (0)