MCPcopy Create free account
hub / github.com/SmingHub/Sming / getCodeWordC

Method getCodeWordC

Sming/Libraries/RCSwitch/RCSwitch.cpp:345–377  ·  view source on GitHub ↗

* Like getCodeWord (Type C = Intertechno) */

Source from the content-addressed store, hash-verified

343 * Like getCodeWord (Type C = Intertechno)
344 */
345char* RCSwitch::getCodeWordC(char sFamily, int nGroup, int nDevice, boolean bStatus) {
346 static char sReturn[13];
347 int nReturnPos = 0;
348
349 if ( (byte)sFamily < 97 || (byte)sFamily > 112 || nGroup < 1 || nGroup > 4 || nDevice < 1 || nDevice > 4) {
350 sReturn[0] = '\0';
351 return sReturn;
352 }
353
354 const char* sDeviceGroupCode = dec2binWcharfill( (nDevice-1) + (nGroup-1)*4, 4, '0' );
355 const char familycode[16][5] = {
356 "0000", "F000", "0F00", "FF00",
357 "00F0", "F0F0", "0FF0", "FFF0",
358 "000F", "F00F", "0F0F", "FF0F",
359 "00FF", "F0FF", "0FFF", "FFFF"
360 };
361 for (int i = 0; i<4; i++) {
362 sReturn[nReturnPos++] = familycode[ (int)sFamily - 97 ][i];
363 }
364 for (int i = 0; i<4; i++) {
365 sReturn[nReturnPos++] = (sDeviceGroupCode[3-i] == '1' ? 'F' : '0');
366 }
367 sReturn[nReturnPos++] = '0';
368 sReturn[nReturnPos++] = 'F';
369 sReturn[nReturnPos++] = 'F';
370 if (bStatus) {
371 sReturn[nReturnPos++] = 'F';
372 } else {
373 sReturn[nReturnPos++] = '0';
374 }
375 sReturn[nReturnPos] = '\0';
376 return sReturn;
377}
378
379/**
380 * Decoding for the REV Switch Type

Callers 2

switchOnMethod · 0.95
switchOffMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected