The MGC3130 is the world’s first electrical-field (E-field) based three-dimensional (3D) tracking and gesture controller

Dependencies:   BufferedArray

Dependents:   NucleoMGC3130 i2c_master

Files at this revision

API Documentation at this revision

Comitter:
yangcq88517
Date:
Sat Nov 14 15:44:44 2015 +0000
Parent:
7:eacd776fce29
Commit message:
change to unsigned char array

Changed in this revision

BufferedArray.lib Show annotated file Show diff for this revision Revisions of this file
GestILibrarMessage/BufferedArray.cpp Show diff for this revision Revisions of this file
GestILibrarMessage/BufferedArray.h Show diff for this revision Revisions of this file
GestILibrarMessage/GestICMsg.cpp Show annotated file Show diff for this revision Revisions of this file
Gesture/GestureInfo.cpp Show annotated file Show diff for this revision Revisions of this file
Gesture/GestureInfo.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BufferedArray.lib	Sat Nov 14 15:44:44 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/yangcq88517/code/BufferedArray/#765da30c4d9b
--- a/GestILibrarMessage/BufferedArray.cpp	Thu Oct 15 16:10:55 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-#include "BufferedArray.h"
-
-BufferedArray::BufferedArray()
-{
-    max = EXPANDSIZE;
-    data = new char[EXPANDSIZE];
-    index = 0;
-}
-
-BufferedArray::BufferedArray(int size)
-{
-    max = size;
-    data = new char[size];
-    index = 0;
-}
-
-BufferedArray::BufferedArray(BufferedArray * bufferedArray)
-{
-    this->data = bufferedArray->data;
-    this->index = bufferedArray->index;
-}
-
-BufferedArray::~BufferedArray()
-{
-    if (data == NULL)
-        return;
-
-    delete[] data;
-}
-
-char * BufferedArray::gets()
-{
-    return data;
-}
-
-char * BufferedArray::gets(int position)
-{
-    return data + position;
-}
-
-char BufferedArray::get(int position)
-{
-    return *(data + position);
-}
-
-int BufferedArray::getPosition()
-{
-    return index;
-}
-
-void BufferedArray::setPosition(int position)
-{
-    if (this->index > max)
-        this->index = max;
-    else this->index = position;
-}
-
-void BufferedArray::allocate(int length)
-{
-    if (length <= 0)
-        return;
-
-    if (length > max) {
-        delete[] data;
-        data = new char[length];
-    }
-
-    rewind();
-}
-
-void BufferedArray::rewind()
-{
-    index = 0;
-}
-
-void BufferedArray::expandSpace(int length)
-{
-    max += EXPANDSIZE * (1 + length / EXPANDSIZE);
-    char * temp = new char[max];
-    memcpy(temp, data, index);
-    delete[] data;
-    data = temp;
-}
-
-void BufferedArray::set(int position, char value)
-{
-    if (position < 0)
-        return;
-
-    if (position >= max)
-        expandSpace(1);
-
-    data[position] = value;
-}
-
-void BufferedArray::set(char value)
-{
-    set(index, value);
-    index++;
-}
-
-void BufferedArray::sets(const char * value, int offset, int length)
-{
-    if (length <= 0)
-        return;
-        
-    if (offset < 0)
-        return;
-
-    sets(index, value, offset, length);
-    index += length;
-}
-
-void BufferedArray::sets(int position, const char * value, int offset, int length)
-{
-    if (position < 0)
-        return;
-
-    if (length <= 0)
-        return;
-
-    if (offset < 0)
-        return;
-
-    if (position + length - offset > max)
-        expandSpace(position + length - offset - max);
-
-    memcpy(data + position, value + offset, length);
-}
\ No newline at end of file
--- a/GestILibrarMessage/BufferedArray.h	Thu Oct 15 16:10:55 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-#ifndef UK_AC_HERTS_SMARTLAB_BufferedArray
-#define UK_AC_HERTS_SMARTLAB_BufferedArray
-
-#include "mbed.h"
-
-/**
-* Represent a generic, dynamic-length raw binary data buffer.
-*/
-class BufferedArray
-{
-protected :
-    /// initial size and automatically increase length.
-    static const int EXPANDSIZE = 20;
-
-    /// Raw data
-    char * data;
-
-    /// Current index of the data, could also used as data lendth.
-    int index;
-
-    /// Max data size that the raw data can hold.
-    int max;
-    
-    void expandSpace(int length);
-
-public:
-    BufferedArray();
-    
-    BufferedArray(int size);
-
-    BufferedArray(BufferedArray * bufferedArray);
-    
-    ~BufferedArray();
-
-    /** Get the raw data.
-    * @returns char array.
-    */
-    char * gets();
-        
-    /** Get the raw data from a specific location.
-    *
-    * @param position where to retrieve
-    *
-    * @returns char array.
-    */
-    char * gets(int position);
-           
-    /** Get 1 byte data from a specific location.
-    *
-    * @param position where to retrieve
-    *
-    * @returns char.
-    */
-    char get(int position);
-
-    /** Get the current index.
-    * @returns char array.
-    */
-    int getPosition();
-
-    /** Set the index within the max length of raw data.
-    * @param position where to begin read and write
-    */
-    void setPosition(int position);
-
-    /** Reset the raw data.
-    * @param length current max size for the raw data
-    */
-    void allocate(int length);
-
-    /** Reset the position and does not affect the content of the data.
-    * @param length current max size for the raw data
-    */
-    void rewind();
-    
-    /** Write 8-bit data into current posiston and increase by 1.
-    * @param value sigle byte
-    */
-    void set(char value);
-
-    /** Write array of data into current posiston, and increase by the lenght.
-    * @param value array of byte
-    * @param offset start point of the data
-    * @param length length to write
-    */
-    void sets(const char * value, int offset, int length);
-
-    /** Write 8-bit data into specific posiston and deos not affect the current position.
-    * @param position where to write
-    * @param value sigle byte
-    */
-    void set(int position, char value);
-
-    /** Write array of data into specific posiston and deos not affect the current position.
-    * @param position where to write
-    * @param value array of byte
-    * @param offset start point of the data
-    * @param length length to write
-    */
-    void sets(int position, const char * value, int offset, int length);
-};
-
-#endif
--- a/GestILibrarMessage/GestICMsg.cpp	Thu Oct 15 16:10:55 2015 +0000
+++ b/GestILibrarMessage/GestICMsg.cpp	Sat Nov 14 15:44:44 2015 +0000
@@ -1,6 +1,6 @@
 #include "GestICMsg.h"
 
-GestICMsg::GestICMsg(): BufferedArray()
+GestICMsg::GestICMsg(): BufferedArray(20,20)
 {}
 
 int GestICMsg::getMsgSize()
--- a/Gesture/GestureInfo.cpp	Thu Oct 15 16:10:55 2015 +0000
+++ b/Gesture/GestureInfo.cpp	Sat Nov 14 15:44:44 2015 +0000
@@ -1,6 +1,6 @@
 #include "GestureInfo.h"
 
-void GestureInfo::set(char * value)
+void GestureInfo::set(unsigned char * value)
 {
     data = value;
 }
--- a/Gesture/GestureInfo.h	Thu Oct 15 16:10:55 2015 +0000
+++ b/Gesture/GestureInfo.h	Sat Nov 14 15:44:44 2015 +0000
@@ -12,14 +12,14 @@
 private:
 
     /// 4 bytes gesture information.
-    char * data;
+    unsigned char * data;
 public:
 
     /** Set the internal memory, used by API itself.
     *
     * @param value 4 bytes char array
     */
-    void set(char * value);
+    void set(unsigned char * value);
 
     /** Get the recognized gesture information.
     *