Skip to content

Commit f148586

Browse files
author
stuntteam
committed
Added AC(NewKaku) dimmer support
1 parent be3431c commit f148586

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

hardware/RFLink.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ void CRFLink::readCallback(const char *data, size_t len)
301301

302302
}
303303

304+
#define round(a) ( int ) ( a + .5 )
305+
304306
bool CRFLink::WriteToHardware(const char *pdata, const unsigned char length)
305307
{
306308
if (!isOpen())
@@ -317,6 +319,21 @@ bool CRFLink::WriteToHardware(const char *pdata, const unsigned char length)
317319
return false;
318320
}
319321
std::string switchcmnd = GetGeneralRFLinkFromInt(rfswitchcommands, pSwitch->cmnd);
322+
323+
// check setlevel command
324+
if (pSwitch->cmnd == gswitch_sSetLevel) {
325+
//_log.Log(LOG_ERROR, "RFLink: pswitchlevel: %d", pSwitch->level);
326+
// Get device level to set
327+
float fvalue = (15.0f / 100.0f)*float(pSwitch->level);
328+
if (fvalue > 15.0f)
329+
fvalue = 15.0f; //99 is fully on
330+
int svalue = round(fvalue);
331+
//_log.Log(LOG_ERROR, "RFLink: level: %d", svalue);
332+
char buffer[10] = {0};
333+
int number_base = 10;
334+
switchcmnd = itoa( (int)svalue, buffer, number_base);
335+
}
336+
320337
if (switchcmnd.empty())
321338
{
322339
_log.Log(LOG_ERROR, "RFLink: trying to send unknown switch command: %d", pSwitch->cmnd);

0 commit comments

Comments
 (0)