The MGC3130 is the world’s first electrical-field (E-field) based three-dimensional (3D) tracking and gesture controller
Dependents: NucleoMGC3130 i2c_master
Revision 7:eacd776fce29, committed 2015-10-15
- Comitter:
- yangcq88517
- Date:
- Thu Oct 15 16:10:55 2015 +0000
- Parent:
- 6:b511421e7dc8
- Child:
- 8:de7934ec7ea2
- Commit message:
- add sample code
Changed in this revision
--- a/GestILibrarMessage/BufferedArray.cpp Tue Oct 13 19:59:27 2015 +0000 +++ b/GestILibrarMessage/BufferedArray.cpp Thu Oct 15 16:10:55 2015 +0000 @@ -7,6 +7,13 @@ index = 0; } +BufferedArray::BufferedArray(int size) +{ + max = size; + data = new char[size]; + index = 0; +} + BufferedArray::BufferedArray(BufferedArray * bufferedArray) { this->data = bufferedArray->data; @@ -92,7 +99,7 @@ index++; } -void BufferedArray::sets(char * value, int offset, int length) +void BufferedArray::sets(const char * value, int offset, int length) { if (length <= 0) return; @@ -104,7 +111,7 @@ index += length; } -void BufferedArray::sets(int position, char * value, int offset, int length) +void BufferedArray::sets(int position, const char * value, int offset, int length) { if (position < 0) return;
--- a/GestILibrarMessage/BufferedArray.h Tue Oct 13 19:59:27 2015 +0000 +++ b/GestILibrarMessage/BufferedArray.h Thu Oct 15 16:10:55 2015 +0000 @@ -3,6 +3,9 @@ #include "mbed.h" +/** +* Represent a generic, dynamic-length raw binary data buffer. +*/ class BufferedArray { protected : @@ -22,6 +25,8 @@ public: BufferedArray(); + + BufferedArray(int size); BufferedArray(BufferedArray * bufferedArray); @@ -78,7 +83,7 @@ * @param offset start point of the data * @param length length to write */ - void sets(char * value, int offset, int length); + 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 @@ -92,7 +97,7 @@ * @param offset start point of the data * @param length length to write */ - void sets(int position, char * value, int offset, int length); + void sets(int position, const char * value, int offset, int length); }; #endif
--- a/GestILibrarMessage/SensorData.cpp Tue Oct 13 19:59:27 2015 +0000 +++ b/GestILibrarMessage/SensorData.cpp Thu Oct 15 16:10:55 2015 +0000 @@ -7,7 +7,7 @@ SensorData::SensorData(GestICMsg * msg) :GestICMsg(), touch(), gesture() { - data = msg->gets(0); + data = msg->gets(); process(); } @@ -19,7 +19,7 @@ if (msg->getID() != Sensor_Data_Output) return false; - data = msg->gets(0); + data = msg->gets(); process(); return true; }
--- a/MGC3130.h Tue Oct 13 19:59:27 2015 +0000 +++ b/MGC3130.h Thu Oct 15 16:10:55 2015 +0000 @@ -17,6 +17,91 @@ /** * Outlines the function of the Library’s I2C message interface, and contains the complete message reference to control and operate the MGC3X30 system. + * + * Example: + * @code +*#include "mbed.h" +*#include "MGC3130.h" +* +*SensorData * msg = NULL; +* +*void init() +*{ +* AirWheelDetection air(true); +* device.setRuntimeParameter(&air); +* +* TouchDetection touch(true); +* device.setRuntimeParameter(&touch); +* +* OutputEnable setting; +* setting.enableGestureData(true)->enableTouchInfo(true)->enableAirWheelInfo(true)->enableNoisePower(false) +* ->enablexyzPosition(false)->enableDSPStatus(false)->enableUncalibratedSignal(false)->enableSignalDeviation(false); +* device.setRuntimeParameter(&setting); +*} +* +*void touch() +*{ +* TouchInfo * info = msg->getTouchInfo(); +* +* if (info == NULL) +* return; +* +* if (info->isTapCenterElectrode() == false) +* return; +*} +* +*void airWheel() +*{ +* int * wheel = msg->getAirWheelInfo(); +* if (wheel == NULL) +* return; +*} +* +*void gesture() +*{ +* GestureInfo * info = msg->getGestureInfo(); +* +* if (info == NULL) +* return; +* +* switch (info->getRecognizedGesture()) { +* //Garbage Model +* case 1 : +* break; +* //Flick West To East +* case 2 : +* break; +* //Flick East To West +* case 3 : +* break; +* //Flick South To North +* case 4 : +* break; +* //Flick North To South +* case 5 : +* break; +* } +*} +* +*int main() +*{ +* init(); +* +* while(1) { +* msg = device.readSensorData(); +* +* if (msg == NULL) +* continue; +* +* touch(); +* +* gesture(); +* +* airWheel(); +* } +*} + * @endcode + * */ class MGC3130 {