データが大きくなりますが、38kHz搬送波のものは記録できると思います。
-----
/*
code[0],code[1] = ID
code[2],code[3] = length
code[4] = FormatOther 0x04
code[5] - code[31] = reserve
code[32] - = continuous length(16bit BE)
*/
int FormatAnalyzeOther(unsigned int *buf, int bufSize, unsigned char *code, int codeSize) {
int last = -1;
int n = 0;
int c = 0;
memset(code, 0, codeSize);
for(int i = 0; i < bufSize * 32; i++) {
int d = (buf[i / 32] >> (31 - (i % 32))) & 1;
if((last < 0) && (d == 1)) continue; // skip nosignal
if(c && (d != last)) { // data edge
code[32 + n * 2] = c / 256;
code[32 + n * 2 + 1] = c % 256;
n++;
c = 1;
} else { // data continue
c++;
}
last = d;
}
if(last == 0) return -1;
code[2] = (32 + n * 2) / 256;
code[3] = (32 + n * 2) % 256;
code[4] = 4;
return 32 + n * 2;
}
int CodeExpandOther(unsigned char *code, int codeSize, unsigned int *buf, int bufSize) {
memset(buf, 0, bufSize * 4);
int len = (((code[2] << 8) | code[3]) - 32) / 2;
int p = 0;
int o = 1;
for(int i = 0; i < len; i++) {
int c = (code[32 + i * 2] << 8) | code[32 + i * 2 + 1];
for(int j = 0; j < c; j++) {
if(o && !(p & 1)) buf[p / 32] |= (1 << (31 - (p % 32)));
p++;
}
o ^= 1;
}
p += 31;
return p / 32;
}
0 件のコメント:
コメントを投稿