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: BLE_API mbed nRF51822
Fork of nRF51822_SimpleChat by
Revision 6:832162614a19, committed 2017-05-09
- Comitter:
- carbune92
- Date:
- Tue May 09 06:13:54 2017 +0000
- Parent:
- 5:fca87573ed92
- Child:
- 7:806b08205b25
- Commit message:
- Added PWM and analog input functions in ProcessInterface
Changed in this revision
| ProcessInterface.cpp | Show annotated file Show diff for this revision Revisions of this file |
| ProcessInterface.hpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/ProcessInterface.cpp Mon May 08 21:57:59 2017 +0000
+++ b/ProcessInterface.cpp Tue May 09 06:13:54 2017 +0000
@@ -1,7 +1,15 @@
#include "ProcessInterface.hpp"
-ProcessInterface::ProcessInterface() : Output(0), cmd(0) {
+ProcessInterface::ProcessInterface() : Output(0), cmd(0), processRead(P0_4), cmdPin(P0_0) {
this->Ctrl = 0;
+ this->Btd = 0;
+ cmdPin.period(MIN_PWM_PERIOD);
+}
+
+ProcessInterface::ProcessInterface(PinName _analogPin, PinName _pwmPin) : Output(0), cmd(0), processRead(_analogPin), cmdPin(_pwmPin) {
+ this->Ctrl = 0;
+ this->Btd = 0;
+ cmdPin.period(MIN_PWM_PERIOD);
}
void ProcessInterface::attachController(Controller *_Ctrl) {
@@ -13,7 +21,7 @@
}
void ProcessInterface::getProcOutput() {
- Output = input.read();
+ Output = processRead.read();
}
void ProcessInterface::exportOutput() {
@@ -29,12 +37,12 @@
cmd =_cmd;
}
-void ProcessInterface::applyCmd() {}
+void ProcessInterface::applyCmd() {
+ cmdPin.write(cmd);
+}
ProcessInterface::~ProcessInterface() {
delete Ctrl;
delete Btd;
}
-
-
--- a/ProcessInterface.hpp Mon May 08 21:57:59 2017 +0000
+++ b/ProcessInterface.hpp Tue May 09 06:13:54 2017 +0000
@@ -5,12 +5,17 @@
#include "Controller.hpp"
#include "BTDevice.hpp"
-static AnalogIn input(P0_4);
+#define MIN_PWM_PERIOD 0.00001f
+
+//static AnalogIn processRead(P0_4);
+
+// TODO fct de scalat intre 0 si 1 pentru comenzi date de controller care nu se incadreaza
class ProcessInterface{
public:
ProcessInterface();
+ ProcessInterface(PinName, PinName);
void getProcOutput();
void attachController(Controller *);
void attachBTDevice(BTDevice *);
@@ -18,7 +23,6 @@
void updateCmd();
void updateCmd(float);
void applyCmd();
-
~ProcessInterface();
private:
@@ -26,7 +30,8 @@
BTDevice *Btd;
float Output;
float cmd;
-
+ AnalogIn processRead;
+ PwmOut cmdPin;
};
#endif
