player 1
Dependencies: 4DGL-uLCD-SE PinDetect SparkfunAnalogJoystick mbed-rtos mbed SDFileSystem
Fork of 4180FinalLab by
Wireless 2 Player Pong game
Diff: huzzah.cpp
- Revision:
- 10:b57b3fbf8266
- Parent:
- 9:aa967c554d10
--- a/huzzah.cpp Thu Apr 28 20:08:23 2016 +0000 +++ b/huzzah.cpp Fri Apr 29 00:51:56 2016 +0000 @@ -2,11 +2,10 @@ #include "mbed.h" #include "rtos.h" -Huzzah::Huzzah(char *enterssid, char *enterpassword, Serial *esp, Serial *pc) { +Huzzah::Huzzah(char *enterssid, char *enterpassword, Serial *esp) { ssid = enterssid; // enter WiFi router ssid inside the quotes pwd = enterpassword; this->esp = esp; - this->pc= pc; //ESP=esp; // enter WiFi router password inside the quotes } //set ESP baudrate if necessary @@ -37,7 +36,6 @@ strcat(snd, "\")\r\n"); SendCMD(); Thread::wait(2000); - pc->printf("\r\nWifi Configurated"); } void Huzzah::SendCMD() @@ -52,53 +50,51 @@ strcpy(snd, "srv=net.createServer(net.TCP)\r\n"); SendCMD(); - Thread::wait(1000); + Thread::wait(500); strcpy(snd, "srv:listen(80,function(conn)\r\n"); SendCMD(); - Thread::wait(1000); + Thread::wait(500); strcpy(snd, "conn:on(\"receive\",function(conn,payload)\r\n"); SendCMD(); - Thread::wait(1000); + Thread::wait(500); strcpy(snd, "print(payload)\r\n"); SendCMD(); - Thread::wait(1000); + Thread::wait(500); strcpy(snd, "conn:send(\"<!DOCTYPE html>\")\r\n"); SendCMD(); - Thread::wait(1000); + Thread::wait(500); strcpy(snd, "conn:send(\"<html>\")\r\n"); SendCMD(); - Thread::wait(1000); + Thread::wait(500); strcpy(snd, "conn:send(\"<h1> PVP Wireless Pong High Scores</h1>\")\r\n"); SendCMD(); - Thread::wait(1000); + Thread::wait(500); sprintf(snd, "conn:send(\"<h2> Player 1 high score: %i, Player 2 High Score: %i </h2>\")\r\n",_highscore1, _highscore2); - pc->printf("\r\n%s",snd); SendCMD(); - wait(1); + Thread::wait(500); strcpy(snd, "conn:send(\"<h2> Great Job!</h2>\")\r\n"); SendCMD(); - Thread::wait(1000); + Thread::wait(500); strcpy(snd, "conn:send(\"</html>\")\r\n"); SendCMD(); - Thread::wait(1000); + Thread::wait(500); strcpy(snd, "end)\r\n"); SendCMD(); - Thread::wait(1000); + Thread::wait(500); strcpy(snd, "conn:on(\"sent\",function(conn) conn:close() end)\r\n"); SendCMD(); - Thread::wait(1000); + Thread::wait(500); strcpy(snd, "end)\r\n"); SendCMD(); - Thread::wait(1000); - pc->printf("\r\nwebpage is ready"); + Thread::wait(500); }