Temp Fork
Dependencies: MMA8451Q Multi_WS2811 NVIC_set_all_priorities TSI cc3000_hostdriver_mbedsocket mbed
Fork of CubicHand by
Diff: main.cpp
- Revision:
- 3:5f5d75cba8e1
- Parent:
- 1:587189fb6d87
- Child:
- 13:c701f1122797
--- a/main.cpp Mon Dec 01 05:43:35 2014 +0000 +++ b/main.cpp Fri Dec 05 21:35:37 2014 +0000 @@ -1,108 +1,18 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "mbed.h" -#include "cc3000.h" -#include "main.h" -#include "MMA8451Q.h" -#include "TSISensor.h" - -#include "TCPSocketConnection.h" -#include "TCPSocketServer.h" - -using namespace mbed_cc3000; -//#define SSID "wifiisawesome" -//#define PASSWORD "A915FA24" - -#define SSID "CubeNet" -#define PASSWORD "modelbased" - -#define MMA8451_I2C_ADDRESS (0x1d<<1) +#include "mbed.h" +#include "main.h" +#include "DataGlove.h" -/* cc3000 module declaration specific for user's board. Check also init() -#if (MY_BOARD == WIGO) -cc3000 wifi(PTA16, PTA13, PTD0, SPI(PTD2, PTD3, PTC5), SSID, PASSWORD, WPA2, false); -Serial pc(USBTX, USBRX); -#elif (MY_BOARD == WIFI_DIPCORTEX) -cc3000 wifi(p28, p27, p30, SPI(p21, p14, p37), SSID, PASSWORD, WPA2, false); -Serial pc(UART_TX, UART_RX); -#elif (MY_BOARD == MBED_BOARD_EXAMPLE) -cc3000 wifi(p9, p10, p8, SPI(p5, p6, p7), SSID, PASSWORD, WPA2, false); -Serial pc(USBTX, USBRX); -#else -#endif -*/ - -cc3000 wifi(PTD4, PTC9, PTD0, SPI(PTD2, PTD3, PTD1), SSID, PASSWORD, WPA2, false); -Serial pc(USBTX, USBRX); +DataGlove MasterGlove; -MMA8451Q accelerometer(PTE25, PTE24, MMA8451_I2C_ADDRESS); -TSISensor touchSensor; - -/** - * \brief TCP client demo - * \param none - * \return int - */ -int main() { - float data[4]; - - init(); /* board dependent init */ - pc.baud(115200); - - printf("cc3000 tcp client demo. \r\n"); - wifi.init(); - if (wifi.connect() == -1) { - printf("Failed to connect. Please verify connection details and try again. \r\n"); - } else { - printf("IP address: %s \r\n", wifi.getIPAddress()); - } - - const char* ECHO_SERVER_ADDRESS = "192.168.1.33"; - const int ECHO_SERVER_PORT = 2000; - - TCPSocketConnection socket; - while (socket.connect(ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT) < 0) { - printf("Unable to connect to (%s) on port (%d) \r\n", ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT); - wait(1); +int main() +{ + MasterGlove.Init(); + printf("DataGlove Cube Client\r\n"); + while(true) + { + MasterGlove.Receive(); + printf("Looping \r\n"); } - socket.set_blocking(true); - printf("Connected!\r\n"); - char sendb[50]; - sendb[0] = '$'; - sendb[1] = 0x0A; - sendb[2] = 0x03; - sendb[3] = 3; - sendb[4] = (sendb[0]+sendb[1]+sendb[2]+sendb[3])%256; - sendb[5] = '#'; - socket.send(sendb, 6); - printf("Sent!\r\n"); - char Buf[100]; - while(true) { - int numReceived = 5; - //accelerometer.getAccAllAxis(data); - //data[3] = touchSensor.readPercentage(); - //socket.send_all((char*)data, 4*sizeof(float)); - //wait(0.2); - numReceived = socket.receive(Buf, 99); - if(numReceived > 0 && Buf[0] == '$') printf("Accel: %d\r\n", ((int16_t *)Buf)[33]); - } - - socket.close(); - printf("Completed. \r\n"); - wifi.disconnect(); }