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.
main.cpp
- Committer:
- martwerl
- Date:
- 2018-10-17
- Revision:
- 0:afeca64a6543
- Child:
- 1:ff38e3bad33a
File content as of revision 0:afeca64a6543:
#include "MMouse18.h" #include "Serial_HL.h" SerialBLK pc(USBTX, USBRX); // SerialBLK pc(p28, p27); SvProtocol ua0(&pc); void CommandHandler(); void CheckButton(); Motor mL(p22,p24,p23); Motor mR(p26, p21, p25); Encoder encL(p15,p16); Encoder encR(p30,p29); DigitalIn sw(p5); BusOut leds(LED1,LED2,LED3,LED4); int main(void) { pc.format(8,SerialBLK::None,1); pc.baud(115200); mL.SetPow(0); mR.SetPow(0); encL.Init(ENC_A,ENC_RISE); encR.Init(ENC_A,ENC_RISE); ua0.SvMessage("MotTest1"); Timer stw; stw.start(); while(1) { CheckButton(); CommandHandler(); if( stw.read_ms()>10 ) { stw.reset(); if( ua0.acqON ) { ua0.WriteSvI16(1, encL.cnt); ua0.WriteSvI16(2, encR.cnt); } } } return 1; } void CommandHandler() { uint8_t cmd; if( !pc.IsDataAvail() ) return; cmd = ua0.GetCommand(); if( cmd==2 ) { mL.SetPow(ua0.ReadF()); mR.SetPow(ua0.ReadF()); ua0.SvMessage("Set Pow"); } if( cmd==3 ) { encL.cnt=encR.cnt=0; ua0.SvMessage("Reset Cnt"); } } void CheckButton() { if( sw==1 ) leds=0xF; else leds=0; }