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: PositionSensor/PositionSensor.cpp
- Revision:
- 28:ed9c1ca386fd
- Parent:
- 26:955a1dfc2705
- Child:
- 119:ad7a6af6fba3
--- a/PositionSensor/PositionSensor.cpp Sun Nov 06 04:27:40 2016 +0000
+++ b/PositionSensor/PositionSensor.cpp Mon Nov 07 10:56:01 2016 +0000
@@ -12,6 +12,7 @@
PositionSensorEncoder::PositionSensorEncoder(int cpr, float offset) {
_cpr = cpr;
_offset = offset;
+ _valid = false;
__GPIOA_CLK_ENABLE();
__GPIOB_CLK_ENABLE();
@@ -43,10 +44,6 @@
ZPulse->enable_irq();
ZPulse->rise(this, &PositionSensorEncoder::ZeroEncoderCount);
ZPulse->mode(PullDown);
-
- ZTest = new DigitalOut(PC_10);
- ZTest->write(1);
- state = 0;
}
/*
@@ -85,6 +82,11 @@
if (ZSense->read() == 1){
if (ZSense->read() == 1){
TIM2->CNT = 0;
+ _valid = true;
}
}
+}
+
+bool PositionSensorEncoder::IsValid() {
+ return _valid;
}
\ No newline at end of file