the place we got to by the end of the last session
Dependencies: LCDTFT TFT_fonts TSI mbed
Fork of ESP8266_MDM_CJS_KL25 by
Diff: main.cpp
- Revision:
- 4:354d278c0d52
- Parent:
- 3:2b5f88cf893d
- Child:
- 5:882898bb83ed
--- a/main.cpp Fri Jun 10 09:54:48 2016 +0000 +++ b/main.cpp Fri Jun 10 10:38:32 2016 +0000 @@ -1,5 +1,8 @@ #include "mbed.h" #include "TSISensor.h" +#include "LCDTFT.h" +#include "Arial28x28.h" + #define DEBUG #define INFOMESSAGES #define WARNMESSAGES @@ -35,10 +38,14 @@ // PIN DEFS NOW FOR OLD FIRMWARE VERSION OF THE KL25Z Serial pc(USBTX, USBRX); //RawSerial dev(D1, D0); -Serial dev(PTD3,PTD2); //tx,rx +//Serial dev(PTD3,PTD2); //tx,rx +Serial dev(D14,D15); //tx,rx DigitalOut led1(LED1); DigitalOut led4(LED3); // CHANGE TO LED 3 -DigitalOut reset(PTA13,1); +DigitalOut reset(D0,1); + +PortOut MyPort(PortD ,0xFF); // define a port with only the lower 8 bits included - that'llbe PTD0-PTD7 making a single 8 bit port. +LCDTFT MyLCD(PTB0,PTB1,PTB2,PTB3,PTC2,&MyPort);//LCDTFT(PinName PIN_RD,PinName PIN_WR,PinName PIN_RS,PinName PIN_CS,PinName PIN_RESET, PortOut *PORTLCD); PwmOut led(LED_GREEN); @@ -114,6 +121,23 @@ } return p; } +/*Game programme +*/ + void commandReceived(char* buffer){ + char identifier =buffer[0]; + if (identifier == 1) { + newFoodDirect=buffer[4]; + newFoodVel=buffer[8]; + } + + if (identifier == 2) { + newSnakeDirect=buffer[4]; + } + + if (identifier == 3) { + GameRunning=buffer[4]; + } + int main() { float touch; @@ -210,13 +234,27 @@ resp=OKResponse(buffer,"OK"); if (resp!=NULL) { INFO("Ready"); - dev.printf("AT+CIPSTART=4,\"TCP\",\"192.168.1.3\",8080\r\n"); + dev.printf("AT+CIPSERVER=1,5050\r\n"); //Set it as a server state++; } break; - } + } + case 9: { + resp=OKResponse(buffer,"+IPD"); + if (resp!=NULL) { + INFO("Got <%s>",buffer); + commandReceived(buffer); // Interpret data, line 119 + state=9; // Keep on waiting for data + } + + + + break; + } + + /* case 9: { resp=OKResponse(buffer,"OK"); if (resp!=NULL) { INFO("Ready"); @@ -248,7 +286,7 @@ } break; - } + }*/ }