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

Method getCodeWordB

Sming/Libraries/RCSwitch/RCSwitch.cpp:280–310  ·  view source on GitHub ↗

* Returns a char[13], representing the code word to be sent. * A code word consists of 9 address bits, 3 data bits and one sync bit but * in our case only the first 8 address bits and the last 2 data bits were used. * A code bit can have 4 different states: "F" (floating), "0" (low), "1" (high), "S" (sync bit) * * +-----------------------------+-----------------------------+----------+-------

Source from the content-addressed store, hash-verified

278 * @return char[13]
279 */
280char* RCSwitch::getCodeWordB(int nAddressCode, int nChannelCode, boolean bStatus) {
281 int nReturnPos = 0;
282 static char sReturn[13];
283
284 const char* code[5] = { "FFFF", "0FFF", "F0FF", "FF0F", "FFF0" };
285 if (nAddressCode < 1 || nAddressCode > 4 || nChannelCode < 1 || nChannelCode > 4) {
286 sReturn[0] = '\0';
287 return sReturn;
288 }
289 for (int i = 0; i<4; i++) {
290 sReturn[nReturnPos++] = code[nAddressCode][i];
291 }
292
293 for (int i = 0; i<4; i++) {
294 sReturn[nReturnPos++] = code[nChannelCode][i];
295 }
296
297 sReturn[nReturnPos++] = 'F';
298 sReturn[nReturnPos++] = 'F';
299 sReturn[nReturnPos++] = 'F';
300
301 if (bStatus) {
302 sReturn[nReturnPos++] = 'F';
303 } else {
304 sReturn[nReturnPos++] = '0';
305 }
306
307 sReturn[nReturnPos] = '\0';
308
309 return sReturn;
310}
311
312/**
313 * Returns a char[13], representing the code word to be send.

Callers 2

switchOnMethod · 0.95
switchOffMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected