libraries / rc-switch-2.52 / examples / ReceiveDemo_Advanced / helperfunctions.inoon commit Added link to project report (97a3ba0)
   1static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength){
   2  static char bin[64]; 
   3  unsigned int i=0;
   4
   5  while (Dec > 0) {
   6    bin[32+i++] = (Dec & 1 > 0) ? '1' : '0';
   7    Dec = Dec >> 1;
   8  }
   9
  10  for (unsigned int j = 0; j< bitLength; j++) {
  11    if (j >= bitLength - i) {
  12      bin[j] = bin[ 31 + i - (j - (bitLength - i)) ];
  13    }else {
  14      bin[j] = '0';
  15    }
  16  }
  17  bin[bitLength] = '\0';
  18  
  19  return bin;
  20}