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.
Dependents: Sumo_v2 Sumo_v2_Unstable Sumo_v2_RG13
Diff: RadioIn.cpp
- Revision:
- 10:0c22ced44247
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RadioIn.cpp Sat Apr 13 00:55:57 2013 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+#include "RadioIn.h"
+
+
+//Initialization
+RadioIn::RadioIn() :
+ ChInt0(InterruptIn(p21)),
+ ChInt1(InterruptIn(p22)),
+ ChInt2(InterruptIn(p23))
+{}
+
+void RadioIn::Init()
+{
+ Time.start();
+
+ for(int i= 0; i < 2; i++)
+ {
+ LastRise[i]= 0;
+ dTime[i]= 1000;
+ }
+
+ ChInt0.mode(PullDown); ChInt0.rise<RadioIn>(this, &RadioIn::Rise0); ChInt0.fall<RadioIn>(this, &RadioIn::Fall0);
+ ChInt1.mode(PullDown); ChInt1.rise<RadioIn>(this, &RadioIn::Rise1); ChInt1.fall<RadioIn>(this, &RadioIn::Fall1);
+ ChInt2.mode(PullDown); ChInt2.rise<RadioIn>(this, &RadioIn::Rise2); ChInt2.fall<RadioIn>(this, &RadioIn::Fall2);
+ Update();
+}
+
+//Update Method
+void RadioIn::Update()
+{
+ for(int i= 0; i<2; i++)
+ RawChannels[i]= dTime[i];
+
+ //time to float conversion
+ chan1= float(dTime[0]-1500) * 0.002;
+ if (chan1>1){chan1=1;} if (chan1<-1){chan1=-1;}
+ chan2= float(dTime[1]-1500) * 0.002;
+ if (chan2>1){chan2=1;} if (chan2<-1){chan2=-1;}
+ chan3= float(dTime[2]-1500) * 0.002;
+ if (chan3>1){chan3=1;} if (chan3<-1){chan3=-1;}
+ }
\ No newline at end of file