mbed(エンベッド)の仕組みを学び、試作体験!用のサンプル
Dependencies: BD6211F Milkcocoa-os
Fork of MilkcocoaOsSample_Eth by
Revision 7:1d4b77d3eed4, committed 2017-08-07
- Comitter:
- jksoft
- Date:
- Mon Aug 07 07:08:25 2017 +0000
- Parent:
- 6:d2dcba3c77f0
- Commit message:
- First edition
Changed in this revision
BD6211F.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BD6211F.lib Mon Aug 07 07:08:25 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/jksoft/code/BD6211F/#e27bf165308f
--- a/main.cpp Thu Jun 01 05:38:12 2017 +0000 +++ b/main.cpp Mon Aug 07 07:08:25 2017 +0000 @@ -1,14 +1,16 @@ #include "mbed.h" #include "Milkcocoa.h" #include "EthernetInterface.h" +#include "BD6211F.h" EthernetInterface eth; RawSerial pc(USBTX,USBRX); +BD6211F motor(D6,D7); /************************* Your Milkcocoa Setup *********************************/ #define MILKCOCOA_APP_ID "...YOUR_MILKCOCOA_APP_ID..." -#define MILKCOCOA_DATASTORE "mbed_lan" +#define MILKCOCOA_DATASTORE "motor" /************* Milkcocoa Setup (you don't need to change this!) ******************/ @@ -21,6 +23,7 @@ extern void onpush(MQTT::MessageData& md); int main() { + motor = 0.0; pc.baud(9600); pc.printf("Milkcocoa mbed os ver demo\n\r\n\r\n\r"); @@ -38,28 +41,18 @@ pc.printf("%d\n\r",milkcocoa->on(MILKCOCOA_DATASTORE, "push", onpush)); -#ifdef __MILKCOCOA_THREAD - milkcocoa->setLoopCycle(5000); - milkcocoa->start(); -#endif while(1) { - DataElement elem = DataElement(); - elem.setValue("v", 1); - - milkcocoa->push(MILKCOCOA_DATASTORE, elem); - -#ifndef __MILKCOCOA_THREAD milkcocoa->loop(); -#endif - Thread::wait(7000); - } } void onpush(MQTT::MessageData& md) { + int control = 0; MQTT::Message &message = md.message; DataElement de = DataElement((char*)message.payload); - pc.printf("onpush\n\r"); - pc.printf("%d\n\r",de.getInt("v")); + control = de.getInt("Control"); + pc.printf("%d\n\r",de.getInt("Control")); + + motor = (float)control / 100.0; } \ No newline at end of file