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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FTSE100.cpp Source File

FTSE100.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/dispBoBApp.php", &txt);   //load page into buffer
00022         if(r==HTTP_OK){
00023             string str = txt.gets();            //load web page into string
00024 
00025             char buf[10];                       //instantiate buffer and string to store FTSE100
00026             string value;                                  
00027             str.copy(buf,9,0);                  //load buffer with chunk of web page
00028 
00029             sscanf(buf, "%s", value);           //scan until decimal point
00030             
00031             db.scroll("FTSE100", 0.2);          //print info to dispBoB
00032             db.locate(0);
00033             db.printf("%s", value);                    
00034         }
00035         wait(2);                                //wait 2 seconds before looping, so we don't pester the servers too much
00036     }
00037 }
00038 
00039 
00040 
00041 
00042 
00043 
00044