The MGC3130 is the world’s first electrical-field (E-field) based three-dimensional (3D) tracking and gesture controller
Dependents: NucleoMGC3130 i2c_master
GestILibrarMessage/BufferedArray.h@6:b511421e7dc8, 2015-10-13 (annotated)
- Committer:
- yangcq88517
- Date:
- Tue Oct 13 19:59:27 2015 +0000
- Revision:
- 6:b511421e7dc8
- Child:
- 7:eacd776fce29
bug fix
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yangcq88517 | 6:b511421e7dc8 | 1 | #ifndef UK_AC_HERTS_SMARTLAB_BufferedArray |
yangcq88517 | 6:b511421e7dc8 | 2 | #define UK_AC_HERTS_SMARTLAB_BufferedArray |
yangcq88517 | 6:b511421e7dc8 | 3 | |
yangcq88517 | 6:b511421e7dc8 | 4 | #include "mbed.h" |
yangcq88517 | 6:b511421e7dc8 | 5 | |
yangcq88517 | 6:b511421e7dc8 | 6 | class BufferedArray |
yangcq88517 | 6:b511421e7dc8 | 7 | { |
yangcq88517 | 6:b511421e7dc8 | 8 | protected : |
yangcq88517 | 6:b511421e7dc8 | 9 | /// initial size and automatically increase length. |
yangcq88517 | 6:b511421e7dc8 | 10 | static const int EXPANDSIZE = 20; |
yangcq88517 | 6:b511421e7dc8 | 11 | |
yangcq88517 | 6:b511421e7dc8 | 12 | /// Raw data |
yangcq88517 | 6:b511421e7dc8 | 13 | char * data; |
yangcq88517 | 6:b511421e7dc8 | 14 | |
yangcq88517 | 6:b511421e7dc8 | 15 | /// Current index of the data, could also used as data lendth. |
yangcq88517 | 6:b511421e7dc8 | 16 | int index; |
yangcq88517 | 6:b511421e7dc8 | 17 | |
yangcq88517 | 6:b511421e7dc8 | 18 | /// Max data size that the raw data can hold. |
yangcq88517 | 6:b511421e7dc8 | 19 | int max; |
yangcq88517 | 6:b511421e7dc8 | 20 | |
yangcq88517 | 6:b511421e7dc8 | 21 | void expandSpace(int length); |
yangcq88517 | 6:b511421e7dc8 | 22 | |
yangcq88517 | 6:b511421e7dc8 | 23 | public: |
yangcq88517 | 6:b511421e7dc8 | 24 | BufferedArray(); |
yangcq88517 | 6:b511421e7dc8 | 25 | |
yangcq88517 | 6:b511421e7dc8 | 26 | BufferedArray(BufferedArray * bufferedArray); |
yangcq88517 | 6:b511421e7dc8 | 27 | |
yangcq88517 | 6:b511421e7dc8 | 28 | ~BufferedArray(); |
yangcq88517 | 6:b511421e7dc8 | 29 | |
yangcq88517 | 6:b511421e7dc8 | 30 | /** Get the raw data. |
yangcq88517 | 6:b511421e7dc8 | 31 | * @returns char array. |
yangcq88517 | 6:b511421e7dc8 | 32 | */ |
yangcq88517 | 6:b511421e7dc8 | 33 | char * gets(); |
yangcq88517 | 6:b511421e7dc8 | 34 | |
yangcq88517 | 6:b511421e7dc8 | 35 | /** Get the raw data from a specific location. |
yangcq88517 | 6:b511421e7dc8 | 36 | * |
yangcq88517 | 6:b511421e7dc8 | 37 | * @param position where to retrieve |
yangcq88517 | 6:b511421e7dc8 | 38 | * |
yangcq88517 | 6:b511421e7dc8 | 39 | * @returns char array. |
yangcq88517 | 6:b511421e7dc8 | 40 | */ |
yangcq88517 | 6:b511421e7dc8 | 41 | char * gets(int position); |
yangcq88517 | 6:b511421e7dc8 | 42 | |
yangcq88517 | 6:b511421e7dc8 | 43 | /** Get 1 byte data from a specific location. |
yangcq88517 | 6:b511421e7dc8 | 44 | * |
yangcq88517 | 6:b511421e7dc8 | 45 | * @param position where to retrieve |
yangcq88517 | 6:b511421e7dc8 | 46 | * |
yangcq88517 | 6:b511421e7dc8 | 47 | * @returns char. |
yangcq88517 | 6:b511421e7dc8 | 48 | */ |
yangcq88517 | 6:b511421e7dc8 | 49 | char get(int position); |
yangcq88517 | 6:b511421e7dc8 | 50 | |
yangcq88517 | 6:b511421e7dc8 | 51 | /** Get the current index. |
yangcq88517 | 6:b511421e7dc8 | 52 | * @returns char array. |
yangcq88517 | 6:b511421e7dc8 | 53 | */ |
yangcq88517 | 6:b511421e7dc8 | 54 | int getPosition(); |
yangcq88517 | 6:b511421e7dc8 | 55 | |
yangcq88517 | 6:b511421e7dc8 | 56 | /** Set the index within the max length of raw data. |
yangcq88517 | 6:b511421e7dc8 | 57 | * @param position where to begin read and write |
yangcq88517 | 6:b511421e7dc8 | 58 | */ |
yangcq88517 | 6:b511421e7dc8 | 59 | void setPosition(int position); |
yangcq88517 | 6:b511421e7dc8 | 60 | |
yangcq88517 | 6:b511421e7dc8 | 61 | /** Reset the raw data. |
yangcq88517 | 6:b511421e7dc8 | 62 | * @param length current max size for the raw data |
yangcq88517 | 6:b511421e7dc8 | 63 | */ |
yangcq88517 | 6:b511421e7dc8 | 64 | void allocate(int length); |
yangcq88517 | 6:b511421e7dc8 | 65 | |
yangcq88517 | 6:b511421e7dc8 | 66 | /** Reset the position and does not affect the content of the data. |
yangcq88517 | 6:b511421e7dc8 | 67 | * @param length current max size for the raw data |
yangcq88517 | 6:b511421e7dc8 | 68 | */ |
yangcq88517 | 6:b511421e7dc8 | 69 | void rewind(); |
yangcq88517 | 6:b511421e7dc8 | 70 | |
yangcq88517 | 6:b511421e7dc8 | 71 | /** Write 8-bit data into current posiston and increase by 1. |
yangcq88517 | 6:b511421e7dc8 | 72 | * @param value sigle byte |
yangcq88517 | 6:b511421e7dc8 | 73 | */ |
yangcq88517 | 6:b511421e7dc8 | 74 | void set(char value); |
yangcq88517 | 6:b511421e7dc8 | 75 | |
yangcq88517 | 6:b511421e7dc8 | 76 | /** Write array of data into current posiston, and increase by the lenght. |
yangcq88517 | 6:b511421e7dc8 | 77 | * @param value array of byte |
yangcq88517 | 6:b511421e7dc8 | 78 | * @param offset start point of the data |
yangcq88517 | 6:b511421e7dc8 | 79 | * @param length length to write |
yangcq88517 | 6:b511421e7dc8 | 80 | */ |
yangcq88517 | 6:b511421e7dc8 | 81 | void sets(char * value, int offset, int length); |
yangcq88517 | 6:b511421e7dc8 | 82 | |
yangcq88517 | 6:b511421e7dc8 | 83 | /** Write 8-bit data into specific posiston and deos not affect the current position. |
yangcq88517 | 6:b511421e7dc8 | 84 | * @param position where to write |
yangcq88517 | 6:b511421e7dc8 | 85 | * @param value sigle byte |
yangcq88517 | 6:b511421e7dc8 | 86 | */ |
yangcq88517 | 6:b511421e7dc8 | 87 | void set(int position, char value); |
yangcq88517 | 6:b511421e7dc8 | 88 | |
yangcq88517 | 6:b511421e7dc8 | 89 | /** Write array of data into specific posiston and deos not affect the current position. |
yangcq88517 | 6:b511421e7dc8 | 90 | * @param position where to write |
yangcq88517 | 6:b511421e7dc8 | 91 | * @param value array of byte |
yangcq88517 | 6:b511421e7dc8 | 92 | * @param offset start point of the data |
yangcq88517 | 6:b511421e7dc8 | 93 | * @param length length to write |
yangcq88517 | 6:b511421e7dc8 | 94 | */ |
yangcq88517 | 6:b511421e7dc8 | 95 | void sets(int position, char * value, int offset, int length); |
yangcq88517 | 6:b511421e7dc8 | 96 | }; |
yangcq88517 | 6:b511421e7dc8 | 97 | |
yangcq88517 | 6:b511421e7dc8 | 98 | #endif |