--- /dev/null
+#!/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()
return -1;
}
}
- printf("found rawhid device\n");
+// printf("found rawhid device\n");
while (1) {
// check if any Raw HID packet has arrived
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) {
#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;
_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);
+ }
}
}
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;
+ }
}
-