From a9d16c55e719dc0e80ab2c0a8135549e1a46ca52 Mon Sep 17 00:00:00 2001 From: realraum Date: Mon, 12 Dec 2011 23:31:00 +0000 Subject: [PATCH] ifirst working version of rf433 reciever --- rf433rcv/pc/plot.py | 11 +++++++++++ rf433rcv/pc/rawhid_test.c | 21 +++++++++++++-------- rf433rcv/teensy/example.c | 31 +++++++++++++++++++------------ 3 files changed, 43 insertions(+), 20 deletions(-) create mode 100755 rf433rcv/pc/plot.py diff --git a/rf433rcv/pc/plot.py b/rf433rcv/pc/plot.py new file mode 100755 index 0000000..e8d4cfa --- /dev/null +++ b/rf433rcv/pc/plot.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +import fileinput +import numpy +import pylab +for datastr in fileinput.input(): + data = numpy.array(datastr.split(",")) + pylab.plot(range(len(data)),data) + + +pylab.show() diff --git a/rf433rcv/pc/rawhid_test.c b/rf433rcv/pc/rawhid_test.c index 7bea892..1b1b2c3 100644 --- a/rf433rcv/pc/rawhid_test.c +++ b/rf433rcv/pc/rawhid_test.c @@ -30,7 +30,7 @@ int main() return -1; } } - printf("found rawhid device\n"); +// printf("found rawhid device\n"); while (1) { // check if any Raw HID packet has arrived @@ -40,13 +40,18 @@ int main() rawhid_close(0); return 0; } - if (num > 0) { - printf("\nrecv %d bytes:\n", num); - for (i=0; i= 32) { diff --git a/rf433rcv/teensy/example.c b/rf433rcv/teensy/example.c index 649b207..ab7026c 100644 --- a/rf433rcv/teensy/example.c +++ b/rf433rcv/teensy/example.c @@ -29,16 +29,14 @@ #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) -volatile uint8_t do_output=0; +volatile uint16_t output_count=0; +volatile uint8_t active_buffer=0; +volatile uint8_t send_buffer=0; uint8_t read_buffer[64]; -uint8_t write_buffer[64]; +uint8_t write_buffer[2][64]; int main(void) { - int8_t r; - uint8_t i; - uint16_t val, count=0; - // set for 16 MHz clock CPU_PRESCALE(0); DDRF|=3; @@ -61,10 +59,13 @@ int main(void) _delay_ms(1000); while (1) { // if received data, do something with it - r = usb_rawhid_recv(read_buffer, 0); - if (r>0) - usb_rawhid_send(read_buffer, 50); - + //r = usb_rawhid_recv(read_buffer, 0); + //if (r>0) + if (send_buffer) + { + send_buffer=0; + usb_rawhid_send(write_buffer[active_buffer?0:1], 45); + } } } @@ -72,8 +73,14 @@ int main(void) ISR(TIMER0_COMPA_vect) { PORTF^=2; - + write_buffer[active_buffer][output_count/8]<<=1; + write_buffer[active_buffer][output_count++/8]|=PINB&1; + if (output_count>=64*8) + { + output_count=0; + active_buffer=active_buffer?0:1; + send_buffer=1; + } } - -- 1.7.10.4