![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ハイパー・マイコン mbedでインターネット 電子工作 3章 リスト3-2 UDPJoystickのプログラム
Dependencies: EthernetInterface TextLCD mbed-rtos mbed
Revision 0:7990a8b069d4, committed 2014-07-09
- Comitter:
- sunifu
- Date:
- Wed Jul 09 14:08:42 2014 +0000
- Commit message:
- 2014.07.29
Changed in this revision
diff -r 000000000000 -r 7990a8b069d4 EthernetInterface.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetInterface.lib Wed Jul 09 14:08:42 2014 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/EthernetInterface/#6a67d2bddc7c
diff -r 000000000000 -r 7990a8b069d4 TextLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Wed Jul 09 14:08:42 2014 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
diff -r 000000000000 -r 7990a8b069d4 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jul 09 14:08:42 2014 +0000 @@ -0,0 +1,62 @@ +#include "mbed.h" +#include "EthernetInterface.h" +#include "TextLCD.h" + +#define SERVER_ADDRESS "192.168.0.7" +#define SERVER_PORT 55555 + +TextLCD lcd(p24,p26,p27,p28,p29,p30); + +AnalogIn ud(p19); +AnalogIn lr(p20); + +UDPSocket client; +Endpoint DataServer; +float udData,lrData; +char ipaddr[15]; + +unsigned int cnt = 1; + +void sendData(void const *arg) +{ + char out_buffer[42]; + + while(true) + { + Thread::wait(1000); + + sprintf(out_buffer,"%s,%u,%.2f,%.2f,",ipaddr,cnt,udData,lrData); + + client.sendTo(DataServer, out_buffer, sizeof(out_buffer)) ; + + printf("Send Data[%s]\r\n",out_buffer); + + lcd.locate(0,1); + lcd.printf("UD%0.2f : LR%0.2f",udData,lrData); + + cnt++; + } +} + +int main() { + EthernetInterface eth; + + eth.init(); + + eth.connect(); + + client.init(); + + DataServer.set_address(SERVER_ADDRESS, SERVER_PORT); + sprintf(ipaddr,"%s",eth.getIPAddress()); + + lcd.cls(); + lcd.locate(0,0); + lcd.printf("%s",ipaddr); + + Thread thread(sendData); + while(1) { + udData = ud; + lrData = lr; + } +}
diff -r 000000000000 -r 7990a8b069d4 mbed-rtos.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Wed Jul 09 14:08:42 2014 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed-rtos/#29007aef10a4
diff -r 000000000000 -r 7990a8b069d4 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jul 09 14:08:42 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f \ No newline at end of file