Refactoring and other updates
Dependencies: BLE_API mbed nRF51822
Fork of nRF51822_SimpleChat by
ProcessInterface.cpp@6:832162614a19, 2017-05-09 (annotated)
- Committer:
- carbune92
- Date:
- Tue May 09 06:13:54 2017 +0000
- Revision:
- 6:832162614a19
- Parent:
- 3:b6e4e5529a52
Added PWM and analog input functions in ProcessInterface
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
carbune92 | 3:b6e4e5529a52 | 1 | #include "ProcessInterface.hpp" |
carbune92 | 3:b6e4e5529a52 | 2 | |
carbune92 | 6:832162614a19 | 3 | ProcessInterface::ProcessInterface() : Output(0), cmd(0), processRead(P0_4), cmdPin(P0_0) { |
carbune92 | 3:b6e4e5529a52 | 4 | this->Ctrl = 0; |
carbune92 | 6:832162614a19 | 5 | this->Btd = 0; |
carbune92 | 6:832162614a19 | 6 | cmdPin.period(MIN_PWM_PERIOD); |
carbune92 | 6:832162614a19 | 7 | } |
carbune92 | 6:832162614a19 | 8 | |
carbune92 | 6:832162614a19 | 9 | ProcessInterface::ProcessInterface(PinName _analogPin, PinName _pwmPin) : Output(0), cmd(0), processRead(_analogPin), cmdPin(_pwmPin) { |
carbune92 | 6:832162614a19 | 10 | this->Ctrl = 0; |
carbune92 | 6:832162614a19 | 11 | this->Btd = 0; |
carbune92 | 6:832162614a19 | 12 | cmdPin.period(MIN_PWM_PERIOD); |
carbune92 | 3:b6e4e5529a52 | 13 | } |
carbune92 | 3:b6e4e5529a52 | 14 | |
carbune92 | 3:b6e4e5529a52 | 15 | void ProcessInterface::attachController(Controller *_Ctrl) { |
carbune92 | 3:b6e4e5529a52 | 16 | Ctrl = _Ctrl; |
carbune92 | 3:b6e4e5529a52 | 17 | } |
carbune92 | 3:b6e4e5529a52 | 18 | |
carbune92 | 3:b6e4e5529a52 | 19 | void ProcessInterface::attachBTDevice(BTDevice *_Btd) { |
carbune92 | 3:b6e4e5529a52 | 20 | Btd = _Btd; |
carbune92 | 3:b6e4e5529a52 | 21 | } |
carbune92 | 3:b6e4e5529a52 | 22 | |
carbune92 | 3:b6e4e5529a52 | 23 | void ProcessInterface::getProcOutput() { |
carbune92 | 6:832162614a19 | 24 | Output = processRead.read(); |
carbune92 | 3:b6e4e5529a52 | 25 | } |
carbune92 | 3:b6e4e5529a52 | 26 | |
carbune92 | 3:b6e4e5529a52 | 27 | void ProcessInterface::exportOutput() { |
carbune92 | 3:b6e4e5529a52 | 28 | Ctrl->updateOut(Output); |
carbune92 | 3:b6e4e5529a52 | 29 | Btd->updateOut(Output); |
carbune92 | 3:b6e4e5529a52 | 30 | } |
carbune92 | 3:b6e4e5529a52 | 31 | |
carbune92 | 3:b6e4e5529a52 | 32 | void ProcessInterface::updateCmd() { |
carbune92 | 3:b6e4e5529a52 | 33 | cmd = Ctrl->getCmd(); |
carbune92 | 3:b6e4e5529a52 | 34 | } |
carbune92 | 3:b6e4e5529a52 | 35 | |
carbune92 | 3:b6e4e5529a52 | 36 | void ProcessInterface::updateCmd(float _cmd) { |
carbune92 | 3:b6e4e5529a52 | 37 | cmd =_cmd; |
carbune92 | 3:b6e4e5529a52 | 38 | } |
carbune92 | 3:b6e4e5529a52 | 39 | |
carbune92 | 6:832162614a19 | 40 | void ProcessInterface::applyCmd() { |
carbune92 | 6:832162614a19 | 41 | cmdPin.write(cmd); |
carbune92 | 6:832162614a19 | 42 | } |
carbune92 | 3:b6e4e5529a52 | 43 | |
carbune92 | 3:b6e4e5529a52 | 44 | |
carbune92 | 3:b6e4e5529a52 | 45 | ProcessInterface::~ProcessInterface() { |
carbune92 | 3:b6e4e5529a52 | 46 | delete Ctrl; |
carbune92 | 3:b6e4e5529a52 | 47 | delete Btd; |
carbune92 | 3:b6e4e5529a52 | 48 | } |