Chris Styles
/
AA_DemoBoard
main.cpp
- Committer:
- chris
- Date:
- 2009-09-18
- Revision:
- 0:bde94a805da1
File content as of revision 0:bde94a805da1:
#include "mbed.h" #include "HTTPServer.h" #include "HTTPRPC.h" #include "HTTPFS.h" #include "MobileLCD.h" #include "LIS302.h" #include "RFID.h" #include "RGBLED.h" #include "Servo.h" #include "usbhid.h" LocalFileSystem local("local"); Serial pc(USBTX, USBRX); InterruptIn RedButton(p30,"redbutton"); DigitalIn GreenButton(p29,"greenbutton"); DigitalIn BlueButton(p28,"bluebutton"); DigitalOut led1(LED1,"led1"); DigitalOut led2(LED2,"led2"); DigitalOut led3(LED3,"led3"); DigitalOut led4(LED4,"led4"); AnalogIn light(p16); AnalogIn pot(p20,"pot"); RFID rfid (NC,p27); MobileLCD lcd(p11, p12, p13, p14, p15); LIS302 acc (p5,p6,p7,p8); RGBLED rgb (p24,p22,p23); Servo servo (p21); usbhid hid; // Function for Rising ede of RedButton void RedRise () { led1 = !led1; } int main() { // Attach the interupt hander to RedButton RedButton.rise(&RedRise); // Print to LCD and the serial port lcd.printf("Hello World!"); pc.printf("Hello World!"); while (1) { // ---------------------------------- // Accelerometer example // ---------------------------------- /* float x = acc.x(); float y = acc.y(); float z = acc.z(); lcd.locate(0,0); lcd.printf("x=%0.3f ",x); lcd.locate(0,1); lcd.printf("y=%0.3f ",y); lcd.locate(0,2); lcd.printf("z=%0.3f ",z); wait (0.5); */ // ---------------------------------- // RFID Example // ---------------------------------- /* if (rfid.readable()) { int id=rfid.read(); lcd.cls(); lcd.printf("ID : %d",id); } */ // ---------------------------------- // Accelerometer example // ---------------------------------- /* float x = acc.x(); float y = acc.y(); float z = acc.z(); lcd.locate(0,0); lcd.printf("x=%0.3f ",x); lcd.locate(0,1); lcd.printf("y=%0.3f ",y); lcd.locate(0,2); lcd.printf("z=%0.3f ",z); wait (0.5); */ // ---------------------------------- // Servo example // ---------------------------------- /* servo=pot; wait (0.01); */ // ---------------------------------- // RGB LED example with accelerometer // ---------------------------------- /* rgb.red(abs(acc.x())); rgb.green(abs(acc.y())); rgb.blue(abs(acc.z())); */ // ---------------------------------- // Light sensor example // ---------------------------------- /* lcd.locate(0,0); lcd.printf("Light: %.2f ",light.read()); wait (0.2); */ // ---------------------------------- // USB HID // ---------------------------------- /* if (rfid.readable()) { int id; char msg[25]; id = rfid.read(); sprintf(msg,"Tag ID : %d\n",id); hid.keyboard(msg); } */ // ---------------------------------- // RPC over ethernet // ---------------------------------- // Create a HTTPServer on default Port HTTPServer *http = new HTTPServer(); // Register RPC in /rpc space http->addHandler(new HTTPRPC()); // HTTP File system http->addHandler(new HTTPFileSystemHandler("/", "/local/")); // Register the HTTPServer on the Network device (will hopfully disappear in the next Version) http->bind(); NetServer *net = NetServer::get(); lcd.locate(0,1); lcd.printf("%hhu.%hhu.%hhu.%hhu", (net->getIPAddr().addr)&0xFF, (net->getIPAddr().addr>>8)&0xFF, (net->getIPAddr().addr>>16)&0xFF, (net->getIPAddr().addr>>24)&0xFF); while(1) { http->poll(); } } }