MCPcopy Create free account
hub / github.com/DanielOgorchock/ST_Anything / getCodeWordB

Method getCodeWordB

Arduino/libraries/RCSwitch/RCSwitch.cpp:241–270  ·  view source on GitHub ↗

* Returns a char[13], representing the Code Word to be send. * 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" (synchronous bit) * * +-------------------------------+--------------------------------+---------

Source from the content-addressed store, hash-verified

239 * @return char[13]
240 */
241char* RCSwitch::getCodeWordB(int nAddressCode, int nChannelCode, boolean bStatus) {
242 int nReturnPos = 0;
243 static char sReturn[13];
244
245 char* code[5] = { "FFFF", "0FFF", "F0FF", "FF0F", "FFF0" };
246 if (nAddressCode < 1 || nAddressCode > 4 || nChannelCode < 1 || nChannelCode > 4) {
247 return '\0';
248 }
249 for (int i = 0; i<4; i++) {
250 sReturn[nReturnPos++] = code[nAddressCode][i];
251 }
252
253 for (int i = 0; i<4; i++) {
254 sReturn[nReturnPos++] = code[nChannelCode][i];
255 }
256
257 sReturn[nReturnPos++] = 'F';
258 sReturn[nReturnPos++] = 'F';
259 sReturn[nReturnPos++] = 'F';
260
261 if (bStatus) {
262 sReturn[nReturnPos++] = 'F';
263 } else {
264 sReturn[nReturnPos++] = '0';
265 }
266
267 sReturn[nReturnPos] = '\0';
268
269 return sReturn;
270}
271
272/**
273 * 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