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.
Diff: ResistiveTouchController.cpp
- Revision:
- 2:a4ebeb3ba49c
- Parent:
- 1:51bde7ae4a65
--- a/ResistiveTouchController.cpp Sat Oct 08 19:22:11 2016 +0200
+++ b/ResistiveTouchController.cpp Sat Oct 08 19:05:49 2016 +0000
@@ -1,6 +1,6 @@
#include "ResistiveTouchController.hpp"
-ResistiveTouchController::ResistiveTouchController(PinName ur, PinName lr, PinName s, PinName ul, PinName ll, int num_of_samples = 5, int settle = 20) :
+ResistiveTouchController::ResistiveTouchController(PinName ur, PinName lr, PinName s, PinName ul, PinName ll, int num_of_samples, float settle) :
_UR(ur),
_LR(lr),
_UL(ul),
@@ -49,22 +49,22 @@
_yt = MeasureS();
}
-void ResistiveTouchController::RawX()
+float ResistiveTouchController::RawX()
{
return _xt;
}
-void ResistiveTouchController::RawY()
+float ResistiveTouchController::RawY()
{
return _yt;
}
-void ResistiveTouchController::X()
+float ResistiveTouchController::X()
{
return (A*_xt+B*_yt+C);
}
-void ResistiveTouchController::Y()
+float ResistiveTouchController::Y()
{
return (D*_xt+E*_yt+F);
}
@@ -79,7 +79,7 @@
F = Y_D3-D*X_T3-E*Y_T3;
}
-void ResistiveTouchController::SetSettleTime(int settle)
+void ResistiveTouchController::SetSettleTime(float settle)
{
_settle = settle;
}
@@ -120,3 +120,17 @@
_delayTimer.stop();
_delayTimer.reset();
}
+
+float ResistiveTouchController::MeasureS()
+{
+ AnalogIn S(_S);
+
+ float measured_val = 0.0f;
+
+ for( int i =0 ; i < _samples ; i++)
+ {
+ measured_val += S.read();
+ }
+
+ return ( measured_val/_samples);
+}
\ No newline at end of file