mbed publishes real time up-to-date FTSE100 index data and posts it to a 7 segment multipurpose mbed breakout board

Dependencies:   EthernetNetIf dispBoB mbed

Committer:
d_worrall
Date:
Thu Jul 07 14:59:46 2011 +0000
Revision:
5:ce9188b5e787
Parent:
4:eaed26093c4c
version4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
d_worrall 0:60eb2e98d56c 1 #include "mbed.h"
d_worrall 0:60eb2e98d56c 2 #include "EthernetNetIf.h"
d_worrall 0:60eb2e98d56c 3 #include "HTTPClient.h"
d_worrall 0:60eb2e98d56c 4 #include "dispBoB.h"
d_worrall 3:4ccc72cfec87 5 #include "stdio.h"
d_worrall 0:60eb2e98d56c 6
d_worrall 0:60eb2e98d56c 7 EthernetNetIf eth;
d_worrall 0:60eb2e98d56c 8 HTTPClient http;
d_worrall 0:60eb2e98d56c 9 dispBoB db(p28, p27, p26);
d_worrall 0:60eb2e98d56c 10
d_worrall 0:60eb2e98d56c 11 int main() {
d_worrall 0:60eb2e98d56c 12
d_worrall 3:4ccc72cfec87 13 EthernetErr ethErr = eth.setup(); //Setup ethernet connection
d_worrall 3:4ccc72cfec87 14 if(ethErr) return -1;
d_worrall 3:4ccc72cfec87 15
d_worrall 3:4ccc72cfec87 16 db.init(); //initialise screen
d_worrall 0:60eb2e98d56c 17 db.cls();
d_worrall 0:60eb2e98d56c 18
d_worrall 3:4ccc72cfec87 19 HTTPText txt; //instantiate HTTPStream object
d_worrall 0:60eb2e98d56c 20 while(1){
d_worrall 3:4ccc72cfec87 21 HTTPResult r = http.get("http://mbed.net16.net/v1/dispBoBApp.php", &txt); //load page into buffer
d_worrall 0:60eb2e98d56c 22 if(r==HTTP_OK){
d_worrall 5:ce9188b5e787 23 string str = txt.gets(); //load web page into string
d_worrall 3:4ccc72cfec87 24
d_worrall 5:ce9188b5e787 25 char buf[10]; //instantiate buffer and string to store FTSE100
d_worrall 4:eaed26093c4c 26 string value;
d_worrall 3:4ccc72cfec87 27 str.copy(buf,9,0); //load buffer with chunk of web page
d_worrall 3:4ccc72cfec87 28
d_worrall 5:ce9188b5e787 29 sscanf(buf, "%s", value); //scan until decimal point
d_worrall 3:4ccc72cfec87 30
d_worrall 3:4ccc72cfec87 31 db.scroll("FTSE100", 0.2); //print info to dispBoB
d_worrall 4:eaed26093c4c 32 db.locate(0);
d_worrall 5:ce9188b5e787 33 db.printf("%s", value);
d_worrall 0:60eb2e98d56c 34 }
d_worrall 3:4ccc72cfec87 35 wait(2); //wait 2 seconds before looping, so we don't pester the servers too much
d_worrall 0:60eb2e98d56c 36 }
d_worrall 0:60eb2e98d56c 37 }
d_worrall 0:60eb2e98d56c 38
d_worrall 0:60eb2e98d56c 39
d_worrall 0:60eb2e98d56c 40
d_worrall 0:60eb2e98d56c 41
d_worrall 0:60eb2e98d56c 42
d_worrall 0:60eb2e98d56c 43
d_worrall 0:60eb2e98d56c 44