//by marshmellow
void askAmp(uint8_t *BitStream, size_t size)
{
- for(size_t i = 1; i<size; i++){
- if (BitStream[i]-BitStream[i-1]>=30) //large jump up
- BitStream[i]=255;
- else if(BitStream[i]-BitStream[i-1]<=-20) //large jump down
- BitStream[i]=0;
+ uint8_t last = 128;
+ for(size_t i = 1; i < size; ++i){
+ if (BitStream[i]-BitStream[i-1] >= 30) //large jump up
+ last = 255;
+ else if(BitStream[i-1] - BitStream[i] >= 20) //large jump down
+ last = 0;
+
+ BitStream[i] = last;
}
- return;
}
//by marshmellow
return (int)startIdx;
}
-// find presco preamble 0x10D in already demoded data
+// find nedap preamble in already demoded data
int NedapDemod(uint8_t *dest, size_t *size) {
//make sure buffer has data
if (*size < 128) return -3;
+
size_t startIdx = 0;
+ //uint8_t preamble[] = {1,1,1,1,1,1,1,1,1,0,0,0,1};
uint8_t preamble[] = {1,1,1,1,1,1,1,1,1,0};
uint8_t errChk = preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx);
if (errChk == 0) return -4; //preamble not found
- //return start position
return (int) startIdx;
}