Revision:
2:7f104b72b5eb
Parent:
1:b5ab54497d2a
Child:
3:7ef4c240d5e3
diff -r b5ab54497d2a -r 7f104b72b5eb circular_buffer.h
--- a/circular_buffer.h	Mon Jan 30 21:33:18 2012 +0000
+++ b/circular_buffer.h	Mon Jan 30 22:17:58 2012 +0000
@@ -6,11 +6,21 @@
 #define OVERWRITE_ENABLE    1
 #define SEEK_ENABLE         2
 
-/*! Circular Buffers
-    Use init function to initialise (no constructor functions here)
-    buffstart to point to start of memory allocated elsewhere through malloc, float num[SIZE] etc.
+/** Classes circular_buffer_f and circular_buffer_c
+*
+*   Example use:-
+*
+*   circular_buffer_f   readings;   //  create  instance of circular_buffer_f
+*
+*   main    ()  {
+*   float buff[BUF_SIZE];           //  allocate memory for circular buffer_f
+*       //  Use init function to initialise (no constructor functions here)
+*   readings.init(BUF_SIZE, buff, SEEK_ENABLE | OVERWRITE_ENABLE);
+*   //  readings buffer now ready to use
+*   //  
+*   }
+*    buffstart to point to start of memory allocated elsewhere through malloc, float num[SIZE] etc.
 */
-
 class circular_buffer_f   {     //  Circular buffer of floats
     float   *buffbase, *Onbuff, *Offbuff, *buffend;
     int     buffsize;
@@ -18,13 +28,37 @@
             overwrite_enable,   // To allow new data to overwrite old, unread data
             seek_enable;        // To allow read pointer repositioning 'n' behind current newest
     public:
+
+/** readable() returns true if stuff is in buffer to be read
+*   writeable() returns true if space exists in buffer to write more
+*/
     bool    readable    ()  {return !emptyf;}
     bool    writeable   ()  {return !fullf;}
     
+/** init used to setup buffer size, buffer mem address, and flaged options
+*
+*/
     void    init    (int size, float *buffstart, int flags);  // Size and address of buffer to work with
+
+/** Set read pointer to some distance_back in prep for multiple read using get_samps
+*
+*/
     bool    seek    (int distance_back) ;   // Assumes at least that much has been written to buff beforehand
+
+/** Write places one sample into buffer
+*
+*/
     bool    write   (float a)  ;     // Put value into circular buffer
+
+/** Read one sample out from buffer
+*
+*/
     bool    read    (float *rd)  ;
+
+
+/** get_samps reads len samples from buffer into destination array
+*
+*/
     bool    get_samps (float *dest, int len) ;
 }  ; // end of class circular_buffer_f