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: Tutorial04_dspic33fI2cCom Tutorial06_motorPositionControl
Diff: Encoder_dspic33f.cpp
- Revision:
- 1:a9290cf59d1f
- Parent:
- 0:fd0a80fd3738
- Child:
- 2:57634dc24946
--- a/Encoder_dspic33f.cpp Wed Dec 12 04:38:12 2012 +0000
+++ b/Encoder_dspic33f.cpp Sat Jun 08 03:55:09 2013 +0000
@@ -1,6 +1,6 @@
#include "Encoder_dspic33f.h"
- Encoder_dspic33f::Encoder_dspic33f(PinName sda, PinName scl,int16_t resolution, int address, bool invert) :
+Encoder_dspic33f::Encoder_dspic33f(PinName sda, PinName scl,int16_t resolution, int address, bool invert) :
i2c_(sda,scl),
address_ (address),
resolution_ (resolution){
@@ -29,13 +29,14 @@
i2c_.write( (address_<< 1) & 0xFE, dat, 3);
}
-vector<float> Encoder_dspic33f::read(void){
+void Encoder_dspic33f::read(double * inarr){
char rx[8];
- vector<float> data(2, 0.0);
+ float data[2] = {0.0, 0.0};
i2c_.read((address_<< 1) | 0x01, rx, 8);
MakeDWord(data[0],rx[3],rx[2],rx[1],rx[0]);
MakeDWord(data[1],rx[7],rx[6],rx[5],rx[4]);
- return data;
+ inarr[0] = (double)data[0];
+ inarr[1] = (double)data[1];
}