ifirst working version of rf433 reciever
authorrealraum <realraum@realraum.at>
Mon, 12 Dec 2011 23:31:00 +0000 (23:31 +0000)
committerrealraum <realraum@realraum.at>
Mon, 12 Dec 2011 23:31:00 +0000 (23:31 +0000)
rf433rcv/pc/plot.py [new file with mode: 0755]
rf433rcv/pc/rawhid_test.c
rf433rcv/teensy/example.c

diff --git a/rf433rcv/pc/plot.py b/rf433rcv/pc/plot.py
new file mode 100755 (executable)
index 0000000..e8d4cfa
--- /dev/null
@@ -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()
index 7bea892..1b1b2c3 100644 (file)
@@ -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<num; i++) {
-                               printf("%02X ", buf[i] & 255);
-                               if (i % 16 == 15 && i < num-1) printf("\n");
-                       }
-                       printf("\n");
+               if (num == 64) {
+               //      printf("\nrecv %d bytes:\n", num);
+                         for (i=0; i<64*8; i++) {
+          if (buf[i/8] & 0x80)
+          {
+            printf("1");
+          } else {
+            printf("0");
+          }
+          printf(",");
+          buf[i/8]<<=1;
+        }
                }
                // check if any input on stdin
                while ((c = get_keystroke()) >= 32) {
index 649b207..ab7026c 100644 (file)
 
 #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;
+  }
 }
 
 
-