From e9a73bbb3c14af340999f70146747787785f4fee Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 19 Dec 2011 18:20:33 +0000 Subject: initial commit --- electic_streaming2560/main.cpp | 80 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 electic_streaming2560/main.cpp (limited to 'electic_streaming2560/main.cpp') diff --git a/electic_streaming2560/main.cpp b/electic_streaming2560/main.cpp new file mode 100644 index 0000000..71c276e --- /dev/null +++ b/electic_streaming2560/main.cpp @@ -0,0 +1,80 @@ +extern "C" void __cxa_pure_virtual(void); //for C++ defines + +/* +Electric data access template + +TJR 191011 + +Uses Arduino c++ libraries in vanilla AVR environment + +Explanation +http://www.johnhenryshammer.com/WOW2/pagesHowTo/atmelPage.php#index + +*/ +#define SAMPLES 512 //size of ram buffer +#define PACKETSIZE 320 //size of output packet + +#include //import main Arduino header file + + +byte dd[SAMPLES]; // ram buffer +int loopCount=0; +int sample=0; + +void fill_sinewave(){ + /* + sample data to stream + the vital thing is that its possible to distinguish the end of a packet + + here the data is in the range 1-255 and a 0 denotes the end of the packet + */ + float pi = 3.141592; + float fcnt=0; + float fd; + float dx=2 * pi / SAMPLES; // fill the 512 byte bufferarry + int bb; + for (int i = 0; i 0) { + PORTB ^= (1 << 5); + byte in=Serial.read(); + if (in=='a') { + Serial.println("Welcome to electic"); + TCCR1B |= ((1<