mode test

This commit is contained in:
shrkey
2016-10-09 20:40:11 +01:00
parent f61e65ed80
commit 3f682595b9
3 changed files with 46 additions and 14 deletions

View File

@@ -48,8 +48,10 @@ bool DW640::initialize() {
printf("No 640 board found\n");
return 0;
}
this->pwm->setFrequency( 100 );
// set the default frequency
setFrequency( 100 );
// set the default mode to ININ
setMode( DW_ININ );
}
@@ -58,4 +60,36 @@ bool DW640::initialize() {
*/
bool DW640::testConnection() {
return this->pwm->testConnection();
}
/** Calculate prescale value based on the specified frequency and write it to the device.
* @return Frequency in Hz
*/
float DW640::getFrequency() {
return this->pwm->getFrequency();
}
/** Calculate prescale value based on the specified frequency and write it to the device.
* @param Frequency in Hz
*/
void DW640::setFrequency(float frequency) {
this->pwm->setFrequency( frequency );
}
/** Calculate prescale value based on the specified frequency and write it to the device.
* @return Frequency in Hz
*/
uint8_t DW640::getMode() {
return this->mode;
}
/** Calculate prescale value based on the specified frequency and write it to the device.
* @param Frequency in Hz
*/
void DW640::setMode(uint8_t mode) {
this->modePin = new PIN( RPI_GPIO_27 );
this->modePin->setMode(Pin::GpioModeOutput);
this->modePin->write( mode );
}

View File

@@ -38,6 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <math.h>
#include <string>
#include "PCA9685.h"
#include "gpio.h"
#define DW640_DEFAULT_ADDRESS 0x60 // 640 default
@@ -53,8 +54,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define DW_INTERLEAVE 3
#define DW_MICROSTEP 4
#define DW_ININ 5
#define DW_PHASE 6
#define DW_ININ 0
#define DW_PHASE 1
class DW640 {
public:
@@ -63,11 +64,11 @@ class DW640 {
bool initialize();
bool testConnection();
// float getFrequency();
// void setFrequency(float frequency);
float getFrequency();
void setFrequency(float frequency);
// float getMode();
// void setMode(float frequency);
uint8_t getMode();
void setMode(uint8_t mode);
// void setPin(uint8_t channel, uint16_t value);
// void setAllPin(uint16_t value);
@@ -101,6 +102,7 @@ class DW640 {
float frequency;
uint8_t mode;
PCA9685* pwm;
PIN* modePin;
};
#endif // DW640_H

View File

@@ -27,10 +27,6 @@ int main()
DW640 dw;
dw.initialize();
if(dw.testConnection()) {
printf("OK %4.f ", 2000);
} else {
printf("Not Ok %4.f ", 1000);
}
}
}