save loops

Dependencies:   mbed

Committer:
mbedalvaro
Date:
Tue Dec 02 04:39:15 2014 +0000
Revision:
0:df6fdd9b99f0
this new version of skinGames will have a function that stops scanning as the laser reaches the same position (i.e., loops) with a certain precision. It is for extracting contours for Takashita project. It can then save on a file or send on osc

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedalvaro 0:df6fdd9b99f0 1
mbedalvaro 0:df6fdd9b99f0 2 /*
mbedalvaro 0:df6fdd9b99f0 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
mbedalvaro 0:df6fdd9b99f0 4
mbedalvaro 0:df6fdd9b99f0 5 Permission is hereby granted, free of charge, to any person obtaining a copy
mbedalvaro 0:df6fdd9b99f0 6 of this software and associated documentation files (the "Software"), to deal
mbedalvaro 0:df6fdd9b99f0 7 in the Software without restriction, including without limitation the rights
mbedalvaro 0:df6fdd9b99f0 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
mbedalvaro 0:df6fdd9b99f0 9 copies of the Software, and to permit persons to whom the Software is
mbedalvaro 0:df6fdd9b99f0 10 furnished to do so, subject to the following conditions:
mbedalvaro 0:df6fdd9b99f0 11
mbedalvaro 0:df6fdd9b99f0 12 The above copyright notice and this permission notice shall be included in
mbedalvaro 0:df6fdd9b99f0 13 all copies or substantial portions of the Software.
mbedalvaro 0:df6fdd9b99f0 14
mbedalvaro 0:df6fdd9b99f0 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
mbedalvaro 0:df6fdd9b99f0 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
mbedalvaro 0:df6fdd9b99f0 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
mbedalvaro 0:df6fdd9b99f0 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
mbedalvaro 0:df6fdd9b99f0 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mbedalvaro 0:df6fdd9b99f0 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
mbedalvaro 0:df6fdd9b99f0 21 THE SOFTWARE.
mbedalvaro 0:df6fdd9b99f0 22 */
mbedalvaro 0:df6fdd9b99f0 23
mbedalvaro 0:df6fdd9b99f0 24 #ifndef LWIPNETTCPSOCKET_H
mbedalvaro 0:df6fdd9b99f0 25 #define LWIPNETTCPSOCKET_H
mbedalvaro 0:df6fdd9b99f0 26
mbedalvaro 0:df6fdd9b99f0 27 #define NET_LWIP_STACK 1
mbedalvaro 0:df6fdd9b99f0 28 #include "if/net/nettcpsocket.h"
mbedalvaro 0:df6fdd9b99f0 29 #include "LwipNetIf.h"
mbedalvaro 0:df6fdd9b99f0 30
mbedalvaro 0:df6fdd9b99f0 31 #include "stdint.h"
mbedalvaro 0:df6fdd9b99f0 32
mbedalvaro 0:df6fdd9b99f0 33 //Implements NetTcpSockets over lwIP raw API
mbedalvaro 0:df6fdd9b99f0 34
mbedalvaro 0:df6fdd9b99f0 35 struct tcp_pcb; //Represents a Tcp Connection, "Protocol Control Block", see rawapi.txt & tcp.h
mbedalvaro 0:df6fdd9b99f0 36 struct pbuf; //Lwip Buffer Container
mbedalvaro 0:df6fdd9b99f0 37
mbedalvaro 0:df6fdd9b99f0 38 typedef signed char err_t;
mbedalvaro 0:df6fdd9b99f0 39 typedef uint16_t u16_t;
mbedalvaro 0:df6fdd9b99f0 40
mbedalvaro 0:df6fdd9b99f0 41 class LwipNetTcpSocket: public NetTcpSocket
mbedalvaro 0:df6fdd9b99f0 42 {
mbedalvaro 0:df6fdd9b99f0 43 public:
mbedalvaro 0:df6fdd9b99f0 44 LwipNetTcpSocket(tcp_pcb* pPcb = NULL); //Passes a pcb if already created (by an accept req for instance), in that case transfers ownership
mbedalvaro 0:df6fdd9b99f0 45 virtual ~LwipNetTcpSocket();
mbedalvaro 0:df6fdd9b99f0 46
mbedalvaro 0:df6fdd9b99f0 47 virtual NetTcpSocketErr bind(const Host& me);
mbedalvaro 0:df6fdd9b99f0 48 virtual NetTcpSocketErr listen();
mbedalvaro 0:df6fdd9b99f0 49 virtual NetTcpSocketErr connect(const Host& host);
mbedalvaro 0:df6fdd9b99f0 50 virtual NetTcpSocketErr accept(Host* pClient, NetTcpSocket** ppNewNetTcpSocket);
mbedalvaro 0:df6fdd9b99f0 51
mbedalvaro 0:df6fdd9b99f0 52 virtual int /*if < 0 : NetTcpSocketErr*/ send(const char* buf, int len);
mbedalvaro 0:df6fdd9b99f0 53 virtual int /*if < 0 : NetTcpSocketErr*/ recv(char* buf, int len);
mbedalvaro 0:df6fdd9b99f0 54
mbedalvaro 0:df6fdd9b99f0 55 virtual NetTcpSocketErr close();
mbedalvaro 0:df6fdd9b99f0 56
mbedalvaro 0:df6fdd9b99f0 57 virtual NetTcpSocketErr poll();
mbedalvaro 0:df6fdd9b99f0 58
mbedalvaro 0:df6fdd9b99f0 59 protected:
mbedalvaro 0:df6fdd9b99f0 60 volatile tcp_pcb* m_pPcb;
mbedalvaro 0:df6fdd9b99f0 61
mbedalvaro 0:df6fdd9b99f0 62 //Events callbacks from lwIp
mbedalvaro 0:df6fdd9b99f0 63 err_t acceptCb(tcp_pcb* newpcb, err_t err);
mbedalvaro 0:df6fdd9b99f0 64 err_t connectedCb(tcp_pcb* tpcb, err_t err);
mbedalvaro 0:df6fdd9b99f0 65
mbedalvaro 0:df6fdd9b99f0 66 void errCb(err_t err);
mbedalvaro 0:df6fdd9b99f0 67
mbedalvaro 0:df6fdd9b99f0 68 err_t sentCb(tcp_pcb* tpcb, u16_t len);
mbedalvaro 0:df6fdd9b99f0 69 err_t recvCb(tcp_pcb* tpcb, pbuf *p, err_t err);
mbedalvaro 0:df6fdd9b99f0 70
mbedalvaro 0:df6fdd9b99f0 71 private:
mbedalvaro 0:df6fdd9b99f0 72 void cleanUp(); //Flush input buffer
mbedalvaro 0:df6fdd9b99f0 73
mbedalvaro 0:df6fdd9b99f0 74 // queue<tcp_pcb*> m_lpInPcb; //Incoming connections that have not been accepted yet
mbedalvaro 0:df6fdd9b99f0 75 queue<LwipNetTcpSocket*> m_lpInNetTcpSocket; //Incoming connections that have not been accepted yet
mbedalvaro 0:df6fdd9b99f0 76
mbedalvaro 0:df6fdd9b99f0 77 volatile pbuf* m_pReadPbuf; //Ptr to read buffer
mbedalvaro 0:df6fdd9b99f0 78
mbedalvaro 0:df6fdd9b99f0 79 //Static callbacks : Transforms into a C++ callback
mbedalvaro 0:df6fdd9b99f0 80 static err_t sAcceptCb(void *arg, struct tcp_pcb *newpcb, err_t err);
mbedalvaro 0:df6fdd9b99f0 81 static err_t sConnectedCb(void *arg, struct tcp_pcb *tpcb, err_t err);
mbedalvaro 0:df6fdd9b99f0 82
mbedalvaro 0:df6fdd9b99f0 83 static void sErrCb(void *arg, err_t err);
mbedalvaro 0:df6fdd9b99f0 84
mbedalvaro 0:df6fdd9b99f0 85 static err_t sSentCb(void *arg, struct tcp_pcb *tpcb, u16_t len);
mbedalvaro 0:df6fdd9b99f0 86 static err_t sRecvCb(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err);
mbedalvaro 0:df6fdd9b99f0 87
mbedalvaro 0:df6fdd9b99f0 88 };
mbedalvaro 0:df6fdd9b99f0 89
mbedalvaro 0:df6fdd9b99f0 90 #endif