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
FTSE100.cpp
- Committer:
- d_worrall
- Date:
- 2011-07-07
- Revision:
- 3:4ccc72cfec87
- Parent:
- 2:0fa458722bc3
- Child:
- 4:eaed26093c4c
File content as of revision 3:4ccc72cfec87:
#include "mbed.h" #include "EthernetNetIf.h" #include "HTTPClient.h" #include "dispBoB.h" #include "stdio.h" EthernetNetIf eth; HTTPClient http; dispBoB db(p28, p27, p26); int main() { EthernetErr ethErr = eth.setup(); //Setup ethernet connection if(ethErr) return -1; db.init(); //initialise screen db.cls(); HTTPText txt; //instantiate HTTPStream object while(1){ HTTPResult r = http.get("http://mbed.net16.net/v1/dispBoBApp.php", &txt); //load page into buffer if(r==HTTP_OK){ string str = txt.gets(); //load web page intop string char buf[10]; //instantiate buffer and integer to store FTSE100 int value; str.copy(buf,9,0); //load buffer with chunk of web page sscanf(buf, "%d", &value); //scan until decimal point db.scroll("FTSE100", 0.2); //print info to dispBoB db.locate(1); db.printf("%d", value); } wait(2); //wait 2 seconds before looping, so we don't pester the servers too much } }