
Stream messages which you type into an internet app straight to the dispBoB!
Dependencies: EthernetNetIf dispBoB mbed
InternetDispBoB.cpp
00001 #include "mbed.h" 00002 #include "EthernetNetIf.h" 00003 #include "HTTPClient.h" 00004 #include "dispBoB.h" 00005 #include "stdio.h" 00006 00007 EthernetNetIf eth; 00008 HTTPClient http; 00009 dispBoB db(p28, p27, p26); 00010 00011 int main() { 00012 00013 EthernetErr ethErr = eth.setup(); //Setup ethernet connection 00014 if(ethErr) return -1; 00015 00016 db.init(); //initialise screen 00017 db.cls(); 00018 00019 HTTPText txt; //instantiate HTTPStream object 00020 while(1){ 00021 HTTPResult r = http.get("http://mbed.net16.net/v1/messageEcho.php", &txt); //load page into buffer 00022 if(r==HTTP_OK){ 00023 string str = txt.gets(); //load web page intop string 00024 00025 char buf[100]; //instantiate buffer for message 00026 int i = 0; //instantiate integer for iterator 00027 do{ 00028 buf[i] = str[i]; //copy characters into buffer until end of buffer 00029 i++; //or newline tag 00030 } while ((i<100)&&(str[i]!='\n')); 00031 00032 db.scroll(buf, 0.2); //scroll message 00033 } 00034 wait(2); //wait 2 seconds before looping, so we don't pester the servers too much 00035 } 00036 } 00037 00038 00039 00040 00041 00042 00043 00044
Generated on Sun Jul 17 2022 01:31:15 by
