File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -301,6 +301,8 @@ void CRFLink::readCallback(const char *data, size_t len)
301
301
302
302
}
303
303
304
+ #define round (a ) ( int ) ( a + .5 )
305
+
304
306
bool CRFLink::WriteToHardware (const char *pdata, const unsigned char length)
305
307
{
306
308
if (!isOpen ())
@@ -317,6 +319,21 @@ bool CRFLink::WriteToHardware(const char *pdata, const unsigned char length)
317
319
return false ;
318
320
}
319
321
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
+
320
337
if (switchcmnd.empty ())
321
338
{
322
339
_log.Log (LOG_ERROR, " RFLink: trying to send unknown switch command: %d" , pSwitch->cmnd );
You can’t perform that action at this time.
0 commit comments