diff options
author | Joshua Allen <axlecrusher@gmail.com> | 2017-02-10 21:09:14 -0500 |
---|---|---|
committer | Joshua Allen <axlecrusher@gmail.com> | 2017-02-10 21:09:14 -0500 |
commit | acf367aab41e13b047df6670ffbb27cea8afe2d9 (patch) | |
tree | 61b2d734f68db3e2f148887d5590d71d748ddb44 /tools/ootx_decode/ootx_decoder.c | |
parent | 9317538667e6f54661949fee1c1f300ba89d185c (diff) | |
download | libsurvive-acf367aab41e13b047df6670ffbb27cea8afe2d9.tar.gz libsurvive-acf367aab41e13b047df6670ffbb27cea8afe2d9.tar.bz2 |
add code to try to deal with lighthouse data.
need to decode which lighthouse is sending the sync pulse.
I could not get the disambiguator to work.
Diffstat (limited to 'tools/ootx_decode/ootx_decoder.c')
-rw-r--r-- | tools/ootx_decode/ootx_decoder.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/tools/ootx_decode/ootx_decoder.c b/tools/ootx_decode/ootx_decoder.c index 5a14113..b386132 100644 --- a/tools/ootx_decode/ootx_decoder.c +++ b/tools/ootx_decode/ootx_decoder.c @@ -21,7 +21,7 @@ void ootx_init_decoder_context(ootx_decoder_context *ctx) { ctx->buf_offset = 0; ctx->bits_written = 0; - ctx->preamble = 0x00; + ctx->preamble = 0XFFFFFFFF; ctx->bits_processed = 0; ctx->found_preamble = 0; @@ -36,12 +36,27 @@ void ootx_init_buffer() { *payload_size = 0; } */ -uint8_t ootx_decode_bit(uint32_t length) { - length = ((length/500)*500)+500; - length-=3000; - if (length>=2000) { length-=2000; } - if (length>=1000) { return 0xFF; } +/* + how to decode pulses + ticks>2000 && delta>100000== master lighthouse + ticks>2000 && delta>10000 == slave lighthouse +*/ + +int8_t ootx_decode_lighthouse_number(uint8_t last_num, uint32_t ticks, int32_t delta) { + if (ticks<2000) return -1; //sweep + if ((ticks > 2000) & (delta>100000)) return 0; //master + if ((ticks > 2000) & (delta>10000)) return last_num+1; //a slave + return -1; +} + + +uint8_t ootx_decode_bit(uint32_t ticks) { + ticks = ((ticks/500)*500)+500; + + ticks-=3000; + if (ticks>=2000) { ticks-=2000; } + if (ticks>=1000) { return 0xFF; } return 0x00; } @@ -97,7 +112,7 @@ void ootx_process_bit(ootx_decoder_context *ctx, uint32_t length) { if ( ootx_detect_preamble(ctx, dbit) ) { /* data stream can start over at any time so we must always look for preamble bits */ -// printf("Preamble found\n"); + printf("Preamble found\n"); ootx_reset_buffer(ctx); ctx->bits_processed = 0; ctx->found_preamble = 1; |