Jared DiCarlo / plotter

Dependents:   george

Files at this revision

API Documentation at this revision

Comitter:
dicarloj
Date:
Sun Oct 30 22:30:34 2016 +0000
Parent:
0:ed208b547ef9
Commit message:
aqaaaaaa

Changed in this revision

plotter.cpp Show annotated file Show diff for this revision Revisions of this file
plotter.h Show annotated file Show diff for this revision Revisions of this file
diff -r ed208b547ef9 -r 761371998f16 plotter.cpp
--- a/plotter.cpp	Sun Oct 30 19:37:33 2016 +0000
+++ b/plotter.cpp	Sun Oct 30 22:30:34 2016 +0000
@@ -15,57 +15,23 @@
 bool initialized = false;
 void send_message()
 {
-    count++;
-    //pc.printf("in send message...\n\r");
-    if(!send_now) return;
-    //pc.printf("aaaaa...\n\r");
-    
-    count = 0;
+    //printf("in serial send\n\r");
     char start = 236;
-    //float data_6[] = {12.3456, 2.2, 33.4, 45.34, -52.34, 6, 734.234, 84.3, 99};
     ser_send(&pc, &start, 1);
     ser_send(&pc, &start, 1);
-    ser_send(&pc, (void*)plot_ptr, buffer_size);
-    memset((void*)plot_ptr, 0, buffer_size);
-    send_now = false;
+    ser_send(&pc, (void*)data_1, buffer_size);
 }
     
-void init_plotter(int num_vars, int loop_freq, int plot_freq)
+void init_plotter(int num_vars)
 {
     pc.baud(115200);
-    
-    buffer_size = 3 * num_vars * sizeof(float);    
-    send_now = false;
+    buffer_size = num_vars * sizeof(float);    
     data_1 = (volatile float*)malloc(buffer_size);
-    data_2 = (volatile float*)malloc(buffer_size);
-    memset((void*)data_1, 0, 3 * num_vars * sizeof(float));
-    memset((void*)data_2, 0, 3 * num_vars * sizeof(float));
-    samples_per_plot = loop_freq/plot_freq;
-    buffer_size = 3 * num_vars * sizeof(float);
-    if(samples_per_plot < 1)
-        printf("Bad inputs for plooter. try again next time.\n\r");
-    else
-        initialized = true;
+    memset((void*)data_1, 0, buffer_size);
 }
 
 void plot(int index_v, float value)
 {
-    volatile float* data_ptr = (plot_count % 2) == 0 ? data_1 : data_2;
-    if(!initialized)
-    {
-        //printf("plotter not initialized, not plotting!\n\r");
-        return;
-    }
-    data_ptr[3*index_v] += value/(samples_per_plot + 1);
-    data_ptr[3*index_v + 1] = 987;//fmaxf(data_ptr[3*index_v + 1], value);
-    data_ptr[3*index_v + 2] = 236;//fminf(data_ptr[3*index_v + 2], value);
-    //printf("count %d, samples per plot %d \n\r", count, samples_per_plot);
-    
-    if(count > samples_per_plot)
-    {
-        plot_ptr = data_ptr;
-        send_now = true;
-        plot_count++;
-    }
-        
+    volatile float* data_ptr = data_1;
+    data_ptr[index_v] = value;  
 }
diff -r ed208b547ef9 -r 761371998f16 plotter.h
--- a/plotter.h	Sun Oct 30 19:37:33 2016 +0000
+++ b/plotter.h	Sun Oct 30 22:30:34 2016 +0000
@@ -1,7 +1,7 @@
 #ifndef _plotter
 #define _plotter
 
-void init_plotter(int num_vars, int loop_freq, int plot_freq);
+void init_plotter(int num_vars);
 void plot(int index, float value);
 
 void send_message();