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-10-08
- Revision:
- 2:e9042e88abf1
- Parent:
- 1:e694ee3b4a7f
- Child:
- 3:b3ec75e9163f
File content as of revision 2:e9042e88abf1:
#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 'v': //STOP this->stop(); break; case 'w': //STRAIGHT //pc.putc('g'); this->straight(getStraightSpeed()); break; case 's': //STRAIGHT SLOW //pc.putc('g'); this->straight(getStraightSlowSpeed()); break; case 'a': //ROTATE LEFT MEDIUM this->left(getRotateSpeed()); break; case 'd': //ROTATE RIGHT MEDIUM this->right(getRotateSpeed()); break; case 'x': //BACKWARDS this->backwards(getStraightSlowSpeed()); break; case 'q': //ROTATE LEFT FAST (CHANGE TO CIRCLE) pc.putc('g'); this->left(getRotateFastSpeed()); break; case 'e': //ROTATE RIGHT FAST (CHANGE TO CIRCLE) this->right(getRotateFastSpeed()); break; case 'z': this->left(getRotateSlowSpeed()); break; case 'c': this->right(getRotateSlowSpeed()); break; case '1': this->flipLeft(); break; case '3': this->flipRight(); break; } }