Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of RCControlOOP by
WirelessMousr.cpp
- Committer:
- mfillinois
- Date:
- 2014-09-08
- Revision:
- 0:78e2af20cbf3
- Child:
- 1:e694ee3b4a7f
File content as of revision 0:78e2af20cbf3:
#include "WirelessMousr.h" WirelessMousr::WirelessMousr() : Mousr(), pc(p28, p27) {} int WirelessMousr::init() { pc.attach(this,&WirelessMousr::rxCallback); wait(0.1); return 0; } void WirelessMousr::rxCallback() { char state = this->pc.getc(); // read RX character, clearing interrupt pc.putc(state); // loopback pc.putc(10); // state machine switch(state) { case 's': this->stop(); break; case 'w': this->straight(getStraightSpeed()); break; case 'a': this->left(getRotateSpeed()); wait(0.25); stop(); break; case 'd': this->right(getRotateSpeed()); wait(0.25); stop(); break; case 'x': this->backwards(getStraightSpeed()); break; case 'q': this->left(getRotateFastSpeed()); break; case 'e': this->right(getRotateFastSpeed()); break; case 'z': this->left(getRotateSlowSpeed()); break; case 'c': this->right(getRotateSlowSpeed()); break; } }