Buffer for general purpose use. Templated for most datatypes
Dependents: BufferedSoftSerial 09_PT1000 10_PT1000 11_PT1000 ... more
Example
#include "mbed.h" #include "Buffer.h" Buffer <char> buf; int main() { buf = 'a'; buf.put('b'); char *head = buf.head(); puts(head); char whats_in_there[2] = {0}; int pos = 0; while(buf.available()) { whats_in_there[pos++] = buf; } printf("%c %c\n", whats_in_there[0], whats_in_there[1]); buf.clear(); error("done\n\n\n"); }
Diff: Buffer.h
- Revision:
- 5:7b754354b99c
- Parent:
- 4:cd0a1f4c623f
--- a/Buffer.h Wed Jun 26 15:24:27 2013 +0000 +++ b/Buffer.h Wed Jan 07 18:34:56 2015 +0000 @@ -72,6 +72,11 @@ */ Buffer(uint32_t size = 0x100); + /** Get the size of the ring buffer + * @return the size of the ring buffer + */ + uint32_t getSize(); + /** Destry a Buffer and release it's allocated memory */ ~Buffer();