b4b1.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* This line code is used in many remotes such as Princeton chips
  2. * named PT<number>, Silian Microelectronics SC5262 and others.
  3. * Basically every 4 pulsee represent a bit, where 1000 means 0, and
  4. * 1110 means 1. Usually we can read 24 bits of data.
  5. * In this specific implementation we check for a prelude that is
  6. * 1 bit high, 31 bits low, but the check is relaxed. */
  7. #include "../app.h"
  8. static bool decode(uint8_t *bits, uint64_t numbits, ProtoViewMsgInfo *info) {
  9. const char *sync_patterns[3] = {
  10. "10000000000000000000000000000001", /* 30 zero bits. */
  11. "100000000000000000000000000000001", /* 31 zero bits. */
  12. "1000000000000000000000000000000001", /* 32 zero bits. */
  13. };
  14. uint64_t off;
  15. int j;
  16. for (j = 0; j < 3; j++) {
  17. off = bitmap_seek_bits(bits,numbits,0,sync_patterns[j]);
  18. if (off != BITMAP_SEEK_NOT_FOUND) break;
  19. }
  20. if (off == BITMAP_SEEK_NOT_FOUND) return false;
  21. off += strlen(sync_patterns[j]);
  22. uint8_t d[3]; /* 24 bits of data. */
  23. uint32_t decoded =
  24. convert_from_line_code(d,sizeof(d),bits,numbits,off,"1000","1110");
  25. if (decoded != 24) return false;
  26. snprintf(info->name,PROTOVIEW_MSG_STR_LEN,"PT/SC remote");
  27. snprintf(info->raw,PROTOVIEW_MSG_STR_LEN,"%02X%02X%02X",d[0],d[1],d[2]);
  28. info->len = off+(4*24);
  29. return true;
  30. }
  31. ProtoViewDecoder B4B1Decoder = {
  32. "B4B1", decode
  33. };